
// GHP - roll-over state for segment modules

function init_rollover() {
	var rollAction = document.getElementsByTagName('div');
	for (var i=0; i<rollAction.length; i++) {
		var e = rollAction[i];
		if (e.className == 'segOff') {
		e.onmouseover = function () {this.className='segOver';}
		e.onmouseout = function () {this.className='segOff';}
		}
	}
}



// ------------------------------------------------------------------------------------------------------------------

// Search target

function updateTarget(theText) {

		var dd = document.getElementById("searchDDtarget");
	
		var thisLocale = new Array();
		thisLocale = GetLocation();
		
		while (dd.hasChildNodes()) {
			dd.removeChild(dd.childNodes[0]);
		}
		
	var ddNode = document.createTextNode(theText);
	document.getElementById("searchDDtarget").appendChild(ddNode);
	if( ( thisLocale['lg'] == 'en' ) && ( thisLocale['ct'] == 'us' ) )
	{
		document.searchSym.q.focus();
	}
	else
	{
		document.searchSym.qt.focus();
	}


	hideSubNav(6);
}

function changeForm(theValue) {
	document.searchSym.site.value = theValue
	}



// ------------------------------------------------------------------------------------------------------------------

// Set document URL to variable for the next three scripts...

	var curLoc;
	curLoc = document.location.toString();



// ------------------------------------------------------------------------------------------------------------------

// Set URL for Cart (Utility Menu) based on segment

function setCartURL() {

	var o = document.getElementById('cartURL');

		if (o != null) {

			for (i = 1; i <= sniffSegment.length; i++) {
		
				if (curLoc.indexOf(sniffSegment[i].path) > -1) {
				o.href = sniffSegment[i].id
				break;
				}
		
				else {
				o.href = "http://www.symantec.com/"
				}
			}
		}
}




// ------------------------------------------------------------------------------------------------------------------

// Section Nav "ON" States (version 2 for new HDR/FTR - XML/XSL implementation)

	var navList2 = new Array;

	function setNavState2() {
		var id = "";
		for (i = 0; i <= navList2.length; i++) {

			if (curLoc.indexOf(navList2[i].path) > -1) {
				id = navList2[i].id;
				break;
				}
		}

		var z = document.getElementById(id);
		z.className = "mainNavOn";

	  }



// ------------------------------------------------------------------------------------------------------------------

// Product Pages Buy Box

function go(form) {
	location = document.form.site.options[document.form.site.selectedIndex].value;                  
	}



// ------------------------------------------------------------------------------------------------------------------

// Popup Window for PartnerNet

// this is the old script
function P(url,h,w) {
	var p = "height=" + h + ",width=" + w + ",scrollbars=yes";
	window.open(url,"",p);
	}

// this is the newer, more expanded script
function P2(url,h,w,scr) {
	window.open(url,"", "height=" + h + ",width=" + w + "," + scr);
	}


// ------------------------------------------------------------------------------------------------------------------

// Global Utilities Widget Drop-down

function showSubNav(thisitem) {

	var divname = "gSnav" + thisitem;
	var thediv = document.getElementById(divname);
	thediv.style.visibility = 'visible';
	}
	
function hideSubNav(thisitem) {

	var divname = "gSnav" + thisitem;
	var thediv = document.getElementById(divname);
	thediv.style.visibility = 'hidden';
	}

function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){

    cn+="a";
    ecolor=Mix(bk,color);
    }
if(opt && opt.indexOf("small")>=0) cn+="s";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");

        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){
            el.childNodes[i].style.borderLeft="0px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
return(document.createElement(x));
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
} 



// ------------------------------------------------------------------------------------------------------------------

// product finder

// debug: uncomment this to turn debugging on so we don't need to use netscape
self.onerror = function showErr(msg,url,line) {
	alert("ERROR: "+msg+"\nline: "+line);
}

// Popup Windows
function popup (url,width,height,name) {
	var w = window.open (url,name,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height,true);
	w.focus();
	if(arguments.length >= 5) {
		return w;
	}
}

// Menus
var timerID = null; 
var timerOn = false; 
var timecount = 500; 
var check = false;
function getPos(element, which) {
	pos = 0
	while (element != null) {
		pos += element["offset" + which]
		element = element.offsetParent
	}
	return pos;
}

function show(name) {
			var elem = document.getElementById(name);
			var parent = elem.parentNode;
			if (elem != null) {
				elem.style.visibility="visible";
				elem.style.display="block";
				elem.style.left=(getPos(parent, "Left") + 10) + "px";
				elem.style.top=(getPos(parent, "Top") + 18) + "px";
			}
}

function hide(name) {
			var elem = document.getElementById(name);
			if (elem != null) {
				elem.style.visibility="hidden";
				elem.style.display="none";
			}
}

var Divs = new Array();
Divs[0] = "utility_symantec";
Divs[1] = "utility_about";
Divs[2] = "utility_i18n";
Divs[3] = "utility_login";
function hideAll(omit) {
	for (i = 0; i < Divs.length; i++) {
		if (omit != Divs[i]) {
			hide(Divs[i]);
		}
	}
}

function startTime() {
	if (timerOn == false) {
		timerID = setTimeout("hideAll()", timecount);
		timerOn = true;
	}
}

function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

