function addBookmark(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 setHomePage(url){
    if (window.sidebar)
    {
        try { 
           netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
        } 
        catch (e) 
        {  
           alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
        } 
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',url);

    }
}
function checkForm(fm)
{  
if(fm.keyword.value==''){
        alert("请填写要搜索的关键词!");
		fm.keyword.focus();
		return false;
}

if(fm.type.value=="baidu"){
 window.open("http://www.baidu.com/s?tn=ylmf&word="+fm.keyword.value);
 return false;
}else if(fm.type.value=="keygen"){
 window.open("http://www.cracks.hk/?page=search&q="+fm.keyword.value);
 return false;
}
}
//图片自动按比例缩放!
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
var image=new Image();
//var iwidth = 900; //定义允许图片宽度
//var iheight = 1500; //定义允许图片高度
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="点击小图查看大图片!";
}
}
}
function copyurl(){
  meintext=document.getElementById("softname").innerText+'  高速下载\n'+document.location.href;
  copyToClipboard(meintext,'下载页面地址已经复制到剪贴板!可以发送给QQ/MSN上的好友了!');
}
function post2bbs(){
	var obj = document.getElementById('softDetailBbsPost');
	var d=obj.innerText; 
	copyToClipboard(d,'软件详细资料已被复制到粘贴板!')
}
function copyToClipboard(meintext,msg) {
	if (window.clipboardData) {
		window.clipboardData.setData("Text", meintext);
	}
	else if (window.netscape) { 
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		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=meintext;
		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);
	}	alert(msg);
	return false;
}

function logad(id){
     ylmftime=new Date().getTime();
	 url='http://'+document.location.host+'/countjs.php?id='+id+'&ylmftime='+ylmftime;
	 startRequest(url,handleStateChange);
}
function handleStateChange(){
  if(xmlHttp.readyState == 4){
	  //alert(xmlHttp.responseText);
  }	  
}

function createXMLHttpRequest(){
  if(window.ActiveXObject){
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }else if(window.XMLHttpRequest) {
      xmlHttp = new XMLHttpRequest();
  }
} 
function startRequest(url,returnfun) {
   createXMLHttpRequest(); 
   xmlHttp.onreadystatechange =returnfun;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null);    

}
/*
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale'); overflow:hidden;\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);
*/