
//document.onkeydown=look;
function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
}
function sendtab(){
	try{
		var obj = window.event.srcElement ; // submit
		if(obj.type != 'button' && obj.type != 'submit' && obj.type != 'textarea'){
			if(event.keyCode==13){
				var ob=window.event.srcElement;
				if(ob.tagName.toLowerCase()!='textarea'){
					event.keyCode=9;
				}
			}
		}
	}catch(e){
	}
}

function switchSysBar(){
	if (switchPoint.innerText==3){
		switchPoint.innerText=4
		document.all("mnuList").style.display="none"
		top.content.cols="16,*"
	}
	else{
		switchPoint.innerText=3
		document.all("mnuList").style.display=""				
		top.content.cols="166,*"		
	}
}

function tid(url){
	parent.main.location = url;
	//open("brandsearch.aspx?id=" + id);
}
function changebgcolor(a){
	a.style.backgroundColor = "#FFFF40";
	return;
}
function resumebgcolor(a){
	a.style.backgroundColor = "#81BE2C";
	return;
}

function openScript(url){
	var width=900;
	var height=600;
	var userlogin= window.open(url,"userlogin",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
	if (userlogin != null){
		userlogin.focus() ;
	}
	userlogin.moveTo((screen.width-width)/2,(screen.height-height)/2)

}
function openScript2(url, width, height){
	if (width==null){
		width = screen.width-10 ;
	}
	if (height==null){
		height = screen.height-80 ;
	}
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
	Win.moveTo((screen.width-width)/2,(screen.height-height-80)/2) ;
	if (Win != null){
		Win.focus() ;
	}

}

function openScript3(url, width, height){
	if (width==null){
		width = screen.width ;
	}
	if (height==null){
		height = screen.height ;
	}
	window.open(url,"openScript",'width=' + width + ',height=' + height + 'left=2,top=2,resizable=1,scrollbars=yes,menubar=no,status=yes' );
	//Win.moveTo((screen.width-width)/2,(screen.height-height)/2)
}

function openScript4(url, width, height){
	if (width==null){
		width = screen.width ;
	}
	if (height==null){
		height = screen.height ;
	}
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
	Win.moveTo((screen.width-width)/2,(screen.height-height)/2) ;
	if (Win != null){
		Win.focus() ;
	}
}

function openfeedback(url,w,h){
	var width=600;
	var height=350;
	if (w!=null){
		width=w;
	}
	if (h!=null){
		height=h;
	}
	var feedback= window.open(url,"feedback",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
	if (feedback != null){
		feedback.focus() 
	    feedback.moveTo((screen.width-width)/2,(screen.height-height)/2);
	}
}

function opendowntech(url,w,h){
	var width=600;
	var height=350;
	if (w!=null){
		width=w;
	}
	if (h!=null){
		height=h;
	}
	var downtech= window.open(url,"downtech",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
	if (downtech != null) {
		downtech.focus() ;
	    downtech.moveTo((screen.width-width)/2,(screen.height-height)/2);
	}
}

function change(field,list) {
	var temp = list.value ; // list.options[list.selectedIndex].value;
	if (temp==''){
		//return;
	}
	field.value = temp ;
}

function change2(field,list) { // list.value;
	var temp = list.options[list.selectedIndex].text;
	if (temp==''){
		//return;
	}
	field.value = temp ;
}

function search_dis(ob){  
 if (ob.style.display=="none"){
    ob.style.display="";
	window.location.href='#down';
 }else
    {ob.style.display="none";}
}

function SelectAllMessage(){
	// document.all.tags("TABLE")
	//for (var i=0;i<document.form2.elements.length;i++)
	var flag = document.form2.allbox.checked ;
	for (var i=0;i<document.all.tags("input").length;i++){
		var e = document.form2.elements[i];
		if (document.form2.elements[i].type.toLowerCase()=='checkbox'){
			e.checked = flag ;
		}
	}
}

function Gomanage(id){
	var strid = id;
	var theURL="default2.aspx?systemid="+strid;
	var win=window.open(theURL,"win");
	if (win != null){
		win.focus()
	}
}

var sbarbg = "" ;
function sbar(st,bg) { 
	var bg2 = "#f6f6f6" ;
	if (bg != null)	{
		bg2 = bg ;
	}
	sbarbg = st.style.backgroundColor ;
	st.style.backgroundColor = bg2; 
}

function cbar(st) { 
	st.style.backgroundColor = sbarbg; 
}

var sbar3bg = "" ;
function sbar3(st,bg) { 
	var bg2 = "#BBD1E8" ;
	if (bg != null)	{
		bg2 = bg ;
	}
	sbar3bg = st.style.backgroundColor ;
	st.style.backgroundColor = bg2; 
}

function cbar3(st) { 
	st.style.backgroundColor = sbar3bg; 
}

var sbar2bg = "" ;
function sbar2(st,bg) { 
	//alert(st.parentElement.parentElement.tagName)
	var bg2 = "#FEF7F0" ;
	if (bg != null)
	{
		bg2 = bg ;
	}
	obj = st.parentElement.parentElement ;
	sbar2bg = obj.style.backgroundColor ;
	obj.style.backgroundColor = bg2 ; 
}

function cbar2(st) { 
	obj = st.parentElement.parentElement ;
	obj.style.backgroundColor = sbar2bg ; 
}

function fPopUpDlg(endtarget,ctl,WINname,WINwidth,WINheight){
	
	showx =  WINwidth + 200  ; // + deltaX;
	showy = WINheight ; // + deltaY;

	newWINwidth = WINwidth + 4 + 18;
	var features =
		'dialogWidth:'  + newWINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';
	
	retval = window.showModalDialog(endtarget, WINname , features );
	if( retval != null ){
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
}
//

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_validateForm() { //v5.0 // ybh modify
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { 
	  // nm=val.name; 
	  nm=args[i+1];  // tips
	  if ((val=val.value)!="") { // 值不为空
		  //alert(test);
		  if (test.indexOf('isEmail')!=-1) { 
		    // p=val.indexOf('@');
			//if (p<1 || p==(val.length-1)) errors+='- '+nm+' 必须填写正确的E-Mail.\n';
			if (!chkemail(val)){
				errors+='- '+nm+' 必须填写正确的E-Mail.\n';
				break;
			}
		  } else if (test.indexOf('isDate')!=-1) {
			 if (!checkIsValidDate(val)){ // ybh
				 errors+='- '+nm+' 必须正确的日期.\n';
				 break;
			 }
		  } else if (test.indexOf('isLength')!=-1) {
			  len = val.length ;
			  p=test.indexOf(':');
			  min=test.substring(9,p);
			  max=test.substring(p+1);
			  if (len<min || max<len){
				  errors+='- '+nm+' 中输入的字符请在 '+min+' ～ '+max+' 个字符之内.\n';
				  break;
			  }
		  } else if (test!='R') { // 数字
		    num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' 必须填写数字.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num){
				  errors+='- '+nm+' 填写的数字必须在范围 '+min+' ～ '+max+' 之内.\n';
				  break;
			  }
			} 
		  }
	  } else{ // 值为空
		  if (test.charAt(0) == 'R'){
			  errors += '- '+nm+' 必须填写.\n'; 
			  break;
		  }
	  }
	}
  } 
  //
  if (errors) alert('错误提示：\n你提交的信息的有误，请校对:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function checkIsValidDate(str)
{
    //如果为空，则通过校验
    if(str == "")
        return true;
    var pattern = /^((\d{4})|(\d{2}))-(\d{1,2})-(\d{1,2})$/g;
    if(!pattern.test(str))
        return false;
    var arrDate = str.split("-");
    if(parseInt(arrDate[0],10) < 100)
        arrDate[0] = 2000 + parseInt(arrDate[0],10) + "";
    var date =  new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]);
    if(date.getYear() == arrDate[0]
       && date.getMonth() == (parseInt(arrDate[1],10) -1)+""
       && date.getDate() == arrDate[2])
        return true;
    else
        return false;
}
//函数名：chkemail
//功能介绍：检查是否为Email Address
//参数说明：要检查的字符串
//返回值：0：不是  1：是 

function chkemail(a)
{ var i=a.length;
 var temp = a.indexOf('@');
 var tempd = a.indexOf('.');
 if (temp > 1) {
  if ((i-temp) > 3){
    if ((i-tempd)>0){
     return true;
    }
  }
 }
 return false;
}
//
function chkDateTime(str)
{
	 var r = str.match(/^(\d{4})-(\d{2})-(\d{2})$/);  
	 if(r==null)return false; 
	 var d= new Date(r[1], r[2]-1, r[3]); 
	 //r[2] = r[2].replace(/^0/,"");
	 return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[2]&&d.getDate()==r[3]);
}
function chkint(str)
{
	var r= str.match(/^\s*[-\+]?\d+\s*$/) ;
	if(r==null){
		return false;
	}else{
		return true;
	}
}
function chkfloat(str)
{
	var r= str.match(/^\s*[-\+]?(\d+)?(.)?(\d+)?\s*$/) ;
	if(r==null){
		return false;
	}else{
		return true;
	}
}

