function showHide(id,divWidth,url){
	var divId = document.getElementById("dialog");//clarify
	var validPopupscroll = document.getElementById(id+"Scroller");
	var bodyHeight = document.getElementsByTagName('body')[0].offsetHeight;
	if(divId.style.display == "none"){
		maskWindow("open");
		divId.style.display = "";
		loadModel(id,url);
		divId.style.width = divWidth + "px";
		divId.style.left = "50%";
		//divId.style.top = "32%";
		divId.style.top = "365px";
		findDivPos("dialog")//clarify
		divId.style.marginTop = -(divId.offsetHeight/2) + "px";
		divId.style.marginLeft = -(divWidth/2) + "px";
			if(document.all){
				//divId.style.top = (document.documentElement.scrollTop+defaultDivPostop) + "px";
				divId.style.top = "365px";
			}
			else{	
				//divId.style.top = (window.pageYOffset+defaultDivPostop) + "px";
				divId.style.top = "365px";
				}
		}
	else{
		
		maskWindow("closeDiv")
		divId.style.display = "none";
		divId.style.top=""
		divId.style.left="";
		divId.style.marginTop = "";
		divId.style.marginLeft = "";
		defaultDivPostop="";
		}	
}


var defaultDivPostop='';
function findDivPos(id) {
	id = parent.document.getElementById(id);
	var curleft = curtop = 0;
	if (id.offsetParent) {
		curleft += id.offsetLeft;
		curtop += id.offsetTop;
		} while (id = id.offsetParent);
	
	 defaultDivPosLt = curleft;
	 defaultDivPostop = curtop;
}


var xmlHttp

function loadModel(id,url)
{	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	//var url='http://localhost/projects/popup/ajax.php?video='+id; 

	xmlHttp.onreadystatechange=stateChanged_model
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
	
function stateChanged_model() 
{ 
	
	if(xmlHttp.readyState < 4)
	{
		   document.getElementById("dialog-content").innerHTML =  "<center><img src='http://lacrosserecruits.com/img/popup_images/ajax-loader.gif'/></center>";
			 
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var val=xmlHttp.responseText;
		document.getElementById("dialog-content").innerHTML=val;		
		document.getElementById("dialog").style.marginTop = -(document.getElementById("dialog").offsetHeight/2) + "px";
		$(".popup").show("clip",{},1000,callback);
	}
}

function callback() {}
/**
* to handle the exception while using ajax in different browsers
* return string
*/ 
function GetXmlHttpObject()
{
	var xmlHttp = "";

	if (window.XMLHttpRequest) // For Safari, Firefox, and other non-MS
	{
		try {
		  xmlHttp = new XMLHttpRequest();
		} 
		catch (e) {
		  xmlHttp = false;
		}
	} 
	else if (window.ActiveXObject) // For Internet Explorer on Windows
	{
		try {
		  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {
				xmlHttp = false;
			}
		}
	}

	return xmlHttp;
}

function maskWindow(flag){
	var windowHeight = ""
	var parentMaskDiv = parent.document.getElementById('mask');
	var maskDiv = document.getElementById('mask');
	var wrapperDiv = document.getElementById('wrapper');
	
	if(!document.all){
		windowHeight = window.innerHeight;
	}
	else {
		windowHeight =document.documentElement.clientHeight;
	}
	
	if(flag=="open"){
	maskDiv.style.display = "";
	}
	
	else if(flag=="closeDiv"){
		maskDiv.style.height = "auto";
		maskDiv.style.display = "none";	
	}
}

