if(self!=top){top.location=self.location;} 
//设为首页
function set_homepage(url){
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(url);
	}else{
		if (window.sidebar)
		{
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e)
			{
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
				return false;
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',url);

		}
	}
}

//添加书签
function add_bookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

//显示分类更新
function show_box(n){
	for(var i=0;i<11;i++){
		if(document.getElementById("box"+i) != null){
			document.getElementById("boxtitle"+i).className="";
			document.getElementById("box"+i).style.display="none";
		}
	}
	document.getElementById("boxtitle"+n).className="current";
	document.getElementById("box"+n).style.display="block";
}

//显示隐藏软件介绍
function set_introduction(type){

	//取得滚动条的位置
	var position = document.documentElement.scrollTop;

	if(type){
       document.getElementById("softintrd").style.height = 'auto';
		document.getElementById("hide").style.display = 'inline';
		document.getElementById("display").style.display = 'none';
	}else{
		document.getElementById("softintrd").style.height = '100px';
		document.getElementById("hide").style.display = 'none';
		document.getElementById("display").style.display = 'inline';
		window.scrollBy(0,position);
	}

	

}
function showxunlei(){
    var thunder_pid = "45241";
    var restitle = "";
    
    if ($('#base_download').length < 1)
    {
         return false;
    }
    
	var thunder_dxurl = $('#base_download').attr('href');
	var softid = document.getElementById('softid').value;
	var dx_html = '<li><img src="/images/ico-xl-16.gif" alt="" /> <a href="javascript://" title="迅雷高速下载" thunderHref="' + ThunderEncode(thunder_dxurl) + '" thunderPid="' + thunder_pid + '" thunderResTitle="' + restitle + '" onClick="hits('+softid+',\'down\'); return OnDownloadClick_Simple(this,2,4)" oncontextmenu="ThunderNetwork_SetHref(this)">迅雷下载</a></li>'
                +'<li><img src="/images/ico-kc-16.gif" alt="" /> <a href="javascript://" title="快车高速下载" onClick="convertFgURL(\''+thunder_dxurl+'\',1926);hits('+softid+',\'down\'); "  oncontextmenu="Flashget_SetHref_js(\''+thunder_dxurl+'\',1926);" >快车下载</a></li>'
                +'<li><img src="/images/ico-xf-16.gif" alt="" /> <a href="#" OnClick="OnDownload_template(\'qqdl://'+encode64(thunder_dxurl)+'\', 30002,\'http://www.xiazaiba.com/html/224.html\');" title="超级旋风下载">旋风下载</a></li>';
	$("#xunlei_download").prepend(dx_html);

 
    /*
     * 电信
     */
	var dx_html = '<a href="javascript://" title="迅雷高速下载" thunderHref="' + ThunderEncode(thunder_dxurl) 
			      + '" thunderPid="' + thunder_pid + '" thunderResTitle="' + restitle 
			      + '" onClick="return OnDownloadClick_Simple(this,2,4)" oncontextmenu="ThunderNetwork_SetHref(this)" class="xunlei">迅雷下载</a>'
			      + '<a href="javascript://" title="快车高速下载" onClick="convertFgURL(\''+thunder_dxurl+'\',1926)" oncontextmenu="Flashget_SetHref_js(\'' 
			      + thunder_dxurl+'\',1926);"  class="kc">快车下载</a><a href="javascript://" class="xf" OnClick="OnDownload_template(\'qqdl://'+encode64(thunder_dxurl)+'\', 30002 ,\'http://www.xiazaiba.com/html/224.html\');" title="超级旋风下载">旋风下载</a>';
	$("#isp_dx").append(dx_html);
	$("#isp_wt").append(dx_html);  
}
//评论检查
function check_comment(){
	if(document.getElementById('comment').value == ''){
		alert('很抱歉,请您先填写评论!');
		document.getElementById('comment').focus();
		return false;
	}
	if(document.getElementById('comment').value.length < 3){
		alert('很抱歉,评论字数不能少于3个!');
		document.getElementById('comment').focus();
		return false;
	}
	if(document.getElementById('imgcode').value == ''){
		alert('很抱歉,请您先填写验证码!');
		document.getElementById('imgcode').focus();
		return false;
	}
	if(document.getElementById('comment').value.length > document.getElementById('reviewlong').value){
		alert('很抱歉,评论字数不能超过'+document.getElementById('reviewlong').value+'个!');
		document.getElementById('comment').focus();
		return false;
	}
}

