/*
 公用js 函数
 */
// 允许上传的图片扩展名
var picExt="JPEG|JPG|BMP|GIF|TIF|PNG|ICO|";
// 允许上传的文件扩展名
var fileAllowExt="DOC|XLS|PPT|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 Dformat(date,sFormat)
{
	var dt=date;
	if(sFormat==null || typeof(sFormat)!="string")
		sFormat="";
	sFormat=sFormat.replace(/yyyy/ig,dt.getFullYear());
	var y=""+dt.getYear();
	if(y.length>2)
	{
		y=y.substring(y.length-2,y.length);
	}
	var month=dt.getMonth()+1;
	if(month<10)month="0"+month;
	var day=dt.getDate();
	if(day<10)day="0"+day;
	var hour=dt.getHours();
	if(hour<10)hour="0"+hour;
	var minute=dt.getMinutes();
	if(minute<10)minute="0"+minute;
	var second=dt.getSeconds();
	if(second<10)second="0"+second;
	sFormat=sFormat.replace(/yy/ig,y);
	sFormat=sFormat.replace(/MM/g,month);
	sFormat=sFormat.replace(/dd/ig,day);
	sFormat=sFormat.replace(/HH/ig,hour);
	sFormat=sFormat.replace(/mm/g,minute);
	sFormat=sFormat.replace(/SS/ig,second);
	return sFormat;
}
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(/^([a-zA-Z]|\d|_)*$/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(!isAlphaOrNum(value.substr(0,1))||value.toUpperCase()!= value|| !isAlphaOrNum(value)||value.indexOf("_")>=0||isDigit(value)){
	 	return false;			
	}else{
		return true;
	}
}
/*
判断是否是票号
*/
function isTicketno(value){
	if(value.length!=10||!isDigit(value)){
		return false;
	}else{
		return true;
	}
}
/* 
返回数值
*/
function isNumber(v) {
  //return (s.search(/^[+-]?[0-9.]*$/) >= 0);   
  return  (!isNaN(v) && !/^\s+$/.test(v));
}

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+"条。如果开通长短信每条能发1900个汉字。";
	}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如果开通长短信每条能发1900个汉字。\n\n继续请按 确定 重新修改 请按 取消。";
	  if( window.confirm(s)==1) 
	   return true;
	  else
	   return false;
	}
	return true;
}
/**
	判断是否为移动号码 判断是否为手机号码 1是 0不是
*/
function isMobile(v_sjhd){
	return isTrueMobile(v_sjhd);
}

/**
	判断是否为手机号码 1是 0不是
*/
function isTrueMobile(mobile){
	var ydtel="134,135,136,137,138,139,150,151,154,157,158,159,188";
	var lttel="130,131,132,133,152,153,155,156,189,185,186,187";
	 mobile = mobile.replace(/(^\s*)|(^\u3000*)|(\u3000*$)|(^\ue4c6*)|(\ue4c6*$)|(\s*$)/g,"");
    if(!isDigit(mobile)) return 0;
    if(mobile == null || mobile == "") return 0;
	if(mobile.substr(0,1)=='0'){
	   mobile=mobile.substr(1)
	}
	if(mobile.length != 11){
	   return 0;
    }
	if(ydtel.indexOf(mobile.substr(0, 3))>=0){
		return 1;
	}else if(lttel.indexOf(mobile.substr(0, 3))>=0){
		return 1;
	}else{
		return 0;
	}
}

/**
	判断是否为多个正确的手机号码 true是 false不是
*/
function isMoreMobile(v_more_sj){
  var cattwo;
  if(v_more_sj == null || v_more_sj == "") return false;
    cattwo = v_more_sj.toString().split(",");
    for(var i=0;i < cattwo.length;i++){
	  if(isTrueMobile(cattwo[i]) == 0){
	    return false;
	  }  
    }
    return true;
}

