function resizer()
{
	
	ofleft=document.getElementById("f1").offsetLeft;
	if(ofleft<580)
	{
		document.getElementById("f1").style.left=580+"px";
	}
}

function filter_sort(Key){

  document.getElementById("sort_filter_input").value=Key;
  document.getElementById("sort_filter_form").submit();
}

function resizer2()
{
	height=document.getElementById("toplayer").offsetHeight;
	valtop=document.getElementById("toplayer").style.marginTop;	
	shr=screen.height-120;
	height=height+250;
	height=height+10;
		
	
}


function closediv(id)
{
		document.getElementById("l"+id).style.display="none";
		document.getElementById(id+"popimg").src="img/blank.gif";	
		document.getElementById(id+"seld").className="img_watches";		
}
var oldid="";
function opendiv(url,w,h,id)
{
		if(oldid=="")
		{
			iRealWidth=w;
			var iLeft = Math.round ((screen.width - iRealWidth) / 2)-300;
			document.getElementById(id+"seld").className="selected_img";			
			document.getElementById("l"+id).style.display="";
			document.getElementById("l"+id).style.width=w+"px";			
			document.getElementById("l"+id).style.height=h+"px";						
			document.getElementById("l"+id).style.left=iLeft+"px";		
			document.getElementById(id+"popimg").src=url;
			oldid=id;
		}
		else
		{
			document.getElementById("l"+oldid).style.display="none";
			document.getElementById(id+"seld").className="selected_img";
			document.getElementById(oldid+"seld").className="img_watches";			
			document.getElementById(oldid+"popimg").src="img/blank.gif";				
			iRealWidth=w;
			var iLeft = Math.round ((screen.width - iRealWidth) / 2)-300;
			document.getElementById("l"+id).style.width=w+"px";			
			document.getElementById("l"+id).style.height=h+"px";									
			document.getElementById("l"+id).style.display="";
			document.getElementById("l"+id).style.left=iLeft+"px";		
			document.getElementById(id+"popimg").src=url;
			oldid=id;
		}
}
var oldformd="";
function open_order_form(id)
{
		if(!oldformd)
		{		
			document.getElementById(id).style.display="";
			oldformd=id;
			iRealWidth=700;			
			left = Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
		}
		else
		{
			iRealWidth=700;		
			
			left= Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
			document.getElementById(oldformd).style.display="none";									
			document.getElementById(id).style.display="";
			oldformd=id;
		}

}

function open_order_form2(id)
{
		if(!oldformd)
		{		
			document.getElementById(id).style.display="";
			oldformd=id;
			iRealWidth=700;			
			left = Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
		}
		else
		{
			iRealWidth=700;		
			
			left= Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
			document.getElementById(oldformd).style.display="none";									
			document.getElementById(id).style.display="";
			oldformd=id;
		}

		scrtop=document.documentElement.scrollTop;
		scrtop = Number(scrtop) -140;
		document.getElementById(id).style.marginTop = scrtop+"px";
}

function open_desc_form(id)
{		id="df"+id;
		if(!oldformd)
		{	
			document.getElementById(id).style.display="";
			oldformd=id;
			iRealWidth=700;			
			left = Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
		}
		else
		{
			iRealWidth=700;			
			left= Math.round ((screen.width - iRealWidth) / 2)-280;	
			document.getElementById(id).style.left=left+"px";				
			
			document.getElementById(oldformd).style.display="none";									
			document.getElementById(id).style.display="";
			oldformd=id;
		}
}

function close_order_watch(id)
{
document.getElementById(id).style.display="none";	
if(document.getElementById("df"+id))
document.getElementById("df"+id).style.display="none";	
	
}
function close_desc_watch(id)
{
document.getElementById("df"+id).style.display="none";	
	
}
function check_inputs(n)
{
	
	val1=document.getElementById("name"+n).value;
	val2=document.getElementById("tel"+n).value;

	city=document.getElementById("city"+n).value;	
	
	if(document.getElementById("dname"+n)) val3=document.getElementById("dname"+n).value;
	if(document.getElementById("demail"+n)) val4=document.getElementById("demail"+n).value;	
	
	if(val1!="" && val2!="" && city!="")
	{
		document.getElementById("send_order"+n).disabled=0;			
	}
	else
	{
		document.getElementById("send_order"+n).disabled=1;	
	}
	
/*	if(val3!="" && val4!="")
	{
		document.getElementById("send_desc"+n).disabled=0;			
	}
	else
	{
		if(document.getElementById("send_desc"+n)) document.getElementById("send_desc"+n).disabled=1;	
	}	*/
}
function load_flash(){
	document.getElementById('f1').innerHTML='<embed src="http://brandwatches.com.ua/data/img/main4.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" Flashvars="MyURL='+window.location.href+'&" type="application/x-shockwave-flash" width="413" height="430"></embed>';
}


