function showHideLayers(folder,file,lefts,kind) { //v3.0 傳入showLayer 
    if(kind==1){
    str=""
    document.getElementById("divs").innerHTML="<img src="+folder+"/"+file+".jpg border=1 width=136 height=113>";
    }else if(kind==2){
        str="下載"
        if(file=="all"){
        document.getElementById("divs").innerHTML="<img src="+folder+"/b.jpg border=1 >";
        }else{
            str="下載"
         document.getElementById("divs").innerHTML="<img src="+folder+"/"+file+".jpg border=1 width=272 height=226>";   
        }
    }else{
          str=""
          document.getElementById("divs").innerHTML="<img src="+folder+"/"+file+".jpg border=1 >";
    }

     if(file=="all"){
    document.getElementById("divs").style.top=document.body.scrollTop+25;
    document.getElementById("divs").style.left=event.clientX+document.body.scrollLeft+lefts+25;        
    }else{
        document.getElementById("divs").style.top=event.clientY+document.body.scrollTop+10;
        document.getElementById("divs").style.left=event.clientX+document.body.scrollLeft+lefts;                
    }
    

    if(file=="s"){
    document.getElementById("divss").innerHTML="全片";
    }else if(file=="all"){
    document.getElementById("divss").innerHTML="";        
    }else{
    document.getElementById("divss").innerHTML=str+"第"+file+"段";    
    }

document.getElementById("divss").style.top=event.clientY+document.body.scrollTop+10;
document.getElementById("divss").style.left=event.clientX+document.body.scrollLeft+lefts;
}
function hide() { //v3.0 傳入showLayer 
document.getElementById("divs").innerHTML="";
document.getElementById("divss").innerHTML="";

}


function changcolor(i,count){
    
    for(j=1;j<=count;j++){
        if(j==i){
        }else{
           if(document.getElementById("tr"+j)!=null){            
       document.getElementById("tr"+j).style.backgroundColor='';
        if(j%2==0){
        }else{
            
        }
        }
        }
    }
}
	function activepoint(){
//var d = new Date();
//document.getElementById("divs").innerHTML=d.getSeconds() ;
sendrequest("json.php");
}
//setInterval("activepoint()",5000);


var request = null;
try {
  request = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      request = null;
    }
  }
}

if (request == null)
  alert("Error creating request object!");
function sendrequest(url) {
//    alert(url)
   request.open("GET", url, true);
    if(url.search('json.php')==0){
     request.onreadystatechange =  function(){ updatePage("showpoint"); };
      request.send(null);
    }else if(url.search('cook.php')==0){
      //    alert('')
  request.onreadystatechange =function(){ updatePage("bottomlink"); };
   request.send(null);
  }
 
}


function updatePage(id) {
  
  if (request.readyState == 4) {
    if (request.status == 200) {
       // alert(request.responseText)
       if(request.responseText!=""){                
                
      // Get the updated totals from the JSON response
                
            //   var jsonData =request.responseText ;
                        
               var jsonData = eval("(" + request.responseText + ")");
//               var jsonData = JSON.stringify(jsonster);
               var obj=document.getElementById(id);	
             //  alert(request.responseText)                                             
//               var jsonData = JSON.parse(jsonstr);

                             
      //     alert(jsonData.catname);

//	
  if(id=="bottomlink"){
   // alert('')
str="<font class=down1>我的候選菜單</font><br>"
 for(var i=jsonData.length-1;i>=0;i--) {
   // alert(jsonData[i].catid);
    str+="<font class=downtxt><a href='index.php?search[0]="+jsonData[i].catid+"'><img class=favimg  src=http://image.avhigh.com/images/"+jsonData[i].catid+"/s.jpg width=33 height=46></a></font>";
 }
 }else{
    var str=jsonData.piece;
    document.getElementById("showpiece").innerHTML=str;

var str=jsonData.point;
 }
    			obj.innerHTML=str;

              //  obj.innerHTML='k';
         
}
    } else {
      var message = request.getResponseHeader("Status");
      if ((message.length == null) || (message.length <= 0)) {
        alert("Error! Request status is " + request.status);
      } else {
        alert(message);
      }
    }
  }
}
/**
 * 回到页面顶部
 * @param acceleration 加速度
 * @param time 时间间隔 (毫秒)
 **/
