﻿var floatdiv;
var floatinvit;
/*值越大越往下*/
var flvtotop=200;
var old=flvtotop;
//var kstvid=10;

/*初始化函数*/
function initmedth(){
  getdiv();
  floatdiv=document.getElementById('fdiv');
  floatinvit=document.getElementById('invit');
  movediv();
}
/*生成一个悬浮层*/
function getdiv(){
  var divcont="<iframe src='http://www.kstv.tv/t2_newWindowsLeft.aspx?kstvid="+kstvid+"&csscolor="+csscolor+"&strdirection=left' width='192px' height='225px' scrolling='no' frameborder='0' allowTransparency='true'></iframe>";
  var div1="<div id='fdiv' style='position:absolute;top:250px;left:20px;width:192px; height:225px;'>"+divcont+"</div>";
  document.write(div1);
/*邀请框 中置flash*/
  //var invitdiv="<div id='invit' style='position:absolute;width:400px;height:200px; background-color:red; overflow:hidden; visibility:hidden '><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' id='guestChat' width='0' height='0' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'><param name='movie' value='guestChat.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#869ca7' /><param name='wmode' value='transparent' /><param name='allowScriptAccess' value='sameDomain' /><embed src='guestChat.swf' quality='high' bgcolor='#869ca7' width='200' height='100' name='guestChat' align='middle' play='true' loop='false' quality='high' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer'></embed></object></div>";
  //document.write(invitdiv);
}
/*隐藏邀请框*/
//function invithidden(){
//   if(floatinvit.style.visibility=='hidden'){
//     floatinvit.style.visibility='inherit';
//   }else{
//     floatinvit.style.visibility='hidden';
//   }
//   
//}
/*控制层的移动*/
function movediv(){
  var tt=50;
  if(window.innerHeight){
    pos=window.pageYOffset;

  }
  else if(document.documentElement && document.documentElement.scrollTop){
    pos = document.documentElement.scrollTop;

  }
    else if (document.body) {
    pos = document.body.scrollTop;

  }
  pos=pos-floatdiv.offsetTop+flvtotop;

  pos=floatdiv.offsetTop+pos/10;

  if (pos < flvtotop) {
  pos = flvtotop;

  }
  if (pos != old) {
    floatdiv.style.top = pos+"px";
    //floatinvit.style.top=pos+"px";
    tt=10;
  }
  old = pos;
  setTimeout(movediv,tt);
}
function scall(){
  document.getElementById("fdiv").style.right=20+'px';
  //document.getElementById("invit").style.left=document.documentElement.clientWidth/2-200+'px';
  //document.getElementById("invit").style.right=document.body.clientWidth/2-200+'px';
}
/*执行区*/
initmedth();
scall();
//setTimeout('invithidden()',6000);