function insertIntoLot(val)
{
	document.getElementById("livesearch_pole").value=val;
	document.getElementById("livesearch_pole").focus();
}

var napr=new Array();

/*
function correctPNG()
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if(imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : "";
			var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText;
			if (img.align == "left") imgStyle = "float:left;" + imgStyle;
			if (img.align == "right") imgStyle = "float:right;" + imgStyle;
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
			img.outerHTML = strNewHTML;
			i = i-1;
		}
	}
}*/
   
function SetPoles()
{
	var lot=document.getElementById('v5');
	var km=document.getElementById('v1');
	var sq=document.getElementById('v2');
	var naz=document.getElementById('v6');
				
	if(lot.options[lot.options.selectedIndex].value!='')
	{
		km.disabled=true;
		sq.disabled=true;
		naz.disabled=true;
					
		for(var i=0;i<napr.length;i++)
		{
			var temp=document.getElementById(napr[i]);
			temp.disabled=true;
		}
	}
	else
	{
		km.disabled=false;
		sq.disabled=false;
		naz.disabled=false;
					
		for(var i=0;i<napr.length;i++)
		{
			var temp=document.getElementById(napr[i]);
			temp.disabled=false;
		}
	}
}

function pngdisplay(image, width, height, cl, alt, onclk) 
{
	if(navigator.appName=='Microsoft Internet Explorer') 
	{ 
		document.write('<img src="images/empty.gif" style="width: ' + width + '; height: ' + height + '; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + image + ', sizingMethod=scale)" alt="' + alt + '" title="' + alt + '" class="' + cl + '" onclick="' + onclk + '">');
	} 
	else 
	{
		document.write('<img src="' + image + '" style="width: ' + width + '; height: ' + height + ';" alt="' + alt + '" title="' + alt + '" class="' + cl + '" onclick="' + onclk + '">');
	}
}

function GetIndex()
{
	document.location.href='/';
}

function ReplacePhoto()
{
	if(document.getElementById('photo-is-active') && document.getElementById('photo-is-active').value!=0)
	{
		PositionPhoto();
	}
}

function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else 
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) 
	{	
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		} 
		else 
		{
			windowWidth = self.innerWidth;
		}
		
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) 
	{ 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	} 
	else 
	{ 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	} 
	else 
	{
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;
}

function HeightObj()
{
	var height=parseFloat(document.getElementById('photo-td').style.height);
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;
	var nn=document.getElementById('photo-is-active').value;

	if(height < h - 100)
	{
		document.getElementById('photo-td').style.height=height + 100;
	}
	else
	{
		if(height >= h - 100 && height < h - 10)
		{
			document.getElementById('photo-td').style.height=height + 10;
		}
		else
		{
			if(height >= h - 10 && height <= h)
			{
				document.getElementById('photo-td').style.height=height + 1;
			}
		}
	}

	if(height!=h) setTimeout('HeightObj()', 0.5);
	
	if(height==h)
	{
		document.getElementById('photo-td').innerHTML=document.getElementById('img'+nn).innerHTML;
		document.getElementById('img'+nn).innerHTML='';
	}
}

function WidthObj()
{
	var width=parseFloat(document.getElementById('photo-td').style.width);
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	if(width < w - 100)
	{
		document.getElementById('photo-td').style.width=width + 100;
	}
	else
	{
		if(width >= w - 100 && width <= w - 10)
		{
			document.getElementById('photo-td').style.width=width + 10;
		}
		else
		{
			if(width >= w - 10 && width <= w)
			{
				document.getElementById('photo-td').style.width=width + 1;
			}
		}
	}

	
	if(width!=w) setTimeout('WidthObj()', 0.5);

	if(width==w) HeightObj();
}

function PositionPhoto()
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	PositionShadow();
	
	document.getElementById('photo').style.top=document.body.scrollTop + ((y / 2) - h / 2 - 10);
	document.getElementById('photo').style.left=x / 2 - w / 2 - 30;
	document.getElementById('photo').style.display='block';
}

function PositionShadow()
{
	if(document.getElementById('shadow') && document.getElementById('shadow').style.display=='block')
	{
		var arrayPageSize=getPageSize();

		document.getElementById('shadow').style.height=arrayPageSize[1];
		document.getElementById('shadow').style.width=arrayPageSize[0];
	}
}

function SwitchSelectors(param)
{
	for(var i=1;i<=6;i++)
	{
		if(document.getElementById('v'+i))
		{
			if(param==0) document.getElementById('v'+i).style.display='none';
			if(param==1) document.getElementById('v'+i).style.display='block';
		}
	}
}

function ShowBigPhoto(w,h,nn)
{
	SwitchSelectors(0);
	
	document.getElementById('photo-is-active').value=nn;
	document.getElementById('photo-width').value=w;
	document.getElementById('photo-height').value=h;

	document.getElementById('shadow').style.display='block';
	PositionPhoto();

	document.getElementById('photo-td').style.width=0;
	document.getElementById('photo-td').style.height=100;

	WidthObj();
}

function CloseBigPhoto(nn)
{
	SwitchSelectors(1);
	
	document.getElementById('shadow').style.display='none';
	document.getElementById('photo-is-active').value=0;		
	document.getElementById('photo-width').value=0;
	document.getElementById('photo-height').value=0;
	
	document.getElementById('photo').style.top=0;
	document.getElementById('photo').style.left=0;
	document.getElementById('photo').style.display='none';

	document.getElementById('photo-td').style.width='0px';
	document.getElementById('photo-td').style.height='0px';

	document.getElementById('img'+nn).innerHTML=document.getElementById('photo-td').innerHTML;
	document.getElementById('photo-td').innerHTML='';
	
}

function Init()
{
	if(window.addEventListener) 
	{
		window.addEventListener('resize', ReplacePhoto, false);
		window.addEventListener('resize', PositionShadow, false);
	} 
	else if (window.attachEvent) 
	{
		window.attachEvent('onresize', ReplacePhoto);
		window.attachEvent('onresize', PositionShadow);
	}
}