// JavaScript Document

/*Include Function to Dynamically Load External Javascript Files*/
function inc(filename)
{
var head = document.getElementsByTagName('head').item(0);
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
head.appendChild(script)
}

/*Include Login Control Script*/
inc("http://www.milaproperties.com/js/login.js");

function LayerVisible()
	{
	   var a = LayerVisible.arguments;
		for(i=0; i<a.length; i++)
		{
	        try{test = document.getElementById(a[i]); test.style.display="";}
	        catch(e){}
	    }
	}


function ResetVisible()
    {
	  for(i=0; i<layerarray.length; i++)
	  {
	     try{document.getElementById(layerarray[i]).style.display="none";}
		 catch(e){}
		
	  }	 
	}
	
function ResetSingle()
    {
		var a = ResetSingle.arguments;
		for(i=0; i<a.length; i++)
		{
			try{document.getElementById(a[i]).style.display="none";}
		    catch(e){}
		}
	}
	

function TabPosition()
    {
		y=0;
		//z=document.getElementById("mainleft").style.height;
		if(x=window.innerWidth)
		{
			y=(x-740)/2 + 415;
			if(y > 415){document.getElementById("toptab").style.left = y + "px";}
			else{document.getElementById("toptab").style.left =  "415px"; }
	    }
		else
		{
			x=document.body.clientWidth;
			y=(x-740)/2 + 415; 
			if(y > 415){document.getElementById("toptab").style.left = y + "px";}
			else{document.getElementById("toptab").style.left = "415px";}
		}
		
		
	}
	
function gotoURL (a) 
{
	window.open(a, "_blank");
}

function domRollover() {
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	var imgarr=document.getElementsByTagName('img');
	var imgPreload=new Array();
	var imgSrc=new Array();
	var imgClass=new Array();
	for (i=0;i<imgarr.length;i++){
		if (imgarr[i].className.indexOf('domroll')!=-1){
			imgSrc[i]=imgarr[i].getAttribute('src');
			imgClass[i]=imgarr[i].className;
			imgPreload[i]=new Image();
			if (imgClass[i].match(/domroll (\S+)/)) {
				imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1]
			}
			imgarr[i].setAttribute('xsrc', imgSrc[i]);
			imgarr[i].onmouseover=function(){
				this.setAttribute('src',this.className.match(/domroll (\S+)/)[1])
			}
			imgarr[i].onmouseout=function(){
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}
domRollover();


function SetBrowserSize()
    {
	if( typeof( window.innerWidth ) == 'number' ) 
	{
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    }
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
	}
	createCookie('browserwidth', myWidth);
	createCookie('browserheight', myHeight);
	//x=document.getElementById("emailpoost").href;
	//document.getElementById("emailpoost").href = x + '&width=' + myWidth + '&height=' + myHeight;
	}
function GetResizedBrowser()
    {
    if(readCookie('browserwidth'))
	  {	
	  window.resizeTo(readCookie('browserwidth'), readCookie('browserheight'));
	  eraseCookie('browserwidth'); 
	  eraseCookie('browserheight');
	  }
	}
	
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
