if (document.all) {
	top.window.moveTo(0,0);
	top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
	if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
		top.window.outerHeight = screen.availHeight;
		top.window.outerWidth = screen.availWidth;
	}
}

function createPanWindow(num){
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+p+p*q;
	WinFeatures = "top=100,left=100,width=700,height=500,Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open(num,windowName,WinFeatures);
}

function createPictureWindow(Path,Width,Height,Title)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open("",windowName,WinFeatures);
	w.document.open();
	w.document.write('<head><title></title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>');
	w.document.write("<body bgcolor='#FFFFFF' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='"+Path+"' height='"+Height+"' width='"+Width+"' alt='&quot;"+Title+"&quot;'></body>"); 
	w.document.close();
}

function checkSubscribeForm(form) {
	f1 = document.forms[form].elements['field[name]'].value;
	f2 = document.forms[form].elements['field[email]'].value;
	
	if ((f1 == "") || (f1 == "Ваше имя")) {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if ((f2 == "") || (f2 == "Ваш e-Mail") || (f2.indexOf('@')<0) || (f2.indexOf('.')<0)) {
		alert("Введите, пожалуйста, корректный e-Mail");
		return false;
	}
	else return true;
}

function checkFeedbackForm(form) {
	f1 = document.forms[form].elements['field[title]'].value;
	f2 = document.forms[form].elements['field[email]'].value;
	f3 = document.forms[form].elements['field[subject]'].value;
	f4 = document.forms[form].elements['field[text]'].value;
	
	if (f1 == "") {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if ((f2 == "") || (f2.indexOf('@')<0) || (f2.indexOf('.')<0)) {
		alert("Введите, пожалуйста, корректный e-Mail");
		return false;
	}
	else if (f3 == "") {
		alert("Введите, пожалуйста, тему сообщения");
		return false;
	}
	else if (f4 == "") {
		alert("Введите, пожалуйста, Ваше сообщение");
		return false;
	}
	else return true;
}

function checkPropertySearchForm(form) {
	f1 = document.forms[form].elements['field[name]'].value;
	f2 = document.forms[form].elements['field[type]'].value;
	if (f1 == "" && f2 == "") {
		alert("Введите, пожалуйста, название или тип собственности");
		return false;
	}
	else return true;
}

function createDynamicWindow(Path,Width,Height,Title)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open("",windowName,WinFeatures);
	w.document.open();
	w.document.write('<head><title>&quot;'+Title+'&quot;</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>');
	w.document.write("<body bgcolor='#FFFFFF' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src='"+Path+"' height='"+Height+"' width='"+Width+"' alt='&quot;"+Title+"&quot;'></body>"); 
	w.document.close();
}

function createPopup(num){
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+p+p*q;
	WinFeatures = "top=100,left=100,width=500,height=500,Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open(num,windowName,WinFeatures);
}

function MakeImageArray(n)	{
	this.length=n; for (var i=0; i<=n; i++) this[i] = new Image(); return this
	}

button_home = new MakeImageArray(2); button_home[0].src = "/pics/button_home.gif"; button_home[1].src = "/pics/button_home_a.gif";
button_mail = new MakeImageArray(2); button_mail[0].src = "/pics/button_mail.gif"; button_mail[1].src = "/pics/button_mail_a.gif";
button_map = new MakeImageArray(2);  button_map[0].src = "/pics/button_map.gif";   button_map[1].src = "/pics/button_map_a.gif";

var actBlock = '_text';
function showBlock(_block){
	if(actBlock != ''){	document.getElementById(actBlock).className = "td_pas"; document.getElementById('block'+actBlock).className = "block_pas";	}
	document.getElementById(_block).className = "td_act"; document.getElementById('block'+_block).className = "block_act";
	actBlock = _block;
}

function showOverLayer(_layer,_width,_height){
	document.getElementById('lightboxLayer').innerHTML = document.getElementById(_layer).innerHTML;
	var obj = Lightbox.prototype;
	var arrayPageSize = obj.getPageSize();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
	$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
	new Effect.Appear(document.getElementById('overlay'), { duration: 0.2, from: 0.0, to: 0.8 });
	var arrayPageScroll = document.viewport.getScrollOffsets();
	var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
	var lightboxLeft = arrayPageScroll[0];
	document.getElementById('lightbox').setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();
	document.getElementById('loading').show();
    document.getElementById('lightboxImage').hide();
    document.getElementById('lightboxLayer').hide();
    document.getElementById('hoverNav').hide();
    document.getElementById('prevLink').hide();
    document.getElementById('nextLink').hide();
	document.getElementById('imageDataContainer').hide();
	document.getElementById('numberDisplay').hide();
	$('lightboxLayer').setStyle({ width: _width + 'px', height: _height + 'px' });
	var widthCurrent  = document.getElementById('outerImageContainer').getWidth();
	var heightCurrent  = document.getElementById('outerImageContainer').getHeight();
	var widthNew  = (_width  + LightboxOptions.borderSize * 2); var heightNew = (_height + LightboxOptions.borderSize * 2);
	var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew;
	var xScale = (widthNew  / widthCurrent)  * 100; var yScale = (heightNew / heightCurrent) * 100;
	
	if (hDiff != 0) new Effect.Scale(document.getElementById('outerImageContainer'), yScale, {scaleX: false, duration: ((11 - LightboxOptions.resizeSpeed) * 0.15), queue: 'front'}); 
	if (wDiff != 0) new Effect.Scale(document.getElementById('outerImageContainer'), xScale, {scaleY: false, duration: ((11 - LightboxOptions.resizeSpeed) * 0.15), delay: ((11 - LightboxOptions.resizeSpeed) * 0.15)}); 
	
	var timeout = 0;
	if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; }
	
	(function(){
		document.getElementById('imageDataContainer').setStyle({ width: widthNew + 'px' });
		new Effect.Appear(document.getElementById('lightboxLayer'), { duration: ((11 - LightboxOptions.resizeSpeed) * 0.15), queue: 'end', afterFinish: (function(){ document.getElementById('loading').hide(); document.getElementById('imageDataContainer').show(); }).bind(this) });	
	}).bind(this).delay(timeout / 1000);
}
