// Updated 5/30/2007.
// 2/21/2008 - Added "ShowSWNVol2"
// 2/21/2008 - Modified "ShowSWNVol2" with 'location=yes' attribute

var divlayer = document.getElementsByTagName("div");
var imglayer = document.getElementsByTagName("img");
var formlayer = document.getElementsByTagName("input");
var selectlayer = document.getElementsByTagName("select");
var optionlayer = document.getElementsByTagName("option");
var anchorlayer = document.getElementsByTagName("a");
var iframelayer = document.getElementsByTagName("iframe");
var tdlayer = document.getElementsByTagName("td");
var spanlayer = document.getElementsByTagName("span");
var scrollthis = 0;

function SubMenuNavOptions_LE(Action,Item) {
	imglayer['' + Item + ''].src="/Images/Generic/" + Item + Action + ".gif";
}

function AppTabImage(Action,Root,Destination) {
	if (Action == "Over") {imglayer['AppNav'].src="/Images/Application/" + Root + '_' + Destination + ".gif";}
	if (Action == "Out") {imglayer['AppNav'].src="/Images/Application/" + Root + "_0.gif";
	}
}

function GetCurrentWhereLocation() {
	var WhereLocationSearchResultsTest = top.Main.WhereAvailable.location.href.indexOf("WhereSearchResults");
	var WhereLocationStatesTest = top.Main.WhereAvailable.location.href.indexOf("WhereST");
	var WhereLocationCountiesTest = top.Main.WhereAvailable.location.href.indexOf("WhereCE");
	var WhereLocationPlacesTest = top.Main.WhereAvailable.location.href.indexOf("WherePL");
	var WhereLocationMetrosTest = top.Main.WhereAvailable.location.href.indexOf("WhereMSA");
	if (WhereLocationSearchResultsTest > 0) { CurrentWhereLocation = "SearchResults" }
	if (WhereLocationStatesTest > 0) { 	CurrentWhereLocation = "States" }
	if (WhereLocationCountiesTest > 0) { CurrentWhereLocation = "Counties" }
	if (WhereLocationPlacesTest > 0) { 	CurrentWhereLocation = "Places" }
	if (WhereLocationMetrosTest > 0) { CurrentWhereLocation = "Metros" }
	return CurrentWhereLocation;
}

//Image Swapper
function WhereLocationOver(Action,Item) {
	if (Action == "Over") {
		imglayer['' + Item + ''].src="/Images/Application/" + Item + "Over.gif";
	}
	if (Action == "Out") {
		ThisLocation = GetCurrentWhereLocation();
		if (ThisLocation == "States") {
			imglayer['USStates'].src="/Images/Application/USStatesOver.gif";
		} else {
			imglayer['USStates'].src="/Images/Application/USStatesOut.gif";
		}
		if (ThisLocation == "Counties") {
			imglayer['Counties'].src="/Images/Application/CountiesOver.gif";
		} else {
			imglayer['Counties'].src="/Images/Application/CountiesOut.gif";
		}
		if (ThisLocation == "Places") {
			imglayer['Places'].src="/Images/Application/PlacesOver.gif";
		} else {
			imglayer['Places'].src="/Images/Application/PlacesOut.gif";
		}
		if (ThisLocation == "Metros") {
			imglayer['Metros'].src="/Images/Application/MetrosOver.gif";
		} else {
			imglayer['Metros'].src="/Images/Application/MetrosOut.gif";
		}
	}
}

function GetCurrentViewBy(){
	var ViewByListTest = WhereSelections.location.href.indexOf("List");
	var ViewByStatesTest = WhereSelections.location.href.indexOf("States");
	var ViewByMetrosTest = WhereSelections.location.href.indexOf("Metros");
	if (ViewByListTest > 0) {CurrentViewBy = "List"}
	if (ViewByStatesTest > 0) {CurrentViewBy = "States"}
	if (ViewByMetrosTest > 0) {CurrentViewBy = "Metros"}
	return CurrentViewBy;
}