function Err(msg)
{
	alert(msg);
}
function SelectChk(Tval) //這個Function是給asp.net的checkBox用的   
{   
	 var icount = 0 ;
	 var ctrl = document.getElementById(Tval);   
	 var col = ctrl.all   
	 for (i = 0; i < col.length; i++)   
	 {   
		 if (col[i].tagName.toUpperCase() == 'INPUT')   
		 {   
			 if (col[i].checked){
				icount++ ;
			 }
		 }   
	 }  
	 return icount;   
}   
////////////////////////////////////////
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0 

function dyniframesize(iframename,h) {
  var pTar = null;
  if (h==null)
  {
	  h = 0;
  }
  if (document.getElementById){
    pTar = document.getElementById(iframename);
  }
  else{
    eval('pTar = ' + iframename + ';');
  }
  
  if (pTar && !window.opera){ // parent
    //begin resizing iframe
    //pTar.style.display="block"
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
      //ns6 syntax
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
    }else if (pTar.document && pTar.document.body.scrollHeight ){ //  
      //ie5+ syntax
      pTar.height = pTar.document.body.scrollHeight-h;
    }
  }
}
function setStyleDefault(tipid)
{
	//Err("setStyleDefault ok")
	try {
		document.getElementById(tipid).className = "css_tr_gray1";
	} catch(e) {}
}

