var introContainerId = "showIntroContainer";
var introDivId = "showIntro";
var photosCellId = "photosCell";
var photosPagerDivId = "photosPager";
var photosContainerDivId1 = "photosContainer1";
var photosContainerDivId2 = "photosContainer2";
var photosContainerDivId3 = "photosContainer3";
var photosContainerDivId4 = "photosContainer4";
var introLinkWidth = 142;
var contactFormDivId = "contactsForm";
var outClassName = "out";
var hoverClassName = "jshover";
var photosSmallWidth = 469;
var photosBigWidth = 625;
var photosResizeWidth = 790;
var photosPagerSmallWidth = 477;
var photosPagerBigWidth = 633;

function windowResize()
{
	var introContainer = document.getElementById(introContainerId);
	var introDiv = document.getElementById(introDivId);
	var photosCell = document.getElementById(photosCellId);
	var photosContainerDiv1 = document.getElementById(photosContainerDivId1);
	var photosContainerDiv2 = document.getElementById(photosContainerDivId2);
	var photosContainerDiv3 = document.getElementById(photosContainerDivId3);
	var photosContainerDiv4 = document.getElementById(photosContainerDivId4);
	var photosPagerDiv = document.getElementById(photosPagerDivId);	
	if (introDiv != null)
	{
		if (introContainer.offsetWidth <= introLinkWidth)
		{
			introDiv.style.display = "none";
			introDiv.style.width = "0px";
		}
		else
		{
			introDiv.style.display = "block";
			introDiv.style.width = "100%";			
		}
	}
	if (photosCell != null && photosContainerDiv1 != null)
	{
		photosContainerDiv1.style.width = photosCell.offsetWidth > photosResizeWidth ? (photosBigWidth + "px") : (photosSmallWidth + "px");
	}
	
	if (photosCell != null && photosContainerDiv2 != null)
	{
		photosContainerDiv2.style.width = photosCell.offsetWidth > photosResizeWidth ? (photosBigWidth + "px") : (photosSmallWidth + "px");
	}
	
	if (photosCell != null && photosContainerDiv3 != null)
	{
		photosContainerDiv3.style.width = photosCell.offsetWidth > photosResizeWidth ? (photosBigWidth + "px") : (photosSmallWidth + "px");
	}

	if (photosCell != null && photosContainerDiv4 != null)
	{
		photosContainerDiv4.style.width = photosCell.offsetWidth > photosResizeWidth ? (photosBigWidth + "px") : (photosSmallWidth + "px");
	}

	if (photosPagerDiv != null)
	{
		photosPagerDiv.style.width = photosCell.offsetWidth > photosResizeWidth ? (photosPagerBigWidth + "px") : (photosPagerSmallWidth + "px");
	}
}

function windowLoad()
{
	var contactFormDiv = document.getElementById(contactFormDivId);
	if (contactFormDiv != null)
	{
		var contactInputs = contactFormDiv.getElementsByTagName("input");
		for (var i = 0, contactInputsCount = contactInputs.length; i < contactInputsCount; i++)
		{
			contactInputs[i].onmouseover = function()
			{ 
				this.className = hoverClassName;
			}
			contactInputs[i].onmouseout = function()
			{
				this.className = outClassName;
			}
		}
		var contactTextAreas = contactFormDiv.getElementsByTagName("textarea");
		for (var j = 0, contactTextAreasCount = contactTextAreas.length; j < contactTextAreasCount; j++)
		{
			contactTextAreas[j].onmouseover = function()
			{ 
				this.className = hoverClassName;
			}
			contactTextAreas[j].onmouseout = function()
			{
				this.className = outClassName;
			}
		}		
	}
	var introFlashContainer = document.getElementById("houses");
	var language = document.getElementsByTagName("div")[0].className;
	if (introFlashContainer != null)
	{
		var soHouses = new SWFObject((language != "ru" ? "../" : "") + "flash/intro_" + language + ".swf", "flash_houses", "640", "500", "7", "#656565");
		soHouses.addParam("wmode", "transparent");
		soHouses.write("houses");
	}
	windowResize();
}

function setStyle(element, newStyle)
{
	element.className = newStyle;
}

function insertPNG24Image(imageURL, imageWidth, imageHeight, altImageURL)
{
	if (BrowserDetect.browser != "Explorer")
	{
		document.write("<img src=\"" + imageURL + "\" width=\"" + imageWidth + "\" height=\"" + imageHeight + "\" border=\"0\" alt=\"\" />");
	}
	else
	{
		document.write("<img src=\"" + altImageURL + "\" width=\"" + imageWidth + "\" height=\"" + imageHeight + "\" border=\"0\" alt=\"\" style=\"background-image: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imageURL + "', sizingMethod='scale');\" />");
	}
}

window.onresize = windowResize;
window.onload = windowLoad;

function showIntro()
{
	var w = window.open('intro.html',null,'height=500,width=640,status=no,toolbar=no,menubar=no,location=no');
}

function setImage(imageId, imageSource)
{
	var image = document.getElementById(imageId);
	image.src = imageSource;
}