/*****************************************************************************************************
/  Adds the new option created in the child window to the existing list. It is called by child window to do so.  
******************************************************************************************************/
function addToParentList(p_strName, p_strValue, strCreateFor, strNewItemId, strFormId) {
     var f = document.getElementById(strFormId);
     var optionList;
     switch ( strCreateFor ){
		case "display":
		     if (f.oty){
		         optionList = f.oty;
		         if (f.oty2){
		              var j = f.oty2.length; 
		              f.oty2.options[j] = new Option(p_strName, p_strValue);
		              f.oty2.options[j].selected = true;
		          }  
		     }else if (f.DisplayAs){
		           optionList = f.DisplayAs;
		     } 
		     break;        
		case "search": 
		      if (f.findIn){
		           optionList = f.findIn;
		     }else if (f.SearchSection){
		           optionList = f.SearchSection;
		     }
		     break ;       
		case "customFormat": 
		       optionList = f.custFields;
		       f.strAction.value = "add";
		      
		       if(document.getElementById('strAddTo') && document.getElementById('strAddTo').value == 'group')
		            p_strName = "Group: " + p_strName; 
		       f.listName.value = p_strName;     
		       document.getElementById("Save").style.display = "inline";
		       document.getElementById("Delete").style.display = "none"; 
		       break;         
		}
     var i = optionList.length;
     optionList.options[i] = new Option(p_strName, p_strValue);
     optionList.options[i].selected = true;  
     optionList.options[i].setAttribute ("ITEMID", strNewItemId);
     if(f.name == 'archive'){
          refreshPage("p", false, ""); 
     }
} 

/*****************************************************************************************************
/ Changes display formats, creates new window for customizing searchable fields and formats
 *****************************************************************************************************/
function ChangeFormat(optionSelected, customType){
	  /*f = window.document.forms[0];*/
	  var f=optionSelected.form;
	  f.setAttribute("target","");
      
      if (f.name == 'archive'){
            f.setAttribute("action","");    
      }
      if (optionSelected.value == 'other'){
             var newWindow = NewWindow( customType, "?formId="+f.id);
             
             f.target = '';
             if(f.oty2 && customType != 'customSearch'){
                  if(optionSelected.name == 'oty2'){
                       optionSelected.options[f.oty.selectedIndex].selected = true;
                  }else{
                       optionSelected.options[f.oty2.selectedIndex].selected = true;
                  } 
             }else{
                   optionSelected.options[0].selected = true; 
             }               
      }else{
            if(f.oty2 && customType != 'customSearch'){
                 if(optionSelected.name == 'oty2'){
                       f.oty.options[optionSelected.selectedIndex].selected = true;
                 }else{ 
                       f.oty2.options[optionSelected.selectedIndex].selected = true;
                 }     
            }     
            if (f.name == 'archive'){
                 refreshPage("p", false, "");
            } 
      } 
 }  

/*****************************************************************************************************
/	new cross-browser functions -- please modify them at will, I love constructive criticism. :)
 *****************************************************************************************************/
function getInfo(e) {
	/* USE: TO GATHER INFORMATION ON A PARTICULAR OBJECT*/
	str = "";
	for(prop in e){
		str += prop + ": " + 
			e[prop] + "\t";
	}
	if(!document.all)
	for(prop in e.target){
		str += prop + ": " + 
			e.target[prop] + "\t";
	}
	return(str);
}

function BrowserData(){
	agent  = navigator.userAgent.toLowerCase();
				
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
		
	/* detection for netscape Browsers */
	this.ns    = ((agent.indexOf('mozilla')   !=   -1) && 
				 ((agent.indexOf('spoofer')   ==   -1) && 
				 (agent.indexOf('compatible') ==   -1)));
	this.ns4   = (this.ns && (this.major      ==    4));
	this.ns6   = (this.ns && (this.major      >=    5));
	this.dom = (document.getElementsByTagName && !document.all);
		
	/* detection for ie Browsers */
	this.ie    = (agent.indexOf("msie")       !=   -1);
	this.ie3   = (this.ie && (this.major      < 4));
	this.ie4   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   ==   -1));
		             
	this.ie5 = (document.getElementById && document.all);             
	this.ie50   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   !=   -1));
	this.ie55  = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.5")   !=   -1));
		
	this.ie6   = (this.ie && (agent.indexOf("msie 6.0") != -1) );
		
	this.ie5Mac = ((agent.indexOf("mac") != -1) && this.ie5);
		
	/* detection for aol ie browsers */
	this.aol = (agent.indexOf("aol") != -1);
	this.aol3 = (this.aol && this.ie3);
	this.aol4 = (this.aol && this.ie4);
	this.aol5 = (this.aol && this.ie5);
}

oBD = new BrowserData();

function screenObject() {
	this.bottom = function() {
		if (document.body.scrollHeight) return document.body.scrollHeight;
		};
	this.height = function() {
			if (document.body.offsetHeight) return document.body.offsetHeight;
		};
	this.visHeight = function() {
			if (window.innerHeight) return window.innerHeight;
			if (document.body.clientHeight) return document.body.clientHeight;
		};
	this.width = function() {
			if (document.body.offsetWidth) return document.body.offsetWidth;
		};
	this.scrollTop = function() {
			if(document.body.scrollTop) return document.body.scrollTop
			if (window.pageYOffset) return window.pageYOffset;
			else return 0;
		};
}
curScreen = new screenObject();

var newwindow = new Object();
var sbWindow = new Object();