function setStyleFocus(tipid)
{
	//Err("setStyleFocus ok")
	try {
		document.getElementById(tipid).className = "focus";
	} catch(e) {}
}
function setTdblur(tipid)
{
	try {
		var obj =_(tipid) ;
		var thisTd = obj.parentNode;
		thisTd.className = "rtTip";
	} catch(e) {}
}

function setTdFocus(tipid)
{
	try {
		var obj =_(tipid) ;
		var thisTd = obj.parentNode;
		thisTd.className = "tiptd";
	} catch(e) {}
}

function setval(obj,iMsg) {
	if (typeof obj == "string") {
		obj = _(obj);
	}
	obj.innerHTML = iMsg
}
function _(id) {
	return document.getElementById(id);
}
String.prototype.trim = function(){
	return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
function btcontroll(flag) {
	_("btsubmit").disabled = flag;
	_("btreset").disabled = flag;
}

function btndisplay(btnname,flag) {
	_(btnname).disabled = flag;
}
//显示提示
function showTip(obj,isShow){
	var thisTr = obj.parentNode.parentNode
	//Err(thisTr.tagName);
	var thisTd = obj.parentNode.parentNode.getElementsByTagName("td")[2]
	//Err(thisTd.tagName);
	var thisTip = thisTd.getElementsByTagName("div")[0]
	//Err(thisTip.tagName);
	if(isShow==1){
		thisTd.className="tiptd"
		thisTip.style.display="block"
	}else{
		//if(thisTr.className!="atn"){thisTip.style.display="none"}
	}
}
//显示错误
function ShowAtn(obj,iMsg,status){
	if (typeof obj == "string") {
		obj = _(obj);
	}
	var thisTd = obj.parentNode
	var thisTr = obj.parentNode.parentNode
	
	if(status==1){
		thisTd.className="tiptdc"
		obj.style.display="block"
		obj.innerHTML = iMsg
		thisTr.className="atn"
	}else{
		thisTd.className="rtTip"
		thisTr.className=" "
		obj.innerHTML = iMsg
		//obj.style.display="none"
	}
}
function createXmlHttp() 
{
	var xmlhttp = null;
	// branch for native XMLHttpRequest object
    if(window.XMLHttpRequest)
	{
    	try
		{
			xmlhttp = new XMLHttpRequest();
	    }
		catch(e)
		{
			xmlhttp = null;
	    }
	}
	// branch for IE/Windows ActiveX version
	else if(window.ActiveXObject)
	{
       	try
		{
        		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	     }
		catch(e)
		{
        	try
			{
          			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	       	}
			catch(e)
			{
          			xmlhttp = null;
	       	}
		}
    }
	return xmlhttp;
}

