function killErrors() {
	return true;
}
window.onerror = killErrors;

//选择搜索方式
function CheckSearch(theForm){
   var types = theForm.types.selectedIndex;
   if(types == 0){
      alert("请选择搜索方式!");
      theForm.types.focus();
      return  (false);
   }
   if(trim(theForm.searchkey.value)== ""){
      alert("请输入您要查询的内容!");
      theForm.searchkey.focus();
      return  (false);
   }
}

function changepic(objects,picname){
   return objects.src=picname;
}

//图片等比缩放
function PicFixSize(widths,heights,photosrc,position){
   var breakpoint = 50;
   var i = 0;
   var photowidth = 0;
   var photoheight = 0;
   var photo = new Image();

   if (position=="")
   {
      position = "left"
   }

   while(photowidth == 0 || photoheight == 0){
      photo.src = photosrc;
      photowidth = photo.width;
      photoheight = photo.height;
	  i++;
      if (i == breakpoint){
         break;
      } 
   }

   if(photowidth > widths || photoheight > heights){
      if(photowidth > widths && photoheight > heights){
         height = heights;
         width = (photowidth * height) / photoheight;
         if(width > widths){
            var tmpwidth = width;
            width = widths;
            height = (height * width) / tmpwidth;
         }
      }
      if(photowidth > widths && photoheight <= heights){
         width = widths;
         height = (photoheight * width) / photowidth; 
      }
      if(photowidth <= widths && photoheight > heights){
         height =heights;
         width = (photowidth * height) / photoheight;
      }
   }
   else{
      width = photowidth;
      height = photoheight;  
   }

   if (width < 10 || height < 10){
      width = widths;
	  height = heights;
   }

   //return('<a href="#" onclick="NewImg(\'' + photosrc +'\')"><img src=' + photosrc + ' width=' + width + ' height=' + height +' border=0 align=' + position + '></a>')
   return('<img src=' + photosrc + ' width=' + width + ' height=' + height +' border=0 align=' + position + '>')
}



//图片等比缩放
function DrawImage(ImgD,w,h){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
  if(image.width/image.height>= w/h){ 
   if(image.width>w){
    ImgD.width=w; 
    ImgD.height=(image.height*h)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
  else{ 
   if(image.height>h){
    ImgD.height=h; 
    ImgD.width=(image.width*h)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
}
}




function NewImg(imgurl) {
   newwin=window.open('about:blank','','top=10');
   newwin.document.write('<body leftmargin=0 topmargin=0><img src='+imgurl+' onload="self.resizeTo(this.offsetWidth+10, this.offsetHeight+30);">');
}

function OpenWindow(htmurl,widths,heights,scroll)
{
   if (scroll = "")
   {
       scroll = "no"
   }
   var paramet = 'toolbar=no,resizable=no,scrollbars=' + scroll + ',width='+ widths + ',height=' + heights;
   newWindow = window.open(htmurl,"newWin",paramet);
   newWindow.focus();
}

//管理登陆
function CheckSearch(theForm){
   if(theForm.searchkey.value== ""){
      alert("请输入您要查询的内容!");
      theForm.searchkey.focus();
      return  (false);
   }
}

function CheckLogonForm(theForm){
   var AdminName = theForm.AdminName.value;
   if(AdminName == ""){
      alert("请输入管理员账号!");
      theForm.AdminName.focus();
      return  (false);
   }
   var PassWord = theForm.PassWord.value;
   if(PassWord ==""){
      alert("请输入管理员密码!");
      theForm.PassWord.focus();
      return  (false);
   }
	//theForm.action="/manage/login.asp"
	//theForm.submit
}

function onlynumber(){
if (!((event.keyCode>44 && event.keyCode<58)))
   event.keyCode=0;
}

function CheckJoinForm(theForm){
if (theForm.RegType.selectedIndex==0){
   alert("请选择您要注册的企业会员类型!");
   theForm.RegType.focus();
   return (false);
   }
if (theForm.CorpName.value==""){
   alert("请输入企业名称!");
   theForm.CorpName.focus();
   return (false);
   }
if (theForm.UserName.value==""){
   alert("请输入管理帐户!");
   theForm.UserName.focus();
   return (false);
   }
if (theForm.UserPwd.value==""){
   alert("请输入管理密码!");
   theForm.UserPwd.focus();
   return (false);
   }
if (theForm.UserPwd.value != theForm.ConfirmUserPwd.value ){
   alert("管理密码与确认密码不一致,请重新输入!");
   theForm.ConfirmUserPwd.value = "";
   theForm.ConfirmUserPwd.focus();
   return (false);
   }
if (theForm.UserEmail.value==""){
   alert("请输入邮箱地址!");
   theForm.UserEmail.focus();
   return (false);
   }
if (theForm.CorpInfo.value==""){
   alert("请输入企业简介!");
   theForm.CorpInfo.focus();
   return (false);
   }
if (theForm.CallingType.selectedIndex==0){
   alert("请选择企业类型!");
   theForm.CallingType.focus();
   return (false);
   }
if (theForm.CorpType.selectedIndex==0){
   alert("请选择企业性质!");
   theForm.CorpType.focus();
   return (false);
   }
if (theForm.CorpAddress.value==""){
   alert("请输入企业地址!");
   theForm.CorpAddress.focus();
   return (false);
   }
if (theForm.CorpTel.value==""){
   alert("请输入企业电话!");
   theForm.CorpTel.focus();
   return (false);
   }
if ( confirm("您确定要提交信息吗？")){
   return (true);
   }
else{
   return (false);
   }
}

function initializeSort(data,data2){
   var formstr=""; 
   var tmpArry = new Array();
   if (data2=="") data2 = data;
   for(i = 1; i < SrotArry.length; i++){
      tmpArry = SrotArry[i].split(",");
      if(data == "0"){
         if(tmpArry[0].length == 3){
           if(data2==tmpArry[0])
               formstr = formstr + "<option value=" + tmpArry[0] + " selected>"+ tmpArry[1] + "</option>"
            else
               formstr = formstr + "<option value=" + tmpArry[0] + ">"+ tmpArry[1] + "</option>"
         }
      }
      else{
         if(data2.substring(0,data.length) == tmpArry[0].substring(0,data.length) && tmpArry[0].length == data.length+3){
            if(data2==tmpArry[0])
               formstr = formstr + "<option value=" + tmpArry[0] + " selected>"+ tmpArry[1] + "</option>"
            else
               formstr = formstr + "<option value=" + tmpArry[0] + ">"+ tmpArry[1] + "</option>"
         }
      }
   }
   if(formstr=="") {
      formstr =  "<option value=''>暂无类别</option>";
   }
   return formstr
}

function changeSort(obj,data){
  obj = eval("document.all." + obj)
  var tmpArry = new Array();
  var intFlag = 0
  if(data != ""){
     obj.innerHTML= ""
     obj.options[0] = new Option("全部区域", "");
      for(i = 1; i < SrotArry.length; i++){
         tmpArry = SrotArry[i].split(",");
         if(data == tmpArry[0].substring(0,data.length) && tmpArry[0].length == data.length+3){
            obj.options[obj.length] = new Option(tmpArry[1], tmpArry[0]);
            intFlag = intFlag + 1
         }
      }
      if(intFlag==0) {
         obj.options[0] = new Option("全部区域", "");
      }
   }
}

function changeSort3(obj){
  obj = eval("document.all." + obj)
  obj.innerHTML= ""
  obj.options[0] = new Option("暂无类别", "");
}


function changeTxt(theInputForm){
	if(theInputForm.value=="请输入关键字!"){
		theInputForm.value="";
	}
}


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; 
} 