var vpd="";
var vqd="";
var opc="";
var opp="";
var oid="";
var UU="";
var dourl=0;
var history_info_old="";
var lastEl = [], hasInit;

document.onkeydown = function() { 

var ch = String.fromCharCode(event.keyCode); 

if ((event.ctrlLeft || event.CtrlRight) && (ch == "n" || ch == "N")) 

{ 

return false; 

} 

} 



function $(id){
	return document.getElementById(id);
}

function opcf(cp){
	if (opc!=""){
	opc.className="ce";
	}
	opc=cp;
	cp.className="ce2";
}
function opk(obj){
	if (opc!=obj){
		obj.className="ce";
	}
}

function opk3(obj){
	if (obj.className!='ce2'){
		obj.className="ce3";
	}
}


function oppa(obj){
//alert(obj.className)
	if (obj.className=="pee")
{
obj.className="pee2";
	}
}
function oppb(obj){
//alert(opp)
	if (opp!=""){
		opp.className="pee";
                opp=obj
                obj.className="pee3"
	}
                opp=obj
                obj.className="pee3"
}

function oppc(obj){
//alert(obj)
	if (obj.className=="pee2"){
                obj.className="pee"
	}

}




function showDanp(obj,cid,url){
if(dourl!=0)
{
}else{
vpd=obj;
vqd=vpd;
	if(!hasInit){
		var divs = $('plist').getElementsByTagName('div'), l = divs.length;
		for(var i=0;i<l;i++){
			var d = divs[i];
			if(d.id && d.id.indexOf('kp_')>-1 && d.style.display!='none'){
				lastEl[0] = d;
				lastEl[1] =divs[i-1];
				break;
			}
		}
		hasInit = true;
	}
	if(obj.innerHTML==""){
		psort(cid);
		obj.style.display='block';
		$("cp_"+cid).className="cp2";
	}else{
		if (obj.style.display=='none'){
			if(lastEl && lastEl.length){
				lastEl[0].style.display='none';
				lastEl[1].className='cp1';
			}
			obj.style.display='block';
			$("cp_"+cid).className="cp2";
			lastEl[0] = obj;
			lastEl[1] = $("cp_"+cid);
			location.href=location.href.replace(/#.+/,'')+'#cp_'+cid;
    if(obj.innerHTML=="数据读取中....")
 { 
if(cid==100){
history_show();
}else{
if(url)
{

makeRequest(url);

}else{
obj.innerHTML="<div class='loading'>正在下载中...</div>";
}

}  
}
		}else{
			obj.style.display='none';
			$("cp_"+cid).className='cp1';
			lastEl = [];
		}
	}
}
}
function showlist(url,tem){
if(dourl!=0)
{
}
else{
if (tem=="a"){
vqd="kp_0"
}
if (url!="")
{
vpd=vqd;
oid="";

makeRequest(url);
}

}
}

function showYK(url){
if (url!="")
{
play("play://SY|||"+url);
}
}




function showurl(cid,url){
if(dourl!=0)
{
}else{
	if (oid==""){
	oid="url_"+cid;
	}else{

if(oid!="url_"+cid){
        document.getElementById(oid).style.display='none';
	oid="url_"+cid;}
}


var obj=document.getElementById("url_"+cid);  
		if (obj.style.display=='none'){
			obj.style.display='block';
    if(obj.innerHTML=="....")
 { 

vpd=obj;
makeRequest(url);


  }
		}else{
			obj.style.display='none';
                       vpd=obj;
		}
	}
}

	function makeRequest(url) {
                dourl=1;
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				//http_request.overrideMimeType('text/xml');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}

		if (!http_request) {
			alert('Giving up :( Cannot create an XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = alertContents; 
		http_request.open('GET', url, true);
		http_request.send(null);






	}
	function alertContents() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
                                var vtext = http_request.responseBody;
				vpd.innerHTML =bytes2BSTR(vtext);
                                dourl=0;
                                //alert(vtext);
				}
			
			} else {

                                vpd.innerHTML = "<div class='loading'>正在载入中...</div>"
			}

	}

function history_show()
{ 
var history_info=getCookie_("history_info");
//alert(history_info);

 var content=""; 
 if(history_info!=null)
 {

if(history_info_old!=history_info)
{
 history_info_old=history_info
//alert(history_info_old);
 history_arg=history_info.split("_ab_");
 var i;
 for(i=0;i<=10;i++)
  {


  if(history_arg[i]!=null)
       {

var wlink=history_arg[i].split("_cd_");   
   content+=("<DIV class=ce  onmouseover='opk3(this)' onclick=\"opcf(this)"+";"+"javascript:play('play://LR|"+wlink[0]+"|"+wlink[1]+"')\" onmouseout='opk(this)'>"+wlink[0]+"<span>"+wlink[2]+"</span></DIV>");



}

   }
   if(document.getElementById("kp_100").innerHTML!=content){
   document.getElementById("kp_100").innerHTML=content;
}

   }
   }
else {document.getElementById("kp_100").innerHTML="<div align=center><strong><font style=font-size:12px\;color:red\;>暂无观看记录!</font></strong></div>";}


}


function getCookie_(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function del_history(){setCookie_("history_info","",1);}
function setCookie_(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function play(url) {
	try {
      var DownObj=new ActiveXObject(ocx);
           DownObj.send(url)        
    }
    catch(e) {
    //if (confirm("播放本站电影必须先程序，请先下载安装！"))
    window.open(url);   
    }
  }


function sc_show()
{ 
var history_sc=getCookie_("history_sc");
//alert(history_sc);

 var content=""; 
 if(history_sc!=null)
 {

if(history_sc!=null)
{

 history_scg=history_sc.split("_ab_");
 var i;
 for(i=0;i<=100;i++)
  {


  if(history_scg[i]!=null)
       {

var wlink=history_scg[i].split("_PS_");   
   content+=("<li><a href=\""+wlink[1]+"\" title=\""+wlink[0]+"\"><img src=\""+wlink[2]+"\" /><p>"+wlink[0]+"</p></a></li>");
}

   }
   if(document.getElementById("sclist").innerHTML!=content){
   document.getElementById("sclist").innerHTML=content;
}

   }
   }
else {document.getElementById("sclist").innerHTML="<div align=center><strong><font style=font-size:12px\;color:red\;>暂无收藏节目!</font></strong></div>";}


}