// common js functions
var ua=navigator.userAgent.toLowerCase(); 
var isFirefox=(ua.indexOf('firefox')!=-1);
var isMozilla=(ua.indexOf('mozilla')!=-1);
var isOpera=(ua.indexOf('opera')!=-1);
var isSafari=(ua.indexOf('safari')!=-1);
var isIE=((ua.indexOf("msie") != -1) && !isOpera);

function objXY(obj){
	var newObj=document.getElementById(obj);
	if(newObj.offsetParent){
		for(var posX=0,posY=0;newObj.offsetParent;newObj=newObj.offsetParent){
	   		posX+=newObj.offsetLeft;
			posY+=newObj.offsetTop;
		}
		return [posX,posY];
	} else {
		return [newObj.x,newObj.y];
	}
}

function hideAd(){
	hideForm('cbgHeadTbl');
	if (document.getElementById && document.getElementById("topBannerAd")){ document.getElementById("topBannerAd").style.position='relative'; document.getElementById("topBannerAd").style.left='-1000px'; }
	else if (document.layers && document.layers["topBannerAd"]){ document.layers["topBannerAd"].style.position='relative'; document.layers["topBannerAd"].style.left='-1000px'; }
	else if (document.all && document.all["topBannerAd"]){ document.all["topBannerAd"].style.position='relative'; document.all["topBannerAd"].style.left='-1000px'; }
}

function showAd(){
	showForm('cbgHeadTbl','block');
	if (document.getElementById && document.getElementById("topBannerAd")){ document.getElementById("topBannerAd").style.position='static'; }
	else if (document.layers && document.layers["topBannerAd"]){ document.layers["topBannerAd"].style.position='static'; }
	else if (document.all && document.all["topBannerAd"]){ document.all["topBannerAd"].style.position='static'; }
}

function hideForm(formID){
	if ((isIE==true) && (document.getElementById(formID))) { document.getElementById(formID).style.display='none'; }
}

function showForm(formID,displayType){
	if ((isIE==true) && (document.getElementById(formID))) { document.getElementById(formID).style.display=displayType; }
}

function popUpWindow(url,name,w,h,s,r,t,m){
	var p="height="+h+",width="+w+",scrollbars="+s+",resizable="+r+",toolbar="+t+",menubar="+m;
	var w=window.open(url,name,p);
}

function popVideo(content,vID,lineID,ad){
	var str="";
	if(typeof content!='undefined' && content.length) str+="&content="+content;
	if(typeof vID!='undefined' && vID.length) str+="&vid="+vID;
	if(typeof lineID!='undefined' && lineID.length) str+="&lineID="+lineID;
	if(typeof ad!='undefined' && ad.length) str+="&ad="+ad;
	popUpWindow("/shared/video/player.cfm?"+str,"popmechtv",529,993,0,0,0,0);
}

function showImage(img,caption){
	var imgURL="/content/imageview.cfm?img="+escape(img)+"&caption="+escape(caption);
	popUpWindow(imgURL,"ImageViewer",650,600,1,1,0,0);
}

function doContent(type,id,url){
	var urlString="";
	if(url.length) urlString=url;
	else if(id.length) urlString="/content/"+id+".html";
	else{ alert("No content defined"); return; }
	if(urlString.indexOf("?")==-1) urlString+="?";	else urlString+="&";	
	urlString+="do="+type;	
	switch (type){
		case 'print':	popUpWindow(urlString,"PrintWindow",650,600,1,1,0,1);	break;
		case 'email': popUpWindow(urlString,"EmailWindow",400,440,1,0,0,0); break;
	}
}

function menuStart(parentNode){
	var nodeID=[parentNode];
	for(var j=0;j<nodeID.length;j++){
		if(document.getElementById(nodeID[j])){
		 	var node = document.getElementById(nodeID[j]).getElementsByTagName("div");
			for (var i=0; i<node.length; i++){
				node[i].onmouseover=function(){ this.className+="over"; };
				node[i].onmouseout=function(){ this.className=this.className.replace(new RegExp("over\\b"),""); };
			}
		}
	}
}