
//---------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------

var langArray=["EN","JA-JP","ZH-CN","ZH-TW","KO-KO"];
var langOrder = [3, 1, 0, 4, 2 ];

var ulang = seogetCookie('ulang');
var userCookieValueStr = seogetCookie('User');


//---------------------------------------------------------------------------------------------------------------------------------------------------

function onSeoPageLoad()
{		
	if (("" + ulang == "undefined") || (ulang == ""))
	{
		for (var i=0; i < langArray.length; i++)
	
		if (document.location.href.indexOf (langArray[i] + "/") > 0)
		{
			if (document.location.href.indexOf ("212002") < 0)
				seosetCookie('ulang', langArray[i] ,false,true);
			break;
		}
	}

	//---------------------
	
	if (document.location.href.indexOf ("212002") > 0)
	{
		var v = document.body.getElementsByTagName("a"); 

		for (var i=0;i<v.length;i++)
		{ 
			if ( (v[i].href != null) && (v[i].href != "") && (v[i].href.match("225474.htm") != null))
			{
				v[i].outerHTML = v[i].outerHTML.replace(" href=", " onClick=\"seosetAllCookie('ulang', '" + "EN" + "',false, true);return true;\" href=");
			}
			else if ( (v[i].href != null) && (v[i].href != "") && (v[i].href.match("template.asp") != null))
			{
				var l = ((v[i].href.toLowerCase().split("lang=")[1]).split("&")[0]).toUpperCase();
				v[i].outerHTML = v[i].outerHTML.replace(" href=", " onClick=\"seosetAllCookie('ulang', '" + l + "',false, true);return true;\" href=");
			}
		}
	}

	//---------------------

	if (userCookieValueStr == "")
	{
		if (ulang == "") 
			ulang = "EN";

		userCookieValueStr = "{id:-1, UName:'', Lang:'" + ulang + "', SupportLang:'" + ulang + "', UseAsr:(), Goto:{}, Licenses:0,WlID:0,Version:2,Prop:{},Site:1}";
		seosetCookie('User', userCookieValueStr, false, true);
	}
}

/*****************************************
//-- client support functions for HTML pages
******************************************/

// Missing Array Functions for IE 5.0
//Leave this here for browser compatibility!
if(navigator.appVersion.indexOf("MSIE 5.0")!=-1)
{
	Array.prototype.push = function(element){this[this.length] = element;}
	Array.prototype.pop = function()
	{
		if(this.length < 1)
			return null;

		var element = this[this.length-1];

		this[this.length-1] = null;
		this.length--;

		return element;
	}
}

/*****************************************
/ global variables
******************************************/

var Ctrl;
var extVars = "";
var isIE=(navigator.appName!="Netscape"),
isIE5=(navigator.appVersion.indexOf("MSIE 5")>=0),
isIE5_0 = (isIE5 && (navigator.appVersion.indexOf ("MSIE 5.5") < 0)),
isIE6=(navigator.appVersion.indexOf("MSIE 6")>=0),
oid, cid, Layout, w=window, fullscreen,
isAdmin, Corp=1, isKids=1, kidsCur=0,
loadOnce=0, doubleReq=false, sTimer=null, mainLoaded=0,timeKeep=null;
var Obj = new Object();
var p = window;
var ROOT = "../../../";

var lang = ulang;
var User = {};
    User.Lang = lang;

var chinaKids = false;

/*****************************************
LINK FUNCTIONS
******************************************/

