document.write("<div id='LoadLayer'><img src=\"image/dark/loading.gif\" align=\"absmiddle\" border=0/></div>");
function   killErrors()   {   
  return   true;   
}  
window.onerror   =   killErrors;
function avaPlay(ch_id)
{
	writewatch(ch_id);
	writecookie(ch_id);
	/*if(ocxstatus())
	{
		location.href="ava://"+ch_id;
	}else
	{
		//mask.style.visibility='visible';
		//ssAlert();
		//new dialog().init();
		new dialog().event('^_^  A better version is available!^_^<br><font color=red>Please download and install!</font>  ',1,1,1,'Avarena',300,150,'download.php');
		//location.href="viewer_download.php";
	}*/
	//location.href="avaplay.php?pid="+ch_id;
	window.open("avaplay.php?pid="+ch_id,"_blank");

}
var xmlplayHttp;
function createplayxml(){//创建请求对象
	if(window.XMLHttpRequest){//其它浏览器
		//other browser
		xmlplayHttp = new XMLHttpRequest();
		return xmlplayHttp;
	}else if(window.ActiveXObject){//IE浏览器
		//IE browser
		xmlplayHttp = new ActiveXObject("Microsoft.XMLHTTP");
		return xmlplayHttp;
	}
	throw new Error("XMLHttp object coulde be created!");
}
function writewatch(guid){
	xmlplayHttp = createplayxml();
	xmlplayHttp.open("POST","watch.php?guid="+guid,true);//
	xmlplayHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlplayHttp.send(null);	
}
function writecookie(ch_id)
{
	document.cookie="ProgramItem="+ch_id+";expires="+new Date(new Date().getTime()+60*1000*30).toGMTString();
}
function ocxstatus()
{
	var ocx;
	try{
		ocx = new ActiveXObject("AvaIePlugin.AvaPlus.1");
		return ocx.IsInstalled();
	}catch(e)
	{
		return false;
	}
	
}
function writeNavPosition(obj){//写Cookie，显示所管理的分类(定位管理区域左部导航)
	document.cookie="nav="+obj;
}
writeNavPosition("");
function jumplogin(recordurl,jumpurl){//跳转到登录窗口(Cookie 十分钟后自动失效
	document.cookie="recordurl="+recordurl+";path=/";//+";expires="+new Date(new Date().getTime()+600000).toGMTString()+";path=/";
	document.location.href=jumpurl;
}
var defaultLen=4/*图片个数*/,isPN=false/*true:表示上一张，false:表示下一张*/;
function onMouseMoveImg(obj,evt){	
	//获取图片所在位置的
	var imgPostion_x=obj.offsetLeft;
	//得到图片的宽度
	var imgWidth=obj.width;
	//获取鼠标所在图片位置
	var evt=document.all?window.event:arguments[1];
	var imgMousePostion_x=document.all?evt.offsetX:evt.layerX-((document.body.clientWidth-990)/2+270);
	//分割图片
	var splitImgPostion=(imgWidth/2)+imgPostion_x-10;
	//alert(imgWidth+"  "+imgPostion_x+"  "+splitImgPostion+"  "+imgMousePostion_x);
	//window.status=imgWidth+"  "+imgPostion_x+"  "+splitImgPostion+"  "+imgMousePostion_x;
	if(imgMousePostion_x>splitImgPostion){
		obj.className="imgPrev";
		isPN=true;
		//window.status="true";
	}else{
		obj.className="imgNext";
		//window.status="false";
		isPN=false;
	}
}
function onClickEvent(obj){
	var imgurl=obj.src.replace(/(\s*$)/,"");//去除右边空格
	var imgCode=parseInt(imgurl.substr(imgurl.length-5,1));
	if(isPN && imgCode<defaultLen){//下一张
		imgCode++;
	}else if(isPN){
		imgCode=1;
	}else if(!isPN && imgCode>1){//上一张
		imgCode--;
	}else if(!isPN){
		imgCode=defaultLen;
	}else{
		return false;
	}
	obj.src=obj.src.replace(/[1-4].jpg$/,imgCode+".jpg ");
}