function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// remote scripting library
// (c) copyright 2005 modernmethod, inc
var sajax_debug_mode = false;
var sajax_request_type = "GET";

function sajax_debug(text) {
	if (sajax_debug_mode)
		alert("RSD: " + text)
}
function sajax_init_object() {
	sajax_debug("sajax_init_object() called..")
	
	var A;
	try {
		A=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			A=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			A=null;
		}
	}
	if(!A && typeof XMLHttpRequest != "undefined")
		A = new XMLHttpRequest();
	if (!A)
		sajax_debug("Could not create connection object.");
	return A;
}

function sajax_do_call_videorm(ref, type) {
	var i, x, n;
	var uri;
	var post_data;
	var divname;
	if (type=="news"){
		uri = "news_link.jsp";
		divname="newslink";
	}else if(type=="video"){
		uri = "video_link.jsp";
		divname="videolink";
	}else if(type=="radio"){
		uri = "videorm_radio.jsp";
		divname="audiolink";
	}else if(type=="radio_radio"){
		uri = "videoradio_radio.jsp";
		divname="audiolink";
	}else if(type=="radio_video"){
		uri = "videoradio_video.jsp";
		divname="videolink";
	}else if(type=="podcast"){
		uri = "videopodcast_podcast.jsp"
		divname="podcastlink"
	}
/*
	if (sajax_request_type == "GET") {
		if (uri.indexOf("?") == -1) 
			uri = uri + "?ref=" + escape(ref) ;
		else
			uri = uri + "&ref=" + escape(ref) ;
//				for (i = 0; i < args.length-1; i++) 
//					uri = uri +  "&rsarg"+i+"=" + escape(args[i]);
//				uri = uri + "&rsrnd=" + new Date().getTime();
		post_data = null;
	} else {
		post_data = "?ref=" + escape(ref);
//				for (i = 0; i < args.length-1; i++) 
//					post_data = post_data + "&rsarg"+i+"=" + escape(args[i]);
	}
*/	
	if (uri.indexOf("?") == -1) 
			uri = uri + "?ref=" + escape(ref) ;
		else
			uri = uri + "&ref=" + escape(ref) ;
	//alert(sajax_request_type);
	x = sajax_init_object();
	x.open(sajax_request_type, uri, true);
	if (sajax_request_type == "POST") {
		x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
		x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
	}else{
		x.setRequestHeader("Method", "GET " + uri + " HTTP/1.1");
		x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
		
	}
	x.onreadystatechange = function() {
		if (x.readyState != 4) 
			return;
		sajax_debug("received " + x.responseText);
		//alert(x.responseText);
		
		var status;
		var data;
		status = x.responseText.charAt(0);
//				data = x.responseText;
//				data = data.substring(0,data.indexOf("_"));
		data = x.responseText;
		var div;
		div = document.getElementById(divname);
		div.innerHTML = data;

		if (status == "-") 
			alert("Error: " + data);
//				else  
//					args[args.length-1](data);
	}
	x.send(post_data);
	sajax_debug(ref + " uri = " + uri + "/post = " + post_data);
	sajax_debug(ref + " waiting..");
	delete x;
}
	

function doPlay(){
	document.videoplay.DoPlay();
}
function doPause(){
	document.videoplay.DoPause();
}
function doStop(){
	document.videoplay.DoStop();
}
function doFullScreen(){
	document.videoplay.SetFullScreen ();
}

