var load = true;

function GetEl(layer)
{
	if(document.getElementById) return document.getElementById(layer);
	else if(document.all) return document.all[layer];
	else if(document.layers) return document.layers[layer];
}
function show(layer)
{
    var d = GetEl(layer)
    if(d.style.display != "block") d.style.display = "block";
}
function hide(layer)
{
	var d = GetEl(layer)
    if(d.style.display != "none") d.style.display = "none";
}
function toggle(layer)
{
	var d = GetEl(layer)
    if(d.style.display == "none") 
    {
		d.style.display = "block";
		return "ON";
	}
    else 
    {
		d.style.display = "none";
		return "OFF";
	}
}
function setClass(layer, className)
{
	var d = GetEl(layer);
	if(d.className != className) d.className = className;
}
function getClass(layer)
{
	var d = GetEl(layer);
	return d.className;
}
function setVal(layer, val)
{
	var d = GetEl(layer);
	d.value = val;
}
function getVal(layer)
{
	var d = GetEl(layer);
	return d.value;
}
function setHTML(layer, val)
{
	var d = GetEl(layer);
	d.innerHTML = val;
}

function LeftNavClickGroupPage(parent, child, alsoin)
{
	LeftNavClick(parent, child);
	setHTML("alsoin", alsoin);
	setVal("section", child);
	if(child.toLowerCase()=="consumer")
	{
		hide("also_conferences");
		hide("also_exhibitionsps");
	}
	else
	{
		show("also_conferences");
		show("also_exhibitionsps");
	}
}

function GroupRedirect(link)
{
	window.location = "?page=" + link + "&section=" + GetEl("section").value;
}

function LeftNavClick(parent, child)
{
	ResetChildren("left_nav_main", "nav_item");
	setClass(child + "_link", "nav_item_on_no_arrow");
	HideChildren(parent);
	try
	{
		show(child);
		//Omniture code
		s=s_gi(s_account);
		s.prop2=getVal("breadcrumbtext") + ":" + child;
		s.tl(this,'o', getVal("breadcrumbtext") + ":" + child);
	}
	catch(ex){}
}

function ExecutiveNavClick(id, link)
{
	ResetChildren("executive_nav", "executive_off");
	setClass("executive_" + id + "_nav_item", "executive_on");
	HideChildren("executive_copy");
	show("executive_copy_" + id);
	//Omniture code
	s=s_gi(s_account);
	s.prop2=getVal("breadcrumbtext") + ":Executives:" + link;
	s.tl(this,'o',getVal("breadcrumbtext") + ":Executives:" + link);
}

function SubNavClick(id, groupname)
{
	ResetChildren(groupname  + "_nav", "executive_off");
	setClass(groupname  + "_" + id + "_nav_item", "executive_on");
	HideChildren(groupname  + "_copy");
	show(groupname  + "_copy" + id);
	//Omniture code
	s=s_gi(s_account);
	s.prop2=getVal("breadcrumbtext") + ":" + groupname + ":" + id;
	s.tl(this,'o',getVal("breadcrumbtext") + ":" + groupname + ":" + id);
}

function CorporateNavClick(section)
{
	var layer = section + "Link";
	var initClass = getClass(layer);
	resetContact();
	ChangeContactEmail(getVal("initcontactid"));
	if(initClass != "nav_item_on_no_arrow") 
	{
		setClass(layer, "nav_item_on_no_arrow");
		show(section);
	}
	else 
	{
		setClass(layer, "nav_item");
		hide(section);
	}
}
function ChangeContactEmail(id)
{
	setVal("contactid", id);
	setHTML("mailform_name", getVal("contactid_" + id + "_name"));
}

function resetContact()
{
	var el = GetEl("ContactList");
    var thisChild = el.firstChild;
    while (thisChild != el.lastChild)
    {
		try
        {
			if(thisChild.className=="nav_item_on_no_arrow") thisChild.className = "nav_item";
			if(thisChild.className!="nav_item") 
			{
				if(thisChild.style.display!="none") thisChild.style.display = "none";
			}
		}
        catch(err) {}
		thisChild = thisChild.nextSibling;
    }
    try
    {
		if(thisChild.className=="nav_item_on_no_arrow") thisChild.className = "nav_item";
		if(thisChild.className!="nav_item") 
		{
			if(thisChild.style.display!="none") thisChild.style.display = "none";
		}
    }
	catch(err){}
}

function ResetChildren(parent, resetState)
{
	var el = GetEl(parent);
    var thisChild = el.firstChild;
    while (thisChild != el.lastChild)
    {
		try
        {
			thisChild.className = resetState;
		}
        catch(err) {}
		thisChild = thisChild.nextSibling;
    }
    try
    {
		el.lastChild.className = resetState;
    }
	catch(err){}
}

