/* Browser check */
IS_DOM = (document.getElementById) ? true : false;
IS_IE = (document.all) ? true : false;
IS_IE50 = (navigator.userAgent.indexOf("IE 5.0") != -1);
IS_Mac = (navigator.appVersion.indexOf("Mac") != -1);

var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', sFolderLevel + 'includes/css/hidden.css');
document.getElementsByTagName('head')[0].appendChild(link);

// preload rollovers
var aNavigation = new Array();
aNavigation = ["", "about-us", "managers", "events", "publications", "press"];
for (i = 0; i <= 5; i++) { 
	eval("A"+i+"on = new Image();"); eval("A"+i+"off = new Image();");
	if (sSelectedButton == aNavigation[i]) {
		eval("A"+(i)+"on.src = \"" + sFolderLevel + "img/navigation/l1-" + aNavigation[i] + "-1.gif\";");
		eval("A"+(i)+"off.src = \"" + sFolderLevel + "img/navigation/l1-" + aNavigation[i] + "-1.gif\";");
	} else {
		eval("A"+(i)+"on.src = \"" + sFolderLevel + "img/navigation/l1-" + aNavigation[i] + "-1.gif\";");
		eval("A"+(i)+"off.src = \"" + sFolderLevel + "img/navigation/l1-" + aNavigation[i] + "-0.gif\";");
	}
}

var aNavigation = new Array();
aNavigation = ["", "our-firm", "our-attorneys", "our-practices"];
for (i = 0; i <= 4; i++) { 
	eval("B"+i+"on = new Image();"); eval("B"+i+"off = new Image();");
	if (sSelectedButton == aNavigation[i]) {
		eval("B"+(i)+"on.src = \"" + sFolderLevel + "img/navigation/" + aNavigation[i] + "-1.gif\";");
		eval("B"+(i)+"off.src = \"" + sFolderLevel + "img/navigation/" + aNavigation[i] + "-1.gif\";");
	} else {
		eval("B"+(i)+"on.src = \"" + sFolderLevel + "img/navigation/" + aNavigation[i] + "-1.gif\";");
		eval("B"+(i)+"off.src = \"" + sFolderLevel + "img/navigation/" + aNavigation[i] + "-0.gif\";");
	}
}

// General Site Functions
function imgOn(imgName) {
  if (IS_DOM) {
    document.getElementById(imgName).src = eval(imgName + "on.src");
  }
}
 
function imgOff(imgName) {
  if (IS_DOM) {
    document.getElementById(imgName).src = eval(imgName + "off.src");
  }
}

// image swapper
function changeImages() 
{
  if (document.getElementById) {
    for (var i = 0; i < changeImages.arguments.length; i += 2) { 
  		document.getElementById(changeImages.arguments[i]).src = eval(changeImages.arguments[i + 1] + ".src"); 
	}
  }
}

// image-swapping function for input image type
function changeInputImage(imageName,newImageSource) {
		if (document.getElementById) {
			document.getElementById(imageName).src = newImageSource;
		}
	}

// Get an ID 
function getThis(sId)
{
	var oObject;
	oObject = false;
	
	if (IS_DOM) {
		if (document.getElementById(sId)) {
			oObject = document.getElementById(sId);
		}
	}
	
	return oObject;
}

// This function is used when you want to have browsers that do not 
//have flash player installed write an image file instead

