function showhide(hide_id, show_id, style) {
	document.getElementById(hide_id).style.display = 'none'; 
	document.getElementById(show_id).style.display = style; 
	return false;
}

var _src;


function prewpic(src) {
	_src=src;
	document.getElementById("img_prew").src='/500/400/'+src;
	return false
}
function showpic(src) {
	if (src) {} else { src=_src }
	w=360;
	h=200;
	t=(screen.height-h-130)/2; if (t<0) {t=0;}
	l=(screen.width-w)/2; if (l<0) {l=0;}
	var showpic = window.open('/showpic.html?'+src, 'showpic', 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=1,status=0,toolbar=0,menubar=0,location=0,scrollbars=yes');
//	var showpic = window.open('/cgi-bin/showpic.cgi?'+src, 'showpic', 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=0,status=0,toolbar=0,menubar=0,location=0,scrollbars=auto');
	showpic.focus()
	return false
}
function showpics(id, item_id) {
	w=800;
	h=660;
	t=(screen.height-h-130)/2; if (t<0) {t=0;}
	l=(screen.width-w)/2; if (l<0) {l=0;}
	var showpic = window.open('/ajax/portfolio.cgi?id='+id+'&item_id='+item_id, 'showpics', 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=0,status=0,toolbar=0,menubar=0,location=0,scrollbars=auto');
	showpic.focus()
	return false
}
function showpics_path(path) {
	w=800;
	h=660;
	t=(screen.height-h-130)/2; if (t<0) {t=0;}
	l=(screen.width-w)/2; if (l<0) {l=0;}
	var showpic = window.open('/ajax/portfolio.cgi?path='+path, 'showpics', 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=0,status=0,toolbar=0,menubar=0,location=0,scrollbars=auto');
	showpic.focus()
	return false
}
function showhtml(src, w, h) {
	var t=(screen.height-h-130)/2; if (t<0) {t=0;}
	var l=(screen.width-w)/2; if (l<0) {l=0;}
	var showhtml = window.open(src, 'popup', 'width='+w+',height='+h+',top='+t+',left='+l+',resizable=0,status=0,toolbar=0,menubar=0,location=0,scrollbars=auto');
	showhtml.focus()
	return false
}

var _tips_last_id_=0;

function show_tip(id, evt, i, c, f, r, s){
	var frame=document.getElementById(id);
	if (_tips_last_id_!=i) {
		frame.innerHTML='Корпус: '+c+'<br/>Этаж: '+f+'<br/>Комнат: '+r+'<br/>Площадь: '+s+' m<sup>2</sup>';
		_tips_last_id_=i;
	}
}

function move_tip(id, evt, i, c, f, r, s){
	var x, y, h; 
	var frame=document.getElementById(id);
	if (evt) {
		x = evt.clientX; 
		y = evt.clientY;
	} else {
		x = window.event.clientX; 
		y = window.event.clientY; 
	}
	h = document.documentElement.scrollTop||document.body.scrollTop;
	if (frame.style.display!="block") {
		frame.style.display = "block";
	}
	x = x + 10; 
	y = y + 10 + h;
	frame.style.left = x + 'px'; frame.style.top = y + 'px'; 
}

function hide_tip(id) { 
	document.getElementById(id).style.display = "none"; 
} 

var marva_report_image;
var marva_cooked_dept=0;
var marva_check_count=0;
var cur_dept=0;

function get_online_depts(cur_dept) {
	marva_report_image=new Image();
	marva_report_image.src='http://login.marva.ru/image.asp?l=Palace&x=25983&deptid='+marva_depts[cur_dept]+'&rand='+new Date().getTime();
	setTimeout('wait_loading_depts('+cur_dept+')', 100);
	if (marva_depts[cur_dept]==Get_Cookie('mydept')) { marva_cooked_dept=cur_dept; }
	marva_check_count=0;
}

function wait_loading_depts(cur_dept) {
	marva_check_count++;
	if ((marva_report_image.width > 0) || (marva_check_count > 200)) {
		if (marva_report_image.width==1) {
			cur_deptid=marva_depts[cur_dept];
			document.getElementById('girl').className='girl'+(marva_places[cur_dept]);
			save_marva(cur_dept);
		} else {
			if ((cur_dept+1)<marva_depts.length) {
				cur_dept++;
				get_online_depts()
			} else {
				cur_dept=marva_cooked_dept;
				document.getElementById('girl').className='offline girl'+(marva_places[0]);
				save_marva(cur_dept);
			}
		}
	} else {
		setTimeout('wait_loading_depts('+cur_dept+')', 100);
	}
}
function save_marva(dept) {
	Set_Cookie('mydept', marva_depts[dept]);
	setTimeout('get_online_depts(0)', 60000);
}
function call_marva() { 
	var w=450;
	var h=360;
	var t=(screen.height-h-130)/2; if (t<0) {t=0;}
	var l=(screen.width-w)/2; if (l<0) {l=0;}
	var newWin = window.open(
		'http://login.marva.ru/r.asp?l=Palace&x=25983&deptid='+cur_deptid+
			'&page='  + escape(location.toString())+
			'&unique='+ new Date().getTime()+
			'&refer=' + escape(document.referrer),
		'marva_alace',
		'menubar=no,resizable=0,directories=no,location=no,toolbar=no,status=no,scrollbars=0,screenX=50,screenY=100,top='+t+',left='+l+',width='+w+',height='+h
	);
	if (newWin) newWin.focus();
	return false;
}

function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie(name,value,expires,path,domain,secure) { 
    var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function Delete_Cookie(name,path,domain) { 
   if (Get_Cookie(name)) document.cookie = name + "=" + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
}
