$(document).ready(function(){(gDom=whiich.unit.getDomIfExist('div#w-masthead'))&&whiich.module.masthead(gDom);(gDom=whiich.unit.getDomIfExist('div#f-findhotelfrom'))&&whiich.module.findhotelfrom(gDom);(gDom=whiich.unit.getDomIfExist('div#f-resultsList'))&&whiich.module.resultsList(gDom)});whiich={};whiich.unit={getDomIfExist:function(xpath){var dom=$(xpath);return(dom.length>0)?dom:null}};whiich.config={searchUrl:'/server/search.php',regexMail:/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/};whiich.tmpVars={};whiich.common={autoComplete:function(modId,conId){var wDS=new YAHOO.widget.DS_XHR(whiich.config.searchUrl,['\n','\t']);wDS.responseType=YAHOO.widget.DS_XHR.TYPE_FLAT;var wAC=new YAHOO.widget.AutoComplete(modId,conId,wDS);wAC.maxResultsDisplayed=10;wAC.minQueryLength=3;wAC.queryDelay=0.3;wAC.highlightClassName='highlight';wAC.formatResult=function(oResultItem,sQuery){YAHOO.util.Dom.removeClass(document.getElementById(modId),'loading');var sKey=oResultItem[0];this.querystring=sQuery;return sKey.replace(sQuery,'<q>'+sQuery+'</q>')};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);YAHOO.log("Property minQueryLength is set to -1","info",this.toString());return}var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex}}if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break}}}if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1}this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart)}else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null}}if((sQuery&&(sQuery.length<this.minQueryLength))||(!sQuery&&this.minQueryLength>0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID)}this._toggleContainer(false);YAHOO.util.Dom.removeClass(document.getElementById(modId),'loading');YAHOO.log("Query \""+sQuery+"\" is too short","info",this.toString());return}sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;sQuery=this.doBeforeSendQuery(sQuery);YAHOO.util.Dom.addClass(this._oTextbox,'loading');this.dataRequestEvent.fire(this,sQuery);YAHOO.log("Sending query \""+sQuery+"\"","info",this.toString());this.dataSource.getResults(this._populateList,sQuery,this)}},setDomsShowAndHide:function(target,doms,sw,css,speed){if(sw==undefined)sw=true;speed=speed||'slow';sw=sw?false:true;var css=sw?css[0]:css[1];$(target).removeClass().addClass(css);sw?$(doms).show(speed):$(doms).hide(speed);return sw},appendMsg:function(target,msg){$(target).find('p').remove();$(target).append(msg)}};whiich.module={masthead:function(subDom){var searchInput=subDom.find('input').get(0);var form=subDom.find('form').get(0);$(form).submit(function(){if($(searchInput).val()==''){return false}});whiich.common.autoComplete('s-keyword','s-tip')},findhotelfrom:function(subDom){whiich.common.autoComplete('s-keyword1','s-tip1');subDom.find('form').submit(function(){var name=subDom.find('input:eq(0)').val();var city=subDom.find('input:eq(1)').val();if(($.trim(name)=='')&&($.trim(city)=='')){return false}})},resultsList:function(subDom){var item=subDom.find('.newsbox');item.hover(function(){$(this).addClass("newsbox_bgcolor")},function(){$(this).removeClass("newsbox_bgcolor")});item.click(function(){var accUrl=$(this).find('h2:eq(0)').find('a:eq(0)').attr('href');top.location.href=accUrl})}};
