var projPath = "http://218.85.135.180:8080/itv/";
/*节目列表*/
function showCatalogList(catalog){
	$('#curr-routeway').html(catalog);
	
	showList(0, 10);
}
/*节目列表*/
function showList(start, range){
	//alert(start + ":" + range);
	var catalog = $('#curr-routeway').html();
	var curr = event.srcElement||event.target;
	$(curr.parentNode.childNodes).each(function(i){	   
	   $(this).attr("class","");
	   $(this).css("color","#097edb");
	 }); 
	$(curr).attr("class","curr-routeway");
	$(curr).css("color","#ffffff");
	
	var url;
	if(catalog == "topic"){
		url = "./list/programAction.do?task=showTopicList&start="+start+"&range="+range;
	}else{
		url = "./list/programAction.do?task=showProgList&catalog="+catalog+"&start="+start+"&range="+range;
	}

	$('#loadStatus').show();
	
	$.ajax({
		url:url,
		type:'GET',
		dataType:'html',
		timeout:10000,
		error:function(){
			alert('加载出错了');
			$('#loadStatus').hide();
		},
		success:function(html){
			$('#loadStatus').hide(1000);
			//alert(html);
			$('#prog-list').html(html);
			$('#curr-routeway').html(catalog);
		}
	})
}
/*直播*/
function showLive(tvId){
	window.location.href = "./programAction.do?task=showLive&tvId="+tvId;
}

/*卡通直播*/
function showLive3(tvId){
	window.location.href = "../programAction.do?task=showLive&tvId="+tvId;
}

/*聚场*/
function showLive2(tvId){
	window.location.href = "./programAction.do?task=showLive&dayType=2&tvId="+tvId;
}

/*点播*/
function showPlay(progId){
	//alert(progId);
	window.location.href = "./programAction.do?task=showPlay&id=" + progId;
}

/*点播*/
function showSubPlay(progId){
	//alert(progId);
	window.open("./programAction.do?task=showPlay&id=" + progId,"_blank");
}

/*专题列表*/
function showTopicList(topicId){
	window.location.href = "./programAction.do?task=showTopicList&topicId="+topicId;
}

/*专题*/
function showTopic(topicId){
	var imgs = document.getElementById("topic-list").getElementsByTagName("img");
	//alert(imgs.length);
	for(var i=0; i<imgs.length; i++){
		imgs[i].style.border="5px solid #E3E5E4";
	}
	document.getElementById("topic-img-"+topicId).style.border="5px solid #ff7300";
	//$('#iframe-topic').attr("src", "./list/programAction.do?task=showTopic&topicId="+topicId);
	document.all('iframe-topic').src= "./list/programAction.do?task=showTopic&topicId="+topicId;
}
/*专题换大图*/
function showTopicBig(title, imgUrl, mapId){
	
	$('#topic-title').html(title);
	$('#topic-big-img').attr("src", imgUrl);
	alert(document.getElementById(mapId).innerHTML);
	$('#topic-map').html(document.getElementById(mapId).innerHTML);
	alert($('#topic-map').html());
}
function openAllPlaybill(){
	var pbs = document.getElementById("today-playbill").getElementsByTagName("tr");
	for(var i=0;i<pbs.length;i++){
		pbs[i].style.display="";
	}
	document.getElementById("open-all").style.display="none";
}
function switchPart(part){
	var parts = document.getElementById("playurl-list").getElementsByTagName("a");
	for(var i=0;i<parts.length;i++){
		parts[i].style.backgroundColor = "#ffffff";
	}
	document.getElementById(part).style.backgroundColor = "#ff7300"
	
}

function switchPart2(part){
	var parts = document.getElementById("playurl-list-2").getElementsByTagName("a");
	for(var i=0;i<parts.length;i++){
		parts[i].style.color = "#778899";
	}
	document.getElementById(part).style.color = "#ff7300"
	
}

/*DIV上下滚动*/
var $ = function(id){
  return document.getElementById(id);
}

function Scroll(){
}

Scroll.prototype={
    init:function(scrollobj){
         this.scrollBox = scrollobj;
         this.scrollBoxHeight = this.scrollBox.clientHeight;
         this.scrollBoxInner = this.scrollBox.innerHTML;
         this.scrollCol = this.scrolln = 0;
         this.scrollBox.innerHTML += "<br>" + this.scrollBoxInner;
         this.scrollCol =this.scrollBox.scrollTop;
         this.scrolln = 0;
         $('up').disabled="disabled";
    },
    downScroll:function(){
        $('up').disabled="";
        this.scrollBox.scrollTop = this.scrollCol + this.scrolln;
        if(this.scrolln==this.scrollBoxHeight)
         {$('down').disabled="disabled";return;}
        else
         this.scrolln = this.scrolln + 3;
         var o = this;
        function m(){o.downScroll();}
        this.timer = setTimeout(m,20);
    },
    upScroll:function(){
        $('down').disabled="";
        this.scrollBox.scrollTop = this.scrollCol + this.scrolln;
        if(this.scrolln==0)
         {$('up').disabled="disabled";return;}
        else
         this.scrolln = this.scrolln - 3;
         var o = this;
        function m(){o.upScroll();}
        this.timer = setTimeout(m,20);
    },
    stopScroll:function(){
        clearTimeout(this.timer);
    }
}

function installActiveX(){
	try {
		var comActiveX = new ActiveXObject("Itvsystem.ITVEnv.1");   
	} catch(e) {
		return false;   
	}
	return true;
}

function isInstallITVActiveX(){
	var   bResult=false;   
	var obj;
	try{   
		obj = new   ActiveXObject("Itvsystem2010.Itv2010.1");   
		//bResult = obj.IsSetup;
	}catch(e){
		return false;
	} 
	return true;
}

function playProg(playUrl){
	//alert(playUrl);
	/*var installFlag = installActiveX();
	
  	if (installFlag==true){
		//alert("已经安装控件");
		window.location.href = playUrl; 
	}
	else{
		//alert("没有安装控件");
		window.location.href = "http://vod.oooxm.com/getitv.html"; 
	}*/
	var installFlag = isInstallITVActiveX();
	if(installFlag==true){
		//alert("已经安装控件");	
		window.location.href = document.getElementById(playUrl).value;
	}else{
		//alert("没有安装控件");
		window.location.href = "./itv-download.jsp"; 
	}
}

function topicPlayProg(playUrl){
	//alert(playUrl);
	/*var installFlag = installActiveX();
	
  	if (installFlag==true){
		//alert("已经安装控件");
		window.location.href = playUrl; 
	}
	else{
		//alert("没有安装控件");
		window.location.href = "http://vod.oooxm.com/getitv.html"; 
	}*/
	/*var   bResult=false;   
	var obj;
	try{   
		obj = new   ActiveXObject("Itvsystem.ITVEnv.1");   
		bResult = obj.IsSetup;
	}catch(e){
		bResult=false;
	} 
	*/
	var installFlag = isInstallITVActiveX();
	if(installFlag==true){
		//alert("已经安装控件");	
		window.location.href = playUrl; 
	}else{
		//alert("没有安装控件");
		parent.window.location.href = "./2010itv-download.jsp"; 
	}
}