/*
Copyright(C) Ctrip.COM 2006.All Rights Reserved.
Not to be reused without permission.
Created by Chu Chengdong, UI group, IT department.
Last modified by Chu Chengdong, Tian Guofa, UI group, IT department. 2008/02/25
*/
window.$Ctrip=function(_){
	this.window=function(){
		this._=_;
		this.__=_.document;
		this.___=_.__.documentElement;
		_.__.write("<div id=\"jsContainer\"><input id=\"jsSaveStatus\" type=\"text\" style=\"display:none;\" \/><div id=\"tuna_alert\" style=\"display:none;position:absolute;z-Index:999;overflow:hidden;\"><\/div><\/div>");
		// to do
		this.$$=new function(){
			this.status=new function(){
				this.domReady=false;	//页面是否已加载
				this.busy=0;
				this.domReadyFunc=[];
				this.dealt={};
				this.regEvent=[];
				this.regEventHash={};
				this.charset=(((_.__.charset?_.__.charset:_.__.characterSet)||"")
					.match(/^(gb2312|big5|utf-8)$/gi)||"gb2312").toString().toLowerCase();
				this.version={
					"gb2312":"zh-cn",
					"big5":"zh-tw",
					"utf-8":"en"
				}[this.charset];
				//this.chs=!this.charset.toString().match(/^utf-8$/g);
				var script=top.__.getElementsByTagName("script");
				this.debug=false;
				this.alertDiv=_.__.getElementById("tuna_alert");
				this.container=_.__.getElementById("jsContainer");
				this.saveStatus=_.__.getElementById("jsSaveStatus");
			};
			this.module={
				iframe:[],
				list:{
					address:"tuna_address_071206",
					calendar:"tuna_calendar_071206"
				},
				tab:{},
				selectAll:{},
				checkInput:{},
				address:{
					source:{}
				},
				calendar:{},
				jmpInfo:{array:{}},
				init:[]
			};
			with (navigator){with(userAgent){
				this.browser={
					IE:!!match(/MSIE/),
					IE6:!!appVersion.match(/MSIE 6\.0/),	//是否为ie6
					Moz:match(/Mozilla/)&&!match(/(compatible|webkit)/),
					Opera:!!match(/Opera/),
					Safari:!!match(/Mac|Safari/)
				}
			}}
			this.string={
				"zh-cn":{
					weekday:"日一二三四五六",
					display:"@▲|▼@显示|隐藏@"
				},
				"zh-tw":{
					weekday:"日一二三四五六",
					display:"@▲|▼@顯示|隱藏@"
				},
				"en":{
					weekday:"SMTWTFS",
					display:"@Show|Hidden@"
				}
			}[this.status.version];
		};
		this.$fixE=function(e){
			e=_.event||e||arguments.callee.caller.arguments[0];
			Ctrip.Object.apply(e.$target=e.target?(e.target.nodeType==3?e.target.parentNode:e.target):e.srcElement);
			return e;
		};
		this.$stopEvent=function(e,flag){
			e=$fixE(e);
			flag=flag||0;
			if (flag>=0) e.preventDefault?e.stopPropagation():(e.cancelBubble=true);
			if (flag!=0) e.preventDefault?e.preventDefault():(e.returnValue=false);
		};
		this.$getUid=function(){
			return "uid_"+(new Date()).getTime()+Math.random().toString().substr(2,5);
		};
		this.$c=this.$createElement=function(tag){
			if (tag.constructor==Array) return Ctrip.Object.apply(_.__.createTextNode(tag.join("\n")));
			else return Ctrip.Object.apply(_.__.createElement(tag));
		};
		this.$getQuery=function(name){
			var query=(location.search||"").match(new RegExp("[\\?&]"+name+"=([^&]+)","i"));
			return query?unescape(query[1]):null;
		};
		this.$loadJs=function(url,charset,callback) {
			var me=arguments.callee;
			var queue=me.queue||(me.queue={});
			charset=charset||$$.status.charset;
			url=url.replace('{$charset}',charset);
			if(url in queue) {
				if(callback) {
					if(queue[url])
						queue[url].push(callback);
					else
						callback();
				}
				return;
			}
			queue[url]=callback?[callback]:[];
			var script=_.__.createElement("script");
			script.type="text/javascript";
			script.charset=charset;
			script.onload=script.onreadystatechange=function() {
				if(script.readyState && script.readyState!="loaded" && script.readyState!="complete")
					return;
				script.onreadystatechange=script.onload=null;
				while(queue[url].length)
					queue[url].shift()();
				queue[url]=null;
			};
			script.src=url;
			_.__.getElementsByTagName("head")[0].appendChild(script);
		};
		this.$loadCss=function(file,charset){
			if (top.$$.browser.IE)
				_.__.createStyleSheet(file).charset=charset||$$.status.charset;
			else{
				var css=_.__.createElement("link");
				with (css){
					type="text\/css";
					rel="stylesheet";
					href=file;
				}
				_.__.$("head")[0].appendChild(css);
			}
		};
		this.$init=function(func){
			if (func) $$.module.init.push(func);
			else $$.module.init.each();
		};
		this.$parserRe=function(obj){
			var objList=[];
			var re_mod=/<[^>]+\smod=[\'\"]?([\w|]+)[^>]+/g;
			var re_page=/\smod_jmpInfo_page=[\'\"]?([^\'\"\s]+)/;
			var re_id=/id=[\'\"]?([\w\-]+)/i;
			var pa=null;
			var id=null;
			var el=null;
			(obj&&obj.innerHTML?obj:_.__.body).innerHTML.replace(re_mod,function(tag,mod){
				try{
					if(mod=="jmpInfo"){
						if(pa=tag.match(re_page))
							Ctrip.module.jmpInfo(pa[1]);
					}else if((id=tag.match(re_id))&&(el=$(id[1]))){
						if(mod in Ctrip.module)
							new Ctrip.module[mod](el);
						else
							objList.push(el)
					}
				}catch(e){
					$t("parserRe函数错误:"+func.toString().slice(0,50)+"...","red");
				};
				return "";
			});
			var clock=setInterval(function(){
				var obj=objList.shift();
				if (obj)
					_.$d(obj);
				else
					clearInterval(clock);
			},50);
		};
		this.$d=this.$dealElement=function(obj){
			Ctrip.Object.apply(obj);
			(obj.getAttribute("mod")||"").replace(/\w+/ig,function(mod){
				if (top.$$.module.list[mod]){
					if (!top.$$.module[mod].list){
						top.$$.module[mod].list=[];
						top.$loadJs("/common/css/tuna_calendar_071206.js","utf-8");
					}
					top.$$.module[mod].list.push(obj);
					top.$init();
				}else if (Ctrip.module[mod]){
					if(mod=='jmpInfo')
						Ctrip.module[mod](obj);
					else
						new Ctrip.module[mod](obj);
				}
				return '';
				/*
				else
					$t("错误:元素["+(obj.id||obj.tagName)+"]引用未知模块["+mod+"]","red");
				*/
			});
		};
		this.$fixElement=function(obj){
			//for debug
			function addEvent(el,evt,fn){
				if('attachEvent' in el)
					el.attachEvent('on'+evt,fn);
				else
					el.addEventListener(evt,fn);
			}
			function firstInput(el){
				el=el.getElementsByTagName('input');
				for(var i=0;i<el.length;i++)
					if(/checkbox|radio/.test(el[i].type))
						return el[i];
				return null;
			}
			function srcElement(e){
				if(!e)
					e=window.event;
				return e.srcElement||e.target;
			}
			function mover(lbl){
				var box=lbl._for;
				if(box){
					lbl.htmlFor=box.id||(box.id=$getUid());
					lbl._for=null;
				}
				var sty=lbl.style;
				sty.borderBottom='#aaa 1px dashed';
				sty.paddingBottom='0px';
				sty.color='#1E1A75';
			}
			function mout(lbl){
				var sty=lbl.style;
				sty.borderBottom='';
				sty.paddingBottom='';
				sty.color='';
			}
			obj=obj&&obj.nodeType?obj:_.__;
			if ($$.browser.IE6){
				var label=obj.getElementsByTagName("label");
				for (var i=0;i<label.length;i++){
					var el=firstInput(label[i]);
					if(el&&/checkbox|radio/.test(el.type))(function(lbl,box){
						lbl._for=box;
						addEvent(lbl,'mouseover',function(){mover(lbl)});
						addEvent(lbl,'mouseout',function(){mout(lbl)});
					})(label[i],el);
				}
			}
			if ($$.browser.IE){
				var select=obj.getElementsByTagName("select");
				for (var i=0;i<select.length;i++)
					select[i].onmousewheel=function(){
						return false;
					};
			}
		};
		this.$ajax=function(url,content,callback){
			var xmlVer=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"],xmlObj;
			try {
				xmlObj=new XMLHttpRequest();
			} catch(e) {
				for (var i=0;i<xmlVer.length;i++)
					try {
						xmlObj=new ActiveXObject(xmlVer[i]);
						break;
					} catch(e) {}
			}
			if (!xmlObj) return;
			xmlObj.open(content?"POST":"GET",url||_.location.href,!!callback);
			xmlObj.setRequestHeader("Content-Type","application\/x-www-form-urlencoded");
			xmlObj.setRequestHeader("If-Modified-Since",new Date(0));
			if (callback)
				xmlObj.onreadystatechange=function(){
					if (xmlObj.readyState==4)
						if (callback(xmlObj.status==200?xmlObj.responseText:null)===true){
							setTimeout(function(){
								_.$ajax(url,content,callback);
							},1000);
						}
				};
			xmlObj.send(content||'');
			return callback?xmlObj:(xmlObj.status==200?xmlObj.responseText:null);
		};
		function $getDebug(){
			var obj=top.frames["Ctrip_debug"];
			if (obj) return obj;
			with(obj=top.$c("iframe")){
				frameBorder=0;
				id=name="Ctrip_debug";
				style.border="1px solid red";
				style.width="400px";
				style.height="300px";
				style.position=$$.browser.IE6?"absolute":"fixed";
				style.bottom=style.right="10px";
			}
			top.$$.status.container.appendChild(obj);
			if ($$.browser.IE6)
				top.$r("scroll",function(){
					with($("Ctrip_debug").style){
						zoom=1;
						zoom=0;
					}
				});
			with((obj=$getDebug()).document){
				open();
				write("<style>body{margin:0;padding:0;font-family:fixedsys;font-size:12px;overflow:hidden}<\/style><body><\/body>");
				close();
			}
			return obj;
		}
		this.$t=function(info,color){
			if (!top.$$.status.debug)
				return;
			if (_!=top)
				return top.$t(info,color);
			var obj=$getDebug(),msg=info;
			with(obj.document.body){
				msg=new Date().getTime()%(1E7)+":"+msg;
				if (color)
					msg="<font color=\""+color+"\">"+msg+"<\/font>";
				innerHTML=msg+"<br \/>"+innerHTML;
			}
			return info;
		};
//		this.onerror=function(msg,url,line){
//			$t("<span title=\""+url+"\">行"+line+","+msg+"<\/span>","red");
//			return false;
//		};
		this.$alert=function(obj,info,showDisplay,direction1,direction2){
			var alertInfo=$("alertInfo"),alertTable=$("alertTable"),flag=1;
			if (typeof(obj)=="string")
				obj=$(obj);
			else
				Ctrip.Object.apply(obj);
			alertInfo.innerHTML=info;
			$$.status.alertDiv.style.display="";
			$$.status.alertDiv.$setPos(obj,direction1||"tl",direction2||"tr");
			$$.status.alertDiv.$setIframe();
			obj.className+=" pubGlobal_checkinfo_input01";
			if (showDisplay!==false)
				obj.$setDisplay();
			function clearAlertDiv(){
				obj.className=obj.className.replace("pubGlobal_checkinfo_input01","");
				$$.status.alertDiv.style.display="none";
				$$.status.alertDiv.$clearIframe();
				obj.$ur("onblur",clearAlertDiv);
				_.__.body.$ur("onmousedown",clearAlertDiv);
				obj.clearAlert=null;
				_.$alert.element=null;
			}
			if (obj.disabled)
				flag=0;
			else
				setTimeout(function(){
					try{obj.focus();}
					catch(e){flag=0;};
				},0);
			if (flag)
				obj.$r("onblur",clearAlertDiv);
			else
				_.__.body.$r("onmousedown",clearAlertDiv);
			_.$alert.element=obj;
			obj.clearAlert=clearAlertDiv;
		};
		
		//兼容
		this.checkinfo=this.$alert;
		this.$fix_height=function(){};
		
		//链接列表
		this.c_linklist={};
		
		//广告配置
		this.c_allyes_text={};
		this.c_allyes_delay=1000;
	};
	this.Object=function(){
		if (!this||this.nodeType==3||this.$) return this;
		if (this.__)
			this.$=function(objId){
				var obj=_.__.getElementById(objId);
				Ctrip.Object.apply(obj);
				return obj;
			};
		else
			this.$=function(objTag){
				var obj=this.getElementsByTagName(objTag);
				obj.$each=function(func){
					var flag;
					if (obj.length!==undefined)
						for (var i=0;i<obj.length&&(flag=func.call(this,obj[i],i))!==false;i++);
					else func.call(this,obj,0);
					return flag===false?0:1;
				};
				for (var i=0;i<obj.length;i++) Ctrip.Object.apply(obj[i]);
				return obj;
			};
		this.module={};
		if (!this.hasAttribute)
			this.hasAttribute=function(str){
				return typeof this.attributes[str]!="undefined";
			};
		this.$parentNode=function(){
			return Ctrip.Object.apply(this.parentNode);
		};
		this.$firstChild=function(){
			return Ctrip.Object.apply(this.firstChild);
		};
		this.$lastChild=function(){
			return Ctrip.Object.apply(this.lastChild);
		};
		this.$childNodes=function(){
			var obj=this.childNodes;
			for (var i=0;i<obj.length;i++)
				Ctrip.Object.apply(obj[i]);
			return obj;
		};
		this.$nSib=this.$nextSibling=function(){
			return Ctrip.Object.apply(this.nextSibling);
		};
		this.$pSib=this.$previousSibling=function(){
			return Ctrip.Object.apply(this.previousSibling);
		};
		this.$getStyle=function(style){
			var css=this.currentStyle||_.getComputedStyle(this,null);
			return style?css[style]:css;
		};
		this.$getPara=function(){
			var _t_para,para=(_t_para=this.getAttribute(arguments[0])||"").split(_t_para.indexOf("")>-1?"":"|");
			for (var i=0;i<Math.max(arguments.length-1,para.length);i++)
				para[i]=para[i]||arguments[i+1]||"";
			return para;
		};
		this.$r=this.$regEvent=function(eventList,funcList,hash){
			var obj=this;
			if (eventList.constructor!=Array) eventList=[eventList];
			if (funcList.constructor!=Array) funcList=[funcList];
			eventList.each(function(e){
				funcList.each(function(f){
					if (obj.__&&e.match(/^(on)?domready$/i)){
						if ($$.status.domReady)
							f();
						else
							$$.status.domReadyFunc.push(f);
						return;
					}
					if (obj.attachEvent) obj.attachEvent(e.replace(/^(on)?/i,"on"),f);
					else obj.addEventListener(e.replace(/^(on)?/i,""),f,false);
					if ($$.browser.IE6)
						$$.status.regEvent.push([obj,e,f]);
					if (hash){
						if (!$$.status.regEventHash[hash])
							$$.status.regEventHash[hash]=[];
						$$.status.regEventHash[hash].push([obj,e,f]);
					}
				});
			});
		};
		this.$ur=this.$unregEvent=function(eventList,funcList){
			var obj=this;
			if (eventList.constructor!=Array) eventList=[eventList];
			if (funcList.constructor!=Array) funcList=[funcList];
			eventList.each(function(e){
				funcList.each(function(f){
					if (obj.detachEvent) obj.detachEvent(e.replace(/^(on)?/i,"on"),f);
					else obj.removeEventListener(e.replace(/^(on)?/i,""),f,false);
				});
			});
		};
		this.$urh=this.$unregEventHash=function(hash){
			var regEvent=$$.status.regEventHash[hash];
			if (!regEvent) return;
			for (var i=regEvent.length-1;i>=0;i--){
				if (this.__||this==regEvent[i][0]){
					regEvent[i][0].$ur(regEvent[i][1],regEvent[i][2]);
					regEvent.splice(i,1);
				}
			}
			$$.status.regEventHash[hash]=regEvent.length?regEvent:null;
		};
		this.$getWin=function(){
			var doc=this.ownerDocument;
			return doc.parentWindow||doc.defaultView;
		};
		this.$g=this.$selNode=function(sel){
			function _m_query(sel,node){
				var em=[],re=sel.match(/^([\.\#]*)([a-zA-Z0-9\-_*]+)(.*)$/i);
				if (!re) return [];
				if (re[1]=="#"){
					var _t_obj=$(re[2]);
					if (_t_obj) em.push(_t_obj);
				}
				else if(re[1]==".")
					node.each(function(obj){
						$each(obj.$("*"),function(obj){
							if (obj.className.match(new RegExp("\\b"+re[2]+"\\b"))) em.push(Ctrip.Object.apply(obj));
						});
					});
				else
					for (var i=0;i<node.length;i++){
						var _t_obj=node[i].$(re[2]);
						if (_t_obj) for (var j=0;j<_t_obj.length;j++) em.push(_t_obj[j]);
					}
				re[3].replace(/\[([^!=]+)(=|!=)([^\]]*)\]/gi,function(a,b,c,d){
					var _t_em=em.slice(0);
					em=[];
					_t_em.each(function(obj){
						b={_class:"className",_for:"htmlFor"}["_"+b]||b;
						var _t_attr=obj[b]||obj.getAttribute(b);
						if (c!="="^_t_attr==d) em.push(Ctrip.Object.apply(obj));
					});
				});
				return em;
			}
			var em=[this==_?_.__.body:this];
			sel.replace(/(#|\*)/gi," $1").replace(/([^\^ ])\.(\w+)/gi,"$1[className=$2]").trim().split(/\s+/g).each(function(str){em=_m_query(str,em);});
			return em.length==0?null:em;
		};
		this.$getPos=function(){
			var obj=this,w,pos=[0,0],_t_height,flag,border={"thin":2,"medium":4,"thick":6},_t_border;
			function _m_fixBorder(){
				_t_border=[obj.$getStyle("borderLeftStyle").match(/none|hidden/)?0:obj.$getStyle("borderLeftWidth"),
				obj.$getStyle("borderTopStyle").match(/none|hidden/)?0:obj.$getStyle("borderTopWidth")];
				pos[0]+=border[_t_border[0]]||parseInt(_t_border[0])||0;
				pos[1]+=border[_t_border[1]]||parseInt(_t_border[1])||0;
			}
			do{
				w=Ctrip.Object.apply(obj).$getWin();
				if (obj.tagName.match(/^(iframe|frameset)$/i))
					_m_fixBorder();
				flag=-1;
				do{
					pos[0]+=obj.offsetLeft-obj.scrollLeft;
					pos[1]+=obj.offsetTop-($$.browser.Safari&&obj==w.document.body?0:obj.scrollTop);
					switch (obj.$getStyle("position")){
						case "absolute":
							_m_fixBorder();
							break;
						case "fixed":
							flag=1;
							break;
					}
				} while(obj.offsetParent&&obj!=obj.offsetParent&&(obj=Ctrip.Object.apply(obj.offsetParent))&&obj!=_.___);
				if ($$.browser.Safari){
					pos[0]+=w.__.body.leftMargin||0;
					pos[1]+=w.__.body.topMargin||0;
				}
				if (flag==1||w!=top){
					pos[0]+=w.___.scrollLeft*flag;
					pos[1]+=w.___.scrollTop*flag;
				}
			} while (obj=w.frameElement);
			return pos;
		};
		this.$setPos=function(obj2,pos1,pos2){
			function _m_query(re,i){
				function _m_cal(pos,obj,px,i){
					return px+{"l":0,"c":obj.offsetWidth/2,"r":obj.offsetWidth,"t":0,"m":obj.offsetHeight/2,"b":obj.offsetHeight}[pos||"l"]*i;
				}
				return _m_cal(pos1.match(re),this,_m_cal(pos2.match(re),obj2,pos[i],1),-1)+"px";
			}
			var pos=obj2.$getPos();
			pos1=pos1||"lt";
			pos2=pos2||"lb";
			this.style.left=_m_query.call(this,/[lcr]/i,0);
			this.style.top=_m_query.call(this,/[tmb]/i,1);
		};
		this.$setIframe=function(flag){
			if (flag!==true&&!$$.browser.IE6) return;
			if (this.module.iframe)
				iframe=this.module.iframe;
			else{
				function getIframe(){
					for (var i=0;i<top.$$.module.iframe.length;i++){
						if (top.$$.module.iframe[i].$getStyle("display")=="none")
							return top.$$.module.iframe[i];
					}
				}
				var iframe=getIframe();
				if (!iframe){
					iframe=top.$c("iframe");
					with(iframe.style){
						width=height="0px";
						background="#FFF";
						position="absolute";
						display="none";
						zIndex=100;
					}
					iframe.frameBorder=0;
					iframe.id=iframe.name=$getUid();
					top.$$.status.container.appendChild(iframe);
					top.$$.module.iframe.push(iframe);
					with(top.frames[iframe.id].document){
						open();
						write('<style>html,body{overflow:hidden}</style>');
						close();
					}
				}
				this.module.iframe=iframe;
			}
			iframe.$setPos(this,"tl","tl");
			with (iframe.style){
				width=this.offsetWidth+"px";
				height=this.offsetHeight+"px";
				display="";
			}
			return iframe;
		};
		this.$clearIframe=function(){
			var iframe=this.module.iframe;
			if (iframe){
				iframe.style.display="none";
				this.module.iframe=null;
			}
			return iframe;
		};
		function $abs(obj,flag,func){
			if (!obj) return null;
			flag=flag||"n";
			var re=new RegExp(({1:"n",3:"t",8:"c"}[obj.nodeType])||"o","i");
			return flag.match(re)?obj:func.call(obj,flag);
		}
		this.$nAbs=function(flag){
			var obj=this,objTmp=obj.firstChild||obj.nextSibling;
			if (!objTmp)
				do {
					obj=obj.parentNode;
					if (obj==_.__.body) return null;
					objTmp=obj.nextSibling;
				} while (!objTmp);
			return Ctrip.Object.apply($abs(objTmp,flag,arguments.callee));
		};
		this.$pAbs=function(flag){
			if (this==_.__.body) return null;
			var objTmp=this.previousSibling;
			if (objTmp){
				while (objTmp.lastChild)
					objTmp=objTmp.lastChild;
			}else
				objTmp=this.parentNode;
			return Ctrip.Object.apply($abs(objTmp,flag,arguments.callee));
		};
		this.$focusNext=function(){
			if (!this.form) return;
			try{this.blur();}catch(e){;};
			var obj=this.form.elements,flag;
			for (var i=0;i<obj.length;i++){
				if (flag){
					Ctrip.Object.apply(obj[i]);
					if (!obj[i].disabled&&obj[i].$isDisplay())
						try{obj[i].focus();return;}catch(e){};
				}
				if (obj[i]==this) flag=true;
			};
		};
		this.$setDisplay=function(){
			var pos=this.$getPos();
			with(top.___){
				scrollLeft=pos[0]-80;
				scrollTop=pos[1]-80;
			}
		};
		this.$isDisplay=function(){
			var obj=this;
			do {
				if (obj.tagName=="INPUT"&&obj.type=="hidden"||
					obj.$getStyle("display")=="none"||
					obj.$getStyle("visibility")=="hidden")
						return false;
			} while ((obj=obj.$parentNode())&&obj.nodeType==1);
			return true;
		};
		return this;
	};
	this.Array=function(){
		this.each=function(func){
			for (var i=0;i<this.length;i++)
				if ((func?func(this[i],i):this[i]())===false) return 0;
			return 1;
		};
		if ($$.browser.IE)
			this.map=function(func){
				var arr=[];
				for (var i=0;i<this.length;i++)
					arr.push(func(this[i]));
				return arr;
			};
	};
	this.Number=function(){
		this.parseCur=function(decimalDigits){
			var num=this.toFixed(decimalDigits||2),re=/(\d)(\d{3}[,\.])/;
			while(re.test(num))
				num=num.replace(re,"$1,$2");
			num=num.replace(/^(-?)\./,"$10.");
			return decimalDigits===0?num.replace(/\..*$/,""):num;
		};
	};
	this.String=function(){
		this.replaceWith=function(obj){
			return this.replace(/\{\$(\w+)\}/g,function(s,k){
				if(k in obj)
					return obj[k];
				else
					return s;
			});
		};
		this.trim=function(){
			return this.replace(/^\s+|\s+$/g,'');
		};
		this.isEmail=function(){
			var re=/^\w+([\-\+\.]\w+)*@\w+([\-\.]\w+)*\.\w+([\-\.]\w+)*$/;
			return re.test(this);
		};
		this.isDateTime=function(){
			var date=$$.status.version.match(/^zh-/)?this:this.replace(/^(\d{1,2})-(\d{1,2})-(\d{4})$/,"$3-$1-$2");
			var arr=date.match(/^((19|20)\d{2})-(\d{1,2})-(\d{1,2})$/);
			if (!arr) return false;
			for (var i=1;i<5;i++)
				arr[i]=parseInt(arr[i],10);
			if(arr[3]<1||arr[3]>12||arr[4]<1||arr[4]>31) return false;
			var _t_date=new Date(arr[1],arr[3]-1,arr[4]);
			return _t_date.getDate()==arr[4]?_t_date:null;
		};
		//判断身份证号码是否有效
		this.isChinaIDCard=function(){
			var num=this.toLowerCase().match(/./g);
			if (this.match(/^\d{17}[\dx]$/i)){
				var sum=0,times=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
				for (var i=0;i<17;i++)
					sum+=parseInt(num[i],10)*times[i];
				if ("10x98765432".charAt(sum%11)!=num[17])
					return false;
				return !!this.replace(/^\d{6}(\d{4})(\d{2})(\d{2}).+$/,"$1-$2-$3").isDateTime();
			}
			if (this.match(/^\d{15}$/))
				return !!this.replace(/^\d{6}(\d{2})(\d{2})(\d{2}).+$/,"19$1-$2-$3").isDateTime();
			return false;
		};
		this.parseStdDate=function(){
			var month="January|1@February|2@March|3@April|4@May|5@June|6@July|7@August|8@September|9@October|10@November|11@December|12",re=this.replace(/[ \-,\.\/]+/g,"-").replace(/(^|-)0+(?=\d+)/g,"$1").replace(/[a-z]{3,}/i,function(re){
				return (_t_re=month.match(new RegExp("(^|@)"+re+"[^\\|]*\\|(\\d+)","i")))?_t_re[2]:re;
			}).replace(/^([^-]{1,2}-[^-]{1,2})-([^-]{4})$/,"$2-$1");
			return re.isDateTime()?re:null;
		};
		this.parseEngDate=function(){
			var std=this.parseStdDate();
			if (!std) return null;
			var re=std.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);
			return "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec".split("|")[parseInt(re[2])-1] +"-"+re[3]+"-"+re[1];
		};
	};
	this.Date=function(){
		this.dateValue=function(){
			return new Date(this.getFullYear(),this.getMonth(),this.getDate());
		};
	};
	this.module=new function(){
		this.linklist=function(obj){
			var cls=obj.getAttribute('mod_linklist_class');
			if(cls===null) cls='pubSidebar_linkmargin01';
			var s='<a class="'+cls+'" href="{$link}" title="{$text}" target="{$target}">{$text}</a>';
			var a=obj.getAttribute('mod_linklist_id');
			if(!a||!(a=window.c_linklist[a])||a.constructor!==Array)
				return;
			for(var i=0;i<a.length;i++){
				var t=a[i].split('|',2);
				a[i]=s.replaceWith({
					text:$s2t(t[0]),
					link:t[1],
					target:a[i].target||'_blank'
				});
			}
			obj.innerHTML=a.join('');
		};
		this.allyes=function(obj){
			var user=attr("user")||attr("mod_allyes_user");
			if(!user){
				var buttons=attr('mod_allyes_buttons',window);
				var text=attr('mod_allyes_text',window.c_allyes_text);
				if(!buttons&&!text)
					return;
			}
			var c_div_template='<div class="pubGlobal_ad140x60" style="height:{$height}px">{$iframe}<\/div>';
			var c_txt_template='<div class="pubGlobal_adtxt140">{$text}<\/div>';
			var c_frm_template='<iframe marginheight="0" width="100%" height="100%" marginwidth="0" frameborder="0" scrolling="no" src="http://allyes.ctrip.com/main/adfshow?user={$user}&db=ctrip&border=0&local=yes"><\/iframe>';
			setTimeout(function(){
				if(user){
					if(user.indexOf('@')>-1)
						user=choose(user.split('@'));
					obj.innerHTML=c_frm_template.replace('{$user}',user);
				}else{
					var html=[];
					if(buttons)	html=buttons.map(function(b){
						b.button=b.button||';';
						return c_div_template.replace('{$height}',b.height)
							.replace('{$iframe}',c_frm_template.replace('{$user}',b.user));
					});
					if(text)
						html.push(c_txt_template.replace('{$text}',$s2t(text)));
					obj.innerHTML=html.join('');
				}
			},window.c_allyes_delay);
			function attr(name,context){
				var v=obj.getAttribute(name);
//alert("v----------"+v);			
				if(!v)
					return null;
				if(context)
					return context[v]||null;
				else
					return v;
			}
			function choose(arr){
				var re=/^(SearchFlights\.aspx|SearchHotels\.aspx|query\.asp)$/i;
				var pn=location.pathname;
				pn=pn.slice(pn.lastIndexOf('/')+1);
				return re.test(pn)?arr[0]:arr[1];
			}
		};
		
	this.notice=function(obj){
		//alert("11111-----"+obj);
			obj.module.notice=new function(){
		//alert("2222");	
				this.enabled=true;
				this.tip=obj.getAttribute("mod_notice_tip")||"";
				//this.tip=obj.getAttribute("mod_notice_tip");
				this.check=function(){
		//alert("this.enabled---"+this.enabled);		
		//alert("obj type----"+obj.tagname);	
					if (obj.module.notice.enabled){
	// alert("44");		
						with(obj){
	//alert("value-----"+module.notice.tip);						
							if (isNull()){
						
			//alert("7777---");
								
								style.color="gray";
								value=module.notice.tip;
								
							}else
		//	alert("66");			
								style.color="";
						}
					}
				};
				this.isNull=obj.isNull=function(){
					return obj.value.trim()==""||obj.value==obj.module.notice.tip;
				};
			};
			obj.$r("focus",function(){
				if (obj.module.notice.enabled){
					obj.style.color="";
					if (obj.value==obj.module.notice.tip)
						obj.value="";
				}
			});
			obj.$r("blur",function(){
				setTimeout(obj.module.notice.check,1);
			});
			obj.module.notice.check();
		};
		this.tab=function(obj){
			var obj1=_.$g(obj.getAttribute("mod_tab_button")||"");
			var obj2=_.$g(obj.getAttribute("mod_tab_panel")||"");
			var select=parseInt(obj.getAttribute("mod_tab_select")||1,10);
			var event=((obj.getAttribute("mod_tab_event")||"").match(/^mouseover$/i)||"click").toString();
			var c={"true":"_"+"current","false":"_"+"nocurrent"};
			if (!obj1||!obj2) return;
			obj.module.tab=new function(){
				this.funcListHash={};
				this.select=function(i){
					if (this.funcListHash[i-1])
						this.funcListHash[i-1]();
				};
			};
			obj1.each(function(objTmp1,j){
				obj.module.tab.funcListHash[j]=function(){
					obj1.each(function(objTmp2,k){
						objTmp2.className=objTmp2.className.replace(c[j!=k],c[j==k]);
						if (obj2[k]) obj2[k].style.display=(j==k)?"":"none";
					});
				};
				objTmp1.$r(event,obj.module.tab.funcListHash[j]);
			});
			obj.module.tab.select(select);
		};
		this.display=function(obj){
			var selList=obj.$getPara("mod_display_panel"),list=[];
			selList.each(function(sel){
				sel=_.$(sel)||_.$selNode(sel);
				if (sel){
					if (sel.length)
						sel.each(function(sel){list.push(sel);});
					else
						list.push(sel);
				}
			});
			obj.$r("click",function(){
				(function(obj){
					for (var i=0;i<obj.childNodes.length;i++){
						with(obj.childNodes[i]){
							if (nodeType==3){
								var re=new RegExp($$.string.display.match(/[^@]+/g).join("|"),"gi");
								nodeValue=nodeValue.replace(re,function(str){
									var re=new RegExp("@"+str+"\\|([^@]+)|([^@]+)\\|"+str+"@","i");
									var arr=$$.string.display.match(re);
									return arr[1]||arr[2];
								});
							}else
								arguments.callee(obj.childNodes[i]);
						}
					}
				})(obj);
				list.each(function(obj){
					obj.style.display=obj.$getStyle("display")=="none"?"":"none";
				});
			});
		};
		this.selectAll=function(obj){
			var input=$selNode(obj.getAttribute("mod_selectAll_input")||"");
			if (!input) return;
			input.each(function(_t_input){
				if (_t_input!=obj)
					_t_input.$r("onclick",function(){
						obj.checked=input.each(function(_t_input){
							if (_t_input!=obj&&!_t_input.checked)
								return false;
						});
					});
			});
			obj.$r("click",function(){
				input.each(function(_t_input){
					_t_input.checked=obj.checked;
				});
			});
		};
		this.validate=function(obj){
			var msgTrue=_.$(obj.getAttribute("mod_validate_true")||"");
			var msgFalse=_.$(obj.getAttribute("mod_validate_false")||"");
			var fun=obj.getAttribute("mod_validate_function")||"";
			if (!fun) return;
			var re=fun.match(/^\/(.*?[^\\])\/([gmi]*?)$/);
			var clock,flagTrue,flagFalse;
			fun=_[fun];
			if (re||fun){
				obj.module.validate=new function(){
					this.check=function(){
						if (obj.value||!msgTrue&&!msgFalse)
							flagFalse=!(flagTrue=fun?
								fun(obj.value,obj):
								obj.value.match(new RegExp(re[1],re[2])));
						else
							flagTrue=flagFalse=false;
						if (msgTrue) msgTrue.style.display=flagTrue?"":"none";
						if (msgFalse) msgFalse.style.display=flagFalse?"":"none";
					};
				};
				obj.$r("focus",function(){
					clock=setInterval(obj.module.validate.check,200);
				});
				obj.$r("blur",function(){
					obj.module.validate.check();
					clearInterval(clock);
				});
			}
		};
	};
	this.debug=new function(){
		
	};
	this.window.apply(_);
	this.Object.apply(_);
	this.Object.apply(_.__);
	this.Object.apply(_.___);
	this.Array.apply(_.Array.prototype);
	this.Number.apply(_.Number.prototype);
	this.String.apply(_.String.prototype);
	this.Date.apply(_.Date.prototype);
	this.Object.apply($$.status.alertDiv);
	this.init=new function(){
		//简繁转换函数
		if($$.status.charset=='big5')
			__.write('<script src="/common/css/public_s2t.js" charset="utf-8"></script>');
		else
			_.$s2t=function(s){return s};
		//修正IE6背景图不缓存
		if ($$.browser.IE6)
			__.execCommand("BackgroundImageCache",false,true);
		//初始化debug
		$$.status.debug=/^(true|1)$/.test($getQuery("debug"));
		//初始化$alert函数
		$$.status.alertDiv.innerHTML=$$.status.version.match(/^zh-/)?"<table id=\"alertTable\" cellpadding=\"0\" cellspacing=\"0\" style=\"text-align:center;\"><tr><td style=\"width:10px;height:10px;background:url(/common/css/blk_jmpInfo02_tl.gif) left top no-repeat;\"><\/td><td style=\"height:10px;background:url(/\common\/css\/blk_jmpInfo02_tm.gif) left top repeat-x;\"><\/td><td style=\"width:10px;height:10px;background:url(/\common\/css\/blk_jmpInfo02_tr.gif) left top no-repeat;\"><\/td><\/tr><tr><td style=\"width:10px;height:10px;background:url(/common/css/blk_jmpInfo02_ml.gif) left top repeat-y;\"><\/td><td id=\"alertInfo\" style=\"margin:0;padding:5px 10px 10px 5px;background:#FFFFE8;\">内容<\/td><td style=\"width:10px;height:10px;background:url(/\common\/css\/blk_jmpInfo02_mr.gif) left top repeat-y;\"><\/td><\/tr><tr><td style=\"width:10px;height:10px;background:url(/\common\/css\/blk_jmpInfo02_bl.gif) left top no-repeat;\"><\/td><td style=\"height:10px;background:url(/\common\/css\/blk_jmpInfo02_bm.gif) left top repeat-x;\"><\/td><td style=\"width:10px;height:10px;background:url(/\common\/css\/blk_jmpInfo02_br.gif) left top no-repeat;\"><\/td><\/tr><\/table>":"<table id=\"alertTable\" style=\"font-family:Arial;margin:0;\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"margin:0;padding:0px 2px 2px 0px;background:#E7E7E7;\"><div id=\"alertInfo\" style=\"margin:0px;padding:10px;font-size:12px;text-align:left;background:#FFFFE8;border:1px solid #FFDF47;color:#000;white-space:nowrap;\">内容<\/div><\/td><\/tr><\/table>";
		//初始化domReady事件
		function evtDomReady(e){
			var func;
			$$.status.domReady=true;
			while (func=$$.status.domReadyFunc.shift())
				try{func(e);}catch(e){$t("domReady函数错误:"+func.toString().slice(0,50)+"...","red");};
		}
		if($$.browser.Moz||$$.browser.Opera)
			_.$r("DOMContentLoaded",evtDomReady);
		else if($$.browser.IE){
			_.__.write("<script id=\"ieDomReady\" src=\":\/\/\" defer=\"true\"><\/script>");
			_.__.getElementById("ieDomReady").onreadystatechange=function(){
				if(this.readyState=="complete")
					evtDomReady();
			};
		}else if($$.browser.Safari){
			var domReadyTimer=setInterval(function(){
				if(_.__.readyState=="loaded"||_.__.readyState=="complete"){
					clearInterval(domReadyTimer);
					evtDomReady();
				}
			},10); 
		}
		if ($$.browser.IE6)
			_.$r("unload",function(){
				var regEvent;
				while(regEvent=$$.status.regEvent.shift()){
					if (regEvent[0])
						regEvent[0].$ur(regEvent[1],regEvent[2]);
				}
			});
		_.$r("domready",[function(){
			Ctrip.Object.apply(_.__.body);
		},_.$parserRe,_.$fixElement]);
	};
};
var Ctrip=new $Ctrip(window);

//////
Ctrip.module.jmpInfo=(function(){
	var c_page_folder='\/webresource\/ui\/jmpinfo_tuna\/';
	var c_css_path='/common/css/control_jmpinfo_tuna_071206.css';
	var c_para_js={
		CraftType:'/common/css/CraftType_{$charset}.js'
	};
	var c_pos_map={
		"align-center":"cbct",
		"align-left":"lblt",
		"corner-left":"rblt",
		"align-right":"rbrt",
		"corner-right":"lbrt",
		"above-align-left":"ltlb",
		"above-align-right":"rtrb"
	};
	
	var c_gid_prefix='__jpi_';
	
	var c_hide_delay=200;
	var c_show_delay=400;
	
	var	div=null,
		cur=null,
		pre=null,
		
		gid=0,
	
		timerHide=null,
		timerShow=null,
	
		dataHash={},
		pageHash={},
		paraHash={},
	
		initFlag=false;

	window.$r('domReady',init);

	return function(arg){
		init();
		if(arg.nodeType==1){
			if(!arg.id)
				arg.id=c_gid_prefix+gid++;
			setConfig(arg);
		}else{
			requestPage(arg);
		}
	};
	
	function init(){
		if(initFlag)
			return;
		initFlag=true;
		$loadCss(c_css_path);
		div=document.createElement("div");
		div.id='tuna_jmpinfo';
		div.style.cssText='visibility:hidden;position:absolute;z-index:120;overflow:hidden';
		$$.status.container.appendChild(div);
		div=$(div.id);
		var de=document.documentElement;
		if(de.attachEvent)
			de.attachEvent('onmouseover',hover);
		else
			de.addEventListener('mouseover',hover,false);
	}
	function hover(e){
		var el=src(e),mo=null;
		if(el.id&&(el.id in dataHash)){
			if(el!=cur&&el!=pre){
				pre=el;
				clearTimeout(timerShow);
				timerShow=setTimeout(show,c_show_delay);
			}
		}else if((mo=el.getAttribute('mod'))=='jmpInfo'){
			setConfig(el);
			if(el!=cur&&el!=pre){
				pre=el;
				clearTimeout(timerShow);
				timerShow=setTimeout(show,c_show_delay);
			}			
		}else if(cur){
			if(inArea(el,cur,div))
				clearTimeout(timerHide);
			else
				timerHide=setTimeout(hide,c_hide_delay);
		}else if(pre){
			if(!inArea(el,pre)){
				clearTimeout(timerShow);
				pre=null;
			}
		}
	}
	function getPos(el){
		if(!el.$getPos) Ctrip.Object.apply(el);
		var p=el.$getPos();
		return {left:p[0],top:p[1]};
	}
	function display(el,pos){
		var st=el.style;
		if(!pos){
			st.visibility='hidden';
			el.$clearIframe();
		}else{
			var st=el.style;
			st.left=pos.left+'px';
			st.top=pos.top+'px';
			st.visibility='visible';
			el.$setIframe();
		}
	}
	function show(){
		if(!pre)
			return;
		var config=getConfig(pre);
		if(!config)
			return;
		cur=pre;
		pre=null;
		div.innerHTML=pageHash[config.page];
		for(var i=1;el=document.getElementById('para'+i);i++)
			el.innerHTML=config.content[i-1]||'';
		for(var i=1;el=document.getElementById('array'+i);i++)
			el.innerHTML=config.para[i-1]||'';
		display(div,decidePos(cur,config.position));
	}
	function hide(){
		cur=null;
		display(div,null);
	}
	function inArea(el,p1,p2){
		while(el&&el!=p1&&el!=p2)
			el=el.parentNode;
		return !!el;
	}
	function src(evt){
		evt=evt||window.event;
		return evt.srcElement||evt.target;
	}
	function decidePos(el,rela){
		var p=getPos(el);
		var w0=el.offsetWidth,h0=el.offsetHeight;
		var w1=div.offsetWidth,h1=div.offsetHeight;
		var s1={l:0,c:w0>>1,r:w0};
		var s2={t:0,c:h0>>1,b:h0};
		var d1={l:0,c:w1>>1,r:w1};
		var d2={t:0,c:h1>>1,b:h1};
		p.left+=s1[rela[0]]-d1[rela[2]];
		p.top+=s2[rela[1]]-d2[rela[3]];
		return p;
	}
	function setConfig(el){
		var page=attr(el,'mod_jmpInfo_page','default_normal.asp');
		var obj=requestPage(page);
		obj.position=(c_pos_map[attr(el,'mod_jmpInfo_position','align-left')]||'lblt').split('');
		obj.content=attr(el,'mod_jmpInfo_content','').split('|');
		dataHash[el.id]=obj;
	}
	function getConfig(el){
		var d=dataHash[el.id];
		if(!pageHash[d.page])
			return null;
		if(d.search)
			d.para=d.search.hash[d.search.key]||[];
		return d;
	}
	function attr(el,name,def){
		return el.getAttribute(name)||def||'';
	}
	function requestPage(page){
		var p=page,s=null;
		var i=page.indexOf('?');
		if(i>=0){
			p=page.slice(0,i).trim();
			s=requestPara(page.slice(i+1));
		}
		if(!(p in pageHash))
			doRequestPage(p);
		return {page:p,search:s};
	}
	function doRequestPage(p){
		pageHash[p]=false;
		$ajax(c_page_folder+p,null,function(html){
			if(html)
				pageHash[p]=html.replace(/\n/g,'').replace(/^[\s\S]*<body.*?>|<\/body>[\s\S]*$/gi,'');
		});
	}
	function requestPara(s){
		var i=s.indexOf('=');
		if(i==-1)
			return null;
		var type=s.slice(0,i);
		var key=s.slice(i+1);
		if(!(type in paraHash))
			doRequestPara(type);
		return {hash:paraHash[type],key:key};
	}
	function doRequestPara(type){
		var p=paraHash[type]={};
		$loadJs(c_para_js[type],null,function(){
			var a=$$.module.jmpInfo.array[type].slice(1,-1).split('@');
			for(var i=0;i<a.length;i++){
				var b=a[i].split('|');
				p[b[0]]=b;
			}
		});
	}
})();