function setConsAccess(oid, anchor)
{
	if(anchor)
		Obj.Anchor = anchor;

	tm(204,oid);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function anchorLink(c,o,a)
{
	//c = classId, o = objectId, a=anchor
	Obj.Anchor = a;
	tm(c,o);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function tm(c,i,a,p,e, delimiter){
	var o=new Object();
	o.ClassId=c != null? c: null;
	o.Id=i? i: null;
	doLink(o,a,p,e, delimiter);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

// Passes obj containing classId and id to doLinkStr to build url
// sends url to make request to server
function doLink(o,a,p,e, delimiter)
{
	if(!delimiter)
		delimiter = ",";
	if(a)Obj.Asp=a;
	if(p)Obj.Prop=p.split(delimiter);
	if(e){
		if (Obj.Ext)
			e += "," + Obj.Ext;
		Obj.Ext=e.split(delimiter);
	}
	else if (Obj.Ext)
	{
		var str = Obj.Ext.toString(); //for IE5, split() only works with a string -AP
		Obj.Ext = str.split(delimiter);
	}
	
	var s=doLinkStr(o);

	if(s&&!doubleReq) {
		doubleReq=true;
		parent.document.location.href=s;
	}else {
	  setTimeout('doubleReq=false',1000);
	  return false;
	}
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

// Returns a complete url based on obj.classId, obj.id and the existing page's Obj
// Also handles Obj.ExParm; adds anything to the url exactly as specified,
// Obj.Anchor for html anchors
function doLinkStr(obj)
{
	// special code for minicore.js: extract lang from path
	var o=obj? obj: new Object();
	var s = "";
	if(o.site){
		s += "http://" + o.site + "/";
	}
	else
		s += serverPath();
	s+=(Obj.Asp=="default".toLowerCase())?"":"templates/bin/";
	s+=((Obj.Asp)? Obj.Asp: "template")+".asp?lang="+lang;
	if (o.ClassId || o.ClassId==0) s+="&ClassId="+o.ClassId;
	if (o.Id) s+="&ObjectId="+o.Id;
	if (Obj.ExParm) s+=Obj.ExParm;

	var d=["Prop","Ext","Save"];
	for(var i=0;i<d.length;i++)
		if (Obj[d[i]]) s+= eval("get"+ d[i] +"(s)");
	if(w.isCurriculum && (isCurriculum(o.ClassId) || o.ClassId == 0))
		s+="&CurId=4";
	if(Obj.Anchor) s+="#"+Obj.Anchor;

//	reset page vars for when only using function to create url string
	Obj.Prop=Obj.Ext=Obj.Asp=Obj.ExParm=null;
	return s;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

// if (Obj.Prop), builds Prop string
// to set this up, Obj.Prop=[name1=value1,name2=value2]
// on the next page Obj.name1=value1 & Obj.name2=value2 will be present
function getProp()
{
	var ret="&Prop="+escape(mkPrs(Obj.Prop,'|'))
	return (ret.length>6)?ret:"";
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

// Includes &name=value pairs in url
//09/10/2002 jh.  allows client code to use Ext for name anchor tags
function getExt()
{
	if (Obj.Ext[0].indexOf("#") != -1 && Obj.Ext[0].indexOf("=") == -1)
	     return "&" + Obj.Ext
	else
	     return "&"+ mkPrs(Obj.Ext,'&');
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function mkPrs(a,sep)
{
	var t="";
	for(var i=0;i<a.length;i++) {
		var j=a[i].split('=');
		t+=j[0]+"=";
		for(var k=1;k<j.length;k++){
			t+=j[k];
			if (k != j.length-1)
				t+="=";
		}
		if (sep&&i!=a.length-1) t+=sep;
	}
	return t;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function serverPath()
{
	return ROOT;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

/*****

POPUP FUNCTIONS

*****/
var p = this;
p.tog = chooseLangPopup;
p.setLang = chooseLangPopup;

//---------------------------------------------------------------------------------------------------------------------------------------------------

function chooseLangPopup(c)
{
	if(c)
	{
		var d=confirm("To see a translation you need to set your native language to something other than English. Would you like to do this?");
		if (!d) return 0;
	}

	newPopupType = "ChooseLangHTML";
	//altered because Norton rejects all of core.js if size is specified
	Kids_launchPopup(null, "width" + "=" + (3*100) + ",height=500,left=200,top=60")
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function Kids_launchPopup(popURL, popupStr)
{
	paramStr = 0;

	var popupURL = popURL ? popURL : serverPath() + "templates/gsrc/SEO_Popup.htm";
	var winFeatures = popupStr ? popupStr : "width=200,height=350,left=590,top=210";

	popupWin = w.open(popupURL, "ge_mentor", winFeatures);

	// pr - put in if statement here to fix unspecified error in IE5 when trying to launch popup to same window
	if (popupWin && popupWin.focus)
		popupWin.focus();
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function closePopup()
{
     // jh 10/1/02:  keep email popups from Contact Us page open.  some users would like to go to the pages they are having problems with.
	if (popupWin && newPopupType == "mail")
	{
		popupWin=0;
		return
	}
	if (w.popupWin)
	{
		w.popupWin.close();
		popupWin=0;
	}
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function emailWin(str,winName,subject,sec,extraPropPr)
{
	var obj=new Object();
	obj.ClassId=204;
	obj.Id=208290;
	
	if (str.toLowerCase().match("support") != null)
		obj.Id=225317;
		
	var propStr="To="+str;

	if (extraPropPr)
		propStr+= extraPropPr;

	//var extStr=(sec) ? "Sec="+sec: "Sec="+Sec.Id;

	if (winName) propStr+=",WinName="+winName;
	if (subject) propStr+=",Subject="+subject;

	Obj.Prop=propStr.split(",");
	//Obj.Ext=extStr.split(",");

	if (str.toLowerCase().match("support") != null)
		launchPopup("mail",525,575,doLinkStr(obj),20,20);
	else
		launchPopup("mail",450,375,doLinkStr(obj),20,20);

	Obj.Prop=null;
	Obj.Ext=null;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function logoLink()
{
	document.location.href = "225474.htm";
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

var popupWin=0, popupType=0, oldPopupType=0, newPopupType=0;

//---------------------------------------------------------------------------------------------------------------------------------------------------

function launchPopup(pType,pw,ph,loc,lf,tp,trans,pStr)
{
	var  popupLoc;
	newPopupType=pType;

	if (arguments.length < 3)
	{
		Kids_launchPopup(arguments[0],arguments[1]);
		return
	}

	if(loc)  popupLoc=loc;

	if (pStr) paramStr=pStr;
	else 
	{
		var w=pw? pw: 250;
		var h=ph? ph: 360;
		var l=lf? lf: 0;
		var t=tp? tp: 10;
		h+=60;
		paramStr="width="+w+",height="+h+",left="+l+",top="+t+",resizable=yes";
		paramStr+=",scrollbars=yes,menubar=no";
	}
	Kids_launchPopup(popupLoc, paramStr)
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function changeLang(lang,redirect)
{
	var url=redirect.split("/");
	url[5] = langArray[lang];
	url = url.join("/");
	document.location.href = url;
} 

/*****************************************
/ IMAGE FUNCTIONS
******************************************/
function tSpacer(w,h){return gImg("tspacer.gif",w,h);}
function gImg(imgName,w,h,alt,name){ return pathImg("templates/gimg/"+imgName,w,h,alt,name);}

function pathImg(imgPath,w,h,alt,name,hspace,vspace,valign,align)
{
	var s="<img src='"+ ROOT + imgPath + "'";
	if(w) s+=" width="+w;
	if(h) s+=" height="+h;
	if(alt)	s+=" alt='"+alt+"'";
	if(name) s+=" name='"+name+"'";
	if(hspace) s+=" hspace='"+hspace+"'";
	if(vspace) s+=" vspace='"+vspace+"'";
	if(valign)	s+=" valign='"+valign+"'";
	if(align)	s+=" align='"+align+"'";
	s+= " border=0>";
	return s;
}

/************************
/ About Us
**************************/

function realignLeftCallout()
{
	var nav = document.getElementById("left_nav");
	var callout = document.getElementById("callout_left_low");
	callout.style.top = nav.offsetHeight + 230;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function HTML_OnLoad()
{
	if(!document.getElementById("left_nav"))
		return;
	var leftNavObjects = [204812,221412, 200235, 208232, 000000, 208288, 203994, 211891, 000000, 206404];
	var subNavObjects = [214227, 222397, 221651, 215861, 216251, 000000, 216450];
	var beneathSubNavObjects = [220006, 216871, 221715, 223778, 214798, 224049, 223777, 214801, 204890, 223704, 222683, 224508];

	for(var i = 0; i < leftNavObjects.length; i++)
	{
		if(leftNavObjects[i] == oid)
		{
			document.getElementById("nav_" + i).className = "left_nav_item_selected";
			document.getElementById("nav_" + i).childNodes[0].className = "selected";
		}
	}

	for(var i = 0; i < subNavObjects.length; i++)
	{
		if(subNavObjects[i] == oid)
		{
			document.getElementById("nav_0").className = "left_nav_item_selected";
			document.getElementById("subnav_0_item_" + i).childNodes[0].className = "selected";
			document.getElementById("left_subnav_0").style.display = "block";
		}
	}

	for(var i = 0; i < beneathSubNavObjects.length; i++)
	{
		if(beneathSubNavObjects[i] == oid)
		{
			document.getElementById("nav_0").className = "left_nav_item_selected";
			//document.getElementById("subnav_0_item_" + i).childNodes[0].className = "selected";
			document.getElementById("left_subnav_0").style.display = "block";
		}
	}

	if(oid == leftNavObjects[0])
		document.getElementById("left_subnav_0").style.display = "block";
	document.getElementById("left_nav").style.visibility = "visible";
	if(document.getElementById("callout_left_low"))
   		realignLeftCallout();
}

//window.onload = HTML_OnLoad;


/******************************************
/	FOR LANDING PAGES
/*******************************************/

function doSystemCheckPopup()
{
	launchSystemCheck();
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function launchSystemCheck(popSrc, returnAddress)
{
	var returnProp = null;
	var url=serverPath()+"templates/bin/systemcheck.asp?";

	if(popSrc)  
		url += "returnUrl="+serverPath()+"templates/bin/mypage.asp";

	else if(returnAddress) 
	{
		returnProp = "returnUrl=" + serverPath()+returnAddress;
		url += returnProp;
	}
	else 
	{
		url += "returnUrl=" + escape(document.location.href);
		returnProp = "returnUrl=" + escape(document.location.href);
	}
	sysCheck=1;
	if(popSrc)  opener.document.location=url;
	else //document.location=url;
		tm(null,null,"systemcheck",null,returnProp);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function tmSite(site, c, i, a, p, e)
{
	var o= new Object();
	o.ClassId=c != null? c: null;
	o.Id=i? i: null;
	o.site = site;
	doLink(o,a,p,e);	
}

/******************************************
//LOGIN STUFF
/*******************************************/

//---------------------------------------------------------------------------------------------------------------------------------------------------

function validateOnKeyDown(e)
{
	if (e.keyCode == 13)
		submitLogin(document.theform);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function ValidateRequiredField(field, alertText)
{
	if (field.value==null || field.value=="")
	{
		alert(alertText);
		return false
	}
	return true
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function validate_form(f)
{
	if ((f.Username.value != "") || (f.Password.value != ""))
	{
		if (ValidateRequiredField(f.Username,"Please enter the User Name!")==false)
		{
			f.Username.focus();
			return false
		}
		if (ValidateRequiredField(f.Password,"Please enter the Password!")==false)
		{
			f.Password.focus();
			return false
		}
		return true;
	}
	else ValidateRequiredField(f.Username,"Please enter the User Name!");
	return false;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function submitLogin(f)
{
	if (validate_form(f))
	{
		f.action = "http://" + getServerName(getcurrentPageID()) + "/templates/bin/login.asp";
		f.submit();
	}
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function getServerName(oid)
{
    return (oid == 225557) ? Ini.WWWServerName : (oid == 225503) ? Ini.CorpServerName : Ini.KidsServerName;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seogetCookie(idStr,cStr)
{
	var r = "";
	
	if (!cStr) 
		cStr=document.cookie;
	if(cStr)
	{
		var arr=cStr.split(";");
		for(var i=0;i<arr.length;i++)
		{
			var subArr=arr[i].split("=");
			var key=subArr[0].toLowerCase();
			if (trim(key.toLowerCase()) == idStr.toLowerCase())
				r = subArr[1];
		}
	}
	
	return r;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seosetAllCookie(idStr, l,ses,root)
{
	seosetCookie(idStr,l ,ses,root);
	var userCookieValueStr = "{id:-1, UName:'', Lang:'" + l + "', SupportLang:'" + l + "', UseAsr:(), Goto:{}, Licenses:0,WlID:0,Version:2,Prop:{},Site:1}";
	seosetCookie('User', userCookieValueStr, false, true);	
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seosetCookie(idStr,str,ses,root)
{

	var d = new Date();
	d.setFullYear(d.getFullYear() + 1);
	var expireDate = new Date(d);
	var cStr=idStr+"="+ str;

	if (!ses)	
		cStr+="; expires=\""+expireDate.toGMTString() + "\"; path=/";

	if (!root)
		cStr += "templates/bin";

	document.cookie = cStr;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seokidsDemoPopup(v) 
{

	var w = (screen.width < 801 ? 640 : 820);
	var h = (screen.height < 601 ? 440 : 541);
	loc = "http://" + Ini.WWWServerName + "/templates/bin/template.asp?ClassId=204&ObjectId=225910&lang=EN";
	loc = "/templates/bin/template.asp?ClassId=204&ObjectId=225910&lang=EN";

	launchPopup("kidsdemo",w,h,loc);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seochooseLangPopup(c)
{
	if(c)
	{
		var d=confirm("To see a translation you need to set your native language to something other than English. Would you like to do this?");
		if (!d) return 0;
	}
	seolaunchPopup("ChooseLang",300,480,null,200,60,1);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------
 
function seolaunchPopup(pType,pw,ph,loc,lf,tp,trans,pStr)
{
	var  popupLoc;
	var popupName = "";
	newPopupType=pType;
 
	// md 2005/11/29 - simplify logic for dealing with popups from secure locations
	if (loc)
		popupLoc=loc;
	else
		popupLoc="/pls/popup.htm";

	//  popupLoc=serverPath()+"templates/gsrc/popup"+getMainSuffix()+".htm";

	// don't pay attention to object ids, just make popup secure if coming from secure location

	if (this.location.href.match(/https/))
		popupLoc=popupLoc.replace(/http/,"https");

	if (pStr) 
		paramStr=pStr;
	else 
	{
		var w=pw? pw: 250;
		var h=ph? ph: 360;
		var l=lf? lf: 0;
		var t=tp? tp: 10;
		var scr=newPopupType != "howTo";
		if(scr)
		{
			h+=60;
			scr=1;
		}
		paramStr="width="+w+",height="+h+",left="+l+",top="+t+",resizable=yes";
		if(scr==1)
			paramStr+=",scrollbars=yes,menubar=no";
	}
	if(Obj.HowTo && newPopupType != "tword" && newPopupType != "desc")
	if (!trans && ctrlExists()) asfStop();
	if (newPopupType != "test")
	{
		if (popupWin && (oldPopupType != newPopupType))
		{
			closePopup();
			setTimeout('openNewWindow(\"'+ popupLoc+ '\")',750);
		}else
		{
			popupWin=window.open(popupLoc,popupName,paramStr);
			// pr - put in if statement here to fix unspecified error in IE5 when trying to launch popup to same window
			if (popupWin && popupWin.focus)
			popupWin.focus();
		}
	}else
		testWin=window.open(popupLoc,"GE_TEST",paramStr);
	oldPopupType=newPopupType;
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function seochangeLang(i,ie6url)
{	
	var langArray=["EN","JA-JP","ZH-CN","ZH-TW","KO-KO"];

	if(ie6url)  
		var url=ie6url;
	else  
		var url=document.location.href;

	var l=langArray[i];
	User.Lang=l;
	seosetCookie("ulang",l,false,true);
	
	if (Obj.isCur)
	{
		Obj.Defer=0
		if (p.Obj.Save && getSave(url))
			url = replacePropVal(url,getSave(url));
	}

	var x = url.split("/");
	var objectID = (x[x.length - 1]).split(".")[0];
	
	url = "/templates/bin/template.asp?classID=204&lang=" + l + "&objectID=" + objectID;
	
	try
	{
		document.location.href = url;
	}
	catch (e)
	{
		//
	}

	unloadPopup();
	
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

//launch appropriate Flash Tour in a pop-up
//tour versions: 1=corp, 2=cat, 3=hr, 4=cons

function seolaunchTours(v)
{
	var loc = "/templates/bin/template.asp?ClassId=204&ObjectId=223456&lang=EN&TourType=" + v;
	var w = (screen.width < 801 ? 640 : 820);
	var h = (screen.height < 601 ? 440 : 541);
	launchPopup("tour",w,h,loc);
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function openW(mypage,myname,w,h,features) 
{
	if(screen.width)
	{
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}
	else
	{
		winl = 0;
		wint =0;
	}

	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;

	win = window.open(mypage,myname,settings);
	win.window.focus();
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function unloadPopup()
{
	//document.close();
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function getcurrentPageID(u)
{

	var url = "";

	if ((u == null) || ("" + u == "undefined"))
		url=document.location.href;
	else
		url = u;
	
	if (url.match(".htm") != null)
	{
		var x = url.split("/");
		var objectID = (x[x.length - 1]).split(".")[0];

		return objectID ;
	}
	else if (url.match(".asp?") != null)
	{
		//find the object ID from the url.
		return "";
	}
}

//---------------------------------------------------------------------------------------------------------------------------------------------------

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