function WhereViewByOver(Action,Item) {
	if (Action == "Over") {
		imglayer['' + Item + ''].src="/Images/Application/" + Item + "Over.gif";
	}
	if (Action == "Out") {
		ThisViewBy = GetCurrentViewBy();
		if (ThisViewBy == "List") {
			imglayer['ListView'].src="/Images/Application/ListViewOver.gif";
		} else {
			imglayer['ListView'].src="/Images/Application/ListViewOut.gif";
		}
		if (ThisViewBy == "States") {
			imglayer['StateView'].src="/Images/Application/StateViewOver.gif";
		} else {
			imglayer['StateView'].src="/Images/Application/StateViewOut.gif";
		}
		if (ThisViewBy == "Metros") {
			imglayer['MetroView'].src="/Images/Application/MetroViewOver.gif";
		} else {
			imglayer['MetroView'].src="/Images/Application/MetroViewOut.gif";
		}
	}
}

//spawns the ShowReference window (FR = "From Report")
function ShowReference(InfoId,FR) {
	ShowReferenceWindow = window.open("/ShowReference.asp?InfoId=" + InfoId + "&FR=" + FR, "ShowReference", "width=640, height=480, scrollbars=yes, toolbar=yes, resizable=yes, left=250, top=160") ;
}

//Image Swapper
function SearchOver(Action,Item) {
//	formlayer['' + Item + ''].src="/Images/Application/" + Item + Action + ".gif";
	document.images['' + Item + ''].src="/Images/Application/" + Item + Action + ".gif";
}

//Image Swapper
function AppImageOver(Action,Item) {
	imglayer['' + Item + ''].src="/Images/Application/" + Item + Action + ".gif";
}

//Show Navigational Submenus
function SubMenuOver(Action,Item) {
	imglayer['' + Item + ''].src="/Images/Generic/" + Item + Action + ".gif";
	if (Item == "TipsPreferences") {
		ReferringImageLocation = document.getElementById("SearchOptions");
	} else {
		ReferringImageLocation = document.getElementById("" + Item + "");
	}
	SubMenuLayerLocation = document.getElementById("" + Item + "SubMenu");
	SubMenuLayerLocation.style.left = ReferringImageLocation.offsetLeft +0;
	SubMenuLayerLocation.style.top = ReferringImageLocation.offsetTop + 24;
	if (Item == "TipsPreferences") {
		SubMenuLayerLocation.style.left = ReferringImageLocation.offsetLeft +114;
		SubMenuLayerLocation.style.top = ReferringImageLocation.offsetTop + 6;
	}
	SubMenuLayerLocation.style.visibility = "visible";
}

//Hide Navigational Submenus
function SubMenuOut(Action,Item) {
	imglayer['' + Item + ''].src="/Images/Generic/" + Item + Action + ".gif";
	divlayer['' + Item + 'SubMenu'].style.visibility = "hidden";
}

//Controls the Report NavBar
function ShowReport(){
	// Fetch Current ReportNavBar variables
	var OrganizeBy = selectlayer['OrganizeBy'].value;
	var ViewBy = selectlayer['ViewBy'].value;
	var ReportStyle = selectlayer['ReportStyle'].value;
	var ReportFormat = selectlayer['ReportFormat'].value;
	top.Main.ReportNav.location.href = "ReportNav.asp?OrganizeBy=" + OrganizeBy + "&ViewBy=" + ViewBy + "&ReportStyle=" + ReportStyle + "&ReportFormat=" + ReportFormat + "&Render=N";
}

//Global function used by the application to return iframe documents to original scrollto position
function findScrollTop() {
	scrollamount = 0;
	if (document.body.scrollTop > 0) {
		scrollamount = (document.body.scrollTop);
		return scrollamount;
	} else {
		scrollamount = 0;
		return scrollamount;		
	}
}

//ensures that at least 3 characters are present in a search string
function checklength(){
	TxtSrchTest_1 = document.WhatSearch.TextBox1.value;
//	TxtSrchTest_2 = document.WhatSearch.TextBox2.value;
	if 	(TxtSrchTest_1.length < 3) {	
		alert("Search phrase must be at least three characters long");
		document.WhatSearch.TextBox1.focus();
		document.WhatSearch.TextBox1.value='';
	return false;
	} else
		top.Main.divlayer['WhatWaitScreen'].style.visibility='visible';
		document.WhatSearch.submit();
	}


function SelectDataItem(QSValue){
	ScrollThis = findScrollTop();
 	location.href = "WhatItems.asp?" + QSValue + "&ScrollThis=" + ScrollThis;
}

