﻿// JavaScript Document
var sTime;
function preroll_closed() { //广告播放完后调用
	CPDivDisplay();
    var dateObj = new Date();
    sTime = (dateObj.getTime() - sTime)/1000;
	window.setTimeout("callPlayerplay()",2000);
	if (sTime >=3){
		if ((sTime >= 4) && (sTime < 8))
		  document.getElementById('adstati').innerHTML = '<iframe src=\"http://action.hupo.tv/stat/ad_tv.cfm?aid=59&aname=易传媒广告5秒\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\"></iframe>';
		if ((sTime >= 8) && (sTime < 13))
		  document.getElementById('adstati').innerHTML = '<iframe src=\"http://action.hupo.tv/stat/ad_tv.cfm?aid=60&aname=易传媒广告10秒\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\"></iframe>';
		if ((sTime >= 13) && (sTime < 22))
		   document.getElementById('adstati').innerHTML = '<iframe src=\"http://action.hupo.tv/stat/ad_tv.cfm?aid=57&aname=易传媒广告15秒\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\"></iframe>';
		if (sTime >= 22)
		   document.getElementById('adstati').innerHTML = '<iframe src=\"http://action.hupo.tv/stat/ad_tv.cfm?aid=58&aname=易传媒广告30秒\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\"></iframe>';
	}
}

function callPlayerplay(){
	objVadCP = thisMovie(CPPlayerID);
	if(objVadCP!=null){
		try{
		    objVadCP.AdisOver();
		} catch(e){
			objVadCP[1].AdisOver();
		}
	}
}

var left_old =strwidth;
var top_old = strheight;

if (playtype==null)
{ 
   var playtype="vod";
   var adtime="";
   
}else{
    if (playtype!="vod"){
      var adtime="30";  
	}
}

//adplayer_closed();

AdDivDisplay();

AdPlayerLoad(AdDivName,strheight,strwidth);

//document.onreadystatechange=CreateAdiframe;	

function LoadHupoPlayer(){
	if(mp3refer.indexOf("mp3.baidu.com")!=-1 || mp3refer.indexOf("list.mp3.baidu.com")!=-1)
	{
/*	 AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0','width','468','height','411','align','middle','id','tvplayer','src','http://img.hupo.tv/hupo/tv/nohpbdlayer20081029A','quality','high','bgcolor','#ffffff','name','tvplayer','allowscriptaccess','always','wmode','transparent','allowfullscreen','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','http://img.hupo.tv/hupo/tv/nohpbdlayer20081029A' ); //end AC code*/
	 document.getElementById(CPDivName).innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0\" width=\"466\" height=\"411\" id=\"tvplayer\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"always\"/><param name=\"allowFullScreen\" value=\"true\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"movie\" value=\"http://play.hupo.tv/player/nohpbdlayer20090608.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#000000\" /><embed src=\"http://play.hupo.tv/player/nohpbdlayer20090608.swf\" quality=\"high\" bgcolor=\"#000000\" wmode=\"transparent\" width=\"466\" height=\"411\" name=\"tvplayer\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
	}else{
/*	 AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0','width','468','height','411','align','middle','id','tvplayer','src','http://img.hupo.tv/hupo/tv/hpbdlayer20081029A','quality','high','bgcolor','#ffffff','name','tvplayer','allowscriptaccess','always','wmode','transparent','allowfullscreen','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','http://img.hupo.tv/hupo/tv/hpbdlayer20081029A' ); //end AC code*/
	 document.getElementById(CPDivName).innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0\" width=\"466\" height=\"411\" id=\"tvplayer\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"always\"/><param name=\"allowFullScreen\" value=\"true\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"movie\" value=\"http://play.hupo.tv/player/hpbdlayer20090608.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#000000\" /><embed src=\"http://play.hupo.tv/player/hpbdlayer20090608.swf\" quality=\"high\" bgcolor=\"#000000\" wmode=\"transparent\" width=\"466\" height=\"411\" name=\"tvplayer\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
	}	
}

function AdDivDisplay()
{
	document.getElementById(CPDivName).style.display="none";
	document.getElementById(AdDivName).style.display="";
}

function CPDivDisplay()
{
    document.getElementById(AdDivName).style.display="none";
	document.getElementById(CPDivName).style.display="";
	LoadHupoPlayer();
}		

function resizead(){

	var flvad=document.getElementsByName("adplayer")[0];

	flvad.width = strwidth * 2;
	flvad.height = strheight * 2;
	
	document.getElementById(AdDivName).style.left = left_old -(strwidth * 100 / 400)+"px";
	document.getElementById(AdDivName).style.top = top_old -(strwidth * 100 / 400)+"px";
	document.getElementById(AdDivName).style.visibility="visible";
	showAdNow();
}


function resizead2(){
	
	var flvad=document.getElementsByName("adplayer")[0];
	
	flvad.width = strwidth;
	flvad.height = strheight;
	document.getElementById(AdDivName).style.left = left_old+"px";
	document.getElementById(AdDivName).style.top = top_old+"px";
	document.getElementById(AdDivName).style.visibility="visible";
}

function thisMovie(movieName) 
{
    if (navigator.appName.indexOf("Microsoft") != -1) 
        return window[movieName];
    else 
        return document[movieName];
}

function showAdNow() {
	var videoWidth=strwidth;
	var videoHeight=strheight;	
	document.getElementById(AdDivName).style.visibility="visible";
	var myPos=getPos(document.getElementById(CPDivName));
	document.getElementById(AdDivName).style.left=(myPos[0]-(strwidth*100/400))+"px";
	document.getElementById(AdDivName).style.top=(myPos[1]-(strheight*100/300))+"px";
}

function getPos (element) {   
    var valueT = 0, valueL = 0;   
    do {   
      valueT += element.offsetTop  || 0;   
      valueL += element.offsetLeft || 0;   
      element = element.offsetParent;   
    } while (element);   
    return [valueL, valueT];   
  }



function AdPlayerLoad(AdDivName,strheight,strwidth)
{	
  var adUrl = "";
  var adStr="";
  adUrl ="../player/PreRoll.swf?aid=42426&hc=1&hs=1";
  var thtml = "";
thtml += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' id='adplayer' width='" +strwidth+ "' height='" +strheight+ "'>";
thtml += "<param name='movie' value='" + adUrl + "'>";
thtml += "<param name='menu' value='false'>";
thtml += "<param name='wmode' value='transparent'>";
thtml += "<param name='allowScriptAccess' value='always'>";
thtml += "<embed src='" + adUrl + "' quality='high' allowScriptAccess='always' wmode='transparent' width='" +strwidth+ "' height='" +strheight+ "' name='adplayer' menu='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>";
thtml += "</embed>";
thtml += "</object>";
document.getElementById(AdDivName).innerHTML = thtml;
  var dateObj = new Date();
  sTime = dateObj.getTime();
}
