var searchVal = "输入产品关键字";
function onReturn()
{
	history.back();
}

function onClose()
{
	window.close();
}

function searchTbxLoad(val)
{
	document.searchForm.searchTbx.value=searchVal;
	document.searchForm.searchTbx.select();
}

function onInput(obj)
{
	if(obj.value==searchVal)
	{
		obj.value="";
	}
	else if(obj.value=="")
	{
		obj.value=searchVal;
		obj.select();
	}
}

function onProductSearch(obj)
{
	if(document.searchForm.searchTbx.value==searchVal || document.searchForm.searchTbx.value=="")
	{
		alert("请输入您要搜索的产品关键字");
		return false;
	}
	document.searchForm.submit();
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function login()
{
t=document.forms[0];
if(""==t.userName.value)
{
	alert("用户名不能为空,请输入用户名");
	return;
}
if(""==t.password.value)
{
	alert("密码不能为空,请输入密码");
	return;
}
t.submit();
}


function checkDate(sDate)
{ 
var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31];
var iaDate = new Array(3);
var year, month, day;

//if (arguments.length != 1) 
//	return false;

iaDate = sDate.toString().split("-");

if (iaDate.length != 3)
{
	 alert("错误的日期格式！请确认形如:y-m-d");
	 return false;
}

if (iaDate[1].length > 2 || iaDate[2].length > 2)
{
	alert("错误!月份或天数的位数都不大于2");	
	return false;
}

year = parseFloat(iaDate[0]);
month = parseFloat(iaDate[1]);
day = parseFloat(iaDate[2]);

if (year < 1900 || year > 2100) 
{
	alert("错误!年份无效");	
	return false;
}
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) 
	iaMonthDays[1]=29;
if (month < 1 || month > 12) 
	return false;
if (day < 1 || day > iaMonthDays[month - 1]) 
{
	alert("错误!月份或天数");	
	return false;
}

return true;
}
	


function checkstring(name,data,allowednull)
{
var datastr = data;
var lefttrim = datastr.search(/\S/gi);
if (lefttrim == -1) {
    if (allowednull) {
      return 1;
    } else {
      alert("请输入" + name + "！");
      return -2;
    }
  }

    if (datastr.search(/[<>]/gi) != -1) {
    alert("" + name + "中包含非法字符<>");
    return -1;
  }
  return 0;
}

function checkFormString(name,ctrl,allowednull)
{
var datastr = ctrl.value;
var lefttrim = datastr.search(/\S/gi);
if (lefttrim == -1) {
    if (allowednull) {
      return true;
    } else {
      alert("请输入" + name + "！");
          ctrl.focus();
      return false;
    }
  }

    if (datastr.search(/[<>]/gi) != -1) {
    alert("" + name + "中包含非法字符<>");
        ctrl.focus();
    return false;
  }
  return true;
}

