﻿function search(){
    var k=document.getElementById("QueryWords").value;
    if(k!=""){
    window.location="/common/search.aspx?q="+k;
    }
}

function iKeyword(obj,type){
    var init="请输入要检索的关键词...";
    switch(type){
        case 1:
            if(obj.value==init){obj.value="";}
            obj.style.cssText="color:black";
            break;
        case 2:
            if(obj.value==""){
                obj.value=init;
                obj.style.cssText="";
            }else{
                obj.style.cssText="color:black";
            }
        break;
    }
}


function registerForm_Check(){
    if(document.getElementById("txtLoginName").value==""){
        alert("请输入用户名！");
        document.getElementById("txtLoginName").focus();
        return false;
    }
    if(document.getElementById("txtPassword").value==""){
        alert("请输入登录密码！");
        document.getElementById("txtPassword").focus();
        return false;
    }
    if(document.getElementById("txtPasswordRepeat").value==""){
        alert("请重复登录密码以确认！");
        document.getElementById("txtPasswordRepeat").focus();
        return false;
    }
    if(document.getElementById("txtPassword").value!=document.getElementById("txtPasswordRepeat").value){
        alert("两次密码输入不相符，请确认！");
        document.getElementById("txtPasswordRepeat").focus();
        return false;
    }
    if(document.getElementById("ValidateCodeControl_validateInputControl").value==""){
        alert("请输入验证码来提交！");
        document.getElementById("ValidateCodeControl_validateInputControl").focus();
        return false;
    }
    if(!(document.getElementById("chkAgreement").checked)){
        alert("您还没有同意用户协议！");
        document.getElementById("chkAgreement").focus();
        return false;
    }
    return true;
}

function loginForm_Check(){
    if(document.getElementById("txtLoginName").value==""){
        alert("请输入用户名！");
        document.getElementById("txtLoginName").focus();
        return false;
    }
    if(document.getElementById("txtPassword").value==""){
        alert("请输入登录密码！");
        document.getElementById("txtPassword").focus();
        return false;
    }
    if(document.getElementById("ValidateCodeControl_validateInputControl").value==""){
        alert("请输入验证码来提交！");
        document.getElementById("ValidateCodeControl_validateInputControl").focus();
        return false;
    }
    return true;
}

function postForm_Check(){
    //if(document.getElementById("hidFileUpload").value==""){
    //    alert("您还没有上传种子文件！");
    //    return false;
    //}
    if(document.getElementById("txtSubject").value==""){
        alert("请填写种子资源标题！");
        return false;
    }
    
    return true;
}


function writeForm_Check(){
    if(document.getElementById("txtSubject").value==""){
        alert("请填写文章标题！");
        return false;
    }
    
    return true;
}

//改变图片大小
function resizepic(thispic)
{
if(thispic.width>700) thispic.width=700;
}
//无级缩放图片大小
function bbimg(o)
{
  var zoom=parseInt(o.style.zoom, 10)||100;
  zoom+=event.wheelDelta/12;
  if (zoom>0) o.style.zoom=zoom+'%';
  return false;
}

function killErrors() { 
 return true; 
} 
window.onerror = killErrors;

function playReady(){return true;}

function SetTag(add){
    var obj=document.getElementById("txtTags");

    if((obj.value=="")&&(obj.value.indexOf(add)<0)){
        obj.value+=add;
    }else{
    if((obj.value!="")&&(obj.value.indexOf(","+add)<0)){
        obj.value+=","+add;
    }}
}
 function   Ajax()   
  {   
  var   ajax;   
  try{   
          ajax=new   ActiveXObject("microsoft.XMLHTTP");   
  }   
  catch(e)   
  {   
  try{   
  ajax=new   ActiveXObject("MSXML2.XMLHTTP");   
  }   
  catch(ee)   
  {   
  //alert("初始化Ajax失败"+ee);   
  }   
  }   
  return   ajax;   
  }   
  function   clientclick(linkid)   
  {
try{
    var   ajaxObj=Ajax();   
    ajaxObj.open("get","/client/click.aspx?linkid="+linkid,false);   
    ajaxObj.send(null);
    return true;
   }catch(e){return true;}
  }

function ow(ev,obj,linkid) 
{
	var ev=window.event||ev;
	ev.returnValue=false;
	return wo(obj.href,640,420,1,1,linkid);
}

function wo(url,w,h,m,s,linkid)
{
	var left=(screen.width-w)/2;
	var top=m?(screen.height-h)/2:0;
	window.open(url,'','width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=0,resizable=0,status='+s);
try{
clientclick(linkid);}catch(e){}
	return false;
}

function owII(ev,obj) 
{
	var ev=window.event||ev;
	ev.returnValue=false;
	return woII(obj.href,640,420,1,1);
}

function woII(url,w,h,m,s)
{
	var left=(screen.width-w)/2;
	var top=m?(screen.height-h)/2:0;
	window.open(url,'','width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=0,resizable=0,status='+s);

	return false;
}

  function checkSubmitLink(){
  var eleurl=document.getElementById("ctl00_BasicBody_submitlink1_txtLinkUrl");
  var elename=document.getElementById("ctl00_BasicBody_submitlink1_txtLinkName");
   var url=eleurl.value;
   var name=elename.value;
   if(name==""){
   alert("请输入链接的名称...");   
   elename.focus();
   return false;
   }
   
   if(url==""){
   return false;
   }else{
   if( INDEXOF(url,"ftp://") || INDEXOF(url,"http://") || INDEXOF(url,"https://") || INDEXOF(url,"thunder://") || INDEXOF(url,"ed2k://")){
   return true;
   }else{
   alert("链接地址不正确...");   
   eleurl.focus();
   return false;
   }
   }
  }   
   function INDEXOF(Str,SubStr){
    return (Str.toLowerCase().indexOf(SubStr.toLowerCase())>-1);
   }
   
function uploadTorrent(){
	ret=window.showModalDialog("/aspx/uploadtorrent.aspx",window,"dialogWidth:630px;dialogHeight:430px;status:0;scroll:0;");
	if (ret != "") {
	document.getElementById("ctl00_BasicBody_submitlink1_txtLinkUrl").value=ret;
	}
	return false;
}

function Browse(ele)
    {
        var ifUpload;
        var confirmUpload;
        
        var rbltable = document.getElementById("ctl00_BasicBody_uploadattachment1_rdoType");
  var rbs= rbltable.getElementsByTagName("INPUT");
  var TypeValue;
  for(var i = 0;i<rbs.length;i++)
  { 
    if(rbs[i].checked)
    { 
       TypeValue=rbs[i].value;
    }
}
if (TypeValue==""){alert("请设置您要上传的文件类型！");return false;}
        
        ifUpload = iframeUpload.document.uploadForm; 
        ifUpload.fileUpload.click();
//        confirmUpload = confirm ("You are about to upload the file " + ifUpload.myFile.value + " to the server. Do you agree to Upload?");
//        if (confirmUpload)
//        {
        if(ifUpload.fileUpload.value==""){
        alert("请选择要上传的文件！");
        }else{
        
         ifUpload.hidTypeId.value=TypeValue;
        ifUpload.hidPrimaryId.value=document.getElementById("ctl00_BasicBody_uploadattachment1_hidPrimaryId").value;
        ifUpload.hidAttachmentModule.value=document.getElementById("ctl00_BasicBody_uploadattachment1_hidAttachmentModule").value;
        ifUpload.hidAttachmentName.value=document.getElementById("ctl00_BasicBody_uploadattachment1_txtAttachmentName").value;
        
            ifUpload.btnSubmit.click();}
//        }
//ele.Enabled=false;
        return false;
    }

    function SetTags(ele){
    if(ele.className=="selectedTag"){
    ele.className="";
    }else{
    ele.className="selectedTag";
    }
    
        var tag=document.getElementById("txtTags");
        var tagText=tag.value;
        var tags=tagText.split(",");
        var tagNew=ele.innerText;
        var tagsNew=new Array();
        
        var exists=false;
        for(var i=0;i<tags.length;i++){
            if(tags[i]==tagNew){
                if(ele.className=="selectedTag"){
                    tagsNew.unshift(tags[i]);
                    }
                    exists=true;
                }else{
                    tagsNew.unshift(tags[i]);
                }
        }
        if(!exists){
        tagsNew.unshift(tagNew);
        }
        tag.value=tagsNew.join(",");
    }


function selectMethod(ele){
if(ele.selectedIndex==5){
document.getElementById("ctl00_BasicBody_submitlink1_chkEnableThunder").checked=false;
}else{
document.getElementById("ctl00_BasicBody_submitlink1_chkEnableThunder").checked=true;
}
}

function defsubmit() {
    var sForm=document.getElementById("searchFrom");
    var cLocal=document.getElementById("module");
sForm.keywords.value=sForm.search.value;
	if((sForm.search.value == "") ||(cLocal.value=="2")){
		sForm.action ="/meta/default.aspx";
		sForm.method="post";
	}
	else{
		sForm.action = "http://www.gougou.com/search";
		sForm.method="get";
	}
}

function clientsubscribe(fromaccountid,toaccountid) {
    try {
        var ajaxObj = Ajax();
        ajaxObj.open("get", "/client/addsubscribe.aspx?fromaccountid=" + fromaccountid, false);
        ajaxObj.send(null);
        if (confirm("成功订阅该用户的节目，您可以打开您的影音盒子查看已收藏节目\n现在查看请确定，暂不查看请取消.")) {
            window.open("/u/" + toaccountid);
        }
        return true;
    } catch (e) { return true; }
}

function clientvisit(toaccountid) {
    try {
        var ajaxObj = Ajax();
        ajaxObj.open("get", "/client/addvisit.aspx?toaccountid=" + toaccountid, false);
        ajaxObj.send(null);

        return true;
    } catch (e) { return true; }
}

function clientfavorite(primaryid, favoritemodule) {
    try {
        var ajaxObj = Ajax();
        ajaxObj.open("get", "/client/addfavorite.aspx?primaryid=" + primaryid + "&favoritemodule=" + favoritemodule, false);
        ajaxObj.send(null);
        if (confirm("成功将该节目收藏，您可以打开您的影音盒子查看已收藏节目\n现在查看请确定，暂不查看请取消.")) {
            window.open("/u/");
        }
        return true;
    } catch (e) { return true; }
}

function turnDiv(showLi,hideLi,showDiv, hideDiv) {

    document.getElementById(showLi).className = "redLi";
    document.getElementById(hideLi).className = "blackLi";

    document.getElementById(showDiv).className = "showDiv";
    document.getElementById(hideDiv).className = "hiddenDiv";

    return false;
}