function hasIllegalChar(str){
	if (str.match(/[<>&#\\%+|]/)){
		return true;
	} else {
		return false;
	}
}

function trim(str){ 
	/* this code replicated in login.asp, make changes in both places. */
	for(var i=0;i<str.length;i++){
		if (str.charCodeAt(i) <= 32){
			str = str.substring(0,i) + " " + str.substr(i+1);
		}
	}
	str = str.replace(/^[\s]+/g,"");
	str = str.replace(/[\s]+$/g,"");
	return str;
}

function CStr(vVariant){
	try{
		var str = new String(vVariant).toString();
		if(str == "undefined" || str == "null")
			str = "";
		}
	catch(e){str = "";}
	return str;
}

function CInt(vVariant){
	try{
		var num = 0;
		if (CStr(vVariant) != "" && !isNaN(vVariant))
			num = parseInt(vVariant);
	}
	catch(e){num = 0;}
	return num;
}

function isNumeric(vVariant){
	try {
		var num = 0;
		var numeric = false;
		if (CStr(vVariant) != "" && !isNaN(vVariant)){
			num = parseInt(vVariant);
			numeric = true;
		}
	}
	catch(e){numeric = false;}
	return numeric;
}

/* PROTOTYPES ADDED TO ARRAY OBJECTS */
function deleteIndex(index){
	if (index == -1)
	return this;
	else if (index == 0)
		return this.slice(1);
	else if (index == (this.length - 1))
		return this.slice(0,(this.length - 1));
	else{
		tempArr1 = this.slice(0,index);
		tempArr2 = this.slice(index + 1);
		returnArr = tempArr1.concat(tempArr2);
	}
	return returnArr;
}
Array.prototype.deleteIndex = deleteIndex;
	
function findIndex(value){
	for(i=0; i < this.length; i++)
		if(this[i] == value)
			return (i);
	return (-1);
}
Array.prototype.findIndex = findIndex;
	
function findObjIndex(param,value){
	for(i=0; i < this.length; i++)
		if( this[i][param] == value )
			return (i);
	return (-1);
}
Array.prototype.findObjIndex = findObjIndex;
	
function getNode(obj){
	while ( obj.nodeType != Node.ELEMENT_NODE ){
		obj = obj.parentNode;
	}			
	return obj;
}
	
function findChildNode(nodeObj,tn,cn) {
	cn = (cn)? CStr(cn):"";
	for (var i=0; i<nodeObj.childNodes.length;i++) {
		switch (nodeObj.childNodes[i].nodeType) {
			case 1:
				tVal = null;
				if ( nodeObj.childNodes[i].tagName == tn.toUpperCase() && 
					(nodeObj.childNodes[i].className == cn || nodeObj.childNodes[i].id == cn) ) {
					return nodeObj.childNodes[i];
				}
				else {
					tVal = findChildNode(nodeObj.childNodes[i],tn,cn);
					if (tVal) return tVal;
				}
				break;
		}
	}
}

function findParentElement(node,tagName,className){
	/* USE: TO FIND THE PARENT OF A NODE USING TAGNAME AND CLASSNAME AS THE SEARCH CRETERIA. */
	/* NOTE: ONLY RETURNS THE FIRST NODE FOUND */
	for(;node != null; node = node.parentNode){
		if (className && className.length > 0){
			if (node.nodeType == 1 && node.nodeName.toUpperCase() == tagName.toUpperCase() && (node.className == className || node.id == className)) 
				return node;
		}
		else if (node.nodeType == 1 && node.nodeName.toUpperCase() == tagName.toUpperCase())
			return node;
	}
	return null;
}


function findChildElement(node,tagName,className,index){
	/* USE: TO FIND THE CHILDELEMENTS OF A NODE USING TAGNAME AND CLASSNAME AS THE SEARCH RETERIA. */
	/* NOTE: ONLY RETURNS THE FIRST NODE FOUND */
	if ( node && node.hasChildNodes){
		var sInd = 1;
		for (var i=0;i < node.childNodes.length; i++) {
			childNode = node.childNodes[i];
			if (className && className.length > 0){
				if (childNode.nodeType == 1 && childNode.nodeName.toLowerCase() == tagName.toLowerCase() && (childNode.className == className || childNode.id == className)){
					if (CInt(index) != 0) {
						if (CInt(index) == sInd){
							return childNode;
						}
						sInd++;
					}else{
						return childNode;
					}
				} 
			}
			else if(childNode.nodeType == 1 && childNode.nodeName.toLowerCase() == tagName.toLowerCase())
					return childNode;		
		}
	}
	return null;
}

function getInnerText(nodeObj){
	/* Not needed but it is faster for ie browsers */
	if (oBD.ie5) return nodeObj.innerText;	
		
	var str = "";
	for (var i=0; i<nodeObj.childNodes.length; i++){
		switch (nodeObj.childNodes.item(i).nodeType){
			case 1: 
				/* ELEMENT_NODE */
				str += getInnerText(nodeObj.childNodes[i]);
				break;
			case 3:	
				/* TEXT_NODE */
				str += nodeObj.childNodes[i].nodeValue;
				break;
		}		
	}	
	return str;
}

function findPreviousSibling(node,tagName,className){
	try{
		if (node.previousSibling){
			for (node = node.previousSibling; node != null; node = node.previousSibling)
			if (node.nodeType == 1 && node.nodeName.toUpperCase() == tagName.toUpperCase() && (node.className == className || node.id == className))
				return node;
		}
	}
	catch(e) {return null;}
	return null;
}

function findNextSibling(node,tagName,className){
	try{
		if (node.nextSibling){
			for (node = node.nextSibling ;node != null; node = node.nextSibling) 
				if (node.nodeType == 1 && node.nodeName.toUpperCase() == tagName.toUpperCase() && (node.className == className || node.id == className))
					return node;
		}	
	}
	catch(e) {return null;}
	return null;
}
	
function getCoords(obj){
	var x = 0;
	var y = 0;
	while (obj){
		y += obj.offsetTop;
		x += obj.offsetLeft;
		if (oBD.ie5Mac && obj.tagName.toUpperCase() == "BODY"){
			y += parseInt(obj.currentStyle.marginTop);
			x += parseInt(obj.currentStyle.marginLeft);	
		}
		obj = obj.offsetParent;
	}
	return [x,y];
}
	
function check(){
	if (check.arguments.length == 1) {
		allornone = check.arguments[0];
		inputObj = document.getElementsByTagName("INPUT");
		for (var i=0; i<inputObj.length; i++ ) {
			if (inputObj[i].type == "checkbox" && inputObj[i].getAttribute("disabled") != true) {
				inputObj[i].checked = allornone;
			}
		}
	} 
	else {
		if (check.arguments.length == 2) {
			classNameId = check.arguments[0];
			allornone = check.arguments[1];
			inputObj = document.getElementsByTagName("INPUT");
			for (var i=0; i<inputObj.length; i++ ) {
				if (inputObj[i].type == "checkbox" && inputObj[i].getAttribute("disabled") != true && inputObj[i].parentNode.className == classNameId) {
					inputObj[i].checked = allornone;
				}
			}
		} 
		else {
			return false;				
		}
	}
}

function KillWindows() {
	for(var i=0;i<windowArray.length;i++) {
		if (windowArray[i] != null && !(windowArray[i].closed)) {
			windowArray[i].close();
		}
	}
}

/******************************************************************************************************
/	navbar cross-browser functions -- do not touch
 *****************************************************************************************************/
	
var defaultNavBar = "navBarCont0";
var numberNavBarMenuItems = 5;
var framesInc = true;
var currentTR = "";
var navEdgeImgObjOn = document.createElement("IMG");
navEdgeImgObjOn.setAttribute("src","../../img/edgew.gif");
var navEdgeImgObjOff = document.createElement("IMG");
navEdgeImgObjOff.setAttribute("src","../../img/edgespacer.gif");
curMenuObj = new String();
curNavObj = new String();
	
var windowOnLoad = new Function();
var	doNothing = new Function();
/* var initPage = new Function();*/
var timeOutValue = 0;
var timeOutForDelayNav			= 0;
var srcForDelayNav				= null;
var isMouseOutsideOfNav			= true;
var intInitialDelayForNav		= 175;
	
/* variables for navigation bar colors */
var const_nav_base_Color = "666666";
var const_nav_base_BGColor = "FFFFFF";
var const_nav_mouseOver_Color = "FFFFFF";
var const_nav_mouseOver_BGColor = "6666CC";
var const_nav_default_Color = "#FFFFFF";
var const_nav_default_BGColor = "#666666";
var strPopupHelpLink = "";
/* variable used by helpmenu functions. */
var STR_SA_FROM = "GL";
	
function closeAll() {
	for (var i=0;i<8;i++) {
		targetHeadObj = document.getElementById("navObj" + i);
		if(targetHeadObj) {
			targetHeadObj.className = "navTitle";
			alinkObj = findChildElement(targetHeadObj,"A","navItem");
			alinkObj.style.color = const_nav_base_Color;
			targetHeadObj.style.backgroundColor = const_nav_base_BGColor;
			imgObj = findNextSibling(targetHeadObj,"TH","navEdge");
			imgObj.childNodes[0].src = navEdgeImgObjOff.src;
			imgObj.style.backgroundColor =  const_nav_base_BGColor;
			targetObj = document.getElementById("navBarCont" + i);
			if (targetObj) {
				targetObj.style.backgroundColor = const_nav_mouseOver_BGColor;
				targetObj.style.display = "none";
			}
		}
	}
	return false;
}
function goToHelpSite(cat) {
	var objHelpMenu = document.getElementById("helpMenuCont");
	if (objHelpMenu){
		objHelpMenu.style.visibility = "visible";
	}
	var tempNavHelpURL;
	var langDir = navHelpURL.substr(navHelpURL.lastIndexOf("/"));
	switch ( cat ) {
		case "PRD":
			if (strPopupHelpLink == "" ){
				switch (defaultNavBar) {
					case "navObj1":
						tempNavHelpURL = navHelpURL + "/text/ft_over.html";
						break;
					case "navObj2":
						tempNavHelpURL = navHelpURL + "/text/p_ovr.html";
						break;
					case "navObj3":
						tempNavHelpURL = navHelpURL + "/text/p_ovr.html";
						break;
					case "navObj4":
						tempNavHelpURL = navHelpURL + "/admin/a_ovr.html";
						break;
					case "navObj5":
						/* Current no help url for hear */
						break;
					case "navObj6":
						/* Current no help url for hear */
						break;
					default: {
						switch (defaultNavBarSubIndex) {
							case "MB-M0-0":
								tempNavHelpURL = navHelpURL + "/text/ft_over.html";
								break;
							case "MB-M0-1":
								tempNavHelpURL = navHelpURL + "/text/ss_ovr.html";
								break;
							case "MB-M7-1":
								tempNavHelpURL = navHelpURL + "/text/cs_ovr.html";
								break;
							case "MB-M7-3":
								tempNavHelpURL = navHelpURL + "/text/fq_ovr.html";
								break;
							case "MB-M7-0":
								tempNavHelpURL = navHelpURL + "/text/qs_over.html";
								break;
							default:
								tempNavHelpURL = navHelpURL + "/text/index.html";
						}
							
					}
				}
			}else{
				tempNavHelpURL = navHelpURL  + strPopupHelpLink;
			}
			tempNavHelpURL = navHelpSite  + langDir + "/help/helpmain.asp?SA_FROM=" + STR_SA_FROM + "&helpUrl=" + tempNavHelpURL;
			break;
		case "LRN":
			tempNavHelpURL = navHelpSite + langDir  + "/learning/LearningMain.asp?SA_FROM=" + STR_SA_FROM + "&LearningTab=Home";
			break;
		case "CNT":
			tempNavHelpURL = navHelpSite + langDir + "/Content/contentmain.asp?SA_FROM=" + STR_SA_FROM + "&CWTab=Watch";
			break;
		case "CST":
			tempNavHelpURL = navHelpSite + langDir + "/Support/supportmain.asp?SA_FROM=" + STR_SA_FROM;
			break;
		default:
			tempNavHelpURL = navHelpSite + langDir + "/auth/postlogin.asp?SA_FROM=" + STR_SA_FROM;
	}
	NewWindow(tempNavHelpURL);
	strPopupHelpLink = "";
	if (objHelpMenu) {
		objHelpMenu.style.visibility = "hidden";
	}
	return false;
}

function getHelpURL(e) {
	
		var src = null;
		if (oBD.ns6){
			src = getNode(e.target);
			e.stopPropagation();
		}else{
			src = event.srcElement;
			window.event.cancelBubble = true;
		}
		var tarObj = null;
		tObj1 = findParentElement(src,"TD","supportLink");

		if (tObj1) {
			// find nextSibling
			var tempObj = tObj1.nextSibling;
			tarObj = findChildNode(tempObj,"img","");
		}
		else {
			var tempObj = findParentElement(src,"TD","helpIcon");
			if (tempObj)
				tarObj = findChildNode(tempObj,"img","");
		}	
		if (!tarObj) {
			tarObj = document.getElementById("helpIconCont");
		}
		
		
		if((tarObj.getAttribute("hlink")!= null )&& (tarObj.getAttribute("hlink") != 'undefined')) {
			strPopupHelpLink = tarObj.getAttribute("hlink");
		}
		
		if (tarObj)
		{
			var tempArr = getCoords(tarObj);
			var HelpSelectionObj = document.getElementById("helpMenuCont");
			var HelpObj = document.getElementById("helpMenuFrame");
			var winObj = window["helpMenuFrame"];
			
			if (winObj)
				winObj.updateFrameContainer();
			var intWidth = parseInt(HelpObj.width);
			t = winObj.getDimensions()
			// set the height and the width
			HelpSelectionObj.style.width = t[0] + "px";
			HelpSelectionObj.style.height = t[1] + "px";
			HelpObj.width = t[0] + "px";
			HelpObj.height = t[1] + "px";
			
			var h = curScreen.scrollTop() + curScreen.visHeight();
			var d = (CInt(tempArr[1])+ CInt(HelpSelectionObj.offsetHeight));	
			if (parseInt(d) > parseInt(h) )
				d = CInt(tempArr[1]) - (parseInt(d) - parseInt(h));
			else 
				d = tempArr[1];
			HelpSelectionObj.style.visibility = "visible";
			HelpSelectionObj.style.left = (tempArr[0] + tarObj.offsetWidth - intWidth) + "px";
			HelpSelectionObj.style.top = (d + parseInt(tarObj.offsetHeight) - 2) + "px";
			
			HelpSelectionObj.style.visibility = "visible";

			HelpSelectionObj.style.zIndex = "100";
			if (oBD.ie5Mac) {
				window.setTimeout("popUpHelpMenu()",100);
				HelpSelectionObj.style.visibility = "hidden";
			}
		}
	
	return false;
}

function popUpHelpMenu() {
	var HelpSelectionObj = document.getElementById("helpMenuCont");
	var HelpObj = document.getElementById("helpMenuFrame");
	HelpSelectionObj.style.visibility = "visible";
}

function setDefaultNavElem() {
	if (curNavObj != defaultNavBar) {
		closeAll();
		if (setDefaultNavElem.arguments.length == 1) {
			defaultNavBar = setDefaultNavElem.arguments[0];
		}
		defaultObj = document.getElementById(defaultNavBar);
		if (defaultObj) {
			defaultObjAlink = findChildElement(defaultObj,"A","navItem");
			parentTR = findParentElement(defaultObj,"TR","wrapper");
			imgObj = findNextSibling(defaultObj,"TH","navEdge");
			imgObj.childNodes[0].src = navEdgeImgObjOn.src;
			defaultObj.style.backgroundColor = const_nav_default_BGColor;
			if (defaultObjAlink) {
				defaultObjAlink.style.color = const_nav_default_Color;
			}
			defaultSubNav = document.getElementById(defaultNavBar.replace("navObj","navBarCont"));
			if (defaultSubNav) {
				defaultSubNav.style.backgroundColor = const_nav_default_BGColor;
				defaultSubNav.style.display = "block";
				
				try {
					var objLastTd;
					var objTable	= findChildElement(defaultSubNav,"TABLE");
					var objFirstTd	= objTable.rows[0].cells[0];
					objLastTd		= objTable.rows[0].cells[objTable.rows[0].cells.length-1];
					objLastTd.style.visibility = "visible";
					objLastTd		= objTable.rows[0].cells[objTable.rows[0].cells.length-2];
					objLastTd.style.visibility = "visible";
					if (defaultNavBarSubIndex) {
						objAlink = document.getElementById( defaultNavBarSubIndex );
						if (objAlink) {
							var oldALink = findChildElement(objFirstTd,"A","subNavBold");
							if (oldALink){
								oldALink.className = "subNav";
							}
							objAlink.className = "subNavBold"; 
						}
					}
				} catch(e){return 0;}	
			}
			curNavObj = defaultNavBar;
			timeOutValue = 0;
			isMouseOutsideOfNav = true;
		}
	}
	return false;
}
	
function toggleNav(e) {
	if (toggleNav.arguments.length == 1){
		if (oBD.ie5) {
			src = window.event.srcElement;
		}
		else if (oBD.dom) {
			src = e.target;
		}
	}else if(toggleNav.arguments.length == 2){
		src = toggleNav.arguments[1];
	}
	alinkObj = findParentElement(src,"A","navItem");
		
	if (alinkObj) {
		var curNode = findParentElement(src,"TH","navTitle");
		var curImageNode = findNextSibling(curNode,"TH","navEdge");
		var backgroundObj = document.getElementById("navTarget");
		var tarObj = document.getElementById(curNode.id.replace("navObj","navBarCont"));
		var tarBlockObj = document.getElementById(curNavObj.replace("navObj","navBarCont"));
		var deselectObj = document.getElementById(curNavObj);
		if (!deselectObj) {
			return false;
		}
		var deselectAlinkObj = findChildElement(deselectObj,"A","navItem");
		if (curNode.id == curNavObj) 
			return false;
		if (curNode.id != defaultNavBar && deselectObj) {
			curImageNode.childNodes[0].src = navEdgeImgObjOn.src;
			alinkObj.style.color = const_nav_mouseOver_Color;
			curNode.style.backgroundColor = const_nav_mouseOver_BGColor;
			if (curNavObj != defaultNavBar) {
				deselectImgObj = findNextSibling(deselectObj,"TH","navEdge");
				deselectImgObj.childNodes[0].src = navEdgeImgObjOff.src;
				deselectAlinkObj.style.color = const_nav_base_Color;
				deselectObj.style.backgroundColor = const_nav_base_BGColor;
			}
		}
		else setDefaultNavElem();
		if (tarBlockObj)
			tarBlockObj.style.display = "none";
		if (tarObj)
			tarObj.style.display = "block";
		curNavObj = curNode.id;
		isMouseOutsideOfNav = false;
	}
	else
		startTimeout();
	return false;
}

function keepMenu(e) {
	if (oBD.ie5) window.event.cancelBubble = true;
	else if (oBD.dom) e.stopPropagation();
	if (timeOutValue != 0) {
		window.clearTimeout(timeOutValue);
		timeOutValue = 0;
	}
}

function keepNormalMenu(e) {
	if (oBD.ie5) window.event.cancelBubble = true;
	else if (oBD.dom) e.stopPropagation();
}

function closePopUp() {
	document.getElementById("Popup").style.display = "none";
	currentTR = "";
}

function flipDirectLinkBox() {
	if (document.getElementById("directLinkBox").style.display == "block") {
		document.getElementById("directLinkBox").style.display = "none";
	} else {
		document.getElementById("directLinkBox").style.display = "block";
	}
	if (typeof placeToolBar == "function") placeToolBar();
}
	
function createDirectLink() {
	document.getElementById("directLinkALink").setAttribute("href",document.getElementById("directLinkURLHRef").getAttribute("value"));
	document.getElementById("directLinkALink").innerHTML = document.getElementById("directLinkURLName").getAttribute("value");
}
	
function hideMenu(event) {
	if (oBD.ie5) {
		src = window.event.srcElement;
	}
	else if (oBD.dom) {
		src = event.target;
	}
	if (document.getElementById("Popup")){
		closePopUp();
	}
	if (document.getElementById("helpMenuCont")){
		document.getElementById("helpMenuCont").style.visibility = "hidden";
	}
	if (document.getElementById("dMenuItems")){
		document.getElementById("dMenuItems").style.visibility = "hidden";
	}
	if (document.getElementById("headlineBar")){
		if (tempHeadlineBar != "")
		{
			temp = document.getElementById(tempHeadlineBar.replace("pop",""));
			temp.style.display = "none";
		}
		tempHeadlineBar = "";
	}
	else
		startTimeout();
		
	if ( timeOutForDelayNav != 0 ){
		window.clearTimeout(timeOutForDelayNav);
		timeOutForDelayNav = 0;
	}
}
	
/******************************************************************************************************
/		Terminology:
/		The area to be opened and closed is called a flip.
/		The graphic widget which toggles it is called a flipper.
/		The flip and flipper must share a common base name.
/		ex: base name is "source"
/		flip name is "sourceFlip"
/		flipper name is "sourceFlipper"
 *****************************************************************************************************/

var expanded = document.createElement("IMG");
expanded.setAttribute("src","../../img/collapse.gif");
var collapsed = document.createElement("IMG");
collapsed.setAttribute("src","../../img/expand.gif");

var w_expanded = document.createElement("IMG");
w_expanded.setAttribute("src","../../img/whminus.gif");
var w_collapsed = document.createElement("IMG");
w_collapsed.setAttribute("src","../../img/whplus.gif");

var b_expanded = document.createElement("IMG");
b_expanded.setAttribute("src","../../img/modifyminus.gif");
var b_collapsed = document.createElement("IMG");
b_collapsed.setAttribute("src","../../img/modifyplus.gif");
		
function openFlip(flipObj, type) {
	if (flipObj) {
		var flipperName = flipObj.id.replace("Flip","Flipper");
		flipObj.style.display = "block";
		flipObj.setAttribute("state","open");
		if (document.images[flipperName]) {
			switch (CStr(type).toLowerCase()) {
				case "blue":
					document.images[flipperName].setAttribute("src",b_expanded.getAttribute("src"));
					document.images[flipperName].setAttribute("title","Click to hide custom options.");
					break;
				case "white":
					document.images[flipperName].setAttribute("src",w_expanded.getAttribute("src"));
					document.images[flipperName].setAttribute("title","Click to hide custom options.");
					break;
				default:
					document.images[flipperName].setAttribute("src",expanded.getAttribute("src"));
					document.images[flipperName].setAttribute("title","Click to hide custom options.");
					break;
			}
		}
	}
	return false;
}

function closeFlip(flipObj, type) {
	if (flipObj) {
		var flipperName = flipObj.id.replace("Flip","Flipper");
		flipObj.style.display = "none";
		flipObj.setAttribute("state","close");
		if (document.images[flipperName]) {
			switch (CStr(type).toLowerCase()) {
				case "blue":
					document.images[flipperName].src = b_collapsed.src;
					document.images[flipperName].title = "Click to show custom options.";
					break;
				case "white":
					document.images[flipperName].src = w_collapsed.src;
					document.images[flipperName].title = "Click to show custom options.";
					break;
				default:
					document.images[flipperName].src = collapsed.src;
					document.images[flipperName].title = "Click to show custom options.";
					break;
			}
		}
	}
	return false;
}

/* Toggle the flip. */
function toggleFlip(flipBasename, menuRef, Index) {
	//tarObj = document.getElementsByName(flipBasename + "Flip");
	tName = flipBasename + "Flip"
	divObjs = document.getElementsByTagName("DIV");
	for (var i=0;i<divObjs.length;i++) { 
		if (divObjs[i].className == "flip" && divObjs[i].id == tName) {
			if (divObjs[i].style.display == "none")
				openFlip(divObjs[i],divObjs[i].getAttribute("imageType"));
			else 
				closeFlip(divObjs[i],divObjs[i].getAttribute("imageType"));
				
			if (menuRef) {				 
				menuObj = eval(menuRef);
				menuObj.selectedIndex = Index;
			}
			if (flipBasename == "language") {
				if (document.headlinesForm)
					document.getElementsByName("searchLanguage")[3].checked = true;		
				else
					document.getElementsByName("searchLanguage")[2].checked = true;		
			}	
			if (flipBasename == "main") {
				if (document.forms["headlinesForm"]) {
					recreateSelectBox(document.forms["headlinesForm"].dateRangeMenu,"",false);
					recreateSelectBox(document.forms["headlinesForm"].savedSources,"",true);
					recreateSelectBox(document.forms["headlinesForm"].findIn,"",false);
				}
				if (document.forms["searchForm"]) {
					try {
						recreateSelectBox(document.forms["searchForm"].sortBy,"",false);
						recreateSelectBox(document.forms["searchForm"].findIn,"",false);
					} catch(e) {;}
				}
			}
		}			
	}
	return false;
}
	
/* If last option of menuObj is selected, open the flip; otherwise, close it.*/
function menuFlip(menuObj, flipBasename) {
	if (document.getElementById(flipBasename + "Flip").getAttribute("state") == "close"
		&& menuObj.selectedIndex == menuObj.length - 1) {
		openFlip(document.getElementById(flipBasename + "Flip"));
	} 
	else if (menuObj.selectedIndex == menuObj.length - 1) {
		openFlip(document.getElementById(flipBasename + "Flip"));
	}
	else  {
		closeFlip(document.getElementById(flipBasename + "Flip"));
	}
}
		
function initFlips() {	
	divObjs = document.getElementsByTagName("DIV");
	for (var i=0;i<divObjs.length;i++) {
		if (divObjs[i].getAttribute("state") && divObjs[i].className == "flip" ) {
			if (divObjs[i].getAttribute("state").toLowerCase() == "open")
				openFlip(divObjs[i],divObjs[i].getAttribute("imageType"));
			else
				closeFlip(divObjs[i],divObjs[i].getAttribute("imageType"));
		}
	}
}
	
function startTimeout()	{
	if (timeOutValue == 0)
		timeOutValue = setTimeout('setDefaultNavElem()',1000);
	return false;
}

function startToggleNav(e)	{
	if (isMouseOutsideOfNav){
		if (oBD.ie5) {
			srcForDelayNav = window.event.srcElement;
		}
		else if (oBD.dom) {
			srcForDelayNav = e.target;
		}
		timeOutForDelayNav	= setTimeout('doToggleNav()',intInitialDelayForNav);
	}else{
		toggleNav(e);
	}
	return false;
}
function doToggleNav(){
	toggleNav(null, srcForDelayNav);
}

function putLoadingGeneral(divObjStr,msgStr,position,paddingTop) {
	var divClassName = new String();
	var message = new String();
	if (msgStr && msgStr.length > 0)
		message = msgStr;
	else
		message =  "Loading";
	if (position && position == "center")
		divClassName = "loadingMsg";
	else
		divClassName = "loadingDiv";
	divObj = document.getElementById(divObjStr);
	if (divObj) {
		divObj.innerHTML = "";
		var tempLoadingDiv = document.createElement("DIV");
		tempLoadingDiv.className = divClassName;
		var tempText = document.createTextNode(message);
		tempLoadingDiv.appendChild(tempText);
		divObj.appendChild(tempLoadingDiv);
		divObj.style.paddingTop = paddingTop;
	}
}
	
function initPage() {
	windowOnLoad();
	try {
		document.body.setAttribute("scroll","auto");
		initFlips();
		document.onmouseover = hideMenu;
	} catch(e){}
}
window.onload = initPage;

function restoreDelimiterChars(stringThing) {
	stringThing = stringThing.replace(/```` /g, "|")
	stringThing = stringThing.replace(/``` /g, "\"")
	stringThing = stringThing.replace(/`` /g, "'")
	return stringThing.replace(/` /g, ",")
}
	
function LogMeOut() {
	var mommy = self;
	while (mommy.parent != mommy && mommy.parent != null) {
		mommy = mommy.parent;
	}
	try	{
		var whatever = mommy.window.opener.location.href;
		if (LogMeOut.arguments.length == 1) 
			mommy.window.opener.LogMeOut(LogMeOut.arguments[0]);
		else
			mommy.window.opener.LogMeOut();
	} catch(e) {
		KillWindows();
		if (LogMeOut.arguments.length == 1) 
			mommy.location="../sess/logout.asp?reason=" + LogMeOut.arguments[0];
		else
			mommy.location="../sess/logout.asp";
	}
}

var windowHandle, windowInterval;
var OLD_TARGET = "";
var OLD_ACTION = "";
var CURRENT_FORM = new Object();

function SubmitFormToWin(){ 
	if (CURRENT_FORM.tagName && CURRENT_FORM.tagName.toLowerCase() == "form"){
		CURRENT_FORM.submit();
		if (oBD.ie5Mac)
			window.setTimeout("changeTargetAndAction()",100);
		else
			window.setTimeout("changeTargetAndAction()",1);
	}
}
function changeTargetAndAction(){
	if (CURRENT_FORM.tagName && CURRENT_FORM.tagName.toLowerCase() == "form"){
		CURRENT_FORM.target = OLD_TARGET;
		CURRENT_FORM.action = OLD_ACTION;
		OLD_TARGET = "";
		OLD_ACTION = "";
		CURRENT_FORM = new Object();
	}
}
function NewWindow() {
	var mommy = self;
	while (mommy.parent != mommy && mommy.parent != null) {
		mommy = mommy.parent;
	}
	try	{
		var whatever = mommy.opener.location.href;
		if (NewWindow.arguments.length == 0)
			windowHandle = mommy.opener.newWindow(NewWindow.arguments[0]);
		else
			windowHandle = mommy.opener.newWindow(NewWindow.arguments[0],NewWindow.arguments[1]);
	} catch(e) {
		var x, y, arg0, arg1, itIsAlreadyOpen = false;
		var windowIndex, windowURL, options, reloadNecessary;
		arg0 = NewWindow.arguments[0];
		arg1 = NewWindow.arguments[1];
			
		if (NewWindow.arguments.length > 1) {
			if(typeof arg1 == "string") {
				var querystring = arg1;
				var formObj = null;
				if (querystring == "") {
					reloadNecessary = false;
				} else {
					reloadNecessary = true;
				}
			} else { 
				var querystring = "";
				var formObj = arg1;
				reloadNecessary = true;
			}
		} else {
			var querystring = "";
			var formObj = null;
			reloadNecessary = false;
		}
			
		/* window defaults */
		scrollbar=1;				/* scroll bars are on */
		outsideURL = false;		/* internal site */
			
		switch(arg0 + "") {

			case "assignIPs":
				windowURL = "../admn/addIPs.asp";
				x = 800;
				y = 480;
				windowIndex=0;
			break;

			case "HMD":
				windowURL = "../mds/newglobalstock.asp";
				x = 800;
				y = 480;
				windowIndex=4;
			break;

			case "addUsers":
				windowURL = "../admn/addusers.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;

			case "newClientCode":
				windowURL = "../cibs/newClientCodeSpec.asp";
				x = 500;
				y = 300;
				windowIndex=1;
			break;

			case "addToBriefcase":
				windowURL = "../srch/hl-briefcase.asp";
				x = 400;
				y = 200;
				windowIndex=1;
			break;

			case "briefcase":
				windowURL = "../brfcs/briefcase.asp";
				x = 800;
				y = 500;
				windowIndex=1;
			break;

			case "bulkSave":
				windowURL = "../cust/bulkSave.asp";
				x = 250;
				y = 125;
				windowIndex=1;
			break;

			case "copyToBriefcase":
				windowURL = "../srch/hl-briefcase.asp";
				x = 400;
				y = 200;
				windowIndex=2;
			break;

			case "saveBriefcase":
				windowURL = "../brfcs/briefcase-rename.asp";
				x = 500;
				y = 300;
				windowIndex=2;
			break;

			case "adminPref":
				windowURL = "../pref/Admn-general.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "assignItemToGroup":
				windowURL = "../admn/assignitemtogroup.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "addToGroups":
				windowURL = "../sym/doCompTran.asp";
				x = 500;
				y = 300;
				windowIndex=1;
			break;

			case "bulkRegistrationReviewData":
				windowURL = "../cust/bulkRunJobReview.asp";
				x = 480;
				y = 640;
				windowIndex=0;
			break;

			case "bulkRegistrationSaveProfile":
				windowURL = "../cust/bulk_reg_step3_save_profile.asp";
				x = 250;
				y = 125;
				windowIndex=1;
			break;

			case "cleanCopy":
				windowURL = "../arch/clean_copy.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
				
			case "DisplayArticleReport":
				windowURL = "../arch/display.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;
				
			case "printCopy":
				windowURL = "../arch/print_results.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
				
			case "saveCopy":
				windowURL = "../arch/save_results.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
			
			case "investextPDF":
				windowURL = "../arch/getInvestPdf.pdf";
				x = 800;
				y = 550;
				windowIndex=0;
			break;
			
			case "migrationJobStatus":
				windowURL = "../mig/migrationJobStatus.asp";
				x = 800;
				y = 480;
				windowIndex=0;
			break;
							
			case "mdsCleanCopy":
				windowURL = "../mds/CleanCopy.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;

			case "companyList":
				windowURL = "../sym/colistcreate.asp";
				x = 800;
				y = 575;
				windowIndex=0;
			break;

			case "costCentre":
				windowURL = "../cibs/costlogit.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;

			case "email":
				windowURL = "../ode/email-request.asp";
				x = 800;
				y = 550;
				windowIndex=2;
			break;

			case "trackEmailAdmin":
				windowURL = "../track/emailAdmin.asp";
				x = 800;
				y = 550;
				windowIndex=2;
			break;

			case "modifyGroup":
				windowURL = "../admn/modifygroup.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "onlineUsage":
				windowURL = "../usg/onlineusage.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;
				
			case "redirectEditor":
				windowURL = "../cust/redirectEditor.asp";
				x = 500;
				y = 240;
				windowIndex=0;
			break;

			case "reportCleanCopy":
				windowURL = "../usg/reportCleanCopy.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "reportDownload":
				windowURL = "../usg/reportDownload.csv";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "pricingMessage":
				windowURL = "../srch/Pricing-Message.asp";
				x = 200;
				y = 200;
				windowIndex=3;
			break;

			case "printerFormatCopy":
				windowURL = "../arch/print_results.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "saveFormatCopy":
				windowURL = "../arch/save_results.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "preferences":
				windowURL = "../pref/prefs-general.asp";
				x = 800;
				y = 525;
				windowIndex=0;
				scrollbar=0;
			break;

			case "savedQuotesList":
				windowURL = "../sym/editmodule.asp";
				x = 800;
				y = 575;
				windowIndex=0;
			break;

			case "saveSearch":
				windowURL = "../srch/save-search.asp";
				x = 500;
				y = 300;
				windowIndex=1;
			break;
				
			case "screenTooSmall":
				windowURL = "../sess/screenTooSmall.asp";
				x = 400;
				y = 150;
				windowIndex=3;
			break;

			case "newCustomFormat":
				windowURL = "newCustomFormat.asp";
				x = 500;
				y = 300;
				windowIndex=3;
			break;
				
			case "customSearch":
				windowURL = "../gen/custom_search.asp";
				x = 750;
				y = 600;
				windowIndex=5;
			break;
				
			case "customDisplay":
				windowURL = "../gen/custom_display.asp";
			    x = 750;
				y = 600;
				windowIndex=5;
			break;
				
			case "newItem":
				windowURL = "../sym/newItem.asp";
				x = 500;
				y = 300;
				windowIndex=1;
			break;

			case "searchBuilder":
				reloadNecessary = false;
				tab = "tab0";
				windowURL = "../sb/searchBuilder3.asp";
				x = 700;
				y = 525;
				windowIndex=1;
			break;

			case "sourceBrowser":
				windowURL = "../srb/mainFrame.asp";
				x = 710;
				y = 600;
				windowIndex=1;
				scrollbar=0;
			break;
				
			case "screeningCSV":
				windowURL = "../nds/factiva.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;

			case "sourcesCSV":
				windowURL = "../srb/src.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
			
			case "chartCleanCopy":
				windowURL = "../chmd/cleancopy.asp";
				x = 650;
				y = 550;
				windowIndex=4;
			break;
				
			case "sourcesCleanCopy":
				windowURL = "../srb/viewsources.asp";
				x = 500;
				y = 500;
				windowIndex=4;
			break;

			case "userAgreement":
				windowURL = "../srch/User-Aggrement.asp";
				x = 200;
				y = 200;
				windowIndex=3;
			break;

			case "validationList":
				windowURL = "../cibs/validationList.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;
				
			case "login":
				windowURL = "../sess/login.asp";
				x = 800;
				y = 600;
				windowIndex=4;
			break;

			case "rtfHeadlines":
				windowURL = "../fmt/rtf-display.rtf";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "rtfDisplay":
				windowURL = "../arch/rtf_display.rtf";
				x = 800;
				y = 500;
				windowIndex=4;
			break;
				
			case "examples":
				windowURL = "../help/ft_exmpl.html";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
			
			case "migrationPreviewMessage":
				windowURL = "../mig/migrationPreview.asp";
				x = 500;
				y = 200;
				windowIndex=4;
			break;
			
			case "FIIDetails":
				windowURL = "../sb/viewCode.asp";
				x = 650;
				y = 525;
				windowIndex=1;
			break;
			
			case "FIISrcDetails":
				windowURL = "../srb/viewSources.asp";
				x = 650;
				y = 525;
				windowIndex=1;
			break;
			
			case "FIISrcBrowser":
				windowURL = "../esrcb/sb.asp";
				x = 650;
				y = 525;
				windowIndex=2;
			break;
			
			case "sbCSV":
				windowURL = "../sb/codes.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
				
			case "sbCleanCopy":
				windowURL = "../sb/viewCode.asp";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
            case "manageCategory":
				windowURL = "../gTrack/addRenameCategory.asp";
				x = 500;
				y = 300;
				windowIndex=1;
			break;
			case "unsubscribeItems":
			    windowURL = "../gTrack/unsubscribeItems.asp";
			    x = 500;
				y = 300;
				windowIndex=1;
				break;
			case "":
				alert("There has been an error processing your request: window will not be opened.");
				return false;
			break;

			default:
				windowURL = arg0; /* for outside websites */
				x = 800;
				y = 500;
				windowIndex=4;
				outsideURL = true;
			break;
		}

		/* calculate center of screen */

		var WindowAttrs;
		if (oBD.dom) {
			WindowAttrs = "screenX=" + (window.screenX + ((window.outerWidth - x) / 2)) + ","
				+ "screenY=" + (window.screenY + ((window.outerHeight - y) / 2)) + ",";
		} else {
			WindowAttrs = "top=" + (screen.height - y) / 2 + ","
				+ "left=" + (screen.width - x) / 2 + ",";
		}

		if (windowIndex == 4) { /* if this is an outside source */
			if (outsideURL) 
				var windowName = "" + Math.floor(Math.random() * 100000000);
			else
				var windowName = windowNameArray[windowIndex];

			windowHandle = window.open("", windowName, WindowAttrs + "toolbar=1,scrollbars=" + scrollbar + ",location=1,statusbar=1,menubar=1,resizable=1,width=" + x + ",height=" + y);	

			if (windowHandle.location.href != "about:blank" && windowHandle.location.href != "") {
				try {
					windowHandle.close();
					windowHandle = window.open("", windowName, "toolbar=1,scrollbars=" + scrollbar + ",location=1,statusbar=1,menubar=1,resizable=1,width=" + x + ",height=" + y);
				} catch (e)	{;}
			}
			if (formObj == null) {
				try {
					windowHandle.focus();
				} catch(e) {;}
				windowHandle.location = windowURL + querystring;
			} else { 
				try {
					windowHandle.focus();
				} catch(e) {;}
				OLD_TARGET = formObj.target;
				OLD_ACTION = formObj.action;
				CURRENT_FORM = formObj;
				formObj.target=windowName;
				formObj.action=windowURL + querystring;
				if (oBD.ie5Mac)
					window.setTimeout("SubmitFormToWin()",100);
				else
					window.setTimeout("SubmitFormToWin()",1);
			}
		} else {
			windowHandle = window.open("", windowNameArray[windowIndex], WindowAttrs + "toolbar=0,scrollbars=" + scrollbar + ",location=0,statusbar=1,menubar=0,resizable=0,width=" + x + ",height=" + y);
				
			eval("if (windowHandle." + arg0 + " != null) {itIsAlreadyOpen = true;}");

			if (itIsAlreadyOpen && !reloadNecessary) {
				try {
					windowHandle.focus();
				} catch(e) {;}
				windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
			} else {
				if (formObj == null) {
					windowHandle = window.open(windowURL + querystring,windowNameArray[windowIndex]); 
					/* ********to fix an IE5.0 problem windowHandle.location.href = windowURL + querystring; ***this would be the normal solution.****** */
					windowHandle.resizeTo(x,y);
					try {
						windowHandle.focus();
					} catch(e) {;}
					windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
					eval("windowArray[" + windowIndex + "] = windowHandle");
				} else {
					OLD_TARGET = formObj.target;
					OLD_ACTION = formObj.action;
					CURRENT_FORM = formObj;
					formObj.target=windowNameArray[windowIndex];
					formObj.action=windowURL + querystring;
					if (oBD.ie5Mac)
						window.setTimeout("SubmitFormToWin()",100);
					else
						window.setTimeout("SubmitFormToWin()",1);
				
					windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
					windowHandle.resizeTo(x,y);
					try {
						windowHandle.focus();
					} catch(e) {;}
					eval("windowArray[" + windowIndex + "] = windowHandle");
				}
			}
		}
	}
	return windowHandle;
}

function checkWindowStatus(stringToSet, windowIndex) {
	try {
		if (windowHandle.closed) {
			clearInterval(windowInterval);
		} else {
			if (oBD.ie5) {
				if (windowHandle.document.readyState == "complete") {
					eval("windowHandle." + stringToSet + " = true");
					windowHandle.SubWindowObj = windowHandle;
					windowHandle.SubWindowIndex = windowIndex;
					clearInterval(windowInterval);
				}
			} else {
				eval("windowHandle." + stringToSet + " = true");
				windowHandle.SubWindowObj = windowHandle;
				windowHandle.SubWindowIndex = windowIndex;
				clearInterval(windowInterval);
			}
		}
	} catch (e) {;}
}
	
var SubWindowObj, SubWindowIndex, windowNameArray, windowArray;
	
windowNameArray = new Array("MainPopupWindow","PopupWindow1","PopupWindow2","PopupWindow3","OutsideSource","PopupWindow4");
windowArray = new Array(windowNameArray.length);
	
if (self.parent == self) {
	setInterval("RemindOthers()", 10000);
}
	
function RemindOthers() {
	if (SubWindowObj == null) { /* parent window */
		/*alert(MainPopupWindow + "\n" + SecondaryPopupWindow + "\n" + AlternatePopupWindow + "\n" + SecondAlternatePopupWindow)*/
		try {
			for(var i=0;i<windowArray.length;i++) {
				if (windowArray[i] != null) {
					if (windowArray[i].closed) {
						windowArray[i] = null;
					} else {
						windowArray[i].SubWindowObj = windowArray[i];
						windowArray[i].SubWindowIndex = i;
					}
				}
			}
		} catch (e) {}
	} else { /* why is this code needed? */
		try {
			window.opener.location.href;
			eval("window.opener.windowArray[" + SubWindowIndex + "] = SubWindowObj");
		} catch(e) {
			window.close();
		}
	}
}

function popSearchBuilder(page,tab,w,h) {
	var sbWindow = NewWindow("searchBuilder","?defaultTab=" + tab);
	if (sbWindow.searchBuilder) {
		sbWindow.getInfoFromOpener(tab);
	}
	if (!sbWindow.opener) sbWindow.opener = self;
}
		
function addOption(selectListObj,optObj) {
	if (oBD.ie5)
		selectListObj.options.add(optObj);
	else if (oBD.dom)
		selectListObj.add(optObj,null);
}
	
function removeOption(selectListObj,index) {
	if (oBD.ie5)
		selectListObj.options.remove(index);
	else if (oBD.dom)
		selectListObj.remove(index);
}
	
function deleteFromListByValue(selectList,value) {
	var found = false;
	for(var i=0; i < selectList.options.length; i++) {
		if (selectList.options[i].value == value) {
			found = true;
			break;
		}
	}
	if (found){
		 removeOption(selectList,i);
	}
}
	
function add_to_dropdown(selectlist, keepsorted, option_text, option_value){
	var strAppen = "";
	if (option_value.substr(0,1).toUpperCase() == 'G')
			strAppen = "Group: ";
		else
			strAppen = "";
					
	var newOpt = document.createElement("OPTION");
	newOpt.value = option_value + '|' + option_text;
	newOpt.text = strAppen + option_text;
	newOpt.selected = true;
	addOption(selectlist,newOpt);
	if (keepsorted)
		recreateSelectBox(selectlist,newOpt.value);
}
		
function setOptionByValue(selectList,value) {	
	var found = false;
	for(var i=0; i < selectList.options.length; i++) {
		if (selectList.options[i].value == value) {
			found = true;
			break;
		}
	}
	if (found) {
		selectList.selectedIndex = i;
		return i;
	}
	else
		return -1;
}
	
function charEncode(varIn) {
	var re = /'/g;
	var replaceVarIn = varIn.replace(re,"&apos;");
	var re1 = /"/g;
	var returnValue = replaceVarIn.replace(re1,"&quot;");
	return returnValue;
}
	
function charDecode(varIn) {
	var re = /&apos;/g;
	var replaceVarIn = varIn.replace(re,"'");
	var re1 = /&quot;/g;
	var returnValue = replaceVarIn.replace(re1,'"');
	return returnValue;
}

function stateProto(p_code,p_type,p_country,p_desc){
	this.code	= p_code;
	this.type	= p_type;
	this.country = p_country;
	this.desc	= p_desc;
}

function countryRule(){
	var oCnt		= document.getElementById('countryCode');
	var oState		= document.getElementById('state');
	var index = 0;
	if ( oCnt && oCnt.options && oState && oCnt.selectedIndex > -1 && oState.selectedIndex > -1 ){
		var str  = oCnt.options[oCnt.selectedIndex].value;
		if ( document.getElementById('selectedState') ){
			var str1 = document.getElementById('selectedState').value;
		}else{
			var str1 = oState.options[oState.selectedIndex].value;
		}
		for (var i=0; oState.options.length; i++) {
			removeOption(oState,0);
		}
	
		/* creation of list items */
		newOpt = document.createElement("OPTION");
		newOpt.value = g_stateArray[0].code;
		newOpt.text =  g_stateArray[0].desc;
		addOption(oState,newOpt);
	
		//if ( str == '1USA' || str == '2CAN' ) {
			for(i=1 ; i < g_stateArray.length; i++){
				if ( str == g_stateArray[i].country) {
					newOpt = document.createElement("OPTION");
					newOpt.value = g_stateArray[i].code;
					newOpt.text =  g_stateArray[i].desc;
					addOption(oState,newOpt);
					if (str1 == g_stateArray[i].code)
						index = oState.options.length-1;
				}
			}
		//}
		oState.selectedIndex = index;
	}
	return true;
}
	
	
function asort(selectlist){
	if ( selectlist.options ){
		var sInd = 1;
		if (asort.arguments.length == 2) {
			sInd = asort.arguments[1];
		}
		var intNum 		= selectlist.options.length;
		var a			= new Array();	
		var g			= new Array();
		var cName		= new Array();
		if ( selectlist.selectedIndex != -1){
			var strSelect	= selectlist.options[selectlist.selectedIndex].value;
		}else{
			var strSelect;
		}
		if ( intNum == 0 ){
			return;
		}
		if ( intNum == 1 ){return;}
		for(ix=0 ; ix < intNum -1 ; ix++){
			if ( selectlist.options[ix + sInd].value.substr(0,1) == 'G'){
				g[g.length] = new proto(selectlist.options[ix + sInd].value, selectlist.options[ix + sInd].text, selectlist.options[ix + sInd].getAttribute("cName"));
			}else{
				a[a.length] = new proto(selectlist.options[ix + sInd].value, selectlist.options[ix + sInd].text, selectlist.options[ix + sInd].getAttribute("cName"));
			}
			if ( selectlist.options[ix + sInd].getAttribute("cName") ) {
				var ClassName = selectlist.options[ix + sInd].getAttribute("cName");
				if (cName.findIndex( ClassName ) == -1){
					cName[cName.length] = ClassName;
				} 
			}
		}
			
		a.sort(compareText());
		g.sort(compareText());
			
		var alength = a.length;
		var glength = g.length;
			
		for(i=0 ; i < intNum - 1; i++){
		    try{
				selectlist.options[sInd] = null;
			}catch(e){;}
		}

		selectlist.options.length = intNum + ( cName.length - 1 );
		var curPosition = sInd;
			
		for (ix = 0 ; ix < cName.length; ix++ ){
						
			for(i=0 ; i < alength; i++){
				if (cName[ix] == a[i].cName) {
					selectlist.options[curPosition].text 	= a[i].text;
					selectlist.options[curPosition].value	= charEncode(a[i].value);
					selectlist.options[curPosition].setAttribute( "cName", a[i].cName );
					if (strSelect == a[i].value)
						selectlist.options[curPosition].selected=true;
					curPosition++;
				}
								
			}
			for(i=0 ; i < glength; i++){
				if (cName[ix] == g[i].cName) {
					selectlist.options[curPosition].text 	= g[i].text;
					selectlist.options[curPosition].value	= charEncode(g[i].value);
					selectlist.options[curPosition].setAttribute( "cName", g[i].cName );
					if (strSelect == g[i].value)
						selectlist.options[curPosition].selected=true;
					curPosition++;
				}
			}
			if ( cName.length > 0 && cName.length != ix + 1){
					selectlist.options[curPosition].text 	= '--------------------';
					selectlist.options[curPosition].value	= '';
					selectlist.options[curPosition].setAttribute( "cName", 'UNKNOWN');
					curPosition++;
			}							
		}
	}
}

function recreateSelectBox(selectList,selectedValue,sort) {
	if (selectList){
		var selectObjArr = new Array();
		var groupObjArr = new Array();
		var cName = new Array();
		var firstObj = new Object();
		var maxStrLen = 0;
		var curStr = "";
		var index = 0;
		if (typeof selectedValue == "undefined" || selectedValue == "")
			selectedValue = selectList.options[selectList.selectedIndex].value;
		function optionObj(value,desc) {
			this.value = value;
			this.text = desc;
		}
		for (i=0;selectList.options.length;i++) {
			curOpt = selectList.options[0];
			if (i > 0) { 
				if (curOpt.text.length > maxStrLen)
					maxStrLen = curOpt.text.length;
				if (curOpt.value.substr(0,1).toUpperCase() == "G") 						
					groupObjArr[groupObjArr.length] = new optionObj(curOpt.value,curOpt.text);
				else 
					selectObjArr[selectObjArr.length] = new optionObj(curOpt.value,curOpt.text);
			}
			else
				firstObj = new optionObj(curOpt.value,curOpt.text);
			removeOption(selectList,0)
		}
		for(var i=0; i<Math.round(maxStrLen*1.20); i++)
			curStr = curStr + "-"; 
			
			
		/* sorting of arrays */
		if (typeof sort == "undefined") {
			selectObjArr.sort(compareText());
			groupObjArr.sort(compareText());
		}
		else
			if (sort) {
				selectObjArr.sort(compareText());
				groupObjArr.sort(compareText());
			}
			
		/*creation of new list items */
		newOpt = document.createElement("OPTION");
		newOpt.value = firstObj.value;
		newOpt.text = firstObj.text;
		addOption(selectList,newOpt);
		for (var i=0; i < selectObjArr.length; i++) {
			newOpt = document.createElement("OPTION");
			newOpt.text = selectObjArr[i].text;
			newOpt.value = selectObjArr[i].value;
			addOption(selectList,newOpt);
			curVal = selectObjArr[i].value;
			if ( selectedValue == curVal ) {
				index = selectList.options.length-1;
			}
		}
		for (var i=0; i < groupObjArr.length; i++) {
			newOpt = document.createElement("OPTION");
			newOpt.text = groupObjArr[i].text;
			newOpt.value = groupObjArr[i].value;
			addOption(selectList,newOpt);
			curVal = groupObjArr[i].value;
			if ( selectedValue == curVal ) {
				index = selectList.options.length-1;
			}
		}
		selectList.selectedIndex = index;
	}	
	return false;
}
	
function proto (val1,val2, val3) {
		this.value = val1;
		this.text  = val2;
		this.cName = val3;
}
	
function compareText() {
	function _compareText(n1, n2) {
		var v;
		if (n1.text < n2.text)
			v = -1;
		else if (n1.text > n2.text)
			v = +1;
		else 
			v = 0;
		return v;
	}
	return _compareText;
}

function hideShowSelectNodes(hide) {
	selectNodes = document.getElementsByTagName("SELECT");
	for (var i=0; i < selectNodes.length; i++) {
		if (hide)
			selectNodes[i].style.visibility = "hidden";
		else
			selectNodes[i].style.visibility = "visible";
	}
}

function languageSelect_Click(e) {
	if (oBD.ns6)
		e.stopPropagation();
	else
		window.event.cancelBubble = true;
	srcEvent = (oBD.ns6) ? e: event;
	obj = document.getElementById("langSelector");
	coords = getCoords(obj);
	menuObj = document.getElementById("laguageSelectionMenu");
	menuObj.style.left = coords[0];
	menuObj.style.top = coords[1] + obj.offsetHeight;
	menuObj.style.display = "block";
	/* hideShowSelectNodes(true); */
}
	
function closeLanguageSelectionMenu(e) {
	/* src = (oBD.ns6) ? getNode(e.target): event.srcElement; */
	menuObj = document.getElementById("laguageSelectionMenu");
	menuObj.style.display = "none";
	/* hideShowSelectNodes(); */
}

function documentOnClick(e) {
	menuObj = document.getElementById("laguageSelectionMenu");
	if (menuObj)
		closeLanguageSelectionMenu(e)
}
	
curFlagHighlight = null;
function mouseOverLangSel(e) {
	src = (oBD.ns6) ? getNode(e.target): event.srcElement;
	src = findParentElement(src,"tr","langRow");
			
	if (src) {
		tdNode0 = src.cells[0];	
		tdNode1 = src.cells[1];	
		tdNode0.style.borderColor = "#666666";
		tdNode1.style.borderColor = "#666666";
		tdNode0.style.backgroundColor = "#99CC00";
		tdNode1.style.backgroundColor = "#99CC00";
		aLinkNode =  findChildElement(tdNode1,"a","langtext");
		aLinkNode.style.color = "#000000";
		curFlagHighlight = src;
	}
}
	
function mouseOutLangSel(e) {
	src = (oBD.ns6) ? getNode(e.target): event.srcElement;
	src = findParentElement(src,"tr","langRow");
			
	if (src) {
		tdNode0 = src.cells[0];	
		tdNode1 = src.cells[1];	
		tdNode0.style.borderColor = "#CCCCCC";
		tdNode1.style.borderColor = "#FFFFFF";
		tdNode0.style.backgroundColor = "#CCCCCC";
		tdNode1.style.backgroundColor = "#FFFFFF";
		aLinkNode =  findChildElement(tdNode1,"a","langtext");
		aLinkNode.style.color = "#000000";
	}	
			
}
function onDlRadioClick(){
  try{
	var elem = document.getElementsByName("dlRadioBtn");
	for( var i=0; i<elem.length; i++ ){
		if ( elem[i].checked ){updateDirectLink(elem[i].value);}
	}
  }catch(e){;}
}
function updateDirectLink(strNewUrl){
  try{
	if(!strNewUrl || strNewUrl == ""){
		strNewUrl = document.getElementById ("directLinkLink" + defaultNavIndex ).getAttribute ("value");
	}
	document.getElementById("directLinkURLHRef").setAttribute ("value", strNewUrl);
	//document.getElementById("directLinkLink" + defaultNavIndex ).setAttribute ("value", strNewUrl);
	document.getElementById("directLinkALink").setAttribute ("href", strNewUrl);
  }catch(e){;}
}
function labelOnClick() {
	if (oBD.ie5Mac)
		return false;
	return true;
}
function changeLang_Click(e) {
	src = (oBD.ns6) ? getNode(e.target): event.srcElement;
	src = findParentElement(src,"tr","langRow");	
	changeLanguage(src.getAttribute("langCode"));
}

function textareaSubForm(e)
{
	if ( (e.which && e.which == 13) || 
		(event.keyCode && event.keyCode == 13) )
	{
		if (document.forms["searchForm"])
		{
			myForm = document.forms["searchForm"];
			myForm.subBtn.click();return false;
		}
		return true;
	} 
    else 
		return true;
}
document.onclick = documentOnClick;
