var ChatWindow = null;

function open_popup(sURL, w, h)	
{		
	window.open(sURL,"Popup","width="+ w+" ,height="+h+ " ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}	

function openfixed_popup(sURL)
{                                   
window.open(sURL,"Popup","width=750px,height=660px,scrollbars=yes,resizable=yes");  		      
}

function open_popup_new(sURL, w, h)	
{		
	var t = ((screen.availHeight - h) / 2); 
	var l = ((screen.availWidth - w) / 2);

	window.open(sURL,"Popup","top="+t+" ,left="+l+ ",width="+w+" ,height="+h+ ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function AvailCheck()
{
    var masterControlId;  
    var headId=document.getElementsByTagName("head")(0).id;
	if(headId.indexOf("head")>-1)
	{
		headId=headId.substring(0,headId.length-4)
	}
	else
		headId='ctl00_';
	masterControlId = headId + 'ContentPlaceHolder1_';
	//alert("AvailCheck() called");
	var strChatAvailabilityURL = document.getElementById(masterControlId + 'ChatAvailabilityURL').value;

	checkChatAvailability(strChatAvailabilityURL);
	setInterval("checkChatAvailability('"+strChatAvailabilityURL+"')",60000);
}

function ChatClick(strChatURL, strDummyURL, strPageName, strAppID)	
{
	var chatXML = "<ctcpost><appid>" + strAppID + "</appid><params><param><name>Chat Type</name><value>ClickToChat</value></param><param><name>Source Page</name><value>" + strPageName + "</value></param></params></ctcpost>";					

	//alert(chatXML);
	if ( ChatWindow != null && ChatWindow.closed == false )
	{
		ChatWindow.focus();
	}
	else
	{
		ChatWindow = window.open(strDummyURL,"ChatPopup","width=520,height=580,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
		document.HdnChatForm.strChatData.value = chatXML;
		document.HdnChatForm.action = strChatURL;
		document.HdnChatForm.submit();
	}
}