// Product Selector
var prod_selector = new Object();
prod_selector.anchorDivId = ""; prod_selector.anchorBtmId=""; prod_selector.primaryWidth = 0; prod_selector.secondaryWidth = 0;
prod_selector.mouseOverImg = ""; prod_selector.normalImg = ""; prod_selector.topStatusTxt = ""; prod_selector.bgColorClass = "";
prod_selector.itemBorderClass = ""; prod_selector.menuGraphicClass = ""; prod_selector.btmBorderClass = ""; 
prod_selector.itemContentClass = ""; prod_selector.objWinHgt = ""; prod_selector.objScrollOffset = ""; prod_selector.objWinWidth = "";
prod_selector.spacerGifPath = "/img/spacer.gif"; prod_selector.browser = ""; prod_selector.tOffset = 0; prod_selector.invTOfsset = 0;
prod_selector.iemac = false; prod_selector.psLayers = new Array();

var mItems = new Array();
var lList = new Object();
var selTmrId = null; 
var selTmrOn = false; 
var selTmrCnt = 700; 
prod_selector.iemac = (navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1);
if(document.layers) { // NS 4.x specific
	var origWidth = window.innerWidth;
	var origHeight = window.innerHeight;
	window.onresize = function() {
if(window.innerWidth != origWidth || window.innerHeight != origHeight) {//extra code to ensure a genuine resize has occurred
	origWidth = window.innerWidth; 
	origHeight = window.innerHeight;
	window.location.reload();
	}
};

} // end NS4.x block
function window_on_load () {
	if(document.getElementById) {
		window.onresize = function() {calculate_lOffset()};
		var top = document.getElementById('prod-selector'); 
		if(top) {
				getHghts(); getInvs(); calculate_lOffset();calculate_TOffsets();
				top.onmouseover = function(){window.status = prod_selector.topStatusTxt; showSelDiv('level-1', prod_selector.anchorBtmId); selstop();};
				top.onmouseout = function(){window.status=''; selstart();};
				top=null;;
		}
	}
}

function calculate_lOffset() {
	if(prod_selector.secondaryWidth > 0) {
		var right_terminus = getPos(document.getElementById(prod_selector.anchorDivId), 'Left') + prod_selector.primaryWidth + prod_selector.secondaryWidth;
		if(right_terminus <= eval(prod_selector.objWinWidth) || prod_selector.iemac) {
			prod_selector.leftOffset = prod_selector.primaryWidth;
		} else {
			prod_selector.leftOffset = (-1 * prod_selector.secondaryWidth) - 2;
		}

		if(prod_selector.browser == 'IE') {
			prod_selector.leftOffset = prod_selector.primaryWidth + 1;
		}
	}
}

function calculate_TOffsets() { //values determined empirically
	if(prod_selector.browser == 'IE' && !(prod_selector.iemac)) {
		prod_selector.tOffset = 0;
		prod_selector.invTOfsset = -1;
	} else {
		prod_selector.tOffset = -1;
		prod_selector.invTOfsset = 0;
	}
}

function setobjs(){
	if(navigator.userAgent.indexOf('Safari') != -1)	{
		prod_selector.objWinHgt = 'window.innerHeight';
		prod_selector.objScrollOffset = 'window.pageYOffset';
		prod_selector.objWinWidth = 'window.innerWidth';
		prod_selector.browser = 'Safari';
	}
	else if(window.innerHeight) { //NS
		prod_selector.objWinHgt = 'window.innerHeight';
		prod_selector.objScrollOffset = 'window.pageYOffset';
		prod_selector.objWinWidth = 'window.innerWidth';
		prod_selector.browser = 'Mozilla';
	}	
	else if(document.body.clientHeight) { //IE
		prod_selector.objWinHgt = 'document.body.clientHeight';
		prod_selector.objWinWidth = 'document.body.clientWidth';
		prod_selector.objScrollOffset = 'document.body.scrollTop';
		prod_selector.browser = 'IE';
	}
}

function mustInv(toShow){
	var inv = false;
	var lTop = getPos(prod_selector.psLayers[lList[toShow]].lock, "Top");
	if((lTop + prod_selector.psLayers[lList[toShow]].height) >= (eval(prod_selector.objWinHgt) + eval(prod_selector.objScrollOffset)) && (lTop - prod_selector.psLayers[lList[toShow]].height > 15)) inv = true;
	return inv;
}

function showSelDiv(toshow, lockto){
	if(prod_selector.psLayers.length > 0) {
			var ptr = document.getElementById(toshow);
			var inv = mustInv(toshow);
			if((!(prod_selector.iemac) && inv) || (prod_selector.iemac && toshow != 'level-1' && inv))
			{
				var oLft = (toshow == 'level-1') ? 0 : prod_selector.leftOffset;
				var oTop = 0;
				ptr.style.visibility="visible";
				ptr.style.display="block";
				ptr.style.left= (getPos(prod_selector.psLayers[lList[toshow]].inv_lock, 'Left') + oLft) + "px";
				ptr.style.top = '';
				ptr.style.top= (getPos(prod_selector.psLayers[lList[toshow]].inv_lock, 'Top') - (prod_selector.psLayers[lList[toshow]].height + prod_selector.invTOfsset)) + "px";
			}
			else
			{
				var offsetLeft = (toshow == 'level-1') ? (0) : prod_selector.leftOffset;
				var offsetTop = 0;
				ptr.style.visibility="visible";
				ptr.style.display="block";
				ptr.style.left= (getPos(prod_selector.psLayers[lList[toshow]].lock, 'Left') + offsetLeft) + "px";
				ptr.style.top = ''; //odd hack, necessary to accomodate ie on the mac!
				ptr.style.top = (prod_selector.iemac) ? ((lockto == prod_selector.anchorBtmId) ? '' : (getPos(prod_selector.psLayers[lList[toshow]].lock, 'Top') + prod_selector.tOffset) + "px") : ((getPos(prod_selector.psLayers[lList[toshow]].lock, 'Top') + prod_selector.tOffset) + "px");
			}
	}
}

