//////////////////////////////////////////////
// File:  chi.js
// Description:
//      These methods apply across all sites
//
//////////////////////////////////////////////


//////////////////////////////////////////////
// Overriden Methods
// 
// - all of these methods should be overriden
//   in corefunctions.js

function getLocalDomains() {
	alert("Implement getLocalDomains() within corefunctions.js");
	return new Array();
}

function leavingSitePopUp() {
	alert("Implement leavingSitePopUp() within corefunctions.js");
}

function getSiteName() {
	alert("Implement getSiteName() within corefunctions.js");
}

function getDomainName() {
	alert("Implement getSiteName() within corefunctions.js");
}


////////////////////////////////////
// Standard Functions withing CHI

/**
 * Changes the location of the current window to the specified value on
 * a dropdown list box.
 */
function ex(form)
{
	window.location.href=form.s.options[form.s.selectedIndex].value;
}

function clientAlert(url)
{
	openSite(url,getSiteName(), getDomainName());
}

/**
 * Confirms leaving the site is ok before opening a new url
 */
function openSite(url,siteName,domain)
{
	var answer = confirm("You are now leaving " + siteName 
		+ ". You will be redirected to our corporate site, " + domain + ", which will open in a separate browser window. You will not be able to use the back arrow to return to " + siteName + ", but the site will remain open in a separate window. Click \"OK\"  to proceed.")
	if (answer )
	{
		window.open(url , "" ,'toolbar=yes,menubar=yes,resizeable=yes,status=yes,location=yes');
	}
}

function clickHandlerNetscape6(e) {  
	//alert("In clickHandlerNetscape6")
	if (e.target.parentNode != "" && 
	e.target.parentNode.hostname.indexOf(mydomain)==-1 && 
	e.target.parentNode.hostname.indexOf(suitesmartDomain)==-1 &&
	e.target.parentNode.hostname.indexOf(consumerhiDomain)==-1 )
  	{
		return leavingSitePopUp()
	}
	else
		return true;
}

function clickHandlerNetscape(e) {  
	//alert("In clickHandlerNetscape")
	if (e.target != "" && 
		e.target.hostname.indexOf(mydomain)==-1 && 
		e.target.href.indexOf("JavaScript:")==-1 &&
		e.target.hostname.indexOf(consumerhiDomain)==-1 )
  	{
		return leavingSitePopUp()
	}
	else
		return true;
}

function clickHandlerIE() {  
	//alert("In clickHandlerIE")
	var elementTag = window.event.srcElement.tagName;
	var hrefUrl = "";
	if (elementTag.indexOf("IMG")>=0)
		hrefUrl = window.event.srcElement.parentElement.href;
	else
		hrefUrl = window.event.srcElement.href;
	
	if (hrefUrl != null && 
		hrefUrl.indexOf(mydomain)==-1 && 
		hrefUrl.indexOf(suitesmartDomain)==-1 &&
		hrefUrl.indexOf("javascript:")==-1 &&
                hrefUrl.indexOf(consumerhiDomain)==-1 )
  	{
		return leavingSitePopUp()
	}
	else
		return true;
}


if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	if (window.Event) document.captureEvents(Event.ONCLICK);
	document.onclick = clickHandlerIE;
}

if (navigator.appName == "Netscape") 
{
	if (parseInt(navigator.appVersion) >= 6)
	{
		window.addEventListener(click, clickHandlerNetscape6, true)
	}
	else if (parseInt(navigator.appVersion) == 5)
	{
		window.captureEvents(Event.CLICK);
		window.onclick = clickHandlerNetscape6;
	}
	else 
	{
		window.captureEvents(Event.CLICK);
		window.onclick = clickHandlerNetscape;
	}
}


