/*
	Harbert Managment Corporation
	Basic JavaScript

	version: 2004.07.16
*/


var browser = navigator.userAgent;

var __isIE = (browser.indexOf("MSIE") >= 0);
var __isPC = (browser.indexOf("Windows") >= 0);

var transferPage = "";

function Init()
{
	setExternalLinks();
	try { setBioRotation(); } catch(e) {}
}


// rotate bios (only if there are any divs that have 'shortbio' as the className
var cbio = 0;
var bios = new Array();
function setBioRotation()
{
	divs = document.getElementsByTagName("div");
	
	//bios = new Array();
	//alert(divs.length);
	count = 0;
		
	for(i = 0; i < divs.length; i++)
	{
		if(divs[i].className == "shortbio")
		{
			//alert(divs[i].getAttribute("id"));
			bios[count] = divs[i].getAttribute("id");;
			count++;
		}
	}
	
	if(count > 0)
		setTimeout("rotateBio()", 5000);

}

function rotateBio()
{
	cbio++;
	if(cbio > bios.length) cbio = 0;
	
	BringToFront(bios[cbio]);
	setTimeout("rotateBio()", 5000);
}



// preloads images
// just pass each image source in as an argument
function LoadImages()
{
	var img = new Image();

	var args = LoadImages.arguments;

	for(var x = 0; x < args.length - 1; x++)
		img.src = args[x];
}


// changes a given images source to the given image
var __oldSrc = null;
function ChangeImage(obj, src, ret)
{
	if(obj)
	{
		if(! ret)
		{
			__oldSrc = obj.src;
			obj.src = src;
		}
		else
		{
			obj.src = __oldSrc;
			__oldSrc = null;
		}
	}
}


// changes the innerHTML of an element with the given id
// with the given text
function ChangeDescription(elem, text)
{
	e = document.getElementById(elem);

	if(e) e.innerHTML = text;

}

// changes the cssClass of a given object to the given CssClass name
function ChangeCssClass(object, css, change)
{
	if(change == null || change == true)
		object.className = css;
}

var dz = 1000;
function ChangeSelectedDescription(obj, sectionId)
{
	svc = document.getElementById('svclnk');
	tech = document.getElementById('techlnk');
	exp = document.getElementById('explnk');
	det = document.getElementById('detlnk');
	
	svc.selected = false;
	svc.className = 'advitem';
	tech.selected = false;
	tech.className = 'advitem';
	exp.selected = false;
	exp.className = 'advitem';
	det.selected = false;
	det.className = 'advitem';
	
	obj.selected = true;
	obj.className = 'advitemselected';
	
	cur = document.getElementById(sectionId);
	cur.style.display = "block";
	cur.style.zIndex = dz;
	dz++;
}


// sets the active stylesheet to the stylesheet that has
// the given title attribute
function SetActiveStyleSheet(title)
{
	var i, a, main;

	// find an loop through all the <link> elements in the document
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++)
	{
		// disable all the stylesheet
		if (a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("title"))

			a.disabled = true;

		// if it is the stylesheet requested, then enable it
		if (a.getAttribute("title") == title)
			a.disabled = false;
	}
}

var z = 100;
// used to set the current bio on the overview pages
function BringToFront(id)
{
	el = document.getElementById(id);
	if(el)
	{
		el.style.display = "block";
		el.style.zIndex = z;
		z++;
	}
}




// looks through all of the <a> elements in the document
// and checks for a rel attribute. If the rel attribute is
// set to "ext", "external", "blank", "new" or "_blank"
// then it sets the target attribute to "_blank" so that the link
// will open in a new browser window.
function setExternalLinks()
{
	lnkArr = document.getElementsByTagName("a");

	for(i = lnkArr.length; i-- > 0;)
	{
		if(	lnkArr[i].rel == "ext"	|| lnkArr[i].rel == "external")
		{
			if(transferPage != null && transferPage != "")
			{
				href = new String(lnkArr[i].href);
				href = href.replace(/\?/gi, '[QM]');
				href = href.replace(/\&/gi, '[AMP]');

				lnkArr[i].href = transferPage + "?link=" + href + "&lbl=";

				if(lnkArr[i].title != "" && lnkArr[i].title != "undefined")
					lnkArr[i].href +=  "" + lnkArr[i].title;
			}

			lnkArr[i].target = "_blank";
		}

		if( lnkArr[i].rel == "_blank" || lnkArr[i].rel == "blank" || lnkArr[i].rel == "new" )
			lnkArr[i].target = "_blank";
	}
}