//Opens a child branch in the WhatItems data item tree
function DrillDown(newdatastring){
	ScrollThis = findScrollTop();
 	location.href = "WhatItems.asp?Action=Open&InfoID=" + newdatastring + "&ScrollThis=" + ScrollThis;
}

//Closes a child branch in the WhatItems data item tree
function DrillUp(InfoId){
	ScrollThis = findScrollTop();
 	location.href = "WhatItems.asp?Action=Close&InfoId=" + InfoId + "&ScrollThis=" + ScrollThis;
}

function ModifyWhenSelections(ChosenYear){
	var checkboxvalue = document.YearsAvailable.elements[ChosenYear];
	if (checkboxvalue.checked) {top.Main.WhenResults.WhenSelections.location.href = "/WhenSelections.asp?Action=AddYear&ChosenYear=" + ChosenYear;}
	if (!checkboxvalue.checked) {top.Main.WhenResults.WhenSelections.location.href = "/WhenSelections.asp?Action=RemoveYear&ChosenYear=" + ChosenYear;}
}

function ShowPlayVideo(VideoNumber, ThisW, ThisH, BrowserSession) {
	PlayVideoWindow = window.open('/VideoLibrary/PlayVideo.asp?BrowserSession=' + BrowserSession + '&VideoNumber=' + VideoNumber + '', 'PlayVideo', 'width=' + ThisW + ', height=' + ThisH + ', scrollbars=no, toolbar=no, resizable=yes, left=0, top=0');
}

function ShowPlayVideoFromSplash(VideoNumber, ThisW, ThisH) {
	PlayVideoWindow = window.open('/VideoLibrary/PlayVideo.asp?OAP=Y&VideoNumber=' + VideoNumber + '', 'PlayVideo', 'width=' + ThisW + ', height=' + ThisH + ', scrollbars=no, toolbar=no, resizable=yes, left=0, top=0');
}

function ShowExcludedLocations(OrganizeBy,SysID, InfoID, YearID) {
	ExcludedLocationsWindow = window.open("/ShowExcludedLocations.asp?OrganizeBy=" + OrganizeBy + "&SysID=" + SysID + "&InfoID=" + InfoID + "&YearID=" + YearID + "", "ExcludedLocationsWindow", "width=380, height=300, toolbar=yes, scrollbars=yes, resizable=yes, left=250, top=160") ;
}

function UpdateViewBy(ViewBy) {
	if (ViewBy == "List") {
		top.Main.imglayer['ListView'].src="/Images/Application/ListViewOver.gif";
		top.Main.imglayer['StateView'].src="/Images/Application/StateViewOut.gif";
		top.Main.imglayer['MetroView'].src="/Images/Application/MetroViewOut.gif";
	}
	if (ViewBy == "States") {
		top.Main.imglayer['ListView'].src="/Images/Application/ListViewOut.gif";
		top.Main.imglayer['StateView'].src="/Images/Application/StateViewOver.gif";
		top.Main.imglayer['MetroView'].src="/Images/Application/MetroViewOut.gif";
	}
	if (ViewBy == "Metros") {
		top.Main.imglayer['ListView'].src="/Images/Application/ListViewOut.gif";
		top.Main.imglayer['StateView'].src="/Images/Application/StateViewOut.gif";
		top.Main.imglayer['MetroView'].src="/Images/Application/MetroViewOver.gif";
	}
}

//For Removing a Selection from WhereSelections
function RemoveWhereSelection(ROSCode){
	ScrollThis = findScrollTop();
	location.href = "WhereSelections.asp?Action=Remove&ROSCode=" + ROSCode + "&ScrollThis=" + ScrollThis;
}

function DrillCE(ROSCode,Action){
	scrollthis = findScrollTop();
 	location.href = "WhereCE.asp?ROSCode=" + ROSCode + "&Action=" + Action + "&scrollthis=" + scrollthis;
}

function DrillPL(ROSCode,Action){
	scrollthis = findScrollTop();
 	location.href = "WherePL.asp?ROSCode=" + ROSCode + "&Action=" + Action + "&scrollthis=" + scrollthis;
}

function DrillMSA(ROSCode,Action,SysId){
	scrollthis = findScrollTop();
 	location.href = "WhereMSA.asp?ROSCode=" + ROSCode + "&Action=" + Action + "&SysId=" + SysId + "&scrollthis=" + scrollthis;
}