function HideChildren(parent)
{
	var el = GetEl(parent);
    var thisChild = el.firstChild;
    while (thisChild != el.lastChild)
    {
		try
        {
			thisChild.style.display = "none";
		}
        catch(err) {}
		thisChild = thisChild.nextSibling;
    }
    try
    {
		el.lastChild.style.display = "none";
    }
	catch(err){}
}

function thisMovie(movieName) {	if (navigator.appName.indexOf("Microsoft") != -1) 	{		return window[movieName];	}	else 	{		if(document[movieName].length != undefined)		{			return document[movieName][1];		}		return document[movieName];	}}function iSpeakCheck(){	try	{		switch(GetEl("page").value)		{			case "home":				if(GetCookie("HWHomeFrankVideo")!="played")				{					StartFlash("Frank");					SetCookie("HWHomeFrankVideo", "played", 365);				}				break;			case "businessmedia":				if(GetCookie("HWPeterVideo")!="played")				{					StartFlash("Peter");					SetCookie("HWPeterVideo", "played", 365);				}				break;			case "exhibitions":				if(GetCookie("HWGalenVideo")!="played")				{					StartFlash("Galen");					SetCookie("HWGalenVideo", "played", 365);				}				break;			case "marketintelligence":				if(GetCookie("HWAndyVideo")!="played")				{					StartFlash("Andy");					SetCookie("HWAndyVideo", "played", 365);				}				break;			case "marketing":				if(GetCookie("HWJeanneVideo")!="played")				{					StartFlash("Jeanne");					SetCookie("HWJeanneVideo", "played", 365);				}				break;			default:				break;		}	}	catch(ex) {}}function SetCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
} 
function GetCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}function ToggleFlash(vid){	if(GetEl("iSpeakStartStop").innerHTML == "Stop") StopFlash();	else StartFlash(vid);}function StartFlash(vid){	try	{		if(load) 		{			setTimeout("PlayiSpeak();", 100);			GetEl('iSpeakVideo_Container').style.visibility = 'visible';			load = false;		}		else		{			PlayiSpeak();			setTimeout("GetEl('iSpeakVideo_Container').style.visibility = 'visible';", 1500);		}	}	catch(ex) {}	try	{		var flashmovie = thisMovie("HanleyWood");		flashmovie.flStartMovie();    }    catch(ex) {}	GetEl("iSpeakStartStop").innerHTML = "Stop";	s=s_gi(s_account);	s.prop1=vid;	s.tl(this,'o',vid);}function PlayiSpeak(){	if (navigator.appName.indexOf("Microsoft") != -1)	{		thisMovie("iSpeakVideo_Container_o").flStartVideo();	}	else	{		thisMovie("iSpeakVideoVideo").flStartVideo();	}}function StopiSpeak(){	if (navigator.appName.indexOf("Microsoft") != -1)	{		thisMovie("iSpeakVideo_Container_o").flStopVideo();	}	else	{		thisMovie("iSpeakVideoVideo").flStopVideo();	}}function HideOnLoad(){	GetEl('iSpeakVideo_Container').style.visibility = 'hidden';}function StopFlash(){	GetEl('iSpeakVideo_Container').style.visibility = "hidden";	try	{		StopiSpeak();	}	catch(ex) {}	VideoStopped();}function VideoStopped(){	try	{		var flashmovie = thisMovie("HanleyWood");		flashmovie.flStopMovie();	}	catch(ex) {}	GetEl("iSpeakStartStop").innerHTML = "Play";}function GetProps(o){	var properties = "";	for (var propertyName in o) 
	{
		try
		{
			if (!(o[propertyName] instanceof Function)) 
			{
				properties += propertyName + ", ";
			}
		}
		catch(ex)
		{
			properties += "ERROR - " + propertyName + ", ";
		}
	}
	alert("Properties : " + properties);}function GetFuncs(o){	var functions = "";
	for (var functionName in o) 
	{
		try
		{
			if (o[functionName] instanceof Function) 
			{
				functions += functionName + ", ";
			}
		}
		catch(ex)
		{
			functions += "ERROR - " + functionName + ", ";
		}
	}	alert("Functions : " + functions);}function GetHousingRSS(){	Http.get(
	{
		url: "AJAX.aspx?action=rss",
		callback: FillRSS,
		cache: Http.Cache.GetNoCache
	});}function FillRSS(xmlreply){	if (xmlreply.status == Http.Status.OK)
	{
		setHTML("HousingRSS", xmlreply.responseText);
	}}