
//


//<script>

var _type=''
var _status='LOADING';
var _result='LOADING';

//window.status=_type+" , "+_status+" , "+_result

// Do modify this line
var __cc_urlbase='http://nlc.netcarelivehelp.com:8080/LiveSupport_Client/LiveSupport/';
var __cc_imageurl='http://nlc.netcarelivehelp.com:8080';

var chat_visitTimerid=0;
var _chat_interval=2000;//2s

// URL of the image that pops up when you send a chat invitation to your website visitors
//var URL_live_help_window = __cc_urlbase+"images/live-help-window.gif";
var URL_live_help_window = __cc_imageurl+"/customerfiles/images/chatinvite.jpg";

// URL of the close image button
//var URL_close_chat_button = __cc_urlbase+"images/closechat.gif";
var URL_close_chat_button = __cc_imageurl+"/customerfiles/images/closechat.gif";

// Default window ornaments for the live help dialog
var _liveHelpDialogFeature = "status=1,width=450,height=375,resizable=1";
var _chat_scriptid="LiveSupportVisitorMonitorScript";

function Chat_ChangeUrl(type)
{
	var _chat_script=document.getElementById("LiveSupportVisitorMonitorScript");
	if(_chat_script==null)
	{
		throw(new Error("tag LiveSupportVisitorMonitorScript not found!"));
	}
	var url=__cc_urlbase+'Support-Visitor-monitor-crossdomain.js.aspx'
		+"?_temp="+(new Date().getTime())+"&Type="+type		
		+"&Referrer="+escape(document.referrer);
		
	var _new_script = document.createElement('SCRIPT');
    _new_script.id = _chat_scriptid;
    _new_script.src = url;

    _chat_script.parentNode.replaceChild(_new_script,_chat_script);
}

function Chat_NextRequest()
{
	Chat_ChangeUrl("VISIT")
}

if( _status=="LOADING" )
{
	//script is loading first time
	
	// write the live help window to the page
	document.write('<div id="invitechatwindow" style="position:absolute;visibility:hidden;left:0px;top:0px;"><div style="margin-top:0px;margin-left:50px;text-align:right;"><a href="javascript:closechatwindow();"><img src="'+URL_close_chat_button+'" border="0"></a></div><a href="javascript:acceptchatwindow();"><img src="'+URL_live_help_window+'" border=0></a></div>');

	chat_visitTimerid=setTimeout(Chat_NextRequest,_chat_interval);
}
else
{
	var arr=_result.split(":");
	if(_type=="VISIT")
	{
		if(_status=="INVITE")
		{
			clearTimeout(chat_visitTimerid);//suppend
			var opname=arr[1];
			Chat_InviteConfirm(opname);
		}
		else
		{
			chat_visitTimerid=setTimeout(Chat_NextRequest,_chat_interval);
		}
	}
	if(_type=="ACCEPT")
	{
		if(_status=="READY")
		{
			var locationid=arr[1];
			var win=window.prepopup;
			var url=__cc_urlbase+"SupportClient.aspx?Location=Support&LocationId="+locationid;
			if(win!=null)
			{
				win.location.href=url;
				window.prepopup=null;
			}
			else 
			{
				try
				{
					win=window.open(__cc_urlbase+"SupportClient.aspx?Location=Support&LocationId="+locationid,'',_liveHelpDialogFeature);
				}
				catch(x)
				{
				}
				if(win==null)
				{
					alert("Pop-up blocker detected.");
				}
			}
		}
		if(_status=="EXPIRED")
		{
			alert("Chat session expired.");
		}
		if(_status=="ERROR")
		{
			alert(text.substring(6));
		}
	}
	
}


function Chat_AcceptInvite()
{
	Chat_ChangeUrl("ACCEPT")
}
function Chat_RejectInvite()
{
	Chat_ChangeUrl("REJECT")
}



var dropstart=0;
var ie=document.all;
var ns4=document.layers;
var dom=document.getElementById;
var calunits=(ns4)? "" : "px";
var crossobj;

function dropin(){
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	if (parseInt(crossobj.top)<150+scroll_top) {
		crossobj.top=parseInt(crossobj.top)+40+calunits;
	} else {
		clearInterval(dropstart)
	}
}
function acceptchatwindow()
{
	crossobj.visibility="hidden";
	window.prepopup=window.open("about:blank",'',_liveHelpDialogFeature);
	Chat_AcceptInvite();
}

function closechatwindow(){
	crossobj.visibility="hidden";
	Chat_RejectInvite();
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}


function Chat_InviteConfirm(){
	if (!dom&&!ie&&!ns4) return;
	crossobj=(dom)?document.getElementById("invitechatwindow").style : ie? document.all.invitechatwindow : document.invitechatwindow;
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset;
	scroll_left=(ie)? (truebody().offsetWidth)/2+truebody().scrollLeft-(300/2): 200;
	crossobj.left=scroll_left+calunits;
	crossobj.top=scroll_top-250+calunits;
	crossobj.visibility=(dom||ie)? "visible" : "show";
	dropstart=setInterval("dropin()",60);
	window.status='live help';
}








