﻿// JavaScript Document
function killerrors() {
    return true;
    }
window.onerror = killerrors;

function $(o){return document.getElementById(o);}
function Top_execJs(file,complet_function)
{
		var html_head = top.window.document.getElementsByTagName('head')[0];
		var newElement = top.window.document.createElement("script");
		newElement.src = file;
		html_head.appendChild(newElement);
		newElement.onload=function(){window.eval(complet_function);}
		newElement.onreadystatechange = function(){
		if(this.readyState == "complete" || this.readyState == "loaded"){
			window.eval(complet_function);
			}
		 }
}
// 打开我的工具箱
function OpenMyTool()
{
	if(typeof(openDiv)!="function")
	Top_execJs("/js/pop.js","OpenDiv2()");
	else
	OpenDiv2();
	
}
function OpenDiv2()
{
	openDiv('小工具箱','/mytool.html',680,550,'');
}


// 发表评论
function SendPL(id)
{
	if(typeof(openDiv)!="function")
	Top_execJs("/js/pop.js","SendPL("+ id +")");
	else
	{
		openDiv('发表评论','/pl_send.html?id=' + id,680,410,'');
	}
}

// 查看评论
function SeePL(id,num)
{
	if(num==null){
	try{
	num = $("num4").innerText;
	}
	catch(e){}
	}
	if(num==0){
		if(confirm("暂无相关评论，是否发表评论"))
		{
			SendPL(id);
			return;
		}
		else
		{
			return;
		}
	}
	if(typeof(openDiv)!="function")
	Top_execJs("/js/pop.js","SeePL("+ id +")");
	else
	{
		openDiv('查看评论','/pl_list.html?id=' + id,680,550,'');
	}
}
// 发送邮件
function SendEmail(id)
{
	if(typeof(openDiv)!="function")
	Top_execJs("/js/pop.js","SendEmail("+ id +")");
	else
	{
		openDiv('把小工具发送邮件给我的好友','/SendFirend.html?id=' + id,530,350,'void(0)');
	}
}

// 加入收藏
function AddCell(id)
{
	if(typeof(openDiv)!="function")
	{
		
	Top_execJs("/js/pop.js","AddCell("+ id +")");
	
	}
	else
	{
		openDiv('加入收藏','/AddCell.html?id=' + id,400,200,'');
	}
}


function downFile(id)
{
  code = $("vcode").value;

  if(code=="")
  {
		alert("对不起，请输入上面的下载识别码!");
		return;
  }
  if(code.indexOf("g001").toString().toLowerCase()==-1)
  {
	  alert("注意：识别码g001是字母g加上数字001!");
	  return;
  }
  var newele = document.createElement("form");
  newele.action = "/downFile/index.html?id="+ id +"&code=" + code + "&R=" + Math.random();
  newele.target="_blank";
  newele.id = "submitForm";
  newele.method = "post";
  
 html_head = top.window.document.getElementsByTagName('head')[0];
 html_head.appendChild(newele);
 $("submitForm").submit();
 html_head.removeChild(newele);
}

function M_OrderBy(a,b,c)
{
	if(a!="")
	location = "/list_"+ b +"_"+ encodeURI(c) +"_"+ a +"_1/";
}
function M_OrderBy2(a,b,c,d)
{
	if(a!="")
	location = "/txtlist_"+ b +"_"+ encodeURI(c) +"_"+ d +"_"+ a +"_1/";
}


function SearchKey()
{
	a = $("m_classid").value;
	b = $("m_key").value;
	b  = b=="请输入关键字!"?"":b;

		if(a>=100)
		{
			a = a-100;
			if(a==900)a="";
		 	url = "/txtlist_"+ a +"_"+ encodeURI(b) +"___1/".toString();
			
		}
		else
			url = "/list_"+ a +"_"+ encodeURI(b) +"_100_1/".toString();
			
		window.location = url;

}

function LoginWin(txt)
{
$("MyTool_Box").innerHTML = txt;	
}

function LoginLost()
{
  $("MyTool_Box").innerHTML = "<b>登录注册工具箱</b>";
}



function subSomething()
{
  Top_execJs("/getCookie.aspx");

}

function KeyPreeDown(e,id)
{
  code = $("vcode").value;

  if(code.length>3)
  {
	Top_execJs("/ico2.bmp?r=" + Math.random());
  }
	
}

function loadImg(picpath,w,h)
{
	picpath = picpath.replace(/\$/gi,".");
	picpath = picpath.replace(/\#/gi,"/");
	picpath = picpath.replace(/\"/gi,"");
	picpath = picpath.replace("@","");
	picpath = picpath.replace("g001.net","duote.com");
	if(w==0||h==0)
	document.write("<img src='"+ picpath +"'/>");	
	else
	document.write("<img src='"+ picpath +"' width="+ w +" height="+ h +" />");	
}

// 加载下载链接
function GETDOWN_LISTS(id)
{
	//alert(id);
	Top_execJs("/GetDowonList.aspx?id=" + id);
}