function ShowWhereTip(PromptType) {
	if (PromptType == "WhereItemCap") {parent.WhereSelections.divlayer["WhereTip_WhereItemCap"].style.visibility = "visible";}
	if (PromptType == "None") {parent.WhereSelections.divlayer["WhereTip_WhereItemCap"].style.visibility = "hidden";}
}

function UpdateWhereNav(RegTyp) {
	top.Main.imglayer['USStates'].src='/Images/Application/USStatesOut.gif';
	top.Main.imglayer['Counties'].src='/Images/Application/CountiesOut.gif';
	top.Main.imglayer['Places'].src='/Images/Application/PlacesOut.gif';
	top.Main.imglayer['Metros'].src='/Images/Application/MetrosOut.gif';
	if (RegTyp == "USStates") {
		top.Main.imglayer['USStates'].src='/Images/Application/USStatesOver.gif';
	}
	if (RegTyp == "Counties") {
		top.Main.imglayer['Counties'].src='/Images/Application/CountiesOver.gif';
	}
	if (RegTyp == "Places") {
		top.Main.imglayer['Places'].src='/Images/Application/PlacesOver.gif';
	}
	if (RegTyp == "Metros") {
		top.Main.imglayer['Metros'].src='/Images/Application/MetrosOver.gif';		
	}
}

