﻿function addFavorite()
{
    var title = document.title;
    var url = window.location.href;
    var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL'; 
        if (document.all){ 
          window.external.addFavorite(url,title); 
          }else if (window.sidebar){ 
         window.sidebar.addPanel(title, url, ""); 
       }else { 
               alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹'); 
       }
}
function getTime()
{
    var date = new Date();
    return date.getTime(); 
}
function cancelEnter(e,func)
{
    var msie = (document.all) ? true : false;
    var keycode;
    if(!msie)
    {
        keycode=e.which;
    }
    else
    {    
        keycode=event.keyCode;
    }
    if (keycode==13) 
    {
        func();
        return false;
    }
    return true;
}

function formatFloat(src, pos) 
{
	return formatFloat(src,pos,false)
}  

function formatFloat(src, pos, fill) 
{
    var fillPos=pos;
    var rtn=Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
    if(fill)
    {
	    rtn=rtn.toString();
	    if(rtn.indexOf(".")!=-1)
	    {	        
	        fillPos=parseInt(pos)-rtn.length+rtn.indexOf(".")+1;
	    }
	    else
	    {
	        rtn+=".";	        
	    }
        for (i=1;i<=fillPos;i++)
        {
            rtn+="0";
        }
    }
    return rtn;
}

function thickbox_remove() {
  $("#TB_imageOff").unbind("click");
 $("#TB_closeWindowButton").unbind("click");
 $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
 $("#TB_load").remove();
 if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
  $("body","html").css({height: "auto", width: "auto"});
  $("html").css("overflow","");
 }
 document.onkeydown = "";
 document.onkeyup = "";
}
