﻿// JScript File

function Delete(Id)
{
   if(confirm("真的要删除吗？"))
   {
      location.href = "?mode=del&Id="+Id;
   }
}
function Edit(Id)
{
    location.href = "?mode=edit&Id="+Id;
}

function CheckAll(form)  
{
      for (var i=0;i<form.elements.length;i++)   
      {
		    var e = form.elements[i];
		    if (e.name != 'chkall')      
		    e.checked = form.chkall.checked; 
      }
}

function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}

function IsMobile(_str){
    var pattern = /13|15[0-9]{9}/;
    return pattern.test(_str);
}

function isEmail (s)
{
        // Writen by david, we can delete the before code
        if (s.length > 100)
        {
                return false;
        }
         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return true;
         } else {
               //window.alert ("请输入有效合法的E-mail地址 ！")
               return false;
         }
}
//获取网址上的参数
function Request (name) {
        if (RegExp) {
                var url = (window.frameElement ? window.frameElement.src : window.location.href);
                var exp = new RegExp("[?|&]" + name + "=([^&|^#]+)");
                var match = exp.exec(url);
                if (match == null) {
                        return null;
                } else {
                        return unescape(match[1].replace(/\+/, " "));
                }
        }
}
//获取控件ID
function $(id)
{
    return document.getElementById("ctl00_ContentPlaceHolder1_"+id);
}
function $$(id){
return document.getElementById(id);
}
//显示层
function OpenDiv(Id)
{
    $$(Id).style.display = "block";
}
//隐藏层
function CloseDiv(Id)
{
    $$(Id).style.display = "none";
}

//按比例缩小图片
function DrawImage(ImgD,FitWidth,FitHeight){
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
         if(image.width/image.height>= FitWidth/FitHeight){
             if(image.width>FitWidth){
                 ImgD.width=FitWidth;
                 ImgD.height=(image.height*FitWidth)/image.width;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             }
         } else{
             if(image.height>FitHeight){
                 ImgD.height=FitHeight;
                 ImgD.width=(image.width*FitHeight)/image.height;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             } 
        }
     }
 }

function openWindow(url,w,h)
{
    window.open(url,"","status=no,scrollbars=no,top=20,left=110,width="+w+",height="+h+"");
} 

function ReferCheckImg(id)
{
    var obj = $(id);
    obj.src = "/inc/CheckCode.aspx?id=" + Math.random()
}
