var IMGDIR = '/style/images/';
var attackevasive = '0';
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
function $(id) {
	return document.getElementById(id);
}
Array.prototype.push = function(value) {
	this[this.length] = value;
	return this.length;
}
function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}
function in_array(needle, haystack) {
	if(typeof needle == 'string' || typeof needle == 'number') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}

function Do_help()
{
    window.open("../help/index.htm");
}
function Do_refresh()
{
	 window.location.reload();
}
 function Do_open(URL,title,op_width,op_height)
{ 
	addr="width="+op_width+",height="+op_height+",scrollbars=yes,left="+(window.screen.width-op_width)/2+",top="+(window.screen.height-op_height)/2+'"';
	window.open(URL,title,addr); 
}

function wOpen(URL,width,height,title,additional)
{ 
	var top,addr;
	if(width==undefined) width = window.screen.width;
	top = (window.screen.height-height)/2;
	if(height==undefined)
	{
		height = window.screen.height-65;
		top = 0;
	}
	if(title==undefined) title = '';
	addr = "width="+width+",height="+height+",left="+(window.screen.width-width)/2+",top="+top;
	addr += ",scrollbars=yes";
	if(additional!=undefined) addr += ","+additional;
	window.open(URL,title,addr); 
}

function xmlhttp()
{
	var A=null;
	try
	{
		A=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			A=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			if (typeof XMLHttpRequest != "undefined" );
			{
				A=new XMLHttpRequest();
			}
		}
	}
	return A;
}
var xmlHttp,ajaxMsg,ajaxE;
function ajaxCheck(delUrl,oinput,smsg){
	if(oinput.value=="") return;
	var old,oldname;
	oldname = oinput.name+'_old';
	ajaxMsg = $(smsg);
	ajaxMsg.innerHTML = "";
	if($(oldname)==undefined){
		xmlHttp = xmlhttp();
		ajaxE = oinput;
		xmlHttp.onreadystatechange = ajaxDeal;
		xmlHttp.open("GET",delUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlHttp.send(null);
	}else if($(oldname).value!=oinput.value){
		xmlHttp = xmlhttp();
		ajaxE = oinput;
		xmlHttp.onreadystatechange = ajaxDeal;
		xmlHttp.open("GET",delUrl,true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		xmlHttp.send(null);
	}
}
function ajaxDeal(){
	if(xmlHttp.readyState==4){
		if(xmlHttp.status==200){
			if(xmlHttp.responseText!=""){
				ajaxMsg.className = "warn";
				ajaxMsg.innerHTML = xmlHttp.responseText;
				ajaxE.value="";
				ajaxE.focus();
			}else{
				ajaxMsg.className = "";
				ajaxMsg.innerHTML = "";
			}
		}
	}else{
		ajaxMsg.className = "ajax";
		ajaxMsg.innerHTML = "检测中...";
	}
}
function checkdate(s){
	var re;
	re = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
	if(!s.value.match(re)){
		s.value="";
	}
}
function subDays(date1,date2){
	var arStart,arEnd,msStart,msEnd,days;
  arStart = date1.split("-");   
  arEnd   = date2.split("-");   
  msStart = new Date(arStart[0],arStart[1]-1,arStart[2],0,0,0,0);   
  msEnd   = new Date(arEnd[0],arEnd[1]-1,arEnd[2],0,0,0,0);   
  days = (msEnd.getTime()-msStart.getTime())/(1000*24*3600); 
  return days;   
}
function inputNum(s){
	s.value = s.value.replace(/[^\d]/g,'');
}
function inputMoney(s){
	s.value = s.value.replace(/[^\d.]/g,'');
}
function inputSN(s){
	s.value = s.value.replace(/[^\w]/g,'');
}
function inputNbr(s){
	s.value = s.value.replace(/[^\dxX]/g,'');
}
function inputPhone(s){
	s.value = s.value.replace(/[^\d-]/g,'');
}
function checkMobile(s)
{
	if(s.value!=""){
		var mobile=s.value;
		var reg0=/^13\d{9}$/; 
		var reg1=/^15\d{9}$/; 
		var reg2=/^07\d{9}$/; 
		var reg3=/^18\d{9}$/; 
		var my=false;
		if (reg0.test(mobile))my=true;
		if (reg1.test(mobile))my=true;
		if (reg2.test(mobile))my=true;
		if (reg3.test(mobile))my=true;
		if (!my){
			s.value='';
			alert('请输入正确的手机号码。');
			s.focus();
		}
	}
}

function addCookie(objName,objValue,objHours){//添加cookie
	var str = objName + "=" + escape(objValue);
	if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
		var date = new Date();
		var ms = objHours*3600*1000;
		date.setTime(date.getTime() + ms);
		str += "; expires=" + date.toGMTString();
	}
	str += "; path=/";
	document.cookie = str;
}

function getCookie(objName){//获取指定名称的cookie的值
	var arrStr = document.cookie.split("; ");
	for(var i = 0;i < arrStr.length;i ++){
		var temp = arrStr[i].split("=");
		if(temp[0] == objName) return unescape(temp[1]);
	} 
}

function delCookie(name){//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
	var date = new Date();
	date.setTime(date.getTime() - 10000);
	document.cookie = name + "=a; expires=" + date.toGMTString();
}
function myPrint()
{
	$('butbar').style.display='none';
	window.print();
}
function selAll(checkname)
{
	var em;
	em = document.getElementsByName(checkname);
	for(i=0;i<em.length;i++)
	{
		if(!em[i].checked)
		{
			em[i].checked=true;
		}
	}
}
function noSelAll(checkname)
{
	var em;
	em = document.getElementsByName(checkname);
	for(i=0;i<em.length;i++)
	{
		if(em[i].checked)
		{
			em[i].checked=false;
		}
	}
}
function getAllItem(checkname)
{
	var allSel=new Array;
	var e = document.getElementsByName(checkname);
	var m = 0;
	var ret = '';
	for(var i=0;i<e.length;i++)
	{
		if(e[i].checked)
		{
				allSel[m] = e[i].value;
				m++;
		}
	}
	ret = allSel.join(',');	
	return ret;
}
function getRadio(name)
{
	var e,i;
	e = document.getElementsByName(name);
	for(i=0;i<e.length;i++)
	{
		if(e[i].checked)
		{
			return e[i].value;	
		}
	}
}
function arrSearch(Arr,v)
{
	for(var i=0;i<Arr.length;i++)
	{
		if(Arr[i][1]==v) return true;
	}
	return false;
}
function fckFocus(name)
{
	var oEditor = FCKeditorAPI.GetInstance(name);   
	oEditor.Focus();   
}
function checkEmpty(a,b){
	var e;
	for(var i=0;i<a.length;i++)
	{
		e = $(a[i]);
		if(e.value=="")
		{
			alert(b[i]);
			e.focus();
			return false;
		}
	}
}

function ResumeError() { return true; } window.onerror = ResumeError;
