//只能输入数字的输入框
function jhshnumbertext(){
	if (!(((window.event.keyCode>=48)&&(window.event.keyCode<=57)) || (window.event.keyCode==13)||(window.event.keyCode==46)||(window.event.keyCode==45))){
		window.event.keyCode=0;
	}
}

function lbsong()
{
window.open("about:blank","lbsong","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,top=10,left=10,width=358,height=437");
}
function CheckOthers(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
			if (e.checked)
			{
				e.checked = false;
			}
			else
			{
				e.checked = true;
			}
	}
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
			e.checked = true;
	}
}

function trim(inputString) {

  if (typeof inputString != "string") { return inputString; }
  var retValue = inputString;
  var ch = retValue.substring(0, 1);
  while (ch == " ") { 
  //检查字符串开始部分的空格
	  retValue = retValue.substring(1, retValue.length);
	  ch = retValue.substring(0, 1);
  }
  ch = retValue.substring(retValue.length-1, retValue.length);
  while (ch == " ") {
	 //检查字符串结束部分的空格
	 retValue = retValue.substring(0, retValue.length-1);
	 ch = retValue.substring(retValue.length-1, retValue.length);
  }
  while (retValue.indexOf("  ") != -1) { 
 //将文字中间多个相连的空格变为一个空格
	 retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
  }
  return retValue;
} 
//replace
function newreplace(inputString,oldstr,newstr) {

  if (typeof inputString != "string" || typeof oldstr != "string" || typeof newstr != "string") { return inputString; }
  var retValue = inputString;
  var oldlen=oldstr.length;
  while (retValue.indexOf(oldstr)!=-1) {
	 //检查字符串结束部分的oldstr
	 retValue = retValue.substring(0, retValue.indexOf(oldstr))+newstr+retValue.substring(retValue.indexOf(oldstr)+oldlen, retValue.length);
  }
  return retValue;
} 
//x=542,y=500
function getCookie(cookieName) {
  var cookieString = document.cookie;
  var start = cookieString.indexOf(cookieName + '=');
  if (start == -1) // ???
    return 0;
  start += cookieName.length + 1;
  var end = cookieString.indexOf(';', start);
  if (end == -1) return unescape(cookieString.substring(start));
  return unescape(cookieString.substring(start, end));
}
function setCookie(name, value)
{
  document.cookie = name + "=" + escape(value);
}

function getoption(str){
var message=str;
var m=0
var n=document.all.imgcode.length
message=message.split(",");
for (i=0;i<=message.length-1;i++) {
if (message[i]!='0')
document.all.imgcode.options[i+n-m] = new Option(message[i],message[i]);
else
m+=1;
}
}
function pop_table(pageurl,x,y) {
var popurl=showModalDialog(pageurl,"index", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:auto; resizable:no;dialogWidth:"+x+"px; dialogHeight:"+y+"px");
if (popurl != null){document.all.url.value=popurl;return true;}
else  return false;
}

function pop(pageurl) {
var popurl=showModalDialog(pageurl,"index", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:no;dialogWidth:36em; dialogHeight:36em");
if (popurl != null){getoption(popurl);document.cookie = 'imgcode=' + escape(getCookie("imgcode")+","+popurl);}
else  return false;
}

function pop1(pageurl,str_name) {
var popurl=showModalDialog(pageurl,"index", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:no;dialogWidth:36em; dialogHeight:22em");
if (popurl != null){
	document.getElementById(str_name).value=popurl;
}
else  return false;
}

function DrawImage(ImgD,wid,hei){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= wid/hei){
     if(image.width>wid){  
     ImgD.width=wid;
     ImgD.height=(image.height*wid)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    else{
     if(image.height>hei){  
     ImgD.height=hei;
     ImgD.width=(image.width*hei)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    }
   }






 