/*
是否全部是英文,/,空格,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 && element.disabled == false){
			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  && ctype != "" && value != "") {
		    var jd=-1;
		    if(ctype.indexOf('number-')==0){//number-2 最多2位小数的数字
		    	jd = parseInt(ctype.substring(ctype.indexOf('number-')+7),10);
		    	if(isNaN(jd)){
		    		jd = 0;
		    	}
		    	ctype = "number";
		    }
		
			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;
					}
				}else if(jd>0){//格式为number-2 2为最大小数精度
				   if(value.indexOf(".")>=0){
						if(value.substring(value.indexOf(".")+1).length>jd){
							checkFormChange(po, ele, 3, "小数位数不能超过"+jd+"位.");
							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 "sj":
				if (!isMoreMobile(value)) {
					checkFormChange(po, ele, 3, "请输入正确的手机号，多个手机用(,)逗号隔开");
					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+" 的值是否正确.;";
	}
	if (bz == "A"){
		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  opText(selObj,rv){
   /*如果值为空*/
   if(rv){
   	if(selObj.options[selObj.selectedIndex].value==""){
   		return "";
   	}
   }
	return selObj.options[selObj.selectedIndex].text;
}
 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) {   
         rows = table.getElementsByTagName("tr");   
    } else {   
         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";   
        }   
    }   
} 

/*
*用来实现displaytag中,鼠标经过一行,该行变色
*/  
var previp;
function highlightTableRowsVip(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) {   
         rows = table.getElementsByTagName("tr");   
    } else {   
         rows = tbody.getElementsByTagName("tr");   
    }   
    for (i=0; i < rows.length; i++) {   
        rows[i].onmouseover = function() { 
        	if(this.style.backgroundColor!='#87dfff' && this.style.backgroundColor!='#fcc47a'){
        		this.style.backgroundColor="#e1f5ff";
        	}  
        };   
        rows[i].onmouseout = function() { 
         if(this.style.backgroundColor!='#87dfff' && this.style.backgroundColor!='#fcc47a'){
         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(previp!=null){
        	previp.style.backgroundColor="#fcc47a"
        }
        previp=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="#87dfff";   
        }   
    }   
}

/*
身份证号码验证
*/
function checkIdcard(idcard){
	if(idcard == "")return true;
  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,initbt){
    if(initbt==undefined){
    	initbt="";
    }
	parent.frames[0].location.href='/webcontent/sysmanage/listAllMk.shtml?method=listAllMk&forward=listRight&sjmkm='+sjmkm+'&initbh='+initbh+"&initbt=1";
}
function smsto_open(sjmkm,initbh,initbt){
    if(initbt==undefined){
    	initbt="";
    }
	self.opener.parent.frames[0].location.href='/webcontent/sysmanage/listAllMk.shtml?method=listAllMk&forward=listRight&sjmkm='+sjmkm+'&initbh='+initbh+"&initbt=1";
}

//用于top.jsp弹出窗
function smsto_open_other(sjmkm,initbh,initbt,userbh){
    if(initbt==undefined){
    	initbt="";
    }
    window.opener.parent.frames[1].frames[0].frames[2].location="/webcontent/sysmanage/sms.jsp?sjmkm="+sjmkm+"&userid="+userbh+"&mkurl=";
	window.opener.parent.frames[1].frames[0].frames[2].frames[0].location.href="/webcontent/sysmanage/listAllMk.shtml?method=listAllMk&forward=listRight&sjmkm="+sjmkm+"&initbh="+initbh+"&initbt="+initbt
}

//用于消息弹出窗
function smsto_top(sjmkm,initbh,initbt,userbh){
	if(initbt==undefined){
    	initbt="";
    }
    window.opener.parent.frames[0].frames[1].frames[0].frames[2].location="/webcontent/sysmanage/sms.jsp?sjmkm="+sjmkm+"&userid="+userbh+"&mkurl=";
	window.opener.parent.frames[0].frames[1].frames[0].frames[2].frames[0].location.href="/webcontent/sysmanage/listAllMk.shtml?method=listAllMk&forward=listRight&sjmkm="+sjmkm+"&initbh="+initbh+"&initbt="+initbt
}

