function Loading(url, e)
{

    var arrayPageSize = getPageSize();
	var pos = fetchPos(e);
	
     var divCover = document.getElementById("divCover");
	divCover.style.height = arrayPageSize[5] + "px";
	divCover.style.width = arrayPageSize[4] + "px";
	divCover.style.display="";
	
   var detailDiv = document.getElementById("divDetail");
    detailDiv.style.top = arrayPageSize[3] / 2 + document.documentElement.scrollTop - 200 + "px";
    detailDiv.style.left = arrayPageSize[2] / 2 - 250 + "px";
		
    var lnkViewAll = document.getElementById("lnkViewAll");    
    lnkViewAll.style.display='none';  
	
	var divLoading = document.getElementById("divLoading");
    divLoading.style.top = arrayPageSize[3] / 2 + document.documentElement.scrollTop + "px";
    divLoading.style.left = arrayPageSize[2] / 2 + "px";
	divLoading.innerHTML="<table style='width:40px; height:40px; border:0'><tr><td style='text-align:center'><img border='0' src='../ui/themes/common/loading1.gif' /></td></tr></table>"
    divLoading.style.display="";
	
	var detailFrm = document.getElementById("frmDetail");
	detailFrm.src = url;
}
function resize()
{
	var divCover = document.getElementById("divCover");

	if(divCover.style.display!='none')
	{
		var arrayPageSize = getPageSize();
		divCover.style.height = arrayPageSize[5] + "px";
		divCover.style.width = arrayPageSize[4] + "px";
		divCover.style.display="";
	}
}
function HOSSelect(hos)
{
	var sels = document.getElementsByTagName('select'); 
	for (var i = 0; i < sels.length; i++) 
	{
		if(hos)
		{
            sels[i].style.visibility='hidden';
		}
		else
		{
            sels[i].style.visibility='visible';
		}
	}
}

function fetchPos(e)
{
	var x,y;
	var a = new Array();
	if(!document.all)
	{
		x=e.pageX; 
		y=e.pageY;
		a[0] = x;
		a[1] = y;
	}
	else
	{
		x=document.body.scrollLeft + document.documentElement.scrollLeft+event.clientX;
		y=document.body.scrollTop + document.documentElement.scrollTop+event.clientY; 
		a[0] = x;
		a[1] = y;
	}
	//alert(a);
	return a;
}

function getPageSize()
{  
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.scrollWidth;
		//xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight)
	{  // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}  
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
	
	if(xScroll < windowWidth)
	{  
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll) 
	return arrayPageSize;
}

function DisplayDiv(url,e)
{
    Loading(url, e);
    HOSSelect(true);
} 
 
function DisplayDetail(url)
{
	var detailDiv = document.getElementById("divDetail");
	detailDiv.innerHTML = data;
}

function HideDiv()
{           
    var divCover = document.getElementById("divCover");
	divCover.style.display="none";
	var divHead = document.getElementById("divHead");
	divHead.style.display="none";
    var frmDetail = document.getElementById("frmDetail");   
	try{
		frmDetail.src = "";
	}
	catch(e){}
	try{
		frmDetail.innerHTML = "";
	}
	catch(e){}
    frmDetail.style.display='none';  
    var detailDiv = document.getElementById("divDetail");    
    detailDiv.style.display='none';  
    var lnkViewAll = document.getElementById("lnkViewAll");    
    lnkViewAll.style.display='';  
    HOSSelect(false);
}
function showAllCities(e)
{
	var countryCode = document.getElementById("sltCountry").value;
	var stateName = document.getElementById("sltState").value;
	var url = "/ums/common/allCitiesInFrame";
	url += "?countryCode=" + countryCode;
	url += "&stateName=" + stateName;
	url += "&random" + Math.random();
	DisplayDiv(url, e);
}
