// Talisma(tm) is a trademark and service mark of Talisma Corp. Copyright(c) 1998-2001 Talisma Corporation Pvt. Ltd. and its licensors. All rights reserved. -->
var isIE = (navigator.userAgent.indexOf("MSIE") > -1) ? true : false ;
var isMac = (navigator.userAgent.indexOf("Macintosh") > -1) ? true : false ;
var isIEMac = ((navigator.userAgent.indexOf("Macintosh") > -1) && (navigator.userAgent.indexOf("MSIE") > -1))? true : false ;
isIE4 = (navigator.userAgent.indexOf("MSIE 4") > -1) ? true : false ;

var NS6Image1 = new Image();
NS6Image1.width = 0  ;
NS6Image1.height = 0 ;
var sContextProps = ""
if (typeof school!="undefined")
{
    sContextProps += "school=" + school + "&program=" + program + "&department=" + department; //+ "&email=" + email;
}

function gotoUnavailableForm() {
	window.location = TalismaChatUnavailableForm;
}

function ran()
{
	return Math.floor(10000*Math.random());
}

function getCookieVal (offset) 
{  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}	

function SetCookie (name, value) 
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape(value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
}	

function GetCookie(name) 
{
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) 
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)   
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}			

function StartCheck() 
{
	var iCookieAge = 365;	//in days
	var	expDate = new Date(); 
	expDate.setTime(expDate.getTime() + (iCookieAge*24*60*60*1000));			
		
	///////////Cookie Variables Declaration ////////////
	var QrySTr ="";		

	var tName = null;
	var tEmail = null;
	var bIgnoreCust = null;
	var tURL = window.parent.location.href ;
	var tIPAddress = null;
	var tBrowser = navigator.appName;
	var nCartValue = null;
	var tReferrer = null;
	var nFormSubmit = null;
	var tDemo = null;
	var nDemoClicked = null;
	var tBannerAd = null;
	var nBannerAdClicked = null;
	var tDownloadedFiles = null
	var tSurvey = null;

	/////////////////////////////////////////

	var re = / /g;
	tBrowser = tBrowser.replace(re, "%20");
	
	QryStr = ((tName == null || tName == "" || tName == "undefined" ) ? "" : ("&tName=" + escape(tName))) +  
		((tEmail == null || tEmail == "" || tEmail == "undefined" ) ? "" : ("&tEmail=" + escape(tEmail))) +
		((bIgnoreCust == null || bIgnoreCust == "" || bIgnoreCust == "undefined" ) ? "" : ("&bIgnoreCust=" + escape(bIgnoreCust))) +  
		((tURL == null || tURL == "" || tURL == "undefined") ? "" : ("&tURL=" + escape(tURL))) +  
		((tIPAddress == null || tIPAddress == "" || tIPAddress == "undefined") ? "" : ("&tIPAddress=" + escape(tIPAddress))) +  
		((tBrowser == null || tBrowser == "" || tBrowser == "undefined") ? "" : ("&tBrowser=" + escape(tBrowser))) +  
		((nCartValue == null || nCartValue == "" || nCartValue == "undefined") ? "" : ("&nCartValue=" + escape(nCartValue))) +  
		((tReferrer == null || tReferrer == "" || tReferrer == "undefined") ? "" : ("&tReferrer=" + escape(tReferrer))) +  
		((nFormSubmit == null || nFormSubmit == "" || nFormSubmit == "undefined") ? "" : ("&nFormSubmit=" + escape(nFormSubmit))) +  
		((tDemo == null || tDemo == "" || tDemo == "undefined") ? "" : ("&tDemo=" + escape(tDemo))) +  
		((nDemoClicked == null || nDemoClicked == "" || nDemoClicked == "undefined") ? "" : ("&nDemoClicked=" + escape(nDemoClicked))) +  
		((tBannerAd == null || tBannerAd == "" || tBannerAd == "undefined") ? "" : ("&tBannerAd=" + escape(tBannerAd))) +  
		((nBannerAdClicked == null || nBannerAdClicked == "" || nBannerAdClicked == "undefined") ? "" : ("&nBannerAdClicked=" + escape(nBannerAdClicked))) +  
		((tDownloadedFiles == null || tDownloadedFiles == "" || tDownloadedFiles == "undefined") ? "" : ("&tDownloadedFiles=" + escape(tDownloadedFiles))) +  
		((tSurvey == null || tSurvey == "" || tSurvey == "undefined") ? "" : ("&tSurvey=" + escape(tSurvey))) ; 
		
	strsrc = sTrackURL + "/WebTrack.asp?Fn=Start&DBSvr=" + DBSvr + "&DBName=" + DBName + "&SetCookie=True" + QryStr + "&num=" + ran();
	i400095.src = strsrc;
}

