﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}       

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
  
function closediv()
{
    document.getElementById('div_001').style.visibility="hidden";
}
 
 
 
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=image.width+"×"+image.height;
   } 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=image.width+"×"+image.height;
   }
  }
} 

function TVal(name)
{
    try
    {
        var _value = document.getElementById(name);
        return _value.value;
    }catch(err)
    {
        return "";
    }
}
    
function getSelectedText(name)
{
    var obj=document.getElementById(name);
    for(i=0;i<obj.length;i++){
       if(obj[i].selected==true){
        return obj[i].value;      //关键是通过option对象的innerText属性获取到选项文本
       }
    }
}
 function deletecookies()
{
    delAllCookie("_Cookies_user_name");
    delAllCookie("_Cookies_user_pwd");
    delAllCookie("Cookies_China_Csdf_UserName");
    delAllCookie("Cookies_China_Csdf_UserPwd");
    window.navigate("default.aspx");
}

function delAllCookie(name)
{
    var exp = new Date();
        exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function setCookie(name,value)      //  设置COOKIES
{
    //var Days = 30;
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + 120*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(name)   //  得到COOKIES
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg)) return unescape(arr[2]);
    else return "";
}

function Fun_ChangeCheckCode()
{
    try
    {
        document.getElementById('CodeImg').src='CreateCheckCode.aspx?tmp='+Math.random();
    }catch(err)
    {
        return "";
    }
    try
    {
        document.getElementById('CodeImgm').src=document.getElementById('CodeImg').src;
    }catch(err)
    {
        return "";
    }
}

function Fun_SouSuo(_id,_path)
{
    if(document.getElementById(_id).value == '')
    {
        alert('请输入搜索条件！');
        document.getElementById(_id).focus();
        return;
    }
    window.location = _path + '?_caption=' + document.getElementById(_id).value;
}

function GetRadioValue(RadioName){
    var obj;    
    obj=document.getElementsByName(RadioName);
    if(obj!=null){
        var i;
        for(i=0;i<obj.length;i++){
            if(obj[i].checked){
                return obj[i].value;            
            }
        }
    }
    return null;
}