//搜索检查
function check_search(){
	if(document.getElementById('keyword').value == ""){
		alert('很抱歉,请您先输入您要搜索的内容!');
		document.getElementById('keyword').focus();
		return false;
	}
	if(document.getElementById('keyword').value == "请输入关键字搜索，多关键字用空格隔开"){
		alert('很抱歉,请您先输入您要搜索的内容!');
		return false;
		document.getElementById('keyword').focus();
	}
	if(document.getElementById('keyword').value.length < 2){
		alert('很抱歉,搜索的内容不能少于2个字!');
		return false;
	}
}

//投诉检查
function check_complain(){
	if(document.getElementById('complain').value == ""){
		alert('很抱歉,请您先输入您要投诉的内容!');
		document.getElementById('complain').focus();
		return false;
	}
	if(document.getElementById('complain').value.length < 5){
		alert('很抱歉,投诉的内容不能少于5个字!');
		document.getElementById('complain').focus();
		return false;
	}
}

//评论回复
/*
function comment_reply(id,orderid){

	document.getElementById("comment").value='{回复'+orderid+"楼}:\r\n";

	document.getElementById("reply").value = id;

	//IE
	if(typeof document.selection !="undefined")
	{
		object = document.getElementById("comment").createTextRange();
		object.collapse(true);
		object.moveStart('character',8);
		object.select()
	}

	//FF ?
	//..................
}
*/
function comment_quote(id,orderid){
    document.getElementById("comment_title").parentNode.style.display = 'block';
	document.getElementById("comment_title").innerHTML='回复<strong class="color_f60">'+orderid+"</strong> 楼的评论";

	document.getElementById("quote_id").value = id;

    document.getElementById("cancel").style.display = 'inline';

	//IE
	if(typeof document.selection !="undefined")
	{
		object = document.getElementById("comment").createTextRange();
		object.collapse(true);
		object.moveStart('character',0);
		object.select()
	}

	//FF ?
	//..................
}

function cancel_comment(){
  document.getElementById("comment_title").parentNode.style.display = 'none';
  document.getElementById("comment_title").innerHTML = '';
  document.getElementById("quote_id").value = '';
  document.getElementById("cancel").style.display = 'none';
}

//好评度
function add_vote(type,softid){
	$.ajax({
		type: "POST",
		url: "../vote.php",
		data: "action=add&softid="+softid+"&type="+type,
		cache:false,
		success: function(msg){
			alert(msg);

			//改变调回的数据
			if(msg == '投票成功！'){

				//原始值
				var up = document.getElementById('goodvalue') ;
				var down = document.getElementById('badvalue');
				
				if(!up.innerHTML){
			      up.innerHTML = 0;	
				}
				if(!down.innerHTML){
			      down.innerHTML = 0;
				}

				//计算
				var good = parseInt(up.innerHTML,10);
				var bad = parseInt(down.innerHTML,10);

				if(type == 'good'){
					good +=  1;
				}else{
					bad += 1 ;
				}

				var total = good + bad;

				var goodper = Math.round((good/total)*100);
				var badper = Math.round((bad/total)*100);

				document.getElementById('upbar').style.width = goodper+'%';
				document.getElementById('downbar').style.width = badper+'%';

				up.innerHTML = good;
				down.innerHTML  = bad;

			}
		}
	});
}
// 系统统计
var countimg=document.createElement('img');
function hits(sid,type){
	if (!get_cookie(type+'_'+sid))
	{
	     var gettime = new Date().getTime();
         var url = _PHP_URL+'/softcount.php?action='+type+'&sid='+sid+'&gettime='+gettime;
         countimg.src=url;
	}
}
function logad(id){
       gettime=new Date().getTime();
       url=_PHP_URL+'/countjs.php?id='+id+'&gettime='+gettime;
       countimg.src=url;  
}
function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) {
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1)
                end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

function post2bbs(softid){
    if ( true ){
        copy($("#soft2bbspost").text());
        //window.clipboardData.setData('text', d);
    }else{
        window.open(_PHP_URL+"/post2bbs.php?id="+softid);
    }
}
function post2bbsII (softid) {
    if (window.clipboardData){
        copy($("#soft2bbspost").text());
        //window.clipboardData.setData('text', d);
    }else{
        window.open(_PHP_URL+"/post2bbs.php?id="+softid);
    }
}
function copy(pStr,showMsg)
{
    //IE            
  if(window.clipboardData)
  {
    window.clipboardData.clearData();
    window.clipboardData.setData("Text", pStr);
  }
  //Opera浏览器
  else if(navigator.userAgent.indexOf("Opera") != -1)
  {
      window.location = txt;
  }
  //FireFox
  else if (window.netscape)
  {
      try
      {
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      }
      catch (e)
      {
          alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试");
          return false;
      }
      var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
      if (!clip)
          return;
      var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
      if (!trans)
          return;
      trans.addDataFlavor('text/unicode');
      var str = new Object();
      var len = new Object();
      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
      var copytext = pStr;
      str.data = copytext;
      trans.setTransferData("text/unicode",str,copytext.length*2);
      var clipid = Components.interfaces.nsIClipboard;
      if (!clip)
      return false;
      clip.setData(trans,null,clipid.kGlobalClipboard);
  }
  var showMsg = showMsg ? showMsg:"内容已复制到剪切板！";
  alert(showMsg);
}
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){ 
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width; 
ImgD.height=image.height;
}