/*
  输入起始票号，票号长，数量，返回终止票号
*/
   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 - 5));     
       v2 = startno.substring((startno.length - 5));
       v4 = parseFloat(v2) + parseFloat(v4) - 1;	       
       v3 = parseFloat(startno.substring((startno.length - 5),(startno.length - 4))); 
       
       var endno = v4 + "";
       var lenv2 = 5 - 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 > 5){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;
	}
	param = param + "&date=" +new Date();
	var myAjax = new Ajax.Request(
			'/tag/jstag.shtml',
			{
				method: 'post',
				requestHeaders:{Accept:'application/html'},
				parameters: param,
				onComplete: rtFn
			}
	);
}
/*
*p_value,需要处理的值
*p_compid,根据这个公司的设置处理p_value
*rtn回调函数
**/
function f_round(p_value,p_compid,rtn_r){
	var rrtn=function(transport){
		var json =  eval("("+transport.responseText+")"); 
		var f=0;
		
	  	if(json.success == null ){
	  	    if(json.total > 0){
			  	f = json.rows[0].F;
	  	    }
	  	}else{
	  		f=0;
	  	}
		rtn_r(f);
	}
	commanTag(null,null,"(select pkg_common.f_round("+p_value+",'"+p_compid+"') F from dual)",null,null,rrtn);
}
/*
从address.js中的hotel获得获得城市中文名 ，address.js 是工程启动时生成的。
*/
function getCity(szm,type){
  try{
	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];
			}
		}
	}
  }catch(e){}
	return "";
}

function getCity_gj(szm,type){
try{
	var city$__=fltInternational.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];
			}
		}
	}
}catch(e){}
	return "";
}
/*
从hkgs.js中的Qhkgs获得获得城市中文名 ，hkgs.js 是工程启动时生成的。
*/
function getHkgs(ezdh,type){
try{
	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];
			}
		}
	}
}catch(e){}
	return "";
}