function selstart() {
	if (document.getElementById('selectorHead')){
		document.getElementById('selectorHead').style.backgroundColor = "#f27f1a";
	}
	if (selTmrOn == false) {
		selTmrId = setTimeout("hideselall()", selTmrCnt);
		selTmrOn = true;
	}
}

function selstop() {
	if (document.getElementById('selectorHead')){
		document.getElementById('selectorHead').style.backgroundColor = "#999999";
	}
	if (selTmrOn) {
		clearTimeout(selTmrId);
		selTmrId = null;
		selTmrOn = false;
	}
}

function hideselall() {
	if(arguments.length != 0)
	{
		var exclude;
		for (var i = 0; i < prod_selector.psLayers.length; i++)
		{
			exclude = false;
			for(var ii = 0; ii < arguments.length; ii++)
			{
				if(prod_selector.psLayers[i].id == arguments[ii])
				{
					exclude = true;
					break;
				}
			}
			if(!(exclude))
			{
				hide(prod_selector.psLayers[i].id);
			}
		}
	}
	else
	{
		for (var i = 0; i < prod_selector.psLayers.length; i++)
		{
			hide(prod_selector.psLayers[i].id);
		}
	}
}

function hvr(ID, href, value){
		window.status = href; 
		document.getElementById((ID)).style.backgroundColor = (value) ? "#f27f1a" : ""; //TBD: color in a variable
		document.getElementById(('td-' + ID)).style.color = (value) ? "#ffffff" : ""; //TBD: color in a variable
		if(document.images[('img-' + ID)]) document.images[('img-' + ID)].src = (value) ?  prod_selector.mouseOverImg : prod_selector.normalImg;
		// This code is added so as to make the main category selected when the mouse is at the child layer (Product)
		if (ID.indexOf("_")!= "-1")
		{
			ID = ID.substring(0, ID.indexOf("_"));
			document.getElementById((ID)).style.backgroundColor = (value) ? "#f27f1a" : ""; //TBD: color in a variable
			document.getElementById(('td-' + ID)).style.color = (value) ? "#ffffff" : ""; //TBD: color in a variable
			if(document.images[('img-' + ID)]) document.images[('img-' + ID)].src = (value) ?  prod_selector.mouseOverImg : prod_selector.normalImg;
		}
	}

function copyArray(arrToCopy){
	var temp = new Array();
	for(var i=0; i < arrToCopy.length; i++)
	{
		temp[i] = arrToCopy[i];
	}
	return temp;
}

function initiateBuild()
{
	 if(mItems.length != 0)
	 {
		buildSel(mItems);
	}
}

