/*
 公用js 函数
 */
   // 允许上传的图片扩展名
   var picExt="JPEG|JPG|BMP|GIF|TIF|PNG|ICO|";
   // 允许上传的文件扩展名
   var fileAllowExt="DOC|XLS|PDF|RAR|ZIP|VSD|JPEG|JPG|BMP|GIF|TIF|PNG|ICO|AVI|MIDI|MOV|WMA|RM|MP3|SWF|TXT|";
//全角转半角的
function toDBC(Str) {
 var DBCStr = "";    
 for(var i=0; i<Str.length; i++){
  var c = Str.charCodeAt(i);
  if(c == 12288) {
      DBCStr += String.fromCharCode(32);
   continue;
  }
  if (c > 65280 && c < 65375) {
   DBCStr += String.fromCharCode(c - 65248);
   continue;
  }
  DBCStr += String.fromCharCode(c);
 }
 return DBCStr;
}
/*
 返回字符串的字节数 一个汉字是2个字节   
 */
function getStrBytes(varStr) {
    var count=0; 
    for (var i = 0; i< varStr.length; i++) {     
     if (varStr.charCodeAt(i) > 127 || varStr.charCodeAt(i) == 94) { 
        count=count+2;   
        } 
     else { 
        count=count+1 
     }
    } 
    return count;
}  
  //计算天数差的函数，通用
function DateDiff(sDate1, sDate2){  //sDate1和sDate2是2002-12-18格式
    var aDate, oDate1, oDate2, iDays;
    aDate = sDate1.split("-");
    oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);  //转换为12-18-2002格式
    aDate = sDate2.split("-");
    oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
    iDays = (oDate1 - oDate2) / 1000 / 60 / 60 /24;  //把相差的毫秒数转换为天数
    return iDays;
}
/*
 电话号码验证
*/
function chkTEL(tel)
{
	var i,j,strTemp;
	strTemp="0123456789-()# ";
	for (i=0;i<tel.length;i++)
	{
		j=strTemp.indexOf(tel.charAt(i)); 
		if (j==-1)  return false;
	}
	return true;
}
/*
 Email验证
*/
 function chkemail(a)
{ 
return /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(a);
}
/*
 日期检查   idDate(str)
*/
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
//验证url合法性
function isUrl(url){
	var urlreg=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)((\w+)\.)+(\S)+$/;
	var res=url.match(urlreg);
	if(res==null){
		return false;
	}else{
		return true;
	}
}
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
 	var result=dtStr.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
    if(result==null) return false;


	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(pos2+1)
	var strYear=dtStr.substring(0,pos1)
	
	//var strMonth=dtStr.substring(0,pos1)
	//var strDay=dtStr.substring(pos1+1,pos2)
	//var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}
/*
  校验是否符合yyyy-mm-dd hhmm-hhmm格式并且前面的hhmm 比后面的小
  如果正确返回0  如果 yyyy-mm-dd错误返回1 第一个hhmm格式错误返回2  第二个hhmm格式错误返回3 大小错误返回4
  其他错误5
*/
function ckdt1(yhmhm){
	if(yhmhm==null||yhmhm==""||yhmhm.length!=20){
	   return 5;
	}
	if(yhmhm.substr(15,1)!='-'){
		return 5;
	}
	ymd=yhmhm.substr(0,10); 
	hm1=yhmhm.substr(11,4); 
    hm2=yhmhm.substr(16,4);
    if(!isDate(ymd)){
    	return 1;
    }
    if(!isDigit(hm1)){
    	return 2;
    }
	if(!isDigit(hm2)){
    	return 3;
    }
    if(parseInt(hm1,10)>=parseInt(hm2,10)){
    	return 4;
    }
    hh=hm1.substr(0,2);
    mm=hm1.substr(2,2);
    if(parseInt(hh,10)>=24 || parseInt(hh,10)<0||parseInt(mm,10)>59||parseInt(mm,10)<0){
    	return 2;
    }
    hh=hm2.substr(0,2);
    mm=hm2.substr(2,2);
    if(parseInt(hh,10)>=24 || parseInt(hh,10)<0||parseInt(mm,10)>59||parseInt(mm,10)<0){
    	return 3;
    }
	return 0;
}
/*
 del head and end space
*/
function strTrim(str){
 return str.replace(/(^\s*)|(\s*$)/g, "");
}
/*
  判断字符串是否纯数字
*/
function isDigit(s) {
  return (s.replace(/\d/g, "").length == 0);
}
function isAlpha(s) {
  return (s.replace(/\w/g, "").length == 0);
}
/*
数字、26个英文字母或者下划线组成外加()的字符串
*/
function isAlphaKH(s) {
  return (s.replace(/\w|\(|\)/g, "").length == 0);
}
/*
数字、26个英文字母或者下划线组成的字符串
*/
function isAlphaOrNum(s){
  return (s.replace(/^\w+$/g,"").length ==0);
}
/**
*指定是否符合指定格式的时间，没有指定格式兼容hh:mm hh:mm:ss hhmm hhmmss
*/
function isTime(strTime,f){
   if(f=="hh:mm"){
   	   fmtTime = /^(\d{2})\:(\d{2})$/;
   	   return  fmtTime.test(strTime) && RegExp.$1 < 24 && RegExp.$2 < 60;   	   
   }
   if(f=="hh:mm:ss"){
   	   fmtTime = /^(\d{2})\:(\d{2})\:(\d{2})$/;
   	   return  fmtTime.test(strTime) && RegExp.$1 < 24 && RegExp.$2 < 60 && RegExp.$3 < 60;   	   
   }
   if(f=="hhmm"){
   	   fmtTime = /^(\d{2})(\d{2})$/;
   	   return  fmtTime.test(strTime) && RegExp.$1 < 24 && RegExp.$2 < 60;   	   
   }
   if(f=="hhmmss"){
   	   fmtTime = /^(\d{2})(\d{2})(\d{2})$/;
   	   return  fmtTime.test(strTime) && RegExp.$1 < 24 && RegExp.$2 < 60 && RegExp.$3 < 60;   	
   }
}
/**
判断是否是正确的pnr
*/
function isPnrno(value){
    if(value.length!=5||!isAlphaOrNum(value.substr(0,1))||value.toUpperCase()!= value|| !isAlphaOrNum(value)||value.indexOf("_")>=0||isDigit(value)||
				value.toUpperCase().indexOf("O")>=0||value.toUpperCase().indexOf("I")>=0){
	 	return false;			
	}else{
		return true;
	}
}
/*
判断是否是票号
*/
function isTicketno(value){
	if(value.length!=10||!isDigit(value)){
		return false;
	}else{
		return true;
	}
}
/* 
返回数值
*/
function isNumber(s) {
  return (s.search(/^[+-]?[0-9.]*$/) >= 0);
}