function goTop(acceleration, time) {
 acceleration = acceleration || 0.1;
 time = time || 16;
 var x1 = 0;
 var y1 = 0;
 var x2 = 0;
 var y2 = 0;
 var x3 = 0;
 var y3 = 0;
 if (document.documentElement) {
  x1 = document.documentElement.scrollLeft || 0;
  y1 = document.documentElement.scrollTop || 0;
 }
 if (document.body) {
  x2 = document.body.scrollLeft || 0;
  y2 = document.body.scrollTop || 0;
 }
 var x3 = window.scrollX || 0;
 var y3 = window.scrollY || 0;
 // 滚动条到页面顶部的水平距离
 var x = Math.max(x1, Math.max(x2, x3));
 // 滚动条到页面顶部的垂直距离
 var y = Math.max(y1, Math.max(y2, y3));
 // 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小
 var speed = 1 + acceleration;
 window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));
 // 如果距离不为零, 继续调用迭代本函数
 if(x > 0 || y > 0) {
  var invokeFunction = "goTop(" + acceleration + ", " + time + ")";
  window.setTimeout(invokeFunction, time);
 }
}

function slideLine(box,stf,delay,speed,h)
{
  var slideBox = document.getElementById(box);
  var delay = delay||1000,speed = speed||20,h = h||20;
  var tid = null,pause = false;
  var s = function(){tid=setInterval(slide, speed);}
  var slide = function(){
    if(pause) return;
    slideBox.scrollTop += 1;
    if(slideBox.scrollTop%h == 0){
      clearInterval(tid);
      slideBox.appendChild(slideBox.getElementsByTagName(stf)[0]);
      slideBox.scrollTop = 0;
      setTimeout(s, delay);
    }
  }
  slideBox.onmouseover=function(){pause=true;}
  slideBox.onmouseout=function(){pause=false;}
  setTimeout(s, delay);
}
slideLine('ann_box','div',2000,25,20);

function mongoto(have,url,mn,kind){
    if(kind==1){
str="全片"
    }else{    
str="此片段"
    }
msg='即將扣 1 片並取得'+str+'下載權限，是否繼續？若確定後未跳出下載方塊請在上方「下載紀錄」中取用檔案！'
if(have==1){
    msg=str+"已購買過，是否繼續購買？"
    }

	if (confirm(msg)){
	location.href=url	
	}
}

function goto(have,url,mn,kind){
    if(kind==1){
str="全片"
    }else{    
str="此片段"
    }
msg='即將扣 '+mn+' 點並取得'+str+'下載權限，是否繼續？若確定後未跳出下載方塊請在上方「下載紀錄」中取用檔案！'
if(have==1){
    msg=str+"已購買過，是否繼續購買？"
    }

	if (confirm(msg)){
	location.href=url	
	}
}
		function postToWb(name,img){
			var _t = encodeURI(name);
			var _url = encodeURIComponent(location.href);
			var _appkey = encodeURI('appkey');//你从腾讯获得的appkey
			var _pic = encodeURI(img);//（例如：var _pic='图片url1|图片url2|图片url3....）
			var _site = 'http://x599.net/';//你的网站地址
			var _u = 'http://v.t.qq.com/share/share.php?url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic+'&title='+_t;
			window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
		}
function imgalpha(i,v){
if(document.getElementById("img"+i).style.opacity==undefined){
                if(v==1){
                document.getElementById("img"+i).filters.alpha.opacity=100;  
                }else{
                document.getElementById("img"+i).filters.alpha.opacity=50;        
                }


    }else{
       // alert('')
            if(v==1){
            document.getElementById("img"+i).style.opacity=1;      
            }else{
            document.getElementById("img"+i).style.opacity=0.5;
            }

    }

    
}
