﻿$=function(obj){return document.getElementById(obj);}

//-----------验证评论信息-------------
function checkform(){
    var Str=$('txtContent').value.replace(/\s/ig,"");//过滤空格
    $("txtContent").value=Str;//过滤后重新将内容写入文本域
    
    if(Str.length<1){
         window.alert("对不起,请输入评论内容.");
         $('txtContent').focus();
         return false;
    }
    else if(Str.length>500){
         window.alert("对不起,评论不能超过500字.");
         $('txtContent').focus();
         return false;
    }
    if(!$("chkNoName").checked){
        window.alert("对不起,请先登陆或选择匿名发表.");
        $('chkNoName').focus();
         return false;
    }
    
    return true;
}

//--------------------评论内容插入表情标签(视频)--------------------
//function grin(tag)
//{
//    if (document.selection) 
//    {
//        $('txtContent').focus();
//        sel = document.selection.createRange();
//        sel.text = tag;
//        $('txtContent').focus();
//    }
//}

//------------播放器----------
//w:播放器宽度
//h:播放器高度
//fp:播放器路径
//vp:视频文件路径
function VideoPlayer(w,h,fp,vp){
    //var str = "<img src='/images/sp1.gif' border='0' />";
    var str = "";
    //加载暂停时的广告
    //str += "<table class=\"suspadv\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
    //str += "<tr><td align=\"center\" valign=\"middle\" id=\"suspadv\" style=\"display:;none;\"></td></tr>";
    //str += "</table>";
    
    str += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + w + "' height='" + h + "' id='Player01' align='middle'>";
    str += "<param name='allowScriptAccess' value='sameDomain' />";
    str += "<param name='movie' value='" + fp + "' />";
    str += "<param name='quality' value='high' />";
    str += "<param name='bgcolor' value='#ffffff' />";
    str += "<param name='allowFullScreen' value='true' />";
    str += "<param name='FlashVars' value='" + vp + "' />";
    str += "<embed src='" + fp + "' FlashVars='" + vp + "' quality='high' bgcolor='#ffffff' width='" + w + "' allowFullScreen='true' height='" + h + "' name='Player01' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    str += "</object>";
    
    return str;
}
//--------加载广告-----------
//filepath：广告文件路径
function AdvPlayer(filepath,advurl,intro){
    var str = "<div class='timebar' id='timebar'></div>";
    str +="<div id='advBox'>";
    //判断广告是图片还是动画
    if(filepath.toLowerCase().indexOf(".jpg") > 0 || filepath.toLowerCase().indexOf(".gif") > 0 || filepath.toLowerCase().indexOf(".png") > 0 || filepath.toLowerCase().indexOf(".bmp") > 0)
    { 
        str +="<a href='"+advurl+"' target='_blank'><img src='"+filepath+"' /></a>";
    }
    else if(filepath.toLowerCase().indexOf(".swf") > 0)
    {
        str +="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='360' height='220'>";
        str +="<param name='movie' value='"+filepath+"' />";
        str +="<param name='quality' value='high' />";
    }
    str +=intro != "" ? ("<br><br>" + intro) : "";
    str +="</div>";
    return str;
}
//--------复制文本框中的内容--------
function CopyAll(T){
  T.focus(); //使文本框得到焦点
  T.select(); //把文本框中的内容全选
  if (document.all){
  therange=T.createTextRange();
  therange.execCommand("Copy"); //复制
  alert('复制成功.');
  }
}
//==========================看视频延时扣积分===================================
var ischangecent = false;
function changecent(videoid, videotitle) {
    if (!ischangecent) {
        var str = "/Video_Info_ChangeCent.aspx?videoid=" + videoid + "&videotitle=" + escape(videotitle);
        SendAdd(str); ischangecent = true;
    }
}
//-----------------------------------------------------------------------//
var xmlHttp;
function SendAdd(url) {
    createXMLHTTP();
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                alert(xmlHttp.responseText);
            }
            else {
                alert("积分扣除失败" + xmlHttp.responseText);
            }
        }
    }

    xmlHttp.open("POST", url, false);
    xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    xmlHttp.send(null);
}
//---------//
function createXMLHTTP() {
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Msxml12.XMLHTTP");
        }
        catch (e)
    { }
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
    { }
        if (!xmlHttp) {
            alert("您已评论，请不要在短时间内重复评论本文,请稍后再发表您的评论！");
            return false;
        }
    }
}