//传入会员卡号shykh 和 Ajax回调函数名showResponse 直接查找会员并把返回结果按传入回调函数执行
function setHyid(shykh,showResponse){
	if(shykh!=""){
		var myAjax = new Ajax.Request(
			'/webcontent/ticket/ydzx/kh_khdd_edit_hy_select.shtml',
			{
				method: 'get',
				requestHeaders:{Accept:'application/json'},
				parameters: {shykh:strTrim(shykh)},
				onComplete: showResponse
			}
		);
	}
}
// 根据订单编号 ，查询机票信息列表
 function showTicket(ddbh){
  	var url = "/webcontent/ticket/ydzx/ticket_list.shtml?showType=findTicket&ddbh="+ddbh ;
  	window.open(url,"","height=400,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
  }
/**
*十进制转为2进制字符串
*/
function toBin(intNum)
{
 var answer = "";
 if(/\d+/.test(intNum))
 {
  while(intNum != 0)
  {
   answer = Math.abs(intNum%2)+answer;
   intNum = parseInt(intNum/2);
  }
  if(answer.length == 0)
   answer = "0";
  return answer; 
 }
 else
 {
  //alert("please input a number");
  return null;
 } 
}
//日期格式
 Date.prototype.format00000   =   function(format)   
  {   
      var   o   =   {   
          "M+"   :   this.getMonth()+1,   //month   
          "d+"   :   this.getDate(),         //day   
          "h+"   :   this.getHours(),       //hour   
          "m+"   :   this.getMinutes(),   //minute   
          "s+"   :   this.getSeconds(),   //second   
          "q+"   :   Math.floor((this.getMonth()+3)/3),     //quarter   
          "S"   :   this.getMilliseconds()   //millisecond   
      }   
      if(/(y+)/.test(format))   format=format.replace(RegExp.$1,   
          (this.getFullYear()+"").substr(4   -   RegExp.$1.length));   
      for(var   k   in   o)if(new   RegExp("("+   k   +")").test(format))   
          format   =   format.replace(RegExp.$1,   
              RegExp.$1.length==1   ?   o[k]   :     
                  ("00"+   o[k]).substr((""+   o[k]).length));   
      return   format;   
  };   
  function addDate(vdate,s){
  	return new Date(new Date(Date.parse(vdate)).getTime()+s*24*60*60*1000).format00000("yyyy-MM-dd");
  }
  
	//传入处理值，精确位数，舍入的数值，进行几舍几入
	function vefixed(value,median,num){
		if(isBlank(value.toString()) || isNaN(value)){
			return 0;
		}
		if(isBlank(median.toString()) || isNaN(median)){
			median = 2;
		}else{
			median = strTrim(median);
		}
		if(isBlank(num.toString()) || isNaN(num)){
			num = 4;
		}else{
			num = strTrim(num);
		}
		value = strTrim(value.toFixed(5));
		var point =value.toString().indexOf(".");
		if(point > -1){
			var xsd = value.toString().split(".");
			var return_s = 0;
			var zs = xsd[0];
			var xs = xsd[1];
			if(xs.length >= parseInt(median)){//判断小数位数大于精确位数，进入计算
				if(median == 0){//如果精确位数为0，保留整数
					if(parseInt(xs.substring(0,1)) > parseInt(num)){
						return parseInt(zs)+1;
					}else{
						return zs;
					}
				}else{
					if(parseInt(xs.substring(parseInt(median),parseInt(median)+1)) > parseInt(num)){
						xs = parseInt(xs.substring(0,parseInt(median)))+1;
						return zs + "." + xs;
					}else{
						return zs + "." + xs.substring(0,parseInt(median));
					}
				}
			}else{
				return value;
			}
		}else{
			return value;
		}
	}
	
	//外乎 号码 nxwx 为nx 表示坐席号，wx表示外部号码
function calltel(tel,nxwx){
	if(nxwx==undefined){
		nxwx = "wx";
	}
	window.showModalDialog("/webcontent/callcenter/callcenterCall.jsp?date="+new Date()+"&phoneNo="+tel+"&isnxwx="+nxwx,window,"dialogWidth:380px;dialogHeight:140px");
}	
function MM_findObj(n, d) { //v3.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); return x;

}



function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v3.0

  //Copyright 1998 Macromedia, Inc. All rights reserved.

  var i,j,aLayer,retVal,curDrag=null,NS=(navigator.appName=='Netscape'), curLeft, curTop;

  if (!document.all && !document.layers) return false;

  retVal = true; if(!NS && event) event.returnValue = true;

  if (MM_dragLayer.arguments.length > 1) {

    curDrag = MM_findObj(objName); if (!curDrag) return false;

    if (!document.allLayers) { document.allLayers = new Array();

      with (document) if (NS) { for (i=0; i<layers.length; i++) allLayers[ i]=layers[ i];

        for (i=0; i<allLayers.length; i++) if (allLayers[ i].document && allLayers[ i].document.layers)

          with (allLayers[ i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];

      } else for (i=0;i<all.length;i++) if (all[ i].style&&all[ i].style.position) allLayers[allLayers.length]=all[ i];}

    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;

    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;

    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;

    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;

    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;

    curDrag.MM_oldZ = (NS)?curDrag.zIndex:curDrag.style.zIndex;

    curLeft= (NS)?curDrag.left:curDrag.style.pixelLeft; curDrag.MM_startL = curLeft;

    curTop = (NS)?curDrag.top:curDrag.style.pixelTop; curDrag.MM_startT = curTop;

    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop -cU;

    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop +cD;

    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!

    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;

    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);

  } else {

    var theEvent = ((NS)?objName.type:event.type);

    if (theEvent == 'mousedown') {

      var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;

      var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;

      var maxDragZ=null; document.MM_maxZ = 0;

      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[ i];

        var aLayerZ = (NS)?aLayer.zIndex:aLayer.style.zIndex;

        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;

        var isVisible = (((NS)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);

        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {

          var parentL=0; var parentT=0;

          if (!NS) { parentLayer = aLayer.parentElement;

            while (parentLayer != null && parentLayer.style.position) {

              parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;

              parentLayer = parentLayer.parentElement; } }

          var tmpX=mouseX-(((NS)?pageX:style.pixelLeft+parentL)+MM_hLeft);

          var tmpY=mouseY-(((NS)?pageY:style.pixelTop +parentT)+MM_hTop);

          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS)?clip.width :offsetWidth);

          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS)?clip.height:offsetHeight);

          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null

              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }

      if (curDrag) {

        document.onmousemove = MM_dragLayer; if (NS) document.captureEvents(Event.MOUSEMOVE);

        curLeft = (NS)?curDrag.left:curDrag.style.pixelLeft;

        curTop = (NS)?curDrag.top:curDrag.style.pixelTop;

        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;

        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;

        if(curDrag.MM_toFront) {

          eval('curDrag.'+((NS)?'':'style.')+'zIndex=document.MM_maxZ+1');

          if (!curDrag.MM_dropBack) document.MM_maxZ++; }

        retVal = false; if(!NS) event.returnValue = false;

    } } else if (theEvent == 'mousemove') {

      if (document.MM_curDrag) with (document.MM_curDrag) {

        var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;

        var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;

        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;

        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);

        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);

        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);

        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);

        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;

        if (NS) {left = newLeft; top = newTop;}

        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}

        if (MM_dragJS) eval(MM_dragJS);

        retVal = false; if(!NS) event.returnValue = false;

    } } else if (theEvent == 'mouseup') {

      document.onmousemove = null;

      if (NS) document.releaseEvents(Event.MOUSEMOVE);

      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS

      if (document.MM_curDrag) with (document.MM_curDrag) {

        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&

            (Math.pow(MM_targL-((NS)?left:style.pixelLeft),2)+

             Math.pow(MM_targT-((NS)?top:style.pixelTop),2))<=MM_tol) {

          if (NS) {left = MM_targL; top = MM_targT;}

          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}

          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }

        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);

        if(MM_dropBack) {if (NS) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}

        retVal = false; if(!NS) event.returnValue = false; }

      document.MM_curDrag = null;

    }

    if (NS) document.routeEvent(objName);

  } return retVal;

}