function coords_gcenter_margin(Id,From)
{
	WidthFrom = document.getElementById(From).offsetWidth;
	WidthId = document.getElementById(Id).offsetWidth;
	
	Result = Number(WidthFrom) - Number(WidthId);
	
	Result = Result/2;

	document.getElementById(Id).style.marginLeft = Result + "px";

}
function bottom_it(Id)
{
	if(document.getElementById("addrealty"))
	{
	if(document.getElementById("addrealty").style.marginLeft > 0)
		document.getElementById("footer").style.marginTop = '300px';
	}

}
function normal_it(Id)
{

	document.getElementById("footer").style.marginTop = '-100px';

}
function position($Type,$Object)
{
	$Left=$Object.offsetLeft;
    $Top=$Object.offsetTop;

    for (var parent = $Object.offsetParent; parent; parent = parent.offsetParent)
    {
        $Left += parent.offsetLeft;
        $Top += parent.offsetTop;
    }

    if($Type=="Left")	return $Left;
    if($Type=="Top") return $Top;
}

function locateit($Container,$Left,$Top)
{

	if($Top) $Container.style.marginTop=$Top+"px";
    if($Left)
    {
    	$Container.style.marginLeft=$Left+"px";
    }
}


function tip(Text,Element,Status,L,T)
{
	var Tip = document.getElementById("tip");
	Tip.innerHTML = Text;
	

	
	if(Status == 1) Tip.style.display = 'none';

	if(Status == 0)
	{
		Top = position("Top",Element);
		Left = position("Left",Element);	
		Top = Number(Top)+Number(T);
		Left = Number(Left)+Number(L);
		Tip.style.display = 'block';
		locateit(Tip,Left,Top);
	}
}


function widthmaker()
{
	$Width=document.getElementById("body").offsetWidth;
	
	$Width2=$Width*(25/100);
	$Width=$Width*(35/100);

	if(document.getElementById("widthmaker")) document.getElementById("widthmaker").style.width=$Width+"px";
	if(document.getElementById("widthmaker2")) document.getElementById("widthmaker2").style.width=$Width2+"px";
}

function coords_xCenter(coordsInput_Id)
{
	objectWidth = document.getElementById(coordsInput_Id).style.width;
	bodyWidth = document.getElementById("body").offsetWidth;

	if(objectWidth.match('%'))
	{
		objectWidth = Number(objectWidth.replace('%',""));
		objectWidth = bodyWidth * (objectWidth / 100);
	}
	else
	{
		objectWidth = objectWidth.replace("px","");
	}
		
	x = Math.round((bodyWidth - objectWidth) / 2);
	
	return x + ";" + objectWidth + ";" + bodyWidth;
}

function center(Id,From)
{
	centerTop(Id,From);	
	centerLeft(Id,From);	
}
center_correct_cLeft=0;
center_correct_cTop=0;
function center_correct(Id,From,cLeft,cTop)
{
	center_correct_cLeft=cLeft;
	center_correct_cTop=cTop;
	centerTop(Id,From);	
	centerLeft(Id,From);
	center_correct_cLeft=0;
	center_correct_cTop=0;	
}

function centerTop(Id,From)
{
	HeighthFrom = getWindowHeight();
	HeighthFrom = Number(HeighthFrom);
	scrtop=document.documentElement.scrollTop;
	
	
	if(scrtop=="0") 
		scrtop=document.body.scrollTop;

	
	HeighthFrom = HeighthFrom /2;
	
	HeightId = document.getElementById(Id).offsetHeight;
	HeightId = HeightId /2;

	
	HResult = Number(HeighthFrom) - Number(HeightId);

	
	Itog = HResult + scrtop - 20;
	Itog=Itog+center_correct_cLeft
	if(Itog <20) Itog = 20 + scrtop;
	Itog = Itog;
	document.getElementById(Id).style.marginTop = Itog + "px";	
}


function centerLeft(Id,From)
{
	WidthFrom = document.getElementById(From).offsetWidth;

	WidthId = document.getElementById(Id).offsetWidth;

	
	Result = Number(WidthFrom) - Number(WidthId);

	
	Result = Result/2;

	Result=Result+center_correct_cLeft
	document.getElementById(Id).style.marginLeft = Result + "px";	

}

function getWindowHeight()
{
	 var windowHeight = 0;
	 if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	 }
	 else {
		if (document.documentElement && document.documentElement.clientHeight) {
		   windowHeight = document.documentElement.clientHeight;
		}
		else {
		   if (document.body && document.body.clientHeight) {
			  windowHeight = document.body.clientHeight;
		   }
		}
	 }
	 return windowHeight;
  }