function videorefresh(refid){
	var temp;
	var ref = "";
	var title = "";
	temp = refid + "filepath"
	var fileURL = document.getElementById(temp).value;
	videoplay.URL=fileURL ;
	videoplay.controls.play();

	//temp = refid + "channel"
	//mschannel.innerText=document.getElementById(temp).value;
	temp = refid + "title"
	mstitle.innerHTML=document.getElementById(temp).value;
	document.title=document.getElementById(temp).value+"-CCTV视频播放"; 
	//title = document.getElementById(temp).value;
	temp = refid + "program"
	msprogram.innerHTML=document.getElementById(temp).value;
	temp = refid + "listdate"
	//listdate.innerText=document.getElementById(temp).value;
	temp = refid + "listtime"
	//listtime.innerText=document.getElementById(temp).value;
	temp = refid + "listcontent"
	listcontent.innerHTML=document.getElementById(temp).value;

	temp = refid + "listmore";
	var tempmore = document.getElementById(temp).value;
	if ((tempmore!=null)&&(tempmore!="")){
		listmore.innerHTML="<a href='"+tempmore+"' target='_blank'>查看全文</a>";
	}else{
		listmore.innerHTML="";
	}
	
	//set starttime
	temp = refid + "starttime"
	var starttime = document.getElementById(temp).value;
	if (starttime.length=0) starttime=0;
//alert(videoplay.status)
	document.getElementById("videoplay").controls.currentPosition=starttime;
//alert(videoplay.status)
	

	temp = refid + "listref";
	ref = document.getElementById(temp).value;
	//alert(ref)
	sajax_do_call_videorm(ref,"video");
	//sajax_do_call(ref,"radio");
	sajax_do_call_videorm(ref,"news");
	
//	temp = refid + "filepath";
//	videoplay.SetSource(document.getElementById(temp).value);
//	videoplay.DoPlay();
}


function getN(id){return document.getElementById(id)}

function playStory(storyfilepath){
	videoplay.SetSource(storyfilepath);
	videoplay.SetPosition(0);
	videoplay.DoPlay();
}

//for playlist
var refArray = new Array();
var titleArray = new Array();
var footerArray = new Array();
var contentArray = new Array();
var checkArray = new Array();
var checkIndex = 0;
var refIndex = 0;
function playMyfavorites(){
	if (document.getElementById(iframeFavorites)==null) return;
	var splitword = "SeperatorOfCblinkx";
	var refString = document.iframeFavorites.hReference.value;
	var titleString = document.iframeFavorites.hTitle.value;
	var footerString = document.iframeFavorites.hFooter.value;
	var contentString = document.iframeFavorites.hContent.value;
	//var checkString = document.iframeFavorites.hList.value;
	
	refArray = refString.split(splitword);
	titleArray = titleString.split(splitword);
	footerArray = footerString.split(splitword);
	contentArray = contentString.split(splitword);
	//checkArray = checkString.split(splitword);
	
//	alert(checkArray);
	
//	checkIndex=0;
	doNext();
	
}

function doNext(){
	if (document.iframeFavorites.hReference==null) return;
	if (refArray.length==0) initPage()
	//refIndex = checkArray[checkIndex];

	var reftemp = refArray[refIndex];
	var playFilePath = "";
	if ((reftemp.indexOf("_")>1)&&((reftemp.substring(0,reftemp.indexOf("_")))==("OpenVWMVPath"))){
		playFilePath="cctvvideo";
		playFilePath ="rtsp://wmv.openv.tv/video/"+reftemp.substring(reftemp.indexOf("_")+1,reftemp.length);
	}
	videoplay.URL = playFilePath;
	
	mstitle.innerText = titleArray[refIndex];
	var contenttemp = contentArray[refIndex];
	if (contenttemp.length>250) contenttemp=contenttemp.substring(0,250)+"...";
	listcontent.innerText = contenttemp;
	msprogram.innerText = footerArray[refIndex];
	
	refIndex++
	if (refIndex==refArray.length) refIndex=0;

	//checkIndex++;
	//if (checkIndex==checkArray.length) checkIndex=0;

}
function checkPlayOver(){
  if (isPlayOver==true){
    doNext()
    isPlayOver=false;	
  }
}
window.setInterval("checkPlayOver()",1000);

function initPage(){
	var splitword = "SeperatorOfCblinkx";
	var refString = document.iframeFavorites.hReference.value;
	var titleString = document.iframeFavorites.hTitle.value;
	var footerString = document.iframeFavorites.hFooter.value;
	var contentString = document.iframeFavorites.hContent.value;
	//var checkString = document.iframeFavorites.hList.value;
	
	refArray = refString.split(splitword);
	titleArray = titleString.split(splitword);
	footerArray = footerString.split(splitword);
	contentArray = contentString.split(splitword);
	//checkArray = checkString.split(splitword);
	
	//alert( checkArray );
	
	//checkIndex=0;

}



		