// JavaScript Document
function isNumber(NUM) {
	var i, j, strTemp;
	strTemp = "0123456789";
	if (NUM.length == 0) {
		//alert("not number!");
		return false;
	}
	for (i = 0; i < NUM.length; i++) {
		j = strTemp.indexOf(NUM.charAt(i));
		if (j == -1) {
			//alert("not number!");
			return false;
		}
	}
	return true;
}
function SetSelectByValue(control,value) {
	var con=document.getElementById(control);
	if (!con) return;
	for (i=0;i<con.options.length;i++){
		if (con.options(i).value==value){
			con.selectedIndex=i;	
		}
	}
}
// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue){
	var now	 =new Date();
	var date = new Date(now.getYear()+1,1,1);
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
}
// Retrieve the value of the cookie with the specified name.
function GetCookie(sName){
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++){
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName.toLowerCase() == aCrumb[0].toLowerCase())
		return unescape(aCrumb[1]);
	}
	// a cookie with the requested name does not exist
	return null;
}
// Delete the cookie with the specified name.
function DelCookie(sName){
	document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
/////////////////////////////////////////////////////////////////
var http;
function createHttp() {
  try {
    http = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        http = false;
      }
    }
  }

  if (!http)
    alert("Error initializing XMLHttpRequest!");
}

function JsLoadFile(fp){
	createHttp();
	http.open("GET",fp,false);
	http.send(null);
	if (http.status==200){
		document.write(http.responseText);
	}else{
		document.write('Module load error.');	
	}
}

function LoadGuangGao(name){
	createHttp();
	http.open("GET","/Inc/AjaxGetGuangGao.asp?name=" + name,false);
	http.send(null);
	if (http.status==200){
		document.write(http.responseText);
	}else{
		document.write('广告加载失败');	
	}
}

function WinOpen(url,winWidth,winHeight){ 
	if (winWidth==null){winWidth=300;}
	if (winHeight==null){winHeight=200;}
	var  iWidth=winWidth; //模态窗口宽度
	var  iHeight=winHeight;//模态窗口高度
	var  iTop=(window.screen.height-iHeight)/2;
	var  iLeft=(window.screen.width-iWidth)/2;
	window.open(url,"","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft); 
} 