function WhereLocationsOut(WhereLocation,CTRYST,CE,PL,MSA) {
	CurrentWhereLocation = GetCurrentWhereLocation();
	if (CurrentWhereLocation == "SearchResults")	{
		if (WhereLocations = "States") {
			if (CTRYST == "N") {
				top.Main.imglayer['States'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['States'].src="/Images/Application/StatesOut2.gif";
			}
		}
		if (WhereLocations = "Counties") {
			if (CE == "N") {
				top.Main.imglayer['Counties'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Counties'].src="/Images/Application/CountiesOut2.gif";
			}
		}
		if (WhereLocations = "Places") {
			if (PL == "N") {
				top.Main.imglayer['Places'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Places'].src="/Images/Application/PlacesOut2.gif";
			}
		}
		if (WhereLocations = "Metros") {
			if (MSA == "N") {
				top.Main.imglayer['Metros'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Metros'].src="/Images/Application/MetrosOut2.gif";
			}
		}
	}

	if (CurrentWhereLocation == "States")	{
		if (WhereLocations = "States") {
			if (CTRYST == "N") {
				top.Main.imglayer['States'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['States'].src="/Images/Application/StatesActive2.gif";
			}
		}
		if (WhereLocations = "Counties") {
			if (CE == "N") {
				top.Main.imglayer['Counties'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Counties'].src="/Images/Application/CountiesOut2.gif";
			}
		}
		if (WhereLocations = "Places") {
			if (PL == "N") {
				top.Main.imglayer['Places'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Places'].src="/Images/Application/PlacesOut2.gif";
			}
		}
		if (WhereLocations = "Metros") {
			if (MSA == "N") {
				top.Main.imglayer['Metros'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Metros'].src="/Images/Application/MetrosOut2.gif";
			}
		}
	}

	if (CurrentWhereLocation == "Counties")	{
		if (WhereLocations = "States") {
			if (CTRYST == "N") {
				top.Main.imglayer['States'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['States'].src="/Images/Application/StatesOut2.gif";
			}
		}
		if (WhereLocations = "Counties") {
			if (CE == "N") {
				top.Main.imglayer['Counties'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Counties'].src="/Images/Application/CountiesActive2.gif";
			}
		}
		if (WhereLocations = "Places") {
			if (PL == "N") {
				top.Main.imglayer['Places'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Places'].src="/Images/Application/PlacesOut2.gif";
			}
		}
		if (WhereLocations = "Metros") {
			if (MSA == "N") {
				top.Main.imglayer['Metros'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Metros'].src="/Images/Application/MetrosOut2.gif";
			}
		}
	}

	if (CurrentWhereLocation == "Places")	{
		if (WhereLocations = "States") {
			if (CTRYST == "N") {
				top.Main.imglayer['States'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['States'].src="/Images/Application/StatesOut2.gif";
			}
		}
		if (WhereLocations = "Counties") {
			if (CE == "N") {
				top.Main.imglayer['Counties'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Counties'].src="/Images/Application/CountiesOut2.gif";
			}
		}
		if (WhereLocations = "Places") {
			if (PL == "N") {
				top.Main.imglayer['Places'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Places'].src="/Images/Application/PlacesActive2.gif";
			}
		}
		if (WhereLocations = "Metros") {
			if (MSA == "N") {
				top.Main.imglayer['Metros'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Metros'].src="/Images/Application/MetrosOut2.gif";
			}
		}
	}

	if (CurrentWhereLocation == "Metros")	{
		if (WhereLocations = "States") {
			if (CTRYST == "N") {
				top.Main.imglayer['States'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['States'].src="/Images/Application/StatesOut2.gif";
			}
		}
		if (WhereLocations = "Counties") {
			if (CE == "N") {
				top.Main.imglayer['Counties'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Counties'].src="/Images/Application/CountiesOut2.gif";
			}
		}
		if (WhereLocations = "Places") {
			if (PL == "N") {
				top.Main.imglayer['Places'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Places'].src="/Images/Application/PlacesOut2.gif";
			}
		}
		if (WhereLocations = "Metros") {
			if (MSA == "N") {
				top.Main.imglayer['Metros'].src="/Images/Application/spacer.gif";
			} else {
				top.Main.imglayer['Metros'].src="/Images/Application/MetrosActive2.gif";
			}
		}
	}
}

function ShowSyntheticMetros(InfoID) {
	SyntheticMetrosWindow = window.open("/ShowSyntheticMetros.asp?InfoID=" + InfoID + "", "SyntheticMetrosWindow", "width=380, height=300, toolbar=yes, scrollbars=yes, resizable=yes, left=250, top=160") ;
}

function ShowSubject(DocId) {
	ShowSubjectWindow = window.open("/Subjects/" + DocId + ".pdf", "ShowSubject", "width=800, height=520, scrollbars=yes, toolbar=yes, resizable=yes, left=120, top=120") ;
}

function ShowSWN(Article) {
	ShowSWNWindow = window.open("/SWN/Vol1No1/index.asp?Action=" + Article + "", "ShowSWN", "width=800, height=600, scrollbars=yes, toolbar=yes, resizable=yes, left=0, top=0") ;
}

function ShowSWNVol2(Article) {
	ShowSWNWindow = window.open("/SWN/Vol2No1/index.asp?Action=" + Article + "", "ShowSWN", "width=800, height=600, scrollbars=yes, toolbar=yes, resizable=yes, left=0, top=0, location=yes") ;
}

function ShowSWNVideo() {
	SWNVideoWindow = window.open("/VideoLibrary/PlayVideo.asp?VideoNumber=8&NL=Y&PT=SW","SWNVideoWindow","width=1016, height=768, toolbar=yes, scrollbars=yes, resizable=yes, location=yes") ;
}

function GetActiveBucket() {
	ActiveBucket = "Nothing";
	var WhatTest = top.Main.location.href.indexOf("What");
	if (WhatTest > 0) {ActiveBucket = "SearchOptions"};
	var WhereTest = top.Main.location.href.indexOf("Where");
	if (WhereTest > 0) {ActiveBucket = "SearchOptions"};
	var WhenTest = top.Main.location.href.indexOf("When");
	if (WhenTest > 0) {ActiveBucket = "SearchOptions"};
	var ReportTest = top.Main.location.href.indexOf("Report");
	if (ReportTest > 0) {ActiveBucket = "SearchOptions"};
	var VLTest = top.Main.location.href.indexOf("VideoLibrary");
	if (VLTest > 0) {ActiveBucket = "ViewADemo"};
	var VisionTest = top.Main.location.href.indexOf("Vision");
	if (VisionTest > 0) {ActiveBucket = "CompanyInfo"};
	var PPTest = top.Main.location.href.indexOf("PrivacyPolicy");
	if (PPTest > 0) {ActiveBucket = "CompanyInfo"};
	var ContactTest = top.Main.location.href.indexOf("Contact");
	if (ContactTest > 0) {ActiveBucket = "CompanyInfo"};
	var OverviewTest = top.Main.location.href.indexOf("StatisticalWarehouse");
	if (OverviewTest > 0) {ActiveBucket = "ProductInfo"};
	var DRTest = top.Main.location.href.indexOf("SW_DataReview");
	if (DRTest > 0) {ActiveBucket = "ProductInfo"};
	var EATest = top.Main.location.href.indexOf("EvaluationAccount");
	if (EATest > 0) {ActiveBucket = "ProductInfo"};
	var PQTest = top.Main.location.href.indexOf("PriceQuote");
	if (PQTest > 0) {ActiveBucket = "ProductInfo"};
	return ActiveBucket;
}

function GetActiveTab() {
	ActiveTab = "Other";
	var WhatTabTest = top.Main.location.href.indexOf("What");
	if (WhatTabTest > 0) {ActiveTab = "What"};
	var WhereTabTest = top.Main.location.href.indexOf("Where");
	if (WhereTabTest > 0) {ActiveTab = "Where"};
	var WhenTabTest = top.Main.location.href.indexOf("When");
	if (WhenTabTest > 0) {ActiveTab = "When"};
	var ReportTabTest = top.Main.location.href.indexOf("Report");
	if (ReportTabTest > 0) {ActiveTab = "Report"};
	return ActiveTab;
}

function HeaderBarNav(Bucket,Action) {
	ThisActiveBucket = GetActiveBucket();
	ThisActiveTab = GetActiveTab();
	if (Action == "Over") {
		top.HeaderBar.tdlayer['' + Bucket + ''].style.backgroundColor = "lightblue";
		if (Bucket == "CompanyInfo" || Bucket == "ProductInfo" || Bucket == "SearchOptions") {
			if (ThisActiveTab == "What" || ThisActiveTab == "Where" || ThisActiveTab == "When" || ThisActiveTab == "Report") {
				if (ThisActiveTab == "What" || ThisActiveTab == "Where") 	{ThisSubMenu = top.Main.divlayer['' + Bucket + '_SubMenu'];}
				if (ThisActiveTab == "When") {ThisSubMenu = top.Main.WhenNav.divlayer['' + Bucket + '_SubMenu'];}
				if (ThisActiveTab == "Report") {ThisSubMenu = top.Main.ReportNav.divlayer['' + Bucket + '_SubMenu'];}
			} else {
				ThisSubMenu = top.Main.divlayer['' + Bucket + '_SubMenu'];
			}
			ReferringPosition = top.HeaderBar.tdlayer['' + Bucket + ''];
//			ThisSubMenu.style.left = ReferringPosition.offsetLeft - 1;
//			ThisSubMenu.style.top = ReferringPosition.offsetTop + 0;
			ThisSubMenu.style.visibility = "visible";
		}
	}
	if (Action == "Out") {
		if (ThisActiveBucket == Bucket) {top.HeaderBar.tdlayer['' + Bucket + ''].style.backgroundColor = "lightblue";}
		if (ThisActiveBucket != Bucket) {top.HeaderBar.tdlayer['' + Bucket + ''].style.backgroundColor = "black";}
		if (Bucket == "CompanyInfo" || Bucket == "ProductInfo" || Bucket == "SearchOptions") {
			if (ThisActiveTab == "What" || ThisActiveTab == "Where" || ThisActiveTab == "When" || ThisActiveTab == "Report") {
				if (ThisActiveTab == "What" || ThisActiveTab == "Where") {top.Main.divlayer['' + Bucket + '_SubMenu'].style.visibility='hidden';}
				if (ThisActiveTab == "When") {top.Main.WhenNav.divlayer['' + Bucket + '_SubMenu'].style.visibility='hidden';}
				if (ThisActiveTab == "Report") {top.Main.ReportNav.divlayer['' + Bucket + '_SubMenu'].style.visibility='hidden';}
			} else {
				top.Main.divlayer['' + Bucket + '_SubMenu'].style.visibility='hidden';
			}
		}
	}
}

function SubMenuItem_Over(MenuItem) {
	anchorlayer['' + MenuItem + '_Title'].style.color = "yellow";
	spanlayer['' + MenuItem + '_Pointer'].style.color = "yellow";
}

function SubMenuItem_Out(MenuItem) {
	anchorlayer['' + MenuItem + '_Title'].style.color = "white";
	spanlayer['' + MenuItem + '_Pointer'].style.color = "#6666FF";
}

function WhatSearch_Box2On() {
	document.WhatSearch[5].disabled=false;
	document.WhatSearch[5].style.background="#FFFFFF";
}

function WhatSearch_Box2Off() {
	document.WhatSearch[5].disabled=true;
	document.WhatSearch[5].style.background="#CCCCCC";
//	document.WhatSearch[0].value = "";
	document.WhatSearch[5].value = "";
}

function CloseTipScreen(TipCondition) {
	divlayer['TipScreen_' + TipCondition].style.visibility = "hidden";
}

//Drag and Drop SubScript
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;
function movemouse(e)
{
  if (isdrag)
  {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}
function selectmouse(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "TipsPreferences")
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }
  if (fobj.className=="TipsPreferences")
  {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
var count;
count = 0;
function ChangeTipScreen(HideScreen1,HideScreen2,HideScreen3,HideScreen4,HideScreen5,ShowScreen1,Screen1TimeOut,ShowScreen2,Screen2TimeOut,ShowScreen3,Screen3TimeOut,ShowScreen4,Screen4TimeOut,ShowScreen5,Screen5TimeOut) {
	if (HideScreen1 !== "") {setTimeout("HideTipScreen('" + HideScreen1 + "')",0);}
	if (HideScreen2 !== "") {setTimeout("HideTipScreen('" + HideScreen2 + "')",0);}
	if (HideScreen3 !== "") {setTimeout("HideTipScreen('" + HideScreen3 + "')",0);}
	if (HideScreen4 !== "") {setTimeout("HideTipScreen('" + HideScreen4 + "')",0);}
	if (HideScreen5 !== "") {setTimeout("HideTipScreen('" + HideScreen5 + "')",0);}
	if (ShowScreen1 !== "") {setTimeout("ShowTipScreen('" + ShowScreen1 + "')",Screen1TimeOut);}
	if (ShowScreen2 !== "") {setTimeout("ShowTipScreen('" + ShowScreen2 + "')",Screen2TimeOut);}
	if (ShowScreen3 !== "") {setTimeout("ShowTipScreen('" + ShowScreen3 + "')",Screen3TimeOut);}
	if (ShowScreen4 !== "") {setTimeout("ShowTipScreen('" + ShowScreen4 + "')",Screen4TimeOut);}
	if (ShowScreen5 !== "") {setTimeout("ShowTipScreen('" + ShowScreen5 + "')",Screen5TimeOut);}
}

function HideTipScreen(ShowScreen) {
	ThisActiveTab = GetActiveTab();
	if (ThisActiveTab == "What" || ThisActiveTab == "Where") {top.Main.divlayer['TipScreen_' + ShowScreen].style.visibility = "hidden";}
	if (ThisActiveTab == "When") {top.Main.WhenResults.divlayer['TipScreen_' + ShowScreen].style.visibility = "hidden";}
	if (ThisActiveTab == "Report") {top.Main.ReportResults.divlayer['TipScreen_' + ShowScreen].style.visibility = "hidden";}
}

function ShowTipScreen(ShowScreen) {
	ThisActiveTab = GetActiveTab();
	if (ThisActiveTab == "What" || ThisActiveTab == "Where" || ThisActiveTab == "Other") {top.Main.divlayer['TipScreen_' + ShowScreen].style.visibility = "visible";}
	if (ThisActiveTab == "When") {top.Main.WhenResults.divlayer['TipScreen_' + ShowScreen].style.visibility = "visible";}
	if (ThisActiveTab == "Report") {top.Main.ReportResults.divlayer['TipScreen_' + ShowScreen].style.visibility = "visible";}
}

function UpdateHeaderBar(Bucket) {
	top.HeaderBar.tdlayer['SearchOptions'].style.backgroundColor = 'black';
	top.HeaderBar.tdlayer['ViewADemo'].style.backgroundColor = 'black';
	top.HeaderBar.tdlayer['CompanyInfo'].style.backgroundColor = 'black';
	top.HeaderBar.tdlayer['ProductInfo'].style.backgroundColor = 'black';
	top.HeaderBar.tdlayer['PressRoom'].style.backgroundColor = 'black';
	top.HeaderBar.tdlayer['' + Bucket + ''].style.backgroundColor = 'lightblue';
	top.HeaderBar.tdlayer['Home'].style.backgroundColor = 'black';
}

function LaunchQuickReport(InfoID, BrowserType) {
	AvailWidth = screen.availWidth
	AvailHeight = screen.availHeight
	QR_Window = window.open("/QuickReport.asp?InfoID=" + InfoID + "&Action=NewReport&BrowserType=" + BrowserType + "&AvailWidth=" + AvailWidth + "&AvailHeight=" + AvailHeight + "", "QR_Window", "width=" + AvailWidth + ", height=" + AvailHeight + ", scrollbars=yes, toolbar=yes, resizable=yes") ;
}

function LaunchQuickReport_VPM(InfoID, BrowserType) {
	AvailWidth = screen.availWidth
	AvailHeight = screen.availHeight
	QR_Window = window.open("/QuickReport.asp?InfoID=" + InfoID + "&Action=NewReport&BrowserType=" + BrowserType + "&VPM=Y&AvailWidth=" + AvailWidth + "&AvailHeight=" + AvailHeight + "", "QR_Window", "width=" + AvailWidth + ", height=" + AvailHeight + ", scrollbars=yes, toolbar=yes, resizable=yes") ;
}

function QuickReport_WaitScreen(Mode) {
	if (Mode == "Hide") {divlayer['QuickReport_WaitScreen'].style.visibility = 'hidden';}
	if (Mode == "Show") {divlayer['QuickReport_WaitScreen'].style.visibility = 'visible';}
}

function ShowVPMScreen(Instance){
	if (Instance == 1) {setTimeout("divlayer['TipScreen_175'].style.visibility='visible'",3000);}
	if (Instance == 2) {setTimeout("divlayer['TipScreen_176'].style.visibility='visible'",3000);}
	if (Instance == 3) {setTimeout("divlayer['TipScreen_177'].style.visibility='visible'",3000);}
	if (Instance == 4) {setTimeout("divlayer['TipScreen_178'].style.visibility='visible'",3000);}
	if (Instance == 5) {setTimeout("divlayer['TipScreen_179'].style.visibility='visible'",3000);}
	if (Instance == 6) {setTimeout("divlayer['TipScreen_180'].style.visibility='visible'",3000);}
	if (Instance == 7) {setTimeout("divlayer['TipScreen_181'].style.visibility='visible'",3000);}
	if (Instance == 8) {setTimeout("divlayer['TipScreen_182'].style.visibility='visible'",3000);}
	if (Instance == 9) {setTimeout("divlayer['TipScreen_183'].style.visibility='visible'",3000);}
	if (Instance == 10) {setTimeout("divlayer['TipScreen_184'].style.visibility='visible'",3000);}
}

function ShowVPMScreen2(){
	setTimeout("divlayer['TipScreen_2'].style.visibility='visible'",2500);
	setTimeout("divlayer['TipScreen_2.1'].style.visibility='visible'",17000);
}

function ShowVPMScreen3(){
	setTimeout("divlayer['TipScreen_183'].style.visibility='visible'",2500);
	setTimeout("divlayer['TipScreen_183'].style.visibility='hidden'",7500);
	setTimeout("divlayer['TipScreen_183a'].style.visibility='visible'",7500);
	setTimeout("divlayer['TipScreen_183a'].style.visibility='hidden'",12500);
	setTimeout("divlayer['TipScreen_183b'].style.visibility='visible'",12500);
}

function Show_COLI_Warning() {
	top.Main.divlayer['COLI_Warning'].style.visibility = 'visible';
}

function Get_EnVar (BrowserSession, Refresh, VideoNumber, OAP) {
	document.location.href='/EnVar.asp?Action=Write&Refresh=' + Refresh + '&BrowserSession=' + BrowserSession + '&VideoNumber=' + VideoNumber + '&OAP=' + OAP + '&UserAgent=' + navigator.userAgent + '&ScreenWidth=' + screen.width + '&ScreenHeight=' + top.document.body.clientHeight + '&Platform=' + navigator.platform + '&Cookies=' + navigator.cookieEnabled + '';
}

//Opens the [more] element in a Standard Report
function ShowMoreSources(InfoId){
	ScrollThis = findScrollTop();
	location.href = "QuickReport.asp?Action=NewReport&InfoID=" + InfoId + "&RS=Y&ScrollTo=" + ScrollThis;
}

//Opens the [more] element in a ShowReference Window
function ShowMoreSources_2(InfoId){
	ScrollThis = findScrollTop();
	location.href = "ShowReference.asp?InfoId=" + InfoId + "&RS=Y&ScrollTo=" + ScrollThis;
}

//Opens the [more] element in a PowerUser Report
function ShowMoreSources_3(InfoId){
	ScrollThis = findScrollTop();
	location.href = "ReportResults.asp?RSInfoId=" + InfoId + "&RS=Y&ScrollTo=" + ScrollThis;
}