function lenb(s) {
  return s.replace(/[^\x00-\xff]/g,"**").length;
}
/**
	短信长度提示
	dID:显示提示信息的位置；
	v:短信内容
	m:手机号码
*/
function smslen(dId,v,m){
	var len=64,s="";
	var dc=document.getElementById(dId);
	if(dc==null||v==""||v==null) return;
	nrlength=v.length;
	nrts = parseInt((nrlength / len + (nrlength % len > 0 ? 1 : 0)));
	if(nrts>1){
	   s="请注意每条最多能发送"+len+"个字。您目前输入的短信字数是"+nrlength+"个,将拆分成"+nrts+"条。";
	}else{
		s="请注意每条最多能发送"+len+"个字。您目前输入的短信字数是"+nrlength+"个。";
	}
	dc.innerHTML=s;
}
function smslenAlert(v){
	var len=64,s="";
	nrlength=v.length;
	nrts = parseInt((nrlength / len + (nrlength % len > 0 ? 1 : 0)));
	if(nrts>1){
	   s="请注意每条最多能发送"+len+"个字。您目前输入的短信字数是"+nrlength+"个,将拆分成"+nrts+"条。\n\n继续请按 确定 重新修改 请按 取消。";
	  if( window.confirm(s)==1) 
	   return true;
	  else
	   return false;
	}
	return true;
}
/**
	判断是否为移动号码 判断是否为手机号码 1是 0不是
*/
function isMobile(v_sjhd){
	if(v_sjhd==null||v_sjhd=="") return 0;
	if (v_sjhd.length==11){
   		v_sjhd='0'+v_sjhd.substr(0,3);
    }else{
   		v_sjhd=v_sjhd.substr(0,4);
	}
	if ((v_sjhd>='0134' && v_sjhd<='0139' && v_sjhd.substr(0,5)!='01349') || (v_sjhd>='0158' && v_sjhd<='0159')) {
		return 1;
	}
	return 0;
}
/*
是否全部是英文,/,空格,true表示是
*/
function isEnglish(s){
	return /^[A-Za-z|//|\s]+$/g.test(s);
}
/*
	是否全部是汉字
*/
function isChinese(s){
	return /[^u4E00-u9FA5]$/.test(s)
} 
function isBlank(s){
	if(s==null){
		return true;
	}
	return strTrim(s)=="";
}
/*
 是否包含汉字
*/
function isInChinese(s) {
  return (s.length != s.replace(/[^\x00-\xff]/g,"**").length);
}
/**
判断是否符合ft格式的时间日期
*/
function isDateTime(value,ft){
	   if(isBlank(ft)){ft="yyyy-mm-dd hh:mm";}
	   datevalue=value.substr(0,10);
	   if (!isDate(datevalue)) {
			return false;
	   }else{
			timevalue=value.substr(11);
			timeft=ft.substr(11);
			if(isBlank(timeft)){
				timeft="hh:mm";
			}
			if(isBlank(timevalue)||isBlank(timeft)||value.substr(10,1)!=" " || !isTime(timevalue,timeft)){
				return false;
			}
		}
		return true;
}
/*
	if class="inputred" then is must not empty
*/
function checkForm(fm) {
	var firstele;
	var form = document.getElementById(fm);
	var eles = new Array();
	var rtn = true;
	var formels = form.elements;
	for (var i = 0; i < formels.length; i++) {
		var element = formels[i];
		if (element.type == "text" || element.type == "textarea" || element.type == "select-one" || element.type == "password") {
		    if(element.offsetWidth !=0){
			eles[eles.length] = formels[i];
			}
		}
	}
	for (var i = 0; i < eles.length; i++) {
		var ele = eles[i];
		var value = ele.value;
		//上一级元素
		var po = ele.parentElement;
    	//清除前一次做的标记
		checkFormClear(po, ele);
    	//必须验证
		if(ele.className == "inputDate"){
			if(value.length != 0){
				result = value.replace(" ", "");
				if(result.length % 2 !=0 || result.substring(result.length-1, result.length) == ":"){
					checkFormChange(po, ele, 7, "");
					if (!firstele) {
						firstele = ele;
					}
				}
			}
		}
				
		if (ele.className == "inputred" || ele.request=="true") {
			if (strTrim(value)==""||value.length == 0) {
				checkFormChange(po, ele, 1, "");
				if (!firstele) {
					firstele = ele;
				}
			}
		}
		var maxlen = ele.getAttribute("maxlength");
		if (maxlen != "" && maxlen != null) {
			if (lenb(value) > maxlen) {
				checkFormChange(po, ele, 2, maxlen);
				if (!firstele) {
					firstele = ele;
				}
			}
		}
		var minlen = ele.getAttribute("minlength");
		if (minlen != "" && minlen != null) {
			if (lenb(value) < minlen) {
				checkFormChange(po, ele, 4, minlen);
				if (!firstele) {
					firstele = ele;
				}
			}
		}
		var greatethan = ele.getAttribute("greatethan");
		if (greatethan != "" && greatethan != null) {
				
			if (value!="" && parseFloat(value) < greatethan) {
				checkFormChange(po, ele, 5, greatethan);
				if (!firstele) {
					firstele = ele;
				}
			}
		}
		var lessthan = ele.getAttribute("lessthan");
		if (lessthan != "" && lessthan != null) {
		
			if (value!="" && parseFloat(value) > lessthan) {
				checkFormChange(po, ele, 6, lessthan);
				if (!firstele) {
					firstele = ele;
				}
			}
		}				
		//格式验证,只支持yyyy-mm-dd的日期格式
		var ctype = ele.getAttribute("ctype");
		if (ctype != "" && value != "") {
			switch (ctype) {
			  case "date":
				if (!isDate(value)) {
					checkFormChange(po, ele, 3, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u65e5\u671f\u683c\u5f0f\u4e3a yyyy-mm-dd !");
					if (!firstele) {
						firstele = ele;
					}
				}
				break;
			  case "datetime":
				  ft = ele.getAttribute("fdt");
				  if (!isDateTime(value,ft)) {
						checkFormChange(po, ele, 3, "请输入正确的时间日期格式"+ft);
						if (!firstele) {
							firstele = ele;
						}
					}
					break;
			  case "time":
			     ft = ele.getAttribute("fdt");
			     if(isBlank(ft)){ft="hh:mm";}
			     if (!isTime(value,ft)) {
			     	checkFormChange(po, ele, 3, "请输入有效的时间格式:"+ft);
					if (!firstele) {
						firstele = ele;
					}
			     }
			     break;
			  case "email":
				if (!chkemail(value)) {
					checkFormChange(po, ele, 3, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684Email\u5730\u5740\uff0c\u4ee5\u65b9\u4fbf\u548c\u60a8\u8054\u7cfb\uff01");
					if (!firstele) {
						firstele = ele;
					}
				}
				break;
			  case "digit":
				if (!isDigit(value)) {
					checkFormChange(po, ele, 3, "\u8bf7\u8f93\u51650\u52309\u4e4b\u95f4\u7684\u6570\u5b57\uff01");
					if (!firstele) {
						firstele = ele;
					}
				}
				break;
			  case "number":
				if (!isNumber(value)) {
					checkFormChange(po, ele, 3, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u6570\u5b57\uff01");
					if (!firstele) {
						firstele = ele;
					}
				}
				break;
			  case "telephone":
				if (!chkTEL(value)) {
					checkFormChange(po, ele, 3, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u8bdd\u53f7\u7801\uff01");
					if (!firstele) {
						firstele = ele;
					}
				}
				break;
			  case "corn":
				if (!isAlphaOrNum(value)) {
					checkFormChange(po, ele, 3, "请输入数字、26个英文字母或者下划线组成的字符串");
					if (!firstele) {
						firstele = ele;
					}
				}
			   break;
			  case "pnrno":
				if (!isPnrno(value)) {
					checkFormChange(po, ele, 3, "请输入正确的PNR号码");
					if (!firstele) {
						firstele = ele;
					}
				}
			   break;
			   case "ticketno":
				if (!isTicketno(value)) {
					checkFormChange(po, ele, 3, "请输入正确的票号号码");
					if (!firstele) {
						firstele = ele;
					}
				}
			   break;
			   case "url":
				if (!isUrl(value)) {
					checkFormChange(po, ele, 3, "请输入正确的URL，格式http://www.baidu.com");
					if (!firstele) {
						firstele = ele;
					}
				}
			   break;
			}
		}
	}
	if (firstele) {
	//重新定位
		var ddname;
		if (firstele.name == null || firstele.name == "") {
			ddname = firstele.id;
		} else {
			ddname = firstele.name;
		}
		if(!isBlank(ddname)){
			document.getElementById(ddname).focus();
			if (document.getElementById(ddname).type != "select-one") {
				document.getElementById(ddname).select();
			}
		}
		rtn = false;
	} else {
		rtn = true;
	}
	return rtn;
}
// BORDER-BOTTOM: #ff7300 1px solid;
var wrongstyle="PADDING-RIGHT: 3px;; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; MARGIN: 0px;  LINE-HEIGHT: 130%; PADDING-TOP: 3px; TEXT-ALIGN: left"
function checkFormChange(po, input, bz, str) {
	var span = "";
	if (bz == "1") {
		span = " \u6b64\u9879\u4e3a\u5fc5\u586b!";
	}
	if (bz == "2") {
		span = " \u60a8\u8f93\u5165\u7684\u5185\u5bb9\u4e0d\u80fd\u8d85\u8fc7\u89c4\u5b9a\u957f\u5ea6 " + str + " \u4e2a\u5b57\u8282\uff01";
	}
	if(bz=="4"){
		span="输入的字符数不能少于"+str+"个.";
	}
	if (bz == "3") {
		span = str;
	}
	if (bz=="5"){
		span="请输入大于等于"+str+" 的值.";
	}
	if (bz=="6"){
		span="请输入小于等于"+str+" 的值.;";
	}
	if (bz=="7"){
		span="请确认输入日期 "+str+" 的值是否正确.;";
	}	
	var ddname;//针对name为空的.
	if (input.name == null || input.name == "") {
		ddname = input.id;
	} else {
		ddname = input.name;
	}
	if (po != null) {
		var spanO = document.getElementById("textspan" + ddname);
	    
	    //已经存在 显示的span
		//try{
		if (spanO != null && spanO != "undefined") {
			spanO.innerHTML =  "<br><img src='/images/skin1/icon_noteawake_16x16.gif' /> " + span;
		} else {
			span = "  <span style='"+wrongstyle+"' id='textspan" + ddname + "'>" + "<br><img src='/images/skin1/icon_noteawake_16x16.gif' /> " + span + "</span> ";
			po.innerHTML = po.innerHTML + span;
		}
		po.style.backgroundColor = "fff5d8";	
		//}catch(e){}	
	}
}
function checkFormClear(po, input) {
	var ddname;
	if (input.name == null || input.name == "") {
		ddname = input.id;
	} else {
		ddname = input.name;
	}
	//try{
	var span = document.getElementById("textspan" + ddname);
	if (span != null && span != "undefined") {
		span.innerHTML = "";
	}
	if (po != null && po != "undefined") {
		po.style.backgroundColor = "";
	}
	//}catch(e){	}
}
/*
收藏夹 需要在页面定义一个隐含的元素<div id="favorite" style="display:none"></div>
*/
function favorite(lb,bt,surl){
	   // document.open();
        var favorite=document.getElementById("favorite");
        var html="";
        html="<form name='favorite' method='post' action='/favorite.shtml' target='_blank'>"+
		     "<input type='hidden' name='lb' value='"+lb+"'>"+
		     "<input type='hidden' name='bt' value='"+bt+"'>"+
		     "<input type='hidden' name='surl' value='"+surl+"'>"+
		     "</form>";
		favorite.innerHTML=html;
		//document.write(html);
		document.favorite.submit();
		//document.close();
}

 function winopen(url,w,h) {
    window.open(url,"","toolbar=no,width="+w+",height="+h+",top=200 left=300 directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no")
 }

 function vopen(url, name, w, h) {//	if (! OWinID || OWinID.closed)
    if(w==null||w==""){w=800;}
    if(h==null||h==""){h=500;}
    var top,left;
    var pws=getPageSize();
    top=(pws[5]-h)/2 -20;
    left=(pws[4]-w)/2;
   // getPageSizenew Array(pageWidth,pageHeight,windowWidth,windowHeight,screen_width,screen_height)
	OWinID = window.open(url, name, "height=" + h + ",width=" + w + ",top="+top+",left="+left+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=yes");
	OWinID.focus();
}  

 function mopen(url, name, w, h) {//	if (! OWinID || OWinID.closed)
    if(w==null||w==""){w=800;}
    if(h==null||h==""){h=500;}
    var top,left;
    var pws=getPageSize();
    top=(pws[5]-h)/2 -20;
    left=(pws[4]-w)/2;
   // getPageSizenew Array(pageWidth,pageHeight,windowWidth,windowHeight,screen_width,screen_height)
	OWinID = window.open(url, name, "height=" + h + ",width=" + w + ",top="+top+",left="+left+",toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=no,status=yes");
	OWinID.focus();
} 

/*屏幕尺寸*/
 function getPageSize(){
	var xScroll, yScroll; 
	if (window.innerHeight && window.scrollMaxY) { 
		xScroll = document.body.scrollWidth; 
		yScroll = window.innerHeight + window.scrollMaxY; 
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac 
		xScroll = document.body.scrollWidth; 
		yScroll = document.body.scrollHeight; 
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari 
		xScroll = document.body.offsetWidth; 
		yScroll = document.body.offsetHeight; 
	} 
	var windowWidth, windowHeight; 
	if (self.innerHeight) { // all except Explorer 
		windowWidth = self.innerWidth; 
		windowHeight = self.innerHeight; 
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 
		windowWidth = document.documentElement.clientWidth; 
		windowHeight = document.documentElement.clientHeight; 
	} else if (document.body) { // other Explorers 
		windowWidth = document.body.clientWidth; 
		windowHeight = document.body.clientHeight; 
	} 
// for small pages with total height less then height of the viewport 
	if(yScroll < windowHeight){ 
		pageHeight = windowHeight; 
	} else { 
		pageHeight = yScroll; 
	} 
// for small pages with total width less then width of the viewport 
	if(xScroll < windowWidth){ 
		pageWidth = windowWidth; 
	} else { 
		pageWidth = xScroll; 
	}
	var screen_height = window.screen.availHeight; 
	var screen_width = window.screen.availWidth; 
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,screen_width,screen_height);
	return arrayPageSize; 
}
// --- 设置cookie
function setCookie(name,value,days) {
if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
//--- 获取cookie
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
/*清空使区域中的表单*/
	function cinput(areaqy){
	try{
	   var table
	   if(areaqy==undefined||areaqy==""||areaqy==null){
			table=event.srcElement;
			while(table!=null&&table.tagName.toLowerCase()!="table"){
				table=table.parentElement;
			}			
	   }else{
			table=$(areaqy);
		}
  	  if(table==undefined||table==""||table==null) return;
  	  
		var inputs=table.getElementsByTagName("input");
		for(var i=0;inputs!=null&&i<inputs.length;i++){
			if(inputs[i].type.toLowerCase()=="text"){
			  inputs[i].value="";
			}
			if(inputs[i].type.toLowerCase()=="radio"||inputs[i].type.toLowerCase()=="checkbox"){
			  inputs[i].checked=false;
			}
		}
		var selects=table.getElementsByTagName("select");
		for(var i=0;selects!=null&&i<selects.length;i++){
			selects[i].selectedIndex=0;
		}
		var textareas=table.getElementsByTagName("textarea");
		for(var i=0;textareas!=null&&i<textareas.length;i++){
			textareas[i].value="";
		}
		}catch(ex){}
	}
 /*取得扩展名*/  
 function getFileExt(fileName){
 	var fileExt=fileName.substr(fileName.lastIndexOf(".")+1).toUpperCase();
 	return fileExt;
 }
 /*判断是否为图片*/ 
 function isPicFile(fileName){
    	var fileExt=getFileExt(fileName)+"|";
    	if(fileExt!=""&&picExt.indexOf(fileExt)!=-1){
	       return true;
    	}
    	return false;
    }
 /*判断是否为允许的文件扩展名*/
 function isAllowFile(fileName){ 	
 	var fileExt=getFileExt(fileName)+"|"; 	
 	if(fileAllowExt.indexOf(fileExt)!=-1){
	   return true;
    }
    return false;
 }
/*上传文件
	level 等级 如果是图片那么大小不能超过500k  其他的根据等级来判断 

	field 要加入的字段 如果isDispaly  为false 直接加入相对根目录的路径 如果为false 将判断是否为图片或档案 
	isDisplay 是否显示
	
*/
function upLoadFile(level,field,isDisplay){
	 var hh = window.showModalDialog("/init/uploadFile.jsp?level="+level,"","dialogWidth:600px; dialogHeight:300px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");
	 if(hh == "undefined" || hh==null || hh == "")
	  return ;
	  var k = new Array();
      k = hh.split("|");
	  var sleft = "/"+k[0];
	  var sright=k[1];
	  var  s=sleft;
	
	  if(isDisplay){
	    //如果是图片	    
	  	if(isPicFile(sleft)){
	  		s="<img src='" +  sleft + "' alt='"+sright+"'>";
	  	}else{
  	  	  //flash动画
			if(getFileExt(sleft)=="SWF"){
				s='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="360" height="78">'+
	  			'<param name="movie" value="'+sleft+'">'+
				'<param name="quality" value="high">'+
				'<embed src="'+sleft+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="360" height="78"></embed>'+
				'</object>';		  	
			}else{
	  			s="<A href='"  + sleft + "'>" + sright + "</A>";
	  		}
	  	}
	  	var oEditor = FCKeditorAPI.GetInstance(field) ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ){
		// Insert the desired HTML.
		oEditor.InsertHtml( s ) ;
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
	  }

	  document.getElementById(field).value=s;
}
/*
用来弹出选择员工类别
lx  是决定单选还是多选 lx=0是复选框，lx=1是单选框
bh  是返回的员工编号及姓名  001,002|张三，李四
*/
function setworkers(lx,yhbbh,yhbxm){
    var  kk= "/webcontent/sysmanage/b_class_workers_compid.shtml";
    var  kk1="/webcontent/sysmanage/b_class_workers_compid_checkbox.shtml";
    var  hh;
    if(lx==1){
    hh = window.showModalDialog(kk,"","dialogWidth:450px; dialogHeight:450px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");      
    if(hh == "undefined" || hh==null || hh == "")
          return ;
    var k = new Array();    
    k = hh.split(",");               
     document.getElementById(yhbbh).value=k[0];
     document.getElementById(yhbxm).value=k[1];
    }  
    if(lx==0){
        hh = window.showModalDialog(kk1,"","dialogWidth:450px; dialogHeight:450px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");      
        if(hh == "undefined" || hh==null || hh == "")
          return ;
      var k = new Array();   
      var usearr = new Array();
      
      k=hh.split("@@@");          
      var j =k.length;    
      var jsid="";
      var jsxm="";
       for(var i=0;i<j;i++){
           if(k[i].length > 0){ 
           usearr = k[i].split(",");
	              jsid=jsid + usearr[0]+',';
	              jsxm=jsxm + usearr[1]+',';
          }
       }
       document.getElementById(yhbbh).value=jsid.substring(0,jsid.length-1);
       document.getElementById(yhbxm).value=jsxm.substring(0,jsxm.length-1);
    }        
}
/*
用来弹出选择角色类别
lx  是决定单选还是多选 lx=0是复选框，lx=1是单选框
bh  是返回的角色编号及名称  001,002|管理员，部门领导
*/
function setjs(lx,jsbh,jsmc){
    var  kk= "/webcontent/sysmanage/b_class_js.shtml";
    var  kk1="/webcontent/sysmanage/b_class_js_two.shtml";
    var  hh;
    if(lx==1){
    hh = window.showModalDialog(kk,"","dialogWidth:550px; dialogHeight:450px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");      
    if(hh == "undefined" || hh==null || hh == "")
          return ;
    var k = new Array();    
    k = hh.split(",");  
                 
     document.getElementById(jsbh).value=k[0];
     document.getElementById(jsmc).value=k[1];
    }  
    if(lx==0){
        hh = window.showModalDialog(kk1,"","dialogWidth:450px; dialogHeight:450px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");      
        if(hh == "undefined" || hh==null || hh == "")
          return ;
      var k = new Array();      
      k=hh.split(",");          
      var j =k.length;    
      var jsid="";
      var jsxm="";
       for(var i=0;i<j-1;i++){
           if(i%2==0){
              jsid=jsid + k[i]+',';
           }
           else{
              jsxm=jsxm + k[i]+',';
           }
       }
     
       document.getElementById(jsbh).value=jsid.substring(0,jsid.length-1);
       document.getElementById(jsmc).value=jsxm.substring(0,jsxm.length-1);
    }        
}





/*
用来弹出选择数据字典类别
lb  数据字典的类别
lx  是选第一级还是二级 lx=1只选第一级分类，lx=2选择第二级分类
sfield1  要返回的第一个值
sfield2  要返回的第二个值
sfield3  要返回的第三个值
sfield4  要返回的第四个值
*/
function setClass(lb,lx,sfield1,sfield2,sfield3,sfield4){
     var kk = "/init/b_classPopSele.shtml?lb=" + lb + "&lx=" + lx ;
     var hh = window.showModalDialog(kk,"","dialogWidth:300px; dialogHeight:450px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");
     if(hh == "undefined" || hh==null || hh == "")
          return ; 
     var k = new Array();   
     k = hh.split("|");     
     if(lx == "1"){
       document.getElementById(sfield1).value=k[0];
       document.getElementById(sfield2).value=k[1];
     }
     if(lx == "2"){
       document.getElementById(sfield1).value=k[0];
       document.getElementById(sfield2).value=k[1];
       document.getElementById(sfield3).value=k[2];
       document.getElementById(sfield4).value=k[3];
     }
 
   }
   
/*
用来弹出选择城市
sf  所在的省份或国家(外国)
lx  是返回通用编号还是民航三字代号 =1表示返回通用的编号,!=1表示是民航三字代号
sfield1  要返回的第一个值
sfield2  要返回的第二个值
*/
function setCity(sf,lx,sfield1,sfield2){
   if(sf==null || sf == ""){
      alert("您还没有选择所在的省份或国外国家名,请先选择!");
      return;
   }
     var kk = "/init/b_city_sele_list.shtml?szsf=" + sf + "&lx=" + lx ;
     var hh = window.showModalDialog(kk,"","dialogWidth:300px; dialogHeight:400px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");
     if(hh == "undefined" || hh==null || hh == "")
          return ;
     var k = new Array();
     k = hh.split("|");
     document.getElementById(sfield1).value=k[0];
     document.getElementById(sfield2).value=k[1];

   }

/*
*用来实现displaytag中,鼠标经过一行,该行变色
*/  
var pre;
function highlightTableRows(tableId) {   
    var previousClass = null;   
    var table = document.getElementById(tableId);
if(table==null||table==undefined||table==""){return;}
    var tbody = table.getElementsByTagName("tbody")[0];   
    if (tbody == null) {   
        var rows = table.getElementsByTagName("tr");   
    } else {   
        var rows = tbody.getElementsByTagName("tr");   
    }   
    for (i=0; i < rows.length; i++) {   
        rows[i].onmouseover = function() { 
        	if(this.style.backgroundColor!='#ccff99' && this.style.backgroundColor!='#e7c1ff'){
        		this.style.backgroundColor="#99ccff";
        	}  
        };   
        rows[i].onmouseout = function() { 
         if(this.style.backgroundColor!='#ccff99' && this.style.backgroundColor!='#e7c1ff'){
         this.style.backgroundColor="";
         }
         };   
        //if(i % 2 == 0)   
         //rows[i].style.backgroundColor="red";   
        //if(i % 2 == 1)   
         //rows[i].style.backgroundColor="yellow";   
        rows[i].onclick = function() { 
        if(pre!=null){
        	pre.style.backgroundColor="#E7C1FF"
        }
        pre=this;  
            //var cell = this.getElementsByTagName("td")[0];   
            //var link = cell.getElementsByTagName("a")[0];   
            //var theUrl=link.getAttribute("href");   
            //if(theUrl.indexOf("javascript")!=-1){   
                //eval(theUrl);           }else{   
                //location.href=theUrl;   
            //} 
              
         this.style.backgroundColor="#CCFF99";   
        }   
    }   
} 

/*
身份证号码验证
*/
function checkIdcard(idcard){
  var Errors=new Array("验证通过!","身份证号码位数不对!","身份证号码出生日期超出范围或含有非法字符!",
                 "身份证号码校验错误!","身份证地区非法!");
  var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
            33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",
            46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",
            65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"} 

  var idcard,Y,JYM;
  var S,M;
  var idcard_array = new Array();
  idcard_array = idcard.split("");
  //地区检验
  if(area[parseInt(idcard.substr(0,2))]==null) { alert(Errors[4]); return false;};
  //身份号码位数及格式检验
  switch(idcard.length){
    case 15:
		if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
		  ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
		} else {
		  ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
		}
       if(ereg.test(idcard)) 
           return true;
       else {
          alert(Errors[2]);
           return false;
       }
      break;
    case 18:
		//18位身份号码检测
		//出生日期的合法性检查 
		//闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
		//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
		if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
		   ereg=/^[1-9][0-9]{5}[1-2][0-9][0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
		} else {
		   ereg=/^[1-9][0-9]{5}[1-2][0-9][0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
		}
		if(ereg.test(idcard)){//测试出生日期的合法性
		//计算校验位
	//	S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
	//	+ (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
	//	+ (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
	//	+ (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
	//	+ (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
	//	+ (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
	//	+ (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
	//	+ parseInt(idcard_array[7]) * 1 
	//	+ parseInt(idcard_array[8]) * 6
	//	+ parseInt(idcard_array[9]) * 3 ;
	//	Y = S % 11;
	//	M = "F";
	//	JYM = "10X98765432";
	//	M = JYM.substr(Y,1);//判断校验位
//		if(M == idcard_array[17])
		   return Errors[0]; //检测ID的校验位
//		else{
//		  alert(Errors[3]);
//		  return false;
//		  break;
//		}
     }
       else{
         alert(Errors[2]);
         return false;
          break;
       }
     default:

        alert(Errors[1]);
        return false;
        break;
       return true;
    }
}

/*
  与上面身份证验证配合使用，从身份证号码中提取出生日期
*/
function getBirthday(sid){
  if(!checkIdcard(sid))
    return "";
    if(sid.length == 18){
       var k = sid.substring(6,10);
       var yy = sid.substring(10,12);
       var dd = sid.substring(12,14);
       return k + "-" + yy + "-" + dd;
    }
    if(sid.length == 15){
       var k = sid.substring(6,8);
       var yy = sid.substring(8,10);
       var dd = sid.substring(10,12);
       return "19" + k + "-" + yy + "-" + dd;
    }
}
function getSex(sid){
   	var dd="";
    if(sid.length == 18){
       dd = sid.substring(16,17);
    }
    if(sid.length == 15){
       dd = sid.substring(14,15);
    }
     if(dd%2==0){
       	return "F";
     }else{
       	 return "M";
     }
}
/** 
*导航条跳转
*/
function smsto(sjmkm,initbh){
	parent.frames[0].location.href='/webcontent/sysmanage/listAllMk.shtml?method=listAllMk&forward=listRight&sjmkm='+sjmkm+'&initbh='+initbh;
}
/*
  输入起始票号，票号长，数量，返回终止票号
*/
   function getEndno(startno,len,num){
     if(startno != ""){                
       var v1 = 0;  
       var v2 = 0;
       var v3 = 0;  
       var v4 = 0;
       if(num != ""){	         
         v4 = num;   
       }	   
            
       v1 = startno.substring(0,(startno.length - 6));     
       v2 = startno.substring((startno.length - 6));
       v4 = parseFloat(v2) + parseFloat(v4) - 1;	       
       v3 = parseFloat(startno.substring((startno.length - 6),(startno.length - 5))); 
       
       var endno = v4 + "";
       var lenv2 = 6 - endno.length;
       
       if(lenv2 > 0){
         for(var n=0;n<lenv2;n++){
            endno =  "0" + endno;
         }	  	         
       }	              
          if(v3 == 9){                         
            var v22 = endno;
            v22 = endno.substring(0,1)
            if(v22 != 9){
              v1 = parseFloat(v1) + 1; 
            }          
          }
          if(endno.length > 6){endno = endno.substring(1);}
       return endno = v1 + "" + endno;	        		       
      }
   }
   /*
   	转成人民币大写金额形式
   */
   function toMoneyString(num){
	  var str1 = '零壹贰叁肆伍陆柒捌玖';  //0-9所对应的汉字
	  var str2 = '万仟佰拾亿仟佰拾万仟佰拾元角分'; //数字位所对应的汉字
	  var str3;    //从原num值中取出的值
	  var str4;    //数字的字符串形式
	  var str5 = '';  //人民币大写金额形式
	  var i;    //循环变量
	  var j;    //num的值乘以100的字符串长度
	  var ch1;    //数字的汉语读法
	  var ch2;    //数字位的汉字读法
	  var nzero = 0;  //用来计算连续的零值是几个
	
	  num = Math.abs(num).toFixed(2);  //将num取绝对值并四舍五入取2位小数
	  str4 = (num * 100).toFixed(0).toString();  //将num乘100并转换成字符串形式
	  j = str4.length;      //找出最高位
	  if (j > 15){
	  return '金额超过9999999999999.99，请确认金额是否正确!';
	  }
	  str2 = str2.substr(15-j);    //取出对应位数的str2的值。如：200.55,j为5所以str2=佰拾元角分
	  
	  //循环取出每一位需要转换的值
	  for(i=0;i<j;i++){
	    str3 = str4.substr(i,1);   //取出需转换的某一位的值
	    if (i != (j-3) && i != (j-7) && i != (j-11) && i != (j-15)){    //当所取位数不为元、万、亿、万亿上的数字时
	   if (str3 == '0'){
	     ch1 = '';
	     ch2 = '';
	  nzero = nzero + 1;
	   }
	   else{
	     if(str3 != '0' && nzero != 0){
	       ch1 = '零' + str1.substr(str3*1,1);
	          ch2 = str2.substr(i,1);
	          nzero = 0;
	  }
	  else{
	    ch1 = str1.substr(str3*1,1);
	          ch2 = str2.substr(i,1);
	          nzero = 0;
	        }
	   }
	 }
	 else{ //该位是万亿，亿，万，元位等关键位
	      if (str3 != '0' && nzero != 0){
	        ch1 = "零" + str1.substr(str3*1,1);
	        ch2 = str2.substr(i,1);
	        nzero = 0;
	      }
	      else{
	     if (str3 != '0' && nzero == 0){
	          ch1 = str1.substr(str3*1,1);
	          ch2 = str2.substr(i,1);
	          nzero = 0;
	  }
	        else{
	    if (str3 == '0' && nzero >= 3){
	            ch1 = '';
	            ch2 = '';
	            nzero = nzero + 1;
	       }
	       else{
	      if (j >= 11){
	              ch1 = '';
	              nzero = nzero + 1;
	   }
	   else{
	     ch1 = '';
	     ch2 = str2.substr(i,1);
	     nzero = nzero + 1;
	   }
	          }
	  }
	   }
	 }
	    if (i == (j-11) || i == (j-3)){  //如果该位是亿位或元位，则必须写上
	        ch2 = str2.substr(i,1);
	    }
	    str5 = str5 + ch1 + ch2;
	    
	    if (i == j-1 && str3 == '0' ){   //最后一位（分）为0时，加上“整”
	      str5 = str5 + '整';
	    }
	  }
	  if (num == 0){
	    str5 = '零元整';
	  }
	  return str5;
	}
   
   function showMD(url,name,w,h){
	return window.showModalDialog(url,name,"dialogWidth:"+w+"px; dialogHeight:"+h+"px; directories:no; localtion:no; menubar:no; status:no; toolbar:no; scrollbars:no; resizeable:no;");
   }
   
   function showtkdetail(tkno){
	  winopen("/webcontent/cpzx/ticket_detail.shtml?tkno="+tkno+"&action=edit",650,400);
   }
   
   //onblur=toUpperCase(this)   调用示例
   //转大写
   function toUpperCase(sid){ 
     sid.value = sid.value.toUpperCase();
   }   
   
//灰玻璃对话框
//str提示文本
    function lockScreen(str){
    fun=false;
    var selectTag=document.getElementsByTagName('select');
    for(var i=0;i<selectTag.length;i++){
        selectTag[i].style.display='none';
    }
    
    document.oncontextmenu= function(){event.returnValue=false;}
	var msgw,msgh,bordercolor;
	msgw=400;//提示窗口的宽度
	msgh=100;//提示窗口的高度
	titleheight=25 //提示窗口标题高度
	bordercolor="#336699";//提示窗口的边框颜色
	titlecolor="#99CCFF";//提示窗口的标题颜色
	
	var sWidth,sHeight;
	sWidth=document.body.clientWidth;
	sHeight=document.body.scrollHeight;

	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#efefef";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	bgObj.style.opacity="0.6";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);
	
//	document.body.style.overflow="hidden";
	
	var msgObj=document.createElement("div")
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	msgObj.style.background="white";
	msgObj.style.border="1px solid " + bordercolor;
   	msgObj.style.position = "absolute";
	msgObj.style.left = (document.body.scrollWidth+150)/2; 
	msgObj.style.top = (document.body.scrollHeight)/2; 
    msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
    msgObj.style.marginLeft = "-225px" ;
    msgObj.style.marginTop = -65+document.documentElement.scrollTop+"px";
    msgObj.style.width = msgw + "px";
    msgObj.style.height =msgh + "px";			
    msgObj.style.textAlign = "left";
    msgObj.style.lineHeight ="150%";
    msgObj.style.zIndex = "10001";
	msgObj.style.padding = "0 0 20px 0";
   var title=document.createElement("h4");
   title.setAttribute("id","msgTitle");
   title.setAttribute("align","right");
   title.style.margin="0";
   title.style.padding="3px";
   title.style.background=bordercolor;
   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
   title.style.opacity="0.75";
   title.style.border="1px solid " + bordercolor;
   title.style.height="18px";
   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
   title.style.color="white";
   title.style.cursor="pointer";
   //title.innerHTML="关闭";
   title.title="关闭当前提示信息!";
   title.onclick=function alertclose(){
    	  //document.body.removeChild(bgObj);
          //document.getElementById("msgDiv").removeChild(title);
          //document.body.removeChild(msgObj);
		  if(fun == true){
		  	//window.close();
		  }
      };
   document.body.appendChild(msgObj);
   document.getElementById("msgDiv").appendChild(title);
   var txt=document.createElement("p");
   txt.style.margin="1em 0"
   txt.setAttribute("id","msgTxt");
   txt.style.padding="5px";
   txt.innerHTML=str;
   document.getElementById("msgDiv").appendChild(txt);
}



function NeatDialog(sHTML,fun,rtFn)
{
	var selectTag=document.getElementsByTagName('select');
    for(var i=0;i<selectTag.length;i++){
        selectTag[i].style.display='none';
    }
	var msgw,msgh,bordercolor;
	msgw=420;//提示窗口的宽度
	msgh=100;//提示窗口的高度
	titleheight=20; //提示窗口标题高度
	bordercolor="#336699";//提示窗口的边框颜色
	titlecolor="#99CCFF";//提示窗口的标题颜色
	
	var sWidth,sHeight;
	sWidth=document.body.clientWidth;
	sHeight=document.body.scrollHeight;
	
  window.neatDialog = null;
  this.elt = null;
  if (document.createElement  &&  document.getElementById)
  {
    var dg = document.createElement("div");
    dg.style.zIndex= "100004"; 
	dg.style.margin= "auto"; 
	dg.style.width= msgw; 
	dg.style.border= bordercolor+" 1px solid"; 
	dg.style.position= "relative"; 
	dg.style.top= "17%"; 
	if(document.body.scrollWidth>1024){ 
		dg.style.left= (window.screen.width-420)/2; 
	}else{
		dg.style.left= (document.body.scrollWidth-420)/2; 
	}
	dg.style.background= "#fff";
	
	//不能遮蔽下拉框
    sHTML = "<div id=\"nd-cancel\" title=\"关闭当前提示窗口\" style=\"padding-right: 3px;  background: "+
	"#336699; filter: progid:dximagetransform.microsoft.alpha(startx=20, starty=20, finishx=100, "+
	"finishy=100,style=1,opacity=75,finishopacity=100); padding-bottom: 3px; margin: 0px; "+
	"font: 12px verdana, geneva, arial, helvetica, sans-serif; cursor: pointer; color: white; "+
	"padding-top: 3px; height: "+titleheight+"; opacity: 0.75\"><span style=\"RIGHT: 0.2em; "+
	"POSITION: absolute; TOP: 0.2em\">关闭</span></div>\n<div style=\"padding:5px;\">"+sHTML+"</div>";
	
	//可以遮蔽下拉框
	//sHTML = "<iframe style=\"width:419px; height:"+sHeight+"px; top:0px;position:absolute;background-color:transparent;border:1px solid #369\" frameborder=\"0\" ></iframe>"+
    //         "<div id=\"nd-cancel\" title=\"关闭当前提示窗口\" style=\"padding-right: 3px;  background:#336699;"+
    //         "filter: progid:dximagetransform.microsoft.alpha(startx=20, starty=20, finishx=100, "+
	//         "finishy=100,style=1,opacity=75,finishopacity=100);width:420px; height:200px; position:absolute;"+
	//         "padding-bottom: 3px; margin: 0px; "+
	//         "font: 12px verdana, geneva, arial, helvetica, sans-serif; cursor: pointer; color: white; "+
	//         "padding-top: 3px; height: "+titleheight+"; opacity: 0.75;\"><span style=\"RIGHT: 0.2em; "+
	//         "POSITION: absolute; TOP: 0.2em\">关闭</span></div><br><div style=\"padding:5px; position:absolute;z-index:300000;\" >"+sHTML+"</div>";
    

    dg.innerHTML = sHTML;
    var dbg = document.createElement("div");
    dbg.id = "nd-bdg";
    dbg.style.zIndex = "100002"; 
	dbg.style.filter= "alpha(opacity=70)"; 
	dbg.style.left= "0px"; 
	dbg.style.position= "absolute"; 
	dbg.style.top= "0px"; 
	dbg.style.width= sWidth+"px"; 
	dbg.style.height= sHeight+"px";
	dbg.style.background= "#eee"; 
	dbg.style.opacity= "0.7";
	
    var dgc = document.createElement("div");
    dgc.style.zIndex= "100003"; 
	dgc.style.background= "none transparent scroll repeat 0% 0%"; 
	dgc.style.left= "0px"; 
	dgc.style.width= "100%"; 
	dgc.style.height= "100%";
	dgc.style.position= "absolute"; 
	dgc.style.top= "0px"; 
	
    dgc.appendChild(dbg);
    dgc.appendChild(dg);
    if (document.body.offsetLeft > 0)
      dgc.style.marginLeft = document.body.offsetLeft + "px";
    document.body.appendChild(dgc);
	
    document.getElementById("nd-cancel").onclick = function()
    {
	    for(var i=0;i<selectTag.length;i++){
	        selectTag[i].style.display='';
	    }
	    window.neatDialog.close();
	    if(undefined != rtFn){
	    	rtFn();
	    }
		if(fun == true){
		 	window.close();
		}
    };
    this.elt = dgc;
    window.neatDialog = this;
  }
}
NeatDialog.prototype.close = function()
{
  if (this.elt)
  {
    this.elt.style.display = "none";
    this.elt.parentNode.removeChild(this.elt);
  }
  window.neatDialog = null;
}


//自动填充
autowc = function(inputfiled,inputid,lx, url){
	if (lx==undefined){
		lx="";
	}else{
		lx="&lx="+lx;
	}
	try{
		if($('spinner')==undefined){
		document.body.insertAdjacentHTML('afterBegin'," <img alt='Loading' id='spinner' src='/images/skin1/loading.gif' style='display:none; float:right;position:absolute' />");
		}
	}catch(e){}
	Event.observe($(inputfiled),"keydown",function(event){
	   switch(event.keyCode) {
       case Event.KEY_TAB:
       	 return;
       case Event.KEY_RETURN:
         return;
       case Event.KEY_ESC:         
         return;
       case Event.KEY_LEFT:
         return;
       case Event.KEY_RIGHT:
         return;
       case Event.KEY_UP:         
         return;
       case Event.KEY_DOWN:         
         return;
      }
      $('spinner').style.left  = Position.positionedOffset($(inputfiled))[0];
	  $('spinner').style.top  = Position.positionedOffset($(inputfiled))[1] + $(inputfiled).getHeight();
	  if(inputid!=""){$(inputid).value="";};
	});
	var rand=parseInt(Math.random()*1000);
	pick_inputfiled=inputfiled+rand;
    new Insertion.After(inputfiled, "<div class='auto_complete' id='"+pick_inputfiled+"'></div>");
	$(inputfiled).addClassName("Winput");
	afterupdate =function(e,se){if(inputid!=""){$(inputid).value=se.dh;};$(inputfiled).value=se.text;}
	new Ajax.Autocompleter(inputfiled, pick_inputfiled, url, {frequency:1,paramName:'text',afterUpdateElement:afterupdate})
}
/*
*searchParam:数据对应的字段
*searchValue:字段对应的值
*tablename:表名
*otherWhere:其他查询条件例如:id='9000' and name='章磊'
*orderBy:要排序的字段，多个可以
*rtFn:成功后调用的函数
*/
function commanTag(searchParam,searchValue,tablename,otherWhere,orderBy,rtFn){
	var param="1=1";
	if(searchParam!=null){
		param=param+"&searchParam="+searchParam;
	}
	if(searchValue!=null){
		param=param+"&searchValue="+searchValue;
	}
	if(tablename!=null){
		param=param+"&tablename="+tablename;
	}
	if(otherWhere!=null){
		param=param+"&otherWhere="+otherWhere;
	}
	if(orderBy!=null){
		param=param+"&orderBy="+orderBy;
	}
	var myAjax = new Ajax.Request(
			'/tag/jstag.shtml',
			{
				method: 'post',
				requestHeaders:{Accept:'application/html'},
				parameters: param,
				onComplete: rtFn
			}
	);
}
/*
从address.js中的hotel获得获得城市中文名 ，address.js 是工程启动时生成的。
*/
function getCity(szm,type){
	var city$__=hotel.split("@");
	for(var i=0;i<city$__.length;i++){
		var city=city$__[i].split("|");
		if(city[2]==szm){
			if(type=='1'){
				return city[0]+city[1];
			}else if(type=='2'){
				return city[1];
			}else{
				return city[0]+city[1];
			}
		}
	}
	return "";
}
/*
从hkgs.js中的Qhkgs获得获得城市中文名 ，hkgs.js 是工程启动时生成的。
*/
function getHkgs(ezdh,type){
	var _hkgs$__=_hkgs.split("@");
	
	for(var i=0;i<_hkgs$__.length;i++){
		var _hkgs_p=_hkgs$__[i].split("|");
		if(_hkgs_p[2]==ezdh){
			if(type=='1'){
				return _hkgs_p[0];
			}else if(type=='2'){
				return _hkgs_p[1];
			}else{
				return _hkgs_p[0];
			}
		}
	}
	return "";
}
function getHkgsOptions(gngj){
	var s="";
	var _hkgs$__=_hkgs.split("@");
	for(var i=0;i<_hkgs$__.length;i++){
		var _hkgs_p=_hkgs$__[i].split("|");
		if(gngj=='1'){
			if(_hkgs_p[3]=='1'){
				s=s+"<option value='"+_hkgs_p[2]+"'>"+_hkgs_p[2]+" "+_hkgs_p[1]+"</option>";
			}
		}else{
			if(_hkgs_p[4]=='1'){
				s=s+"<option value='"+_hkgs_p[2]+"'>"+_hkgs_p[2]+" "+_hkgs_p[1]+"</option>";
			}
		}
	}
	return document.write(s);
}
 function loadScript(url){
	var h=document.getElementsByTagName("head")[0];
	var f=document.createElement("script");
	var d=new Date().getTime();
	f.type="text/javascript";
	f.src=url;
	f.charset="utf-8";
	h.appendChild(f);
}
//替换所有
String.prototype.replaceAll = function (AFindText,ARepText){
                raRegExp = new RegExp(AFindText,"g");
                return this.replace(raRegExp,ARepText);
}