function buildSel(arrInfo){
	var markup, itemMU;
	var styleOverride = '';
	var arrArg;
	var xclusion;
	var containingLayer;
	var width;
	var zIndex;
	if(arguments.length == 1) //first time in
	{
		setobjs();
		width = prod_selector.primaryWidth ;
		containingLayer = 'level-1' ;
		var elem = new Object();
		elem['id'] = containingLayer;
		elem['top'] = 0;
		elem['height'] = 0;
		prod_selector.psLayers[0] = elem;
		xclusion = "'" + containingLayer + "'";
		arrArg = new Array(containingLayer);
	}
	else //recursion
	{
		width = prod_selector.secondaryWidth; //TBD: needs to be tweaked, or perhaps controllable dynamically;
		containingLayer = arrInfo[0].parent + '-sub';
		var surr =  arguments[1];
		//build the exclusion list: 
		for(x=0; x < surr.length; x++)
		{
			xclusion = (x==0) ? ("'" + surr[x] + "'") : (xclusion + ",'" + surr[x] + "'");
		}
		xclusion += ",'" + containingLayer + "'";
		arrArg = copyArray(arguments[1]); //copy to augment
		arrArg[arrArg.length] = containingLayer;
	}
	styleOverride = ' style="width:' + width + 'px;"';
	zIndex = arguments.length == 1 ? 1 : 2;
	markup = '<div id="' + containingLayer + '" style="z-Index:' + zIndex + '; position:absolute; visibility:hidden; " onMouseOver="selstop();" onMouseOut="selstart();">';
	markup += '\n<table class="' + prod_selector.bgColorClass + '" width="' + width + '" cellspacing="0" cellpadding="0">\n';
	itemMU = '';
	//for each menu item:
	for(var i=0; i < arrInfo.length; i++)
	{
		var thisExclusion = '';
		var obj = arrInfo[i];
		var aParent = (obj.sub_nav && obj.sub_nav.length >= 1);
		itemMU += '<tr>';
		if(i == arrInfo.length - 1)
		{
			itemMU += '<td class="' + prod_selector.btmBorderClass + '">';
			
		} else {
			itemMU += '<td class="' + prod_selector.itemBorderClass + '">';
		}
		itemMU += '<div id="' + obj.id + '" onClick="window.location=' + "'" + obj.link + "'" + ';"';
		itemMU += ' onMouseOver="hvr(' + "'" + obj.id + "'" + ', ' + "'" + obj.link + "'" + ', true); ';
		/* extra mouseover code here: */
		thisExclusion = ' hideselall(';		
		if(aParent) //if there are children, we have to *show* specific layers, as well as hide others
		{
			thisExclusion += xclusion + ",'" +obj.id + "-sub'" + "); showSelDiv('" + obj.id + "-sub', " + "'" + obj.id + "', '" + containingLayer + "');" + ' selstop();" ';
		}
		else //just hide the others
		{
			thisExclusion += xclusion + ');" ';
		}
		itemMU += thisExclusion;
		itemMU += 'onMouseOut="hvr(' + "'" + obj.id + "'" + ', ' + "''," + ' false);" ';
		itemMU += ' style="width:' + width + 'px;">\n';;  
		itemMU += '<table border="0" cellspacing="0" cellpadding="0">\n';
		var dynamWidth = width - 5; //5 is the width of the arrow graphic
		itemMU += '<tr><td style="padding:.3em 1em; line-height:1.2em" id="td-' + obj.id + '" class="' + prod_selector.itemContentClass + '" >' + obj.text + '</td>';
		//do we need to add the arrow, which signifies that the menu item has children?
		var rightMostCell = (aParent) ? '<img id="img-' + obj.id + '" src="' + prod_selector.normalImg + '" width="5" height="5" border="0">' : '';
		itemMU += '<td style="padding:.2em .3em 0 0" class="' + prod_selector.menuGraphicClass + '" >' + rightMostCell + '</td>';
		itemMU += '</tr></table>\n</div></td></tr>\n';
		if(aParent) //recurse
		{
			buildSel(obj.sub_nav, arrArg)
		}
	}
	markup += itemMU;
	markup += '</table>\n<div id="' + containingLayer + '-bottom"><img src="' + prod_selector.spacerGifPath + '" width="1" height="1" alt="" border="0">' + '</div>\n</div>';
	document.write(markup);
	if(containingLayer != 'level-1')
	{
		var elem = new Object();
		elem['id'] = containingLayer;
		elem['height'] = 0;
		prod_selector.psLayers[prod_selector.psLayers.length] = elem;
	}
}

function fetchNode(id, arrToSearch){
	var found = null;
	for(var i=0; i <= arrToSearch.length - 1; i++)
	{
		var current = arrToSearch[i];
		if(current['id'])
		{
			if(current['id'] == id)
			{
				found = current;
				break;
			}
		}
		if(current['sub_nav'] && current['sub_nav'].length >= 1)
		{
			found = fetchNode(id, current['sub_nav']);
			if(found) break;
		}
	}
	return found;
}

function buildNode(parentID, id, txt, href, hasSub){
if(parentID == prod_selector.anchorDivId)
	{
		mItems[mItems.length] = new Object();
		var node = mItems[mItems.length - 1];
		node['id'] = id;
		node['text'] = txt;
		node['link'] = href;
		//does this have children?
		if(hasSub) node['sub_nav'] = new Array();
	}
	else //build subordinate item:
	{
		var parent = fetchNode(parentID, mItems);
		if(parent)
		{
			if(!parent['sub_nav']) parent['sub_nav'] = new Array();
			var sub = parent['sub_nav'][parent['sub_nav'].length] = new Object();
			sub['parent'] = parent.id;
			sub['id'] = id;
			sub['text'] = txt;
			sub['link'] = href;
			//Does this have a sub nav?
			if(hasSub) sub['sub_nav'] = new Array();
		}
	}
}

function getHghts(){
	for(var i=0; i < prod_selector.psLayers.length; i++)
	{
		var posID;
		var id; 
		if(i==0) //level-1
		{
			posID = prod_selector.anchorBtmId;
			id = 'level-1';
		}
		else //the subs
		{
			posID = prod_selector.psLayers[i].id.substr(0, prod_selector.psLayers[i].id.indexOf('-sub'));
			id = prod_selector.psLayers[i].id;
		}
	//positioning element:
	var posEl = document.getElementById(posID);
	//element to be positioned:
	var el = document.getElementById(id);
	var top = getPos(posEl, "Top");
	el.style.top = top  + "px";
	var bottom = document.getElementById(id + '-bottom');
	var Hght = getPos(bottom, "Top") - top;
	prod_selector.psLayers[i].height = Hght;
	if(i==0)
		{
			prod_selector.psLayers[i]['lock'] = document.getElementById(prod_selector.anchorBtmId);
		}
		else
		{
			prod_selector.psLayers[i]['lock'] = posEl;
		}
		//put entry in the linked list:
		lList[id] = i;
	}
}