function checkemail(name, data, allowednull)
{
  var datastr = data;
  var lefttrim = datastr.search(/\S/gi);
  if (lefttrim == -1) {
    if (allowednull) {
      return 1;
    } else {
      alert("请输入一个正确的E-mail地址！");
      return -1;
    }
  }

  var myRegExp = /[a-z0-9](([a-z0-9]|[_\-\.][a-z0-9])*)@([a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)((\.[a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)*)/gi;
  var answerind = datastr.search(myRegExp);
  var answerarr = datastr.match(myRegExp);

  if (answerind == 0 && answerarr[0].length == datastr.length)
  {
    return 0;
  }
  alert("请输入一个正确的E-mail地址！");
  return -1;
}

function checkFormEmail(name, ctrl, allowednull)
{
  var datastr = ctrl.value;
  var lefttrim = datastr.search(/\S/gi);
  if (lefttrim == -1) {
    if (allowednull) {
      return true;
    } else {
          ctrl.focus();
      alert("请输入一个正确的E-mail地址！");
      return false;
    }
  }

  var myRegExp = /[a-z0-9](([a-z0-9]|[_\-\.][a-z0-9])*)@([a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)((\.[a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)*)/gi;
  var answerind = datastr.search(myRegExp);
  var answerarr = datastr.match(myRegExp);

  if (answerind == 0 && answerarr[0].length == datastr.length)
  {
    return true;
  }
  ctrl.focus();
  alert("请输入一个正确的E-mail地址！");
  return false;
}

function parseNum(theNum){
  if (theNum.substring(0,1)==0)
    theNum=theNum.substring(1)
  return theNum
}

function parseYMD(theYear,theMonth,theDay) {
  theYear=parseNum(theYear)
  theMonth=parseNum(theMonth)
  theDay=parseNum(theDay)
  if ((theYear < 1900) || (theYear > 3000)){
    return 1
  }

  if (theMonth < 1 || theMonth > 12){
    return 2
  }

  if ((theMonth==1 || theMonth==3 || theMonth==5 || theMonth==7 || theMonth==8 || theMonth==10 || theMonth==12) &&
      (theDay <1 || theDay > 31)
     ){
    return 3
  }

  if ((theMonth==4 || theMonth==6 || theMonth==9 || theMonth==11) &&
      (theDay <1 || theDay > 30)
     ){
    return 3
  }

  if (theYear%400==0 || (theYear%4==0 && theYear%100!=0)){  //闰年
    if (theMonth==2 && (theDay <1 || theDay > 29) )
      return 3
  }
  else  //平年
    if (theMonth==2 && (theDay <1 || theDay > 28) )
      return 3
  return 0
}

function isInvalidDate(theDate,separator){
  default_style=1
  if (theDate.length>10 || theDate.length<8)
    return true
  idx1=theDate.indexOf(separator)
  if (idx1==-1)
    return true
  idx2=theDate.indexOf(separator,idx1+1)
  if (idx2==-1)
    return true
  if (isInvalidDate.arguments.length>2)
          default_style=isInvalidDate.arguments[2]
  if (default_style<1 || default_style>9){
          alert("传入参数有误！请检查。")
        return true
  }

  if (default_style==1){
  theYear=theDate.substring(0,idx1)
  theMonth=theDate.substring(idx1+1,idx2)
  theDay=theDate.substring(idx2+1)
  }
  if (default_style==2){
  theMonth=theDate.substring(0,idx1)
  theDay=theDate.substring(idx1+1,idx2)
  theYear=theDate.substring(idx2+1)
  }
  if (theDay.length>2)
    return true
  if (parseYMD(theYear,theMonth,theDay)>0)
    return true
  else
    return false
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setSelectionOption(the_selection, option_list)
{
  var arr_dir, str_dir;
  the_selection.length=0;
  for(var i=0; i<option_list.length; i++)
  {
            str_dir=new String(option_list[i]);
        arr_dir=str_dir.split("===");
        the_selection.options[i] = new Option();
                the_selection.options[i].value = arr_dir[0];
                the_selection.options[i].text = arr_dir[1];
  }
}

function selectOptionInSelect(the_selection, value)
{
    for (var i=0; i<the_selection.length; i++)
    {
    if (the_selection.options[i].value == value)         the_selection.options[i].selected = true;
    }
}

function openWindow(u,n,w,h)
{
var windowLeft = (window.screen.availWidth - w)/2;
var windowTop = (window.screen.availHeight - h)/2;
args = "left="+windowLeft+",top="+windowTop+",width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=1";
window.open(u,n,args);
}

function openProductWin(u)
{
	var w= 815;
	var h=500;
	newWindow = window.open(u,"product_detail","toolbar,resizable,scrollbars,dependent,width=500,height=420,left=150,top=80");
	newWindow.focus();
}

function openInfoWin(u)
{
	var w= 815;
	var h=600;
	var n="信息详细";
	var windowLeft = (window.screen.availWidth - w)/2;
	var windowTop = (window.screen.availHeight - h)/2;
	args = "left="+windowLeft+",top="+windowTop+",width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=0";
	window.open(u,n,args);
}

function openStaticWindow(u,n,w,h)
{
var windowLeft = (window.screen.availWidth - w)/2;
var windowTop = (window.screen.availHeight - h)/2;
args = "left="+windowLeft+",top="+windowTop+",width="+w+",height="+h+",resizable=no,scrollbars=no,status=0";
window.open(u,n,args);
}