//#########################################################################
//#                                 JS                                    #
//#            程启明  Www.Badboy45.Cn ChengQiming8@msn.com               #
//#########################################################################

//滚轮控制图片大小
function AutoImg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
        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;
            }
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针
　　　　　ImgD.onclick = function() { window.open(this.src);} //点击打开大图片
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE
　　　　　　ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开";
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放
　　　　　 {
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100;
　　　　　　　　　　zoom += event.wheelDelta / 12;
　　　　　　　　　　if (zoom> 0)　this.style.zoom = zoom + "%";
　　　　　　　　　　return false;
　　　　　 }
　　　  } else { //如果不是IE
　　　　　　　     ImgD.title = "点击图片可在新窗口打开";
　　　　　　   }
    }
}


//控制图片在某个范围内
function SizeImg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
        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;
                }
        }
        else{
                if(image.height>iheight){
                       ImgD.height=iheight;
                       ImgD.width=(image.width*iheight)/image.height;
                }else{
                        ImgD.width=image.width;
                        ImgD.height=image.height;
                     }
            }
    }
}

//auto IFRAME
//style="height:expression(1); aho:expression(autoResize())"  id=
function autoResize()
{ try { document.all["test"].style.height=test.document.body.scrollHeight } catch(e){} }


//弹出窗口 根据图片大小改变WIDTH HEIGHT
//<img id="Badboy45.cn"> 
//OpenByImg(弹出窗口名称,，要弹出的图片地址，距上，距左)
function OpenByImg(WindowName,ImgUrl,Top,Left)
{
	var $=document.getElementById("Badboy45.cn"); 
	$.src=ImgUrl; 
	$.style.display="none";
	window.open(WindowName+"?ImgUrl="+ImgUrl,"","width="+$.width+",height="+$.height+",top="+Top+",left="+Left);
}



// HTML 获取传值  HtmlGet("id")
function HtmlGet(name){
	var str=window.location.search;
	if (str.indexOf(name)!=-1){
		var pos_start=str.indexOf(name)+name.length+1;
		var pos_end=str.indexOf("&",pos_start);
		if (pos_end==-1)
		{
			return str.substring(pos_start);
		}
		else
		{
			return str.substring(pos_start,pos_end)
		}
		}
	else{
		return "没有值";
	}
}

////双击鼠标滚动屏幕的代码
//var currentpos,timer;
//function initialize()
//{timer=setInterval ("scrollwindow ()",30);}
//function sc()
//{clearInterval(timer);}
//function scrollwindow()
//{currentpos=document.body.scrollTop;
//window.scroll(0,++currentpos);
//if (currentpos !=document.body.scrollTop)
//sc();}
//document.onmousedown=sc
//document.ondblclick=initialize

//全选
function CheckAll(form){
    for (var i=0;i<form.elements.length;i++){  
      var e = form.elements[i];
             e.checked = 1;
        }
} 

//全不选
function Checkzero(form){
    for (var i=0;i<form.elements.length;i++){  
      var e = form.elements[i];
             e.checked = 0;
        }
} 

function CheckBoxAll(o,btname){
	if(o==" 全  选 "){
		CheckAll(form);	
		document.getElementById(btname).value=" 全不选 ";
	}else{
		Checkzero(form);
		document.getElementById(btname).value=" 全  选 ";
	}		
}

var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function callServer() {
  var u_name = document.getElementById("UserName").value;
  if ((u_name == null) || (u_name == "")) return;
  var url = "UserExits.asp?Key=" + escape(u_name);
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePage;
  xmlHttp.send(null);  
}

function updatePage() {
  if (xmlHttp.readyState < 4) {
	test1.innerHTML="loading...";
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	if(response=="true")
	{
	test1.innerHTML="可以使用该帐号";
	}
	if(response=="false")
	{
	test1.innerHTML="<font color=red>该帐号已被使用</font>";
	}
  }
}