var getInvs="function getInvs() {"; 
getInvs += "for(var i=0; i < prod_selector.psLayers.length; i++){";
getInvs += "switch(i) {";
getInvs += "case 0:";
getInvs += "prod_selector.psLayers[i]['inv_lock'] = document.getElementById(prod_selector.anchorDivId); break;";
getInvs += "case (prod_selector.psLayers.length - 1):";
getInvs += "prod_selector.psLayers[i]['inv_lock'] = document.getElementById('level-1-bottom'); break;";
getInvs += "default:";
getInvs += "prod_selector.psLayers[i]['inv_lock'] = prod_selector.psLayers[i + 1]['lock'];}";
getInvs += "} }";
eval(getInvs);



// ------------------------------------------------------------------------------------------------------------------

// threat explorer tab switcher, not used on current implementation

function changeTab(tabindex){

	for (i=1; i<6; i++) {

	var offindex = 'tabModOff' + i;
	var onindex = 'tabModOn' + i;

	var currentTab = document.getElementById(onindex);
		if(currentTab) {
		currentTab.setAttribute("id",  offindex);
		currentTab.setAttribute("class",  "tabModOff");
		currentTab.className = "tabModOff";
		}
	}

	tabindex = 'tabModOff' + tabindex;

	
	var activeTab = document.getElementById(tabindex);
	
	if(activeTab) {
	activeTab.id  = onindex;
	activeTab.setAttribute("id",  onindex);	
	activeTab.setAttribute("clsas",  "tabModOn");		
	activeTab.className = "tabModOn";
	}
}


// ------------------------------------------------------------------------------------------------------------------

// NPC Hover popup
function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function show_popup(obj, lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = newY + 20 + 'px';
	x.style.left = newX + 'px';

	document.getElementById(lyr).style.visibility = 'visible';

	obj.onmouseout = function() {
		clearTimeout();
		document.getElementById(lyr).style.visibility = 'hidden';
	}
}

///////////////////////////////////////////////////////////////////////////////
// NPC_divshow 	- Show a mouse over in the NPC pages
// Author: 		Kevin De Angelis
// Date: 		2006.08.31
// Receive: 	void
// Return: 		void
///////////////////////////////////////////////////////////////////////////////
function NPC_divshow( itemlocation, showdiv, xOffset, yOffset )
{
	var xPosition = findPosX( itemlocation );
	var yPosition = findPosY( itemlocation );

	showdiv.style.visibility 	= 'visible';
	showdiv.style.left 			= xPosition + xOffset;
	showdiv.style.top 			= yPosition + yOffset;
}

