function error(form_obj,errmsg)
{
if(errfound)
return;
window.alert(errmsg);
form_obj.select();
form_obj.focus();
errfound=true;
}

function emailCheck()
{
var emailStr=document.form2.email.value;
if(emailStr!="")
{
var emailPat=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
 return false;
}
return true;
}
else
{
return true;
}
}

//单独处理选择表出错信息
function errselect(form_obj,errmsg)
{
if(errfound) return;
window.alert(errmsg);
form_obj.focus();
errfound=true;
}

//主检验程序
function Validate()
{
 errfound=false;
  if(document.form2.Product.value=="")
  error(document.form2.Product,"感兴趣的产品忘了填写！");
  else if(document.form2.department.value=="")
  error(document.form2.department,"您的单位名称忘了填写！");
  else if(document.form2.yourname.value=="")
  error(document.form2.yourname,"您的姓名忘了填写！"); 
  else if(document.form2.phone.value=="")
  error(document.form2.phone,"联系电话忘了填写！");
  //else if(document.form2.addr.value=="")
  //error(document.form2.addr,"您的联系地址忘了填写！"); 
  //else if(document.form2.email.value=="")
  //error(document.form2.email,"您的常用邮箱忘了填写！");
  else if(!emailCheck()) 
  {
  alert("Email地址有误");
  return false;
  }
  else if(document.form2.message.value=="")
  error(document.form2.message,"对产品的要求忘了填写！");  
  else
  {
      var inputs=document.getElementsByTagName("input");
      for(var i=0;i<inputs.length;i++)
      {
         if(inputs[i].type=="submit"||inputs[i].type=="reset")
            inputs[i].disabled="disabled";
      }
      fSaveP2VDo();
      return true; 
  }
  return !errfound
}
function $$() { var elements = new Array();for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; }
function _gelstn(a){return document.getElementsByTagName?document.getElementsByTagName(a):new Array();}
function fPopSaveWin(pos){
	var a = _gelstn('body')[0];
	var x = document.createElement("div");
	x.id = 'SaveWin';
    x.style.zIndex=90;
    x.style.position="absolute";
    x.style.left=0;
    x.style.top=0;
    x.style.right=0;
    x.style.margin=0;
    x.style.width="100%";
    if(document.documentElement.scrollHeight>document.documentElement.clientHeight){
    	//有滚动条
    	x.style.height = buttom.offsetTop+buttom.offsetHeight;
    }
    else{
    	x.style.height = document.documentElement.clientHeight;
    }
	a.appendChild(x);
	var c = document.createElement('div');
    c.style.position="absolute";
    c.style.filter="alpha(opacity=50)";
    c.style.backgroundColor="#000";
    c.style.width="100%";
    //alert(document.documentElement.clientHeight);
    c.style.height = x.style.height;
    //
	var b =document.createElement('div');
    b.style.textAlign="center";
    b.style.position="absolute";   
    b.style.width="95%";
    if(pos == "d"){
    	  b.style.top=order.offsetTop+order.offsetHeight;
    }
    else{
    	 b.style.top=(document.documentElement.clientHeight-200)/2;
    }    
    var html = '' +
		'<div style="width:320px; height:120px; background-color:#FFFFFF; padding:2px;">' +
			'<div id="SaveFirstStep" style=" height:100%; width:100%; background-color:#f9fcff;border:1px solid #bccce1;font-size:12px">' +
				'<div style=" width:100%; height:29px; background-color:#ebf3fd">' +
					'<div style="padding:8px 0 0 8px;float:left;font:bold 14px "宋体"">正在处理' +
					'</div>' +
				//	'<div style="cursor:pointer;float:right; margin:7px 4px 0 0;" onclick="fCloseSaveInfo();"><img src="style/1/images/close.gif">' +
				//	'</div>' +
				'</div>' +
				'<div style=" height:25px; padding:20px 0 0 30px; text-align:left" id="SaveTitleInfo"><img src="/images/loading.gif">&nbsp;&nbsp;正在发送邮件，请稍候...' +
				'</div>' +
				'<div style="width:86%; font-size:0;border-top:1px dotted #CCCCCC;>' +
				'</div>' +
				'<div style=" width:100%;">' +
						
			'</div>' +
		'</div>';

	x.appendChild(c);
	x.appendChild(b);
	b.innerHTML = html;
}

function fCloseSaveInfo(){
	_gelstn('body')[0].removeChild($$("SaveWin"));
}


function fSaveP2VDo(p){
		fPopSaveWin("d");
};