/*
示例：下面的示例演示了如何判断文件是否已经被加载，以及如何动态加载文件。
<html>
<body>
	<script language="javascript" type="text/javascript" src="DynamicLoad.js"></script>
	<script language="javascript" type="text/javascript">
	<!--
	var dl=new DynamicLoad();				//初始化DynamicLoad对象
	alert(dl.IsLoaded("DynamicLoad.js"));	//判断是否已经加载了文件DynamicLoad.js
	dl.Load("HttpCookie.js");				//加载HttpCookie.js
	alert(dl.IsLoaded("HttpCookie.js"));	//判断是否已经加载了文件HttpCookie.js。加载需要时间，一般情况下这里返回false；如果过一小段时间再判断，很可能返回true。
	//-->
	</script>
</body>
</html>
*/
function DynamicLoad()
{
	//属性
	var Self=this;						//对象自身
	
	//功能：加载指定的文件
	//参数：src——需要被加载的文件
	//返回：（无）
	this.Load=function(src)
	{
		if(Self.IsLoaded(src))				//判断该文件是否已经加载了
		{
			Self.OnLoaded(src);
			return;
		}
		else							//如果没有加载，动态创建
		{
			var objDynamic;				//动态创建的对象
			var type=Self.GetSrcType(src);	//文件类型
			if(type=="js" || type=="vbs")
			{
				objDynamic=document.createElement("script");
				objDynamic.src=src;
				if(type=="js")
				{
					objDynamic.type="text/javascript";
					objDynamic.language="javascript";
				}
				else
				{
					objDynamic.type="text/vbscript";
					objDynamic.language="vbscript";
				}
			}
			else if(type=="css")
			{
				objDynamic=document.createElement("link");
				objDynamic.rel="stylesheet";
				objDynamic.type="text/css";
				objDynamic.href=src;
			}
			else
			{
				Self.OnFailed(src);
				return;
			}
			document.getElementsByTagName("head")[0].appendChild(objDynamic);	//将创建的对象插入到HEAD节中
			objDynamic.onload=objDynamic.onreadystatechange=function()			//加载过程中状态改变引发的事件
			{   
				//在此函数中this指针指的是s结点对象，而不是JsLoader实例，   
				//所以必须用self来调用onsuccess事件，下同。
				if(this.readyState && this.readyState=="loading")
					return;
				else
				  Self.OnLoaded(src);
			};
			objDynamic.onerror=function()												//加载过程中发生错误引发的事件
			{
				document.getElementsByTagName("head")[0].removeChild(objDynamic);
				Self.OnFailed(src);
			};
		}
	};
	
	//功能：判断是否已经加载了某文件
	//参数：src——需要被检查的文件
	//返回：返回是否已经加载了该文件
	this.IsLoaded=function(src)
	{
		var isLoaded=false;			//假设没有加载
		var type=Self.GetSrcType(src);	//得到文件的类型
		var i;						//用于循环的索引
		if(type=="js" || type=="vbs")
		{
			var scripts=document.getElementsByTagName("script");	//得到所有的脚本对象集合
			for(i=0;i<scripts.length;i++)							//依次判断每个script对象
			{
				if(scripts[i].src && scripts[i].src.indexOf(src)!=-1)
				{
					if(scripts[i].readyState=="loaded" || scripts[i].readyState=="complete")
					{
						isLoaded=true;
						break;
					}
				}
			}
		}
		else if(type=="css")
		{
			var links=document.getElementsByTagName("link");		//得到所有的link对象集合
			for(i=0;i<links.length;i++)								//依次判断每个link对象
			{
				if(links[i].href && links[i].href.indexOf(src)!=-1)
				{
					if(links[i].readyState=="loaded" || links[i].readyState=="complete" || links[i].readyState=="interactive")
					{
						isLoaded=true;
						break;
					}
				}
			}
		}
		return isLoaded;
	};
	
	//功能：得到文件的类型（即扩展名）
	//参数：src——文件名
	//返回：返回文件的类型
	this.GetSrcType=function(src)
	{
		var type="";
		var lastIndex=src.lastIndexOf(".");
		if(lastIndex!=-1)
		{
			type=src.substr(lastIndex+1);
		}
		return type;
	};
	
	//功能：当文件加载完成时发生的事件
	//参数：src——加载完成的文件
	//返回：（无）
	this.OnLoaded=function(src)
	{
		Self.LoadedCallback(src);
	};
	
	//功能：文件加载完成时执行的回调函数
	//参数：src——加载完的文件
	//返回：（无）
	this.LoadedCallback=function(src){};
	
	//功能：当文件加载过程中发生错误时发生的事件
	//参数：src——正在加载的文件
	//返回：（无）
	this.OnFailed=function(src)
	{
		Self.FailedCallback(src);
	};
	
	//功能：当文件加载失败时执行的回调函数
	//参数：src——加载失败的文件
	//返回：（无）
	this.FailedCallback=function(src){};
}