///////////////////////////////////////////////////////////////////////////////
// NPC_divhide 	- Hide a mouse over in the NPC pages
// Author: 		Kevin De Angelis
// Date: 		2006.08.31
// Receive: 	void
// Return: 		void
///////////////////////////////////////////////////////////////////////////////
function NPC_divhide( showdiv )
{
	showdiv.style.visibility = 'hidden';
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

// The fadeIn function uses a Timeout to call itself every 100ms with an object Id and an opacity. The opacity is specified as a percentage and increased 10% at a time. The loop stops once the opacity reaches 100%:

function fadeIn(objId,opacity)
{
  if (document.getElementById)
  {
	obj = document.getElementById(objId);
    if (opacity <= 100)
	{
      setOpacity(obj, opacity);
      opacity += 25;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

///////////////////////////////////////////////////////////////////////////////
// GetLocation 	- Get the Language/Country from the page
// Author: 		Kevin De Angelis
// Date: 		2006.09.18
// Receive: 	void
// Return: 		array ("lg","ct")
///////////////////////////////////////////////////////////////////////////////
function GetLocation(  )
{
	var thisPath 		= location.pathname;
	var thisURLArray	= thisPath.split( "/" );
	var LangArray		= new Array();

	if( ( thisURLArray[1].length == 2 ) && ( thisURLArray[2].length == 2 ) )
	{
		// 2006.09.18 KJD: Cut out the language path
		thisPath = location.pathname.substring( 6, location.pathname.length );
		LangArray['lg'] = thisURLArray[1];
		LangArray['ct'] = thisURLArray[2];
	}
	else
	{
		LangArray['lg'] = "en";
		LangArray['ct'] = "us";
	}

	return LangArray;
}




////////////////////////////// YAHOO ITM BELOW ////////////////////////////////

// get browser version
// NN4 layers, IE4+ all, IE5+ NN6+ getElementById

// bCode_itm = 0, no browser support
// bCode_itm = 1, isIE5 = false, supports all
// bCode_itm = 2, isIE5 = true, supports getElementById
// bCode_itm = 2, isNN6 = true, supports getElementById
// bCode_itm = 3, isNN4 = true, supports layers 

var bCode_itm = 0;

var isIE_itm = false;
var isIE5_itm = false;
var isNN4 = false;
var isNN6_itm = false;

var isOpera_itm	= (navigator.userAgent.toLowerCase().indexOf('opera') != -1);
var isFirefox_itm	= (navigator.userAgent.toLowerCase().indexOf('firefox') != -1);



// get browser version function
function getBrowserVersion_itm()
{
	if(document.all){
		isIE_itm = true; bCode_itm = 1;
	}	
	if(document.getElementById){
		if(isIE_itm){
			isIE5_itm = true; bCode_itm = 2;
		}
		else{
			isNN6_itm = true; bCode_itm = 2;
		}
	}	
	if(document.layers){
		isNN4_itm = true; 
		bCode_itm = 3;
	}
}

// get browser version
getBrowserVersion_itm();


// get element function
function getElement_itm(elementName){


	if(bCode_itm==1){
		return document.all[elementName];
	}
	else if(bCode_itm==2){
		return document.getElementById(elementName);
	}
	else {
		return null;
	}
}


// get position of x and y when mouse is clicked

// Register DOM style events
if (document.addEventListener)
	document.addEventListener("mouseover", handleHover_itm, true);

// Register IE style events
if (document.attachEvent)
	document.attachEvent("onmouseover",handleHover_itm);

var eventX_itm = 0;
var eventY_itm = 0;


function handleHover_itm(e)
{
	if (!e)
	var e = window.event;

	eventX_itm = e.clientX;
	eventY_itm = e.clientY;

	// alert("x is " + e.clientX + " and y is " + e.clientY);
}


// set x-coordinate of layer function
function setX_itm(elementName)
{
	 var theElement = getElement_itm(elementName);

	if(isOpera_itm){
			theElement.style.pixelLeft = eventX_itm-779;
	 }
	 else{
			theElement.style.left = eventX_itm-779+"px";
	 }
}


// set y-coordinate of layer function
function setY_itm(elementName)
{
	 var theElement = getElement_itm(elementName);

	 if(isOpera_itm){
			theElement.style.pixelTop = 20;

	 }
	 else{
			theElement.style.top = 20+"px";
	 }
}


function resetX_itm(elementName)
{
	 var theElement = getElement_itm(elementName);
	 
	 if (theElement) {
	 	setVisibility_itm(theElement, "hidden")
	 
		if(isOpera_itm){
			//theElement.style.pixelLeft = eventX_itm-442;
			theElement.style.pixelLeft = eventX_itm-2000;
	 	}
	 	else{
			//theElement.style.left = eventX_itm-442+"px";
			theElement.style.left = eventX_itm-2000+"px";
	 	}
	}
}


// set y-coordinate of layer function
function resetY_itm(elementName)
{
	 var theElement = getElement_itm(elementName);
	 
	 if (theElement) {
	 	setVisibility_itm(theElement, "hidden")
	 
	 	if(isOpera_itm){
			theElement.style.pixelTop = 20;
		 }
	 	else{
			theElement.style.top = 20+"px";
	 	}
	}
}




var newCount_itm = 0;


var visibilityTimeoutId_itm = null;

var opacityTimeoutId1_itm = null;
var opacityTimeoutId2_itm = null;
var opacityTimeoutId3_itm = null;
var opacityTimeoutId4_itm = null;
var opacityTimeoutId5_itm = null;
var opacityTimeoutId6_itm = null;
var opacityTimeoutId7_itm = null;
var opacityTimeoutId8_itm = null;
var opacityTimeoutId9_itm = null;



var newOpacityLevel_itm = 0;



function showSmallITMBackground_Popupbox(id1, src, id2){

	clearTimeouts_itm();
	
	resetOpacity_itm();

	var element1= getElement_itm("itm_small_" + id1);
	var element2= getElement_itm("itm_small_" + id2);

	if(element1 && element2){
		element1.style.backgroundImage = src;

		setX_itm("itm_small_" + id2);
		setY_itm("itm_small_" + id2);
		
		// alert("x is " + eventX_itm + " y is " + eventY_itm);	

		setOpacity_itm(element2, 0);
		
		visibilityTimeoutId_itm = setTimeout(function() { setVisibility_itm(element2,"visible");	}, 0);
		

		opacityTimeoutId1_itm = setTimeout(function() { setOpacity_itm(element2, .15); }, 200);
		opacityTimeoutId2_itm = setTimeout(function() { setOpacity_itm(element2, .25); }, 250);
		opacityTimeoutId3_itm = setTimeout(function() { setOpacity_itm(element2, .35); }, 300);
		opacityTimeoutId4_itm = setTimeout(function() { setOpacity_itm(element2, .45); }, 350);
		opacityTimeoutId5_itm = setTimeout(function() { setOpacity_itm(element2, .55); }, 400);
		opacityTimeoutId6_itm = setTimeout(function() { setOpacity_itm(element2, .65); }, 450);
		opacityTimeoutId7_itm = setTimeout(function() { setOpacity_itm(element2, .75); }, 500);
		opacityTimeoutId8_itm = setTimeout(function() { setOpacity_itm(element2, .85); }, 550);
		opacityTimeoutId9_itm = setTimeout(function() { setOpacity_itm(element2, .99); }, 600);	
	
											
	}
	


}

function setVisibility_itm(element2, visibility) {

		element2.style.visibility = "visible";	


}


function setOpacity_itm(element2, newCount_itm) {

	newOpacityLevel_itm = newCount_itm;

	if(document.all){
		element2.style.filter = "alpha(opacity=" + 100*newCount_itm + ")";
		
			
	}else if(document.getElementById){
    	element2.style.opacity = newCount_itm;
	}

}


function resetOpacity_itm(){

	setOpacity_itm(getElement_itm("itm_small_popupbox1"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox2"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox3"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox4"), .0);	


}

function clearTimeouts_itm(){

	if(visibilityTimeoutId_itm)
		clearTimeout(visibilityTimeoutId_itm);
	
	if(opacityTimeoutId1_itm)
		clearTimeout(opacityTimeoutId1_itm);
	
	if(opacityTimeoutId2_itm)	
		clearTimeout(opacityTimeoutId2_itm);
	
	if(opacityTimeoutId3_itm)	
		clearTimeout(opacityTimeoutId3_itm);
	
	if(opacityTimeoutId4_itm)	
		clearTimeout(opacityTimeoutId4_itm);
	
	if(opacityTimeoutId5_itm)	
		clearTimeout(opacityTimeoutId5_itm);
	
	if(opacityTimeoutId6_itm)	
		clearTimeout(opacityTimeoutId6_itm);
	
	if(opacityTimeoutId7_itm)	
		clearTimeout(opacityTimeoutId7_itm);
	
	if(opacityTimeoutId8_itm)	
		clearTimeout(opacityTimeoutId8_itm);
	
	if(opacityTimeoutId9_itm)	
		clearTimeout(opacityTimeoutId9_itm);

}


function pausecomp_itm(millis)
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
} 



function hideSmallITMBackground_Popupbox(id1, src, id2){

	clearTimeouts_itm();

			
	var element1= getElement_itm("itm_small_" + id1);
	var element2= getElement_itm("itm_small_" + id2);
	
	if(element1 && element2){
	
		resetX_itm("itm_small_popupbox1");
		resetY_itm("itm_small_popupbox1");
		resetX_itm("itm_small_popupbox2");
		resetY_itm("itm_small_popupbox2");
		resetX_itm("itm_small_popupbox3");
		resetY_itm("itm_small_popupbox3");
		resetX_itm("itm_small_popupbox4");
		resetY_itm("itm_small_popupbox4");	

		element1.style.backgroundImage = src;
		fadeOutPopupbox_itm(element2);
	 
	}
}


function fadeOutPopupbox_itm(element2) {

		
		// reset and hide box code
		setOpacity_itm(element2, .0);
		setVisibility_itm(element2,"hidden");
						

}

///////////////////////////////////////////////////////////////////////////////
// Leftnav
// Author: Ashlesha
// Date: 	 2007-07-21
///////////////////////////////////////////////////////////////////////////////
var submenuoffset=0; 
// pid = main parent's id
// mid = id for the DIV containing main menu item
// prefix = prefix for all DIV that contain main menu item
// posfix = postfix to the mid that gives id of the popup-menu DIV.
function showchild(pid, mid, prefix, postfix){
	var cid = mid + postfix;
	var p = document.getElementById(pid);
	var arrdiv = document.getElementsByTagName('div');
	for (i = 0; i < arrdiv.length; i++)	
	{
		var d = arrdiv[i];
		if (d.id.indexOf(prefix) == 0 && d.id != cid && d.id.indexOf(postfix) != -1)
		{
			hidemenu(d.id);
		}
	}
	showmenu(cid);
}

function leftnav_highlight( thisObj )
{
	thisObj.className = "lftNavFlyMenu lftNavOnHover";
}

function leftnav_lowlight( thisObj )
{
	thisObj.className = "lftNavFlyMenu";
}

function leftnav_parent_highlight( thisObj )
{
	thisObj.className = "lftNavMainNav lftNavOnHover";
}

function leftnav_parent_lowlight( thisObj )
{
	thisObj.className = "lftNavMainNav";
}

function hidemenu(mid)
{
	var menu = document.getElementById(mid);

	menu.style.display="none";
	menu.style.visibility="hidden"; 
}

function showmenu(mid) 
{
	cancelfade();
	var menu = document.getElementById(mid);
	
	if (menu == null)
	{
		return;
	}
	
	/*var pos = findPos(menu.parentNode);
	if(document.all){
		menu.style.left="auto";
	} else {
		menu.style.left = (pos[0] + menu.parentNode.offsetWidth + submenuoffset) + "px";
	}*/
	if(document.all){
		menu.parentNode.style.position="relative"
		menu.style.position = "absolute"
//		menu.style.left="auto";
		menu.style.top="0px";
		menu.style.left = menu.parentNode.offsetWidth  - 13 + "px";
	} else {
		menu.parentNode.style.position="relative"
		menu.style.position = "absolute" 
		menu.style.left = menu.parentNode.offsetWidth + "px";
		menu.style.top="0px";
	}

	setOpacity_leftnav(menu, .99);
    menu.style.display = "block";
	menu.style.visibility = "visible";
}

function setOpacity_leftnav(menu, newCount_leftnav) 
{
 	var newOpacityLevel_leftnav = newCount_leftnav;
 	if(document.all)
	{
 		menu.style.filter = "alpha(opacity=" + 100*newCount_leftnav + ")";
 	}
	else if(document.getElementById){
 		menu.style.opacity = newCount_leftnav;
 	}
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

var leftnavOpacityTimeoutId1_leftnav = null;
var leftnavOpacityTimeoutId2_leftnav = null;
var leftnavOpacityTimeoutId3_leftnav = null;
var leftnavOpacityTimeoutId4_leftnav = null;
var leftnavOpacityTimeoutId5_leftnav = null;
var leftnavOpacityTimeoutId6_leftnav = null;
var leftnavOpacityTimeoutId7_leftnav = null;
var leftnavOpacityTimeoutId8_leftnav = null;
var leftnavOpacityTimeoutId9_leftnav = null;

function fademenu(mid)
{
	
	var menu = document.getElementById(mid);
	//alert(menu);
	/*leftnavOpacityTimeoutId1_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .99); }, 100);
	leftnavOpacityTimeoutId2_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .85); }, 200);
	leftnavOpacityTimeoutId3_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .75); }, 300);
	leftnavOpacityTimeoutId4_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .65); }, 400);
	leftnavOpacityTimeoutId5_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .55); }, 500);
	leftnavOpacityTimeoutId6_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .45); }, 600);
	leftnavOpacityTimeoutId7_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .35); }, 700);
	leftnavOpacityTimeoutId8_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .25); }, 800);
	leftnavOpacityTimeoutId9_leftnav = setTimeout(function() { setOpacity_leftnav(menu, .15); hidemenu(mid);}, 900);*/
	//alert("inside the last n");
	hidemenu(mid);
	
}

function cancelfade() 
{
	if(leftnavOpacityTimeoutId1_leftnav)
		clearTimeout(leftnavOpacityTimeoutId1_leftnav);
	
	if(leftnavOpacityTimeoutId2_leftnav)
		clearTimeout(leftnavOpacityTimeoutId2_leftnav);
	
	if(leftnavOpacityTimeoutId3_leftnav)
		clearTimeout(leftnavOpacityTimeoutId3_leftnav);
	
	if(leftnavOpacityTimeoutId4_leftnav)
		clearTimeout(leftnavOpacityTimeoutId4_leftnav);
	
	if(leftnavOpacityTimeoutId5_leftnav)
		clearTimeout(leftnavOpacityTimeoutId5_leftnav);
	
	if(leftnavOpacityTimeoutId6_leftnav)
		clearTimeout(leftnavOpacityTimeoutId6_leftnav);
	
	if(leftnavOpacityTimeoutId7_leftnav)
		clearTimeout(leftnavOpacityTimeoutId7_leftnav);
	
	if(leftnavOpacityTimeoutId8_leftnav)
		clearTimeout(leftnavOpacityTimeoutId8_leftnav);
	
	if(leftnavOpacityTimeoutId9_leftnav)
		clearTimeout(leftnavOpacityTimeoutId9_leftnav);
}
///////////////////////////////////////////////////////////////////////////////
// Footer
// Author: Ashlesha
// Date: 	 2007-07-30
///////////////////////////////////////////////////////////////////////////////
function showdiv(thisitem) {
	var thisitem2= "mainitem"+thisitem;
	var boxObj = document.getElementById(thisitem2);
	var boxStyle = boxObj.style;

	var textitem= "item"+thisitem;
	var urlObj = document.getElementById(textitem);

	var bottomitem = "bottomborder" + thisitem;
	var bottomObj = document.getElementById(bottomitem);
	
	boxObj.parentNode.style.position = "relative";
	boxStyle.bottom = "1em";
	
	document.getElementById("mr1_" + thisitem).style.marginLeft = (urlObj.offsetWidth) + "px";
	
	urlObj.style.background = "#FFF";
	urlObj.style.borderLeft="1px solid #DDD"
	urlObj.style.borderRight="1px solid #DDD";
	urlObj.style.marginLeft = "0px";
	urlObj.style.marginRight = "0px";

	
	// Keep this after modifying url obj margins and borders
	bottomObj.style.width=(urlObj.offsetWidth) + "px";
	
	boxStyle.display = 'block';
	boxStyle.visibility = 'visible';
	bottomObj.style.display = 'block';
	bottomObj.style.visibility = 'visible';
}
	
function hidediv(thisitem) {
	var thisitem2= "mainitem"+thisitem;
	var boxObj = document.getElementById(thisitem2);
	boxObj.style.visibility = 'hidden';
	boxObj.style.display = 'none';
	
	var thisitem3= "item"+thisitem;
	var urlObj = document.getElementById(thisitem3);
  	urlObj.style.background = 'none';
	urlObj.style.borderLeft="none"; 
	urlObj.style.borderRight="none";
	urlObj.style.marginLeft = "1px";
	urlObj.style.marginRight = "1px";
	
	var bottomitem = "bottomborder" + thisitem;
	var bottomObj = document.getElementById(bottomitem);
	bottomObj.style.display = 'none';
	bottomObj.style.visibility = 'hidden';
}

// 2007.09.07 KJD: Create the form to replace the document.location.href so that we can get the document.referrer



document.write("<DIV ID='thisLocationFormDiv' STYLE='visibility:hidden;position:absolute'></DIV>");
/* ****************************************************************************
URLredirect				Send the user to a different URL
Author: 				Kevin De Angelis
Date: 					2007.09.07
Receive: 				string
Return: 				null
**************************************************************************** */
function URLredirect( thisURL )
{
	var thisNav = navigator.userAgent.toLowerCase();
	if( thisNav.indexOf( "msie" ) > -1 )
	{
		var LocationFormString = "<FORM METHOD='POST' NAME='LocationForm' ACTION=\"" + thisURL + "\" STYLE='position:absolute;visibility:hidden;display:inline;'></FORM>";

		document.getElementById( 'thisLocationFormDiv' ).innerHTML = LocationFormString;
		document.LocationForm.submit();
	}
	else
	{
		location.href= thisURL;
	}
}