function JoinChatSession()
{
	if ( isIEMac)
	{
		alert("You need Netscape browser on Macintosh to use chat.");
		return;
	}

	var strurl = "";
	var sAuto = "Join";
	var strFolder = "/VisitorChat";
	if(!IsClientLocalizable())
	{
		strFolder = "/VisitorChatEnu";
	}

	strurl = sChatURL + strFolder+ "/StartChat.asp?" + "Auto=" + sAuto + "&" + sQueryString;
	window.setTimeout("top.location.replace('" + strurl + "')", 20);
	return true;
}


function IsClientLocalizable()
{
	var nFound = 0;
	var nBrowse = 0;
	var ua = window.navigator.userAgent
	nFound = ua.toLowerCase().indexOf ( "mac" )
	nBrowse = ua.toLowerCase().indexOf ( "msie" )
	if(nFound > 0 && nBrowse >0)
	{
		return false;
	}
	nFound = ua.indexOf ( "MSIE 5" )
	if(nFound > 0)
	{
		return true;
	}
	nFound = ua.indexOf ( "MSIE 6" )
	if(nFound > 0)
	{
		return true;
	}
	nFound = ua.indexOf ( "Netscape6" )
	if(nFound > 0)
	{
		return true;
	}
	nFound = ua.indexOf ( "Netscape/7" )
	if(nFound > 0)
	{
		return true;
	}
	 return false;
}

function StartChatSession(sAuto)
{
	if ( isIEMac)
	{
		alert("You need Netscape browser on Macintosh to use chat.");
		return;
	}

	var strurl = "";
	if ( sAuto.toUpperCase() == "FALSE")
	{
		if ( top.frames.length >  0 )
			if ( top.frames[0].name  == "CustPage" )
				return false;
	}
	if ( IntervalID != 0 ) {	
		vIntervalIDExists = true;
		window.clearInterval(IntervalID);
	}	
	if ( sChatURL.length > 0 ) 
	{
		var strFolder = "/VisitorChat";
		if(!IsClientLocalizable())
		{
			strFolder = "/VisitorChatEnu";
		}
		
		var ans = true;
		/*
		if ( sAuto.toUpperCase() == "TRUE")
		{
		 	ans = confirm( "Our customer service representative will come online to assist you. Please wait...")			
		}
		*/
		if (ans) 
		{
			strCurURL = new String(top.window.location.href);
			strCurURL = strCurURL.replace(/\+/g,"%20");
			strCurURL = strCurURL.replace(/ /g,"%20");
			strCurURL = escape(strCurURL);
			strurl = sChatURL + strFolder + "/StartChat.asp?" + "Auto=" + sAuto + "&CurURL="+ strCurURL ;
			if (sContextProps.length > 0 ) 
				strurl += "&" + sContextProps ;
	
            var myForm = document.forms["frmChat"];
            myForm.action = strurl;
            myForm.method = "POST";
            myForm.submit();
	
		}
		else
		{
			i400095 = new Image();
			i400095.src = sTrackURL + "/DenyChat.asp?ChatURL=" + sCheckURL + "&num=" + ran();
		}
	}
	
	return true;
}

function CheckOnTime()
{
	
	if (vIntervalIDExists)
		return; 
	
	var strsrc = sTrackURL + "/CheckChat.asp?num=" + ran() + "&DBSvr=" + DBSvr + "&DBName=" + DBName + "&CheckURL=" + sCheckURL;
	if ( NS6Image1.height == 1 && NS6Image1.width == 1 ) 
	{
		StartChatSession("True");
	}
	else
	{
		NS6Image1 = new Image();
		if ( !isIE  )
		{		
			NS6Image1.width = 0 ;
			NS6Image1.height = 0 ;
		}
		NS6Image1.src = strsrc;
	}
	if(is.mac && is.ie)//fix for allowing proactive chat  on  IE on Mac
		document.all("newsample").innerHTML="<IMG onload= 'if ( this.height == 1 && this.width == 1 ) {StartChatSession(\"True\"); this.height=0;}' SRC="+NS6Image1.src+" > "
}

