/*
	These first 2 functions are translated from the client's original JS so that they fit into the CF environment.	
	They are not currently used.
	
function smAjaxRequest()
{
	if (window.XMLHttpRequest)
	{
		var FX = new XMLHttpRequest();
		if (FX.overrideMimeType)
			FX.overrideMimeType("text/plain");
		FX._timeoutHang = setTimeout(function(){FX.abort()}, 2000);
		return FX;
	}
	else if (window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
}	// smAjaxRequest

function SingleLoad(z)
{
	rq = smAjaxRequest();
	if (!rq) return false;
	rq.onreadystatechange = function()
	{
		if (rq.readyState == 4 && rq.responseText.length > 0)
		{
			var text = rq.responseText;
			var i = text.indexOf("\n");
			var sep = text.substr(0,i);
			var text = text.substr(i+1);
			var j = text.indexOf("\n"+sep+"\n");
			var href = text.substr(0,j);
			var text = text.substr(j+2+sep.length);
			var k = text.indexOf("\n"+sep+"\n");
			var title = text.substr(0,k);
			var thisSocialMedia_html = text.substr(k+2+sep.length);

			var link_div = document.getElementById("socialmedia_" + arrSocialMedium[z] + "_link_" + arrSocialMediumInc[z]);
			var title_div = document.getElementById("socialmedia_" + arrSocialMedium[z] + "_title_" + arrSocialMediumInc[z]);
			var items_div = document.getElementById("socialmedia_" + arrSocialMedium[z] + "_items_" + arrSocialMediumInc[z]);
					
			if (title_div) title_div.innerHTML = title;
			if (link_div) link_div.href = href;
			if (items_div) items_div.innerHTML = thisSocialMedia_html;
		}				
	};
	var url = "#strBaseAjaxUrl#" + arrSocialMediumInc[z] + "&nav=bar";
	try
	{
		rq.open("GET", url, true);
		rq.send(null);
	}
	catch (ex)
	{
		// Cross domain queries aren't allowed. Build site must fetch content the old fashioned way.
		// var items_div = document.getElementById("socialmedia_" + arrSocialMedium[z] + "_items_" + arrSocialMediumInc[z]);
		// if (items_div) items_div.innerHTML = ex.name + "<br>" + ex.message;
	}
	return false;
}	// SingleLoad()
*/

/*
	Below this point is all the client's original JS
*/
var isDHTML=0;
var isLayers=0;
var isAll=0;
var isID=0;
if(document.getElementById){
	isID=1;isDHTML=1;
}else{
	if(document.all){isAll=1;isDHTML=1;
	}else{
		browserVersion = parseInt(navigator.appVersion);
		if((navigator.appName.indexOf('Netscape')!=-1)&&(browserVersion==4)){isLayers=1;isDHTML=1;}
	}
}
function findDOM(objectID,withStyle){
	//alert('findDOM');
	if(withStyle==1){
		if(isID){return(document.getElementById(objectID).style);}
		else{if(isAll){return(document.all[objectID].style);}
		else{if(isLayers){return(document.layers[objectID]);}
		};}
	}else{
		if(isID){return(document.getElementById(objectID));}
		else{if(isAll){return(document.all[objectID]);}
		else{if(isLayers){return(document.layers[objectID]);}
		};}
	}
}
function changeStyle(objectID,styleName,newValue){
	var dom=findDOM(objectID,1);
	if(dom){dom[styleName]=newValue;}
}
function setClass(objectID,newClass){
	var dom=findDOM(objectID,0);
	if(dom){dom.className=newClass;}
}
function openSocial(objectID,nestedObjectID,clipHeight,currentHeight,direction){
	if(direction=='close'){
		changeStyle('closebutton','display','none');
		var clipHeight=eval(clipHeight)-10;
		changeStyle(objectID,'height',clipHeight+'px');
		changeStyle(nestedObjectID,'clip','rect(auto auto '+clipHeight+'px auto)');
		displaySocial(false);
		if(currentHeight!=clipHeight){
			setTimeout('openSocial("'+objectID+'","'+nestedObjectID+'","'+clipHeight+'","'+currentHeight+'","'+direction+'")',10);
		}
	}else{
		// IF IT IS ALREADY OPEN, RETURN
		var dom=findDOM(objectID,1);
		if(dom['height']==clipHeight+'px'){return;}
		changeStyle('closebutton','display','');
		var currentHeight=eval(currentHeight)+10;
		changeStyle(objectID,'height',currentHeight+'px');
		changeStyle(nestedObjectID,'clip','rect(auto auto '+currentHeight+'px auto)');
		if(currentHeight<clipHeight){
			setTimeout('openSocial("'+objectID+'","'+nestedObjectID+'","'+clipHeight+'","'+currentHeight+'","'+direction+'")',10);
		}
	}
}
var activeSocial = false;
function displaySocial(id){
	if (activeSocial) {
		var nav=findDOM('socialnav_'+activeSocial,0);
		if (nav)
			nav.className = nav.className.replace('socialnavselected ', 'socialnav ');

		var dom=findDOM('social_'+activeSocial,0);
		if (dom)
			dom.style.display = 'none';
			
		activeSocial = false;
	}

	if (id) {
		var nav=findDOM('socialnav_'+id,0);
		if (nav)
			nav.className = nav.className.replace('socialnav ', 'socialnavselected ');

		var dom=findDOM('social_'+id,0);
		if (dom)
			dom.style.display = '';
			
		activeSocial = id;
	}
}
var descTop=0;
var descLeft=0;
var domDesc=null;
var oldDomDesc=null;
var t=0;
var lDelay=50;
var lCount=0;
var pause=10;
function popDesc(idTrigger,descID,popX,popY){
	var domTrigger=findDOM(idTrigger,0);
	var domDesc=findDOM(descID,1);
	if(isDHTML){
		t=2;
		if(oldDomDesc){
			oldDomDesc.display='none';
			oldDomDesc.zIndex='0';
			t=2;
			lCount=0;
		}
		if(oldDomDesc!=domDesc){
			domDesc.display='';
			if(isID||isAll){
				descPos=findPosition(domTrigger);

				var container = findDOM(descID,0);
				container = container.offsetParent;
				var contPos = findPosition(container);

				descLeft=descPos[0]-contPos[0]+eval(popX);
				descTop=descPos[1]-contPos[1]+eval(popY);
			}
			domDesc.top=descTop+'px';
			domDesc.left=descLeft+'px';
			domDesc.zIndex='1000';
			oldDomDesc=domDesc;
			oldTrigger=idTrigger;
		}else{oldDomDesc=null;}
	}else{return null;}
}
function delayHide(){
	if((oldDomDesc)&&(t==0)){
		oldDomDesc.display='none';
		oldDomDesc.zIndex='0';
		oldDomDesc=null;
		lCount=0;
		var domTrigger=findDOM(oldTrigger,0);
		return false;
	}
	if(t==2){lCount=0;return false;}
	if(t==1){
		lCount=lCount+1;
		if(lDelay<=lCount){t=0;}
		if(lDelay>=lCount){setTimeout('delayHide('+t+')',pause);}
	}
}
function findPosition(obj){
	tmpObj=obj;
	var obj_left=tmpObj.offsetLeft;
	var obj_top=tmpObj.offsetTop;
	if(tmpObj.offsetParent){
		while(tmpObj=tmpObj.offsetParent){
			obj_left+=tmpObj.offsetLeft;
			obj_top+=tmpObj.offsetTop;
		}
	}
	return [obj_left,obj_top];
}
