﻿//弹出窗口
function openWindow(url, name, width, height) {
window.open( url, name, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,scrollbars=yes,width='+width+',height='+height+',top=30,left=230');
}

//打开新窗口
function popnew(url,title,width,height){
    var w = 1024;
    var h = 768;

    if (document.all || document.layers){
        w = screen.availWidth;
        h = screen.availHeight;
    }

    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);

    window.open(url,title,"width="+width+",height="+height+",top="+topPos+",left="+leftPos+",scrollbars=no,resizable=no,status=no")
}

//脚本容错
function stopError() {
return true;
          }
window.onerror = stopError;



function MM_findObj(n, d) { //v4.0
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 && document.getElementById) x=document.getElementById(n); return x;}
function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }}

function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}

function strlen(str) {
	return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}

function display(id) {
	var obj = $(id);
	if(obj.style.visibility) {
		obj.style.visibility = obj.style.visibility == 'visible' ? 'hidden' : 'visible';
	} else {
		obj.style.display = obj.style.display == '' ? 'none' : '';
	}
}

function showbg(){
eval("select_list.style.display='';");
}
function showoutbg(){
eval("select_list.style.display='none';");
}

function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px'
	}


function goTop(acceleration, time) {
acceleration = acceleration || 0.3;
time = time || 10;
var x1=0;var y1=0;var x2=0;var y2=0;var x3=0;var y3=0;if(document.documentElement){x1=document.documentElement.scrollLeft||0;y1=document.documentElement.scrollTop||0}if(document.body){x2=document.body.scrollLeft||0;y2=document.body.scrollTop||0}var x3=window.scrollX||0;var y3=window.scrollY||0;var x=Math.max(x1,Math.max(x2,x3));var y=Math.max(y1,Math.max(y2,y3));var speed=1+acceleration;window.scrollTo(Math.floor(x/speed),Math.floor(y/speed));if(x>0||y>0){var invokeFunction="goTop("+acceleration+", "+time+")";window.setTimeout(invokeFunction,time)}}


//TAB切换
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}

function isEmail(str){
  var isEmail = (((((str.indexOf("@") != -1) && (str.indexOf(".") != -1)) && (((str.lastIndexOf("@")-str.lastIndexOf("."))<-1))) && str.indexOf("@")!=0) && (str.length-str.lastIndexOf(".")>1));
  if (isEmail){
	return (true);
  }else{
	return (false);
  }
}


function MailCheck(){
if(mailform.Email.value == "")
		{
			alert("请输入电子邮件地址！");
			mailform.Email.focus();
			return false;
		}
if (isEmail(mailform.Email.value) == false)
		{
			alert("请输入有效的电子邮件地址！");
			mailform.Email.focus();
			return false;
		}
return true;
}

 function reHeight(o){
  	 if (o.inFocus) {o.style.height = "80px";}
 }

 function focusMe(o){
 	 o.inFocus=true;
 	 o.style.border="1px solid #999";
 	 o.style.backgroundColor="transparent";
 	 o.style.cursor="text";
 	 o.style.overflowY="scroll";
	 reHeight(o);
 }
 
 function blurMe(o){
 	 o.inFocus=false;
	 o.style.border="1px #999 solid"
 	 o.style.padding="1px";
 	 o.style.backgroundColor="transparent";
 	 o.style.cursor="pointer";
 	 o.style.overflowY="hidden";
 	 o.style.height="30px";
 }
 function overMe(o){
 	 if (!o.inFocus) {
 	 	 o.style.border="1px solid #666";
 	 	 o.style.padding="1px";
 	 	 o.style.backgroundColor="transparent";
 	 }
 }
 
 function outMe(o){
 	 if (!o.inFocus) {
	 	 o.style.border="1px #999 solid"
 	 	 o.style.padding="1px";
 	 	 o.style.backgroundColor="transparent";
  	 }
 }

function jsQueryString(queryStringName){
var returnValue=""; 
var URLString=new String(document.location); 
var serachLocation=-1; 
var queryStringLength=queryStringName.length; 
do { serachLocation=URLString.indexOf(queryStringName+"\="); 
if (serachLocation!=-1) {
if ((URLString.charAt(serachLocation-1)=='?') || (URLString.charAt(serachLocation-1)=='&')) {
    URLString=URLString.substr(serachLocation);
    break; 
} URLString=URLString.substr(serachLocation+queryStringLength+1); 
}  
} while (serachLocation!=-1) if (serachLocation!=-1) { 
var seperatorLocation=URLString.indexOf("&"); 
if (seperatorLocation==-1) { 
   returnValue=URLString.substr(queryStringLength+1); 
} else { 
   returnValue=URLString.substring(queryStringLength+1,seperatorLocation); 
}  
  } 
return returnValue;
}

function addEvent(elm, evType, fn, useCapture)
   {
  if (elm.addEventListener)
  {
   elm.addEventListener(evType, fn, useCapture);
   return true;
  }
  else if (elm.attachEvent)
  {
   var r = elm.attachEvent('on' + evType, fn);
   return r;
  }
  else
  {
   elm['on' + evType] = fn;
  }
   }