//替代系统的toFixed方法，因为系统toFixed()方法有bug
Number.prototype.toFixed = function(d){ 
        var s=this+"";if(!d)d=0; 
        if(s.indexOf(".")==-1)s+=".";s+=new Array(d+1).join("0"); 
        if (new RegExp("^(-|\\+)?(\\d+(\\.\\d{0,"+ (d+1) +"})?)\\d*$").test(s)) 
        { 
            var s="0"+ RegExp.$2, pm=RegExp.$1, a=RegExp.$3.length, b=true; 
            if (a==d+2){a=s.match(/\d/g); if (parseInt(a[a.length-1])>4) 
            { 
                for(var i=a.length-2; i>=0; i--) {a[i] = parseInt(a[i])+1; 
                if(a[i]==10){a[i]=0; b=i!=1;} else break;} 
            } 
            s=a.join("").replace(new RegExp("(\\d+)(\\d{"+d+"})\\d$"),"$1.$2"); 
        }if(b)s=s.substr(1);return (pm+s).replace(/\.$/, "");} return this+""; 
}
/**
 根据传入的汉字返回首字母和全拼用###分割开 调用了ajax  callback是页面定义的一个回调函数  第一个参数是首字母 第二个是全拼
*/
function speel(hz,callback){
	var speelurl = "/init/kz_json.shtml?mothed=spell&hz="+encodeURIComponent(hz);
	new Ajax.Request(speelurl, {
	  method: 'get',
	  onSuccess: function(transport) {
	    var notice =transport.responseText.split("###");
	    if(notice.length==2){
	    	callback(notice[0],notice[1]);
	    }
	  }
	});
}