function writeFlashOrImage(FlashName,ImageName,Width,Height,Alt,FlashVersion) {
	// first, write the opening object tag

	strObjectTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	strObjectTag = strObjectTag + ' width="' + Width + '" height="' + Height + '" ';
	strObjectTag = strObjectTag + 'codebase="http://active.macromedia.com/flash5/cabs/swflash.cab#version=';
	strObjectTag = strObjectTag + FlashVersion + '">';
	strMovieParam = '<param name="movie" value="' + FlashName + '">';
	document.write(strObjectTag);
	document.write(strMovieParam);
	document.write('<param name=\"play\" value=\"true\">');
	document.write('<param name=\"loop\" value=\"true\">');
	document.write('<param name=\"quality\" value=\"high\">');
	document.write('<param name=\"wmode\" value=\"transparent\">');

	// if the Flash Plug-in is installed and a browser than user plug-ins is the browser, write an embed tag
	plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
		strImageTag = '<image src="' + ImageName + '" width="' + Width + '" height="' + Height + '" ';
		strImageTag = strImageTag + ' border="0" alt="' + Alt + '">';
	if ( plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4 )
		{
		strEmbedTag = '<embed src="' + FlashName + '" width="' + Width + '" height="' + Height + '" ';
		strEmbedTag = strEmbedTag + 'play="true" loop="true" quality="high" ';
		strEmbedTag = strEmbedTag + 'wmode="transparent"';
		strEmbedTag = strEmbedTag + 'pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
		document.write(strEmbedTag);
		document.write('</embed>');
		}
	// otherwise, then write an image tag.
	else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
		document.write(strImageTag);
		}
	
	//finally, write the closing object tag
	document.write('</object>');
}
	
// accessible popup functions, this will work with or without javascript enabled
// reference like this "<a href="popup.htm" onclick="popUp(this.href,'console',400,200);return false;" target="newWin" title="This link will pop open a new window">This is my link</a>"
	function popUp(strURL,strType,strHeight,strWidth,strWindow)
	{
	  var strOptions="";
	  if (strType=="console") {
	    strOptions="resizable,height=" + strHeight + ",width=" + strWidth;
	  }
	  if (strType=="fixed") {
	    strOptions="status,height=" + strHeight + ",width=" + strWidth;
	  }
	  if (strType=="elastic") {
	    strOptions="toolbar,menubar,scrollbars,resizable,location,height=" + strHeight + ",width=" + strWidth;
	  }
	  window.open(strURL, strWindow, strOptions);
	}

	// proper way to close a popup window, to be referenced in the popup window
	// if (window.opener) document.write('<strong><a href="#" onclick="self.close();">Close this window</a></strong>');


/*
	tableruler()
	written by Chris Heilmann for alistapart.
	enables a rollover of rows for each table with the classname "hlrows"
*/

function tableruler()
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className=='ruler')
			{
				var trs=tables[i].getElementsByTagName('tr');
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						trs[j].onmouseover=function(){this.className='ruled';return false}
						trs[j].onmouseout=function(){this.className='';return false}
					}
				}
			}
		}
	}
}

function showFlash() {
	var oDiv = document.getElementById("flashContainer");
	oDiv.style.display = "block";
}

function hideFlash() {
	var oDiv = document.getElementById("flashContainer");
	oDiv.style.display = "none";
}


// quicklinks

function selectOffering() {
	var offering = document.offeringForm.offering.value;

	if (offering != "") {
		url = offering;
		location.href = url;
	}
}	

function toggle(oLink, sName, sContainer) {
	var oDiv = document.getElementById(sName);
	var aList = oDiv.getElementsByTagName(sContainer);
	
	for (var i = 3; i < aList.length; i++) {
		if (aList[i].style.display == "" || aList[i].style.display == "none") {
			aList[i].style.display = "block";
		} else {
			aList[i].style.display = "none";
		}
	}
	
	var sSentence;
	if (sName == "articles") {
		sSentence = "articles and publications";
	} else if (sName == "quotes") {
		sSentence = "quotes";
	} else if (sName == "news"){
		sSentence = "news";
	} else {
		sSentence = "speaking engagements";
	}
	var sClose = document.createTextNode("Collapse " + sSentence);
	var sOpen = document.createTextNode("View more " + sSentence);
	
	if (oLink.firstChild.nodeValue == sClose.nodeValue) {
		oLink.replaceChild(sOpen, oLink.firstChild);
		oLink.className = "";
	} else {
		oLink.replaceChild(sClose, oLink.firstChild);
		oLink.className = "close";
	}
}
