// JScript 文件

///全选反选
function SelectAll(selectid){
    var elm = document.all(selectid);
    for(i=0;i<elm.length;i++)
    {
        elm[i].checked = !(elm[i].checked);
    }
}

///翻转图片
function MM_preloadImages() {
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
    for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

///显示帮助提示
function showHelp(id)
{ 
  var obj=document.getElementById(id);
  obj.style.display="";
  obj.style.left=event.clientX;
  obj.style.top=event.clientY;
}
function hidenHelp(id)
{
  var obj=document.getElementById(id);
  obj.style.display="none";
}

///图片自适应大小
function ResizeImage(obj, MaxW, MaxH)
{  
    var imageObject;
    if (obj != null) imageObject = obj;
    
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0) {
        imageObject.width=dW;
		imageObject.height=dH;
	}
}

///原图
function OriginImage(obj)
{
   var newImage=new Image();
   newImage.src=obj.src;
   var str="<img src='"+newImage.src+"'/>";
   var winname = window.open('IDPhoto', "_blank", '');
   winname.document.open('text/html', 'replace');
   winname.opener = null // 防止代码对论谈页面修改
   winname.document.write(str);
   winname.document.close();
}

//写Cookies setCookie(name,value,"s20")
function setCookie(name,value,time)
{
    var strsec = getsec(time);
    var exp = new Date();
    exp.setTime(exp.getTime() + strsec*1);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getsec(str)
{
    var str1=str.substring(1,str.length)*1; 
    var str2=str.substring(0,1); 
    if (str2=="s"){
    return str1*1000;
    }else if (str2=="h"){
    return str1*60*60*1000;
    }else if (str2=="d"){
    return str1*24*60*60*1000;
}
///读Cookies
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg)) return unescape(arr[2]);
    else return null;
}
///删除cookies
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}