/*    POP UP Functions     */
function PopupWindow(FileName,PopUpWidth,PopUpHeight,Scroll)
{
	PopUpLeft=((screen.availWidth-PopUpWidth)/2);
	PopUpTop=((screen.availHeight-PopUpHeight)/2);

	if (Scroll==1)
	{
		window.open (FileName,"_blank","toolbar=No,location=No,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+PopUpWidth+",height="+PopUpHeight+",left="+PopUpLeft+",top="+PopUpTop+"");
	}
	else
	{
		window.open (FileName,"_blank","toolbar=No,location=No,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+PopUpWidth+",height="+PopUpHeight+",left="+PopUpLeft+",top="+PopUpTop+"");
	}
}

/*    Live Chat     */
function LiveChat(ChatURL)
{
	PopUpLeft=((screen.availWidth-600)/2);
	PopUpTop=((screen.availHeight-500)/2);

	window.open (ChatURL,"LivechatWindow","toolbar=No,location=No,directories=no,status=no,menubar=no,scrollbars=no,resizable=No,width=600,height=500,left="+PopUpLeft+",top="+PopUpTop+"");
}



function toggle(div_id) 
{

	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) 
	{
		el.style.display = 'block';
	}
	else 
	{
		el.style.display = 'none';
	}


}

function BlanketSize(PopUpDivVar,BlanketName,DivHeight) 
{


	BlanketHeight=document.body.scrollHeight;
	
	var Blanket = document.getElementById(BlanketName);
	Blanket.style.height = BlanketHeight + 'px';
	Blanket.style.width = document.body.clientWidth +'px';


	
	var PopUpDiv = document.getElementById(PopUpDivVar);
	PopUpDiv_height=document.body.clientHeight/2-(DivHeight/2)+document.body.scrollTop;
	PopUpDiv.style.top = PopUpDiv_height + 'px';

}

function WindowPos(PopUpDivVar) 
{

	if (typeof window.innerWidth != 'undefined') 
	{
		viewportwidth = window.innerWidth;
	}
	else 
	{
		viewportwidth = document.body.clientWidth;
	}

	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) 
	{

		WindowWidth = viewportwidth;
		
	}
	else 
	{

		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) 
		{

			WindowWidth = document.body.parentNode.clientWidth;
			
		}
		else 
		{

			WindowWidth = document.body.parentNode.scrollWidth;
			
		}

		
	}

	var PopUpDiv = document.getElementById(PopUpDivVar);
	WindowWidth=WindowWidth/2-350;//350 is half popup's width
	PopUpDiv.style.left = WindowWidth + 'px';

}

function Popup(WindowName,BlanketName,DivHeight,HideScroll) 
{

	if (HideScroll==1)
	{
		document.body.scroll="no";
	}
	
	BlanketSize(WindowName,BlanketName,DivHeight);
	WindowPos(WindowName);
	toggle(BlanketName);
	toggle(WindowName);		
}