function EstimateTime()
{
	if ( isIEMac)
	{
		alert("You need Netscape browser on Macintosh to use chat.");
		return;
	}

	var strurl = "";
	if ( sTimeURL.length > 0 ) 
	{
		strurl = sTimeURL + "?doCheck=1" + "&CurURL=" + top.window.location.href ;
		if (sContextProps.length > 0 ) 
			strurl += "&" + sContextProps ;
	
        var myForm = document.forms["frmChat"];
        myForm.action = strurl;
        myForm.method = "POST";
        myForm.target = "TimeCal"
        myForm.submit();

	}
	return true;
}

function StartChecking()
{
	window.setTimeout("StartCheck()", 500);
	return;
}

function GetTrimmedString(sel) {
	var tmpStr = "";
	var startPos = 0;
	var endPos = sel.length;
	
	for (i=0; i<sel.length; i++) {
		if ((escape(sel.charAt(i))!="%0A") && (escape(sel.charAt(i))!="%0D") && (escape(sel.charAt(i))!="%09") && (escape(sel.charAt(i))!="%20"))
			break;
	}
	startPos = i;
	
	for (i=sel.length-1; i>-1; i--) {
		if ((escape(sel.charAt(i))!="%0A") && (escape(sel.charAt(i))!="%0D") && (escape(sel.charAt(i))!="%09") && (escape(sel.charAt(i))!="%20"))
			break;
	}
	endPos = i+1;
	
	for (j=startPos;j<endPos;j++)
		tmpStr += sel.charAt(j);
	return(tmpStr);
}

if ( isIE ) 
{
	var i400094 = new Image();
	i400094.height= 0;
	i400094.width = 0;
}
var i400095 = new Image();
var IntervalID=0;
var vIntervalIDExists = true;

// BEGIN COPY FROM TreatCodeSample

if ( top.frames.length == 0 || top.frames[0].name  != "CustPage" ) 
{	
	StartChecking();
	if ( TimerInterval != -1 ) { 
		vIntervalIDExists = false;
		IntervalID = window.setInterval("CheckOnTime()", TimerInterval*1000);
	}	
}

function Is() {
   var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.version=parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ns47 = (this.ns && (this.version == 4.7));
    this.ns61=(this.ns && (agent.indexOf("netscape6/6.1") != -1));
	this.ns62 = (this.ns && (agent.indexOf("netscape6/6.2") != -1));
	this.ns70 = (this.ns && (agent.indexOf("netscape/7") != -1));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie4  = (this.ie && (this.major = 4));
	this.ie5 = (this.ie && (agent.indexOf("msie 5.") != -1));
	this.ie6= (this.ie && (agent.indexOf("msie 6.") != -1));
	this.ie7= (this.ie && (agent.indexOf("msie 7.") != -1));
	this.windows = (agent.indexOf("win") != -1);
	this.AOL=(agent.indexOf("aol") != -1);
	this.mac = (agent.indexOf("mac") != -1);
	this.winXP=(agent.indexOf("XP") != -1);
	this.firefox=(agent.indexOf("firefox") != -1);
}

var is = new Is();

function CheckBrowser( barge )
{

	if(self.name == "CustPage")
		return false;
		
	if(parent.name=="CustPage")
		return false;
		
	if(is.AOL)
 		return window.setTimeout("form_onSubmit('False')", 20);
	
	if(is.windows) //check for windows 95 , 98 and NT
	{
		if(!is.winXP)
		{ 		
			if(is.ie5||is.ie6||is.ie7||is.ns47||is.ns61||is.ns62||is.ns70||is.firefox)
				return window.setTimeout("form_onSubmit('False')", 20);
			else 
			{
				//for browser not belonging to these categories
				if ( !barge ) gotoUnavailableForm();
	            return ;
			}
		}	 
		else
		{	
			if(is.ie6 || is.ie7||is.firefox )
				return window.setTimeout("form_onSubmit('False')", 20);
			else
			{
				//for browser not belonging to these categories
	            if ( !barge ) gotoUnavailableForm();
	        	return ;
		 	}
		}
	}
	else
	{
		if(is.mac)
	    	return window.setTimeout("form_onSubmit('False')", 20);
			
		else   //if OS is neither mac nor Win then chat will not be initiated.
		{
			if ( !barge ) gotoUnavailableForm();
			return ;
		}
	}
}	

function form_onSubmit() {
	return StartChatSession("False");
}


function Estimate()
{
	return (EstimateTime());
}

// END COPY FROM TreatCodeSampl</>e