/*页面上添加浮动DIV*/
function addDiv(divid,w,h,close){
  	if(close == "1"){
  		var obj1 = document.getElementById(divid);
  		var obj2 = document.getElementById("locked");
  		obj1.parentNode.removeChild(obj1);
  		obj2.parentNode.removeChild(obj2);
  		try{autoRef = window.setTimeout("ref()",1000*60);}catch(e){}
  		return;
  	}
  	try{window.clearTimeout(autoRef);}catch(e){}
  	var sw = document.body.clientWidth;
	var qh = document.body.scrollHeight; //网页全文高 锁屏时用到
	var qw = document.body.scrollWidth;  //网页全文宽 锁屏时用到
	var htop = document.body.scrollTop; //滑动条滑动的高度
	var myObj = document.createElement("iframe");
	myObj.setAttribute("id","locked");
	myObj.setAttribute("src","");
	myObj.setAttribute("frameborder","0");
	myObj.style.position = "absolute";
	myObj.style.zIndex= "1";
	myObj.style.top= "0px";
	myObj.style.left= "0px";
	myObj.style.width = qw + "px";
	myObj.style.height = qh + "px";
	myObj.style.background = "transparent";
	myObj.style.filter = "alpha(opacity=50)";
	myObj.style.opacity = "0.5";

	document.body.appendChild(myObj);
	
	myObj = document.createElement("div");
	myObj.setAttribute("id",divid);
	myObj.style.position = "absolute";
	myObj.style.zIndex= "2";
	myObj.style.top= (htop+50) + "px";
	myObj.style.left= (sw-w)/2 + "px";
	myObj.style.width = w + "px";
	myObj.style.height = h + "px";
	myObj.style.padding = "5px 5px";
	myObj.style.border = "1px solid #ffb900";
	myObj.style.background = "#ffffe7";
	var shtml = "<div style='text-align:right' onclick='addDiv(\""+divid+"\",null,null,1)'><img src=\"/images/closex.gif\" style='height:10px;cursor: pointer;' /></div>"
	myObj.innerHTML = shtml;
	
	document.body.appendChild(myObj);
	document.getElementById(divid).focus();
}

function SubmitKeyClick(obj, evt,rtnFun) {
    evt = (evt) ? evt : ((window.event) ? window.event : "")
    keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode);
    if (keyCode == 13) {
    	
    }
}

/* 对象比较 */
function equalObject(obj1,obj2){
	if(obj1 == obj2){
		return true;
	}
	if(obj1 == undefined || obj1 == null || typeof(obj1) != "object" || obj2 == undefined || obj2 == null || typeof(obj2) != "object"){
		return false;
	}
	var l1 = 0;
	var l2 = 0;
	for(var i in obj1){
		l1++;
	}
	for(var i in obj2){
		l2++;
	}
	if(l1 != l2){
		return false;
	}
	if(obj1.constructor == obj2.constructor){
		for(var i in obj1){
			if(typeof(obj1[i]) == "object"){
				if(!equalObject(obj1[i],obj2[i])){
					return false;
				}
			}else if(obj1[i] != obj2[i]){
				return false;
			}
		}
		return true;
	}
	return false;
}