ImgD.alt="点击小图查看大图片!";
}
else{
if(image.height>iheight){ 
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height; 
}else{
ImgD.width=image.width; 
ImgD.height=image.height;
}
ImgD.alt="点击小图查看大图片!";
}
}
}

// flashget union
function convertFgURL(url,id){
    try{
        FlashgetDown(FlashgetEncode_js(url,id),id);
    }catch(e){
        //alert(e.message);
        location.href = url;
    }

}
function Flashget_SetHref_js(url,uid){
    obj.href = FlashgetEncode_js(url,uid) ;
}

function FlashgetEncode_js(t_url,uid) {
    var prefix = "Flashget://";
    var FlashgetURL =  prefix + encode64(strUnicode2Ansi("[FLASHGET]" +t_url + "[FLASHGET]"))+"&"+uid;
    return FlashgetURL;
}
function FlashgetDown(str,uid){
    str = str+"&1248503250";
    AddLink(str,"www.kuaiche.com",window.location.href,uid);
}

function AddLink(durl,text,qurl,uid){
        var JetCarCatch = null;       
    if (navigator.appName == "Netscape")
    {    
        window.open (durl, "newwindow", "");
    }
    else
    {

        try{
            JetCarCatch=new ActiveXObject("FG2CatchUrl.Netscape");
        }catch(e){
            try{
                JetCarCatch = new ActiveXObject("BHO.IFlashGetNetscape");
            }catch(e){
                try{
                    JetCarCatch=new ActiveXObject("JetCar.Netscape");
    			}catch(e){}
			}
		}
	
		if(JetCarCatch!=null){
			try{
				JetCarCatch.AddUrl(durl,text,qurl);
			}catch(e){
				JetCarCatch.AddUrlEx(durl,text,qurl,"","0");	
			}
		}else{
			kuaicheMsg(uid);
		}
	}
}


function Flashget_in_array(uid) {
var u =  new Array(20230,13399,99999);
  for (var i = 0; i <u.length; i++) {
     thisEntry = u[i].toString();
     if (thisEntry == uid) {
	     return true;
     }
  }
  return false;
}


function kuaicheMsg(uid){	
alert("\u672c\u94fe\u63a5\u4e3a\u5feb\u8f66\u9ad8\u901f\u4e0b\u8f7d\u94fe\u63a5\uff0c\u9700\u5b89\u88c5\u65b0\u7248\u5feb\u8f66\uff08\u0046\u006c\u0061\u0073\u0068\u0067\u0065\u0074\uff09\u4ee5\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6\n\u0020\u0020\u0020\u0020\u0020\u70b9\u51fb\u786e\u5b9a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\uff0c\u5373\u53ef\u63d0\u5347\u591a\u500d\u4e0b\u8f7d\u901f\u5ea6\uff0c\u4eab\u53d7\u6781\u901f\u4e0b\u8f7d");
		
		if(uid==7863)
                	window.open("http://www.xiazaiba.com/html/211.html");
					//window.open("http://dl.game.kuaiche.com/flashget/index_union.html?fid="+uid,"","");
		else if(Flashget_in_array(uid))
			//location.href="http://down5.flashget.com/unmini/fgmun_"+uid+"_3.exe";	
			//location.href="http://down6.flashget.com/un/flashget_"+uid+"_1.exe";
			window.open("http://www.xiazaiba.com/html/211.html");
		else
			window.open("http://www.xiazaiba.com/html/211.html");
			//location.href="http://down6.flashget.com/unxp/flashget_"+uid+"_1.exe";
}

Cookie = {};
Cookie.Set = function(name, value, hours){
  var expire = "";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

Cookie.Get = function(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){ 
    offset = document.cookie.indexOf(search);
    if (offset != -1){ 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function search_sort( keyword, type ){
    window.location=_PHP_URL+"search.php?keyword="+keyword+"&order=" + type;
}