// sets the object string to be used
function setobj(obj){
	var theobject; 
	if (typeof obj == "string"){
		if (obj == "document"){
			theobject = document;
		}
		else{
			theobject = document.getElementById(obj);
		}
	}
	else{
		theobject = obj;
	}
	return theobject;
}
function showArrow(thisArrow){
	var obj = setobj(thisArrow);
	try{
		obj.src = 'http://espn-att.starwave.com/espntv/assets/images/show_arrw_on.gif';
	}
	catch(e){
	}		
}
function hideArrow(thisArrow){
	var obj = setobj(thisArrow);
	try{
		obj.src = 'http://espn-att.starwave.com/espntv/assets/images/show_arrw_off.gif';
	}
	catch(e){
	}		
}
function setClass(name,clsName){
	var obj = setobj(name);
	try{
		obj.className = clsName;
	}
	catch(e){
	}
}
function showHTML(){
	var obj = setobj('htmlLayer');
	try{
		obj.style.display = 'block';		
	}
	catch(e){
	}
}
function showHelp(){
	var obj = setobj('htmlHelp');
	var obj2 = setobj('flashShow');
	try{
		obj.style.display = 'block';
		obj2.style.height = 116+'px';
	}
	catch(e){
	}
}
function hideHTML(){
	var obj = setobj('htmlLayer');
	try{
		//obj.style.display = 'none';
		fade(-9,25);
	}
	catch(e){
	}
}
function setFlashHeight(flashHeight){
	var obj = setobj('htmlHome');
	try{
		obj.style.top = flashHeight+"px";
		document.body.style.backgroundImage='none';
	}
	catch(e){
	}
	window.setInterval("showHTML()",500);	
}
function setFlashEmbedHeight(arg){
	var obj = setobj('HomeInit');
	try{
		obj.height = arg;
		setFlashHeight(arg);
	}
	catch(e){
	}
}
function showFlash(args){
	var obj = setobj(args);
	try{
		obj.style.display = "block";		
	}
	catch(e){
	}	
}
//parse thru all links in html and target external links to new window
function checkLinks(){
	var anchorTags = document.getElementsByTagName("a");
	for (var i = 0; i < anchorTags.length ; i++)
	{	
		if(anchorTags[i].href.indexOf('espntv')==-1){
	  		 anchorTags[i].target = "_blank";
	  	}
	}
}
//write page name variable for hitbox
function pagenameHBX(){
	
	docT = document.title;
	
	if(docT.indexOf("'")>=0){
		docT = docT.split("'");
		docT = docT.join("");
	}
	
	hbx.pn = "" + docT;
	
	//hbx.pn = document.title;

}
//fade effects
var
	level = 100,
	interval = null,
	element = null,
	_step = null,
	levelSet = null,
	isMozilla = null;
function fade(step, rate){
	var showIndex = location.href.indexOf('espnShow');
	if(showIndex != -1){
		element = document.getElementById('htmlShow');
	}else{
		element = document.getElementById('htmlHome');
	}
	isMozilla = (document.all)?false:true;
	_step = step;
	interval = setInterval('doAction("fade")',rate);
}
function doAction(action){
	switch(action){
		case(action='fade'):
			if(isMozilla){
				levelSet = 0;
				level += _step;
				element.style.MozOpacity = level/100;
				if(level/100<=levelSet){clearInterval(interval)};
			}else{
				levelSet = 0;
				level += _step;
				element.style.filter = 'alpha(opacity=' + level + ')';
				if(level<=levelSet){clearInterval(interval)};
			}
		break;
	} 
}	
//error reporting functions
var errorID=null,httpStatus=null,failedURI=null,postParams,postStr=null;
function espnError(errorID,httpStatus,failedURI){
	var postParams = 'tURI='+ document.location +'&fURI='+ failedURI +'&status='+ httpStatus +'&errorID='+ errorID +'';
	var postStr = 'http://proxy.espn.go.com/espntv/espnError_test?'+ postParams +'';
	xErrData=new xhttp();
	xErrData.fetch(postStr,'pagenameHBX',{cache:"true"});
}