/*
 * jQuery JavaScript Library v1.4.2
 * http://jquery.com/
 *
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2010, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Sat Feb 13 22:33:48 2010 -0500
 */
(function(window,undefined){var jQuery=function(selector,context){return new jQuery.fn.init(selector,context)},_jQuery=window.jQuery,_$=window.$,document=window.document,rootjQuery,quickExpr=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,isSimple=/^.[^:#\[\.,]*$/,rnotwhite=/\S/,rtrim=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,rsingleTag=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,userAgent=navigator.userAgent,browserMatch,readyBound=false,readyList=[],DOMContentLoaded,toString=Object.prototype.toString,hasOwnProperty=Object.prototype.hasOwnProperty,push=Array.prototype.push,slice=Array.prototype.slice,indexOf=Array.prototype.indexOf;jQuery.fn=jQuery.prototype={init:function(selector,context){var match,elem,ret,doc;if(!selector){return this}if(selector.nodeType){this.context=this[0]=selector;this.length=1;return this}if(selector==="body"&&!context){this.context=document;this[0]=document.body;this.selector="body";this.length=1;return this}if(typeof selector==="string"){match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1]){doc=(context?context.ownerDocument||context:document);ret=rsingleTag.exec(selector);if(ret){if(jQuery.isPlainObject(context)){selector=[document.createElement(ret[1])];jQuery.fn.attr.call(selector,context,true)}else{selector=[doc.createElement(ret[1])]}}else{ret=buildFragment([match[1]],[doc]);selector=(ret.cacheable?ret.fragment.cloneNode(true):ret.fragment).childNodes}return jQuery.merge(this,selector)}else{elem=document.getElementById(match[2]);if(elem){if(elem.id!==match[2]){return rootjQuery.find(selector)}this.length=1;this[0]=elem}this.context=document;this.selector=selector;return this}}else{if(!context&&/^\w+$/.test(selector)){this.selector=selector;this.context=document;selector=document.getElementsByTagName(selector);return jQuery.merge(this,selector)}else{if(!context||context.jquery){return(context||rootjQuery).find(selector)}else{return jQuery(context).find(selector)}}}}else{if(jQuery.isFunction(selector)){return rootjQuery.ready(selector)}}if(selector.selector!==undefined){this.selector=selector.selector;this.context=selector.context}return jQuery.makeArray(selector,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return slice.call(this,0)},get:function(num){return num==null?this.toArray():(num<0?this.slice(num)[0]:this[num])},pushStack:function(elems,name,selector){var ret=jQuery();if(jQuery.isArray(elems)){push.apply(ret,elems)}else{jQuery.merge(ret,elems)}ret.prevObject=this;ret.context=this.context;if(name==="find"){ret.selector=this.selector+(this.selector?" ":"")+selector}else{if(name){ret.selector=this.selector+"."+name+"("+selector+")"}}return ret},each:function(callback,args){return jQuery.each(this,callback,args)},ready:function(fn){jQuery.bindReady();if(jQuery.isReady){fn.call(document,jQuery)}else{if(readyList){readyList.push(fn)}}return this},eq:function(i){return i===-1?this.slice(i):this.slice(i,+i+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(slice.apply(this,arguments),"slice",slice.call(arguments).join(","))},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem)}))},end:function(){return this.prevObject||jQuery(null)},push:push,sort:[].sort,splice:[].splice};jQuery.fn.init.prototype=jQuery.fn;jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options,name,src,copy;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}if(typeof target!=="object"&&!jQuery.isFunction(target)){target={}}if(length===i){target=this;--i}for(;i<length;i++){if((options=arguments[i])!=null){for(name in options){src=target[name];copy=options[name];if(target===copy){continue}if(deep&&copy&&(jQuery.isPlainObject(copy)||jQuery.isArray(copy))){var clone=src&&(jQuery.isPlainObject(src)||jQuery.isArray(src))?src:jQuery.isArray(copy)?[]:{};target[name]=jQuery.extend(deep,clone,copy)}else{if(copy!==undefined){target[name]=copy}}}}}return target};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep){window.jQuery=_jQuery}return jQuery},isReady:false,ready:function(){if(!jQuery.isReady){if(!document.body){return setTimeout(jQuery.ready,13)}jQuery.isReady=true;if(readyList){var fn,i=0;while((fn=readyList[i++])){fn.call(document,jQuery)}readyList=null}if(jQuery.fn.triggerHandler){jQuery(document).triggerHandler("ready")}}},bindReady:function(){if(readyBound){return}readyBound=true;if(document.readyState==="complete"){return jQuery.ready()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",DOMContentLoaded,false);window.addEventListener("load",jQuery.ready,false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",DOMContentLoaded);window.attachEvent("onload",jQuery.ready);var toplevel=false;try{toplevel=window.frameElement==null}catch(e){}if(document.documentElement.doScroll&&toplevel){doScrollCheck()}}}},isFunction:function(obj){return toString.call(obj)==="[object Function]"},isArray:function(obj){return toString.call(obj)==="[object Array]"},isPlainObject:function(obj){if(!obj||toString.call(obj)!=="[object Object]"||obj.nodeType||obj.setInterval){return false}if(obj.constructor&&!hasOwnProperty.call(obj,"constructor")&&!hasOwnProperty.call(obj.constructor.prototype,"isPrototypeOf")){return false}var key;for(key in obj){}return key===undefined||hasOwnProperty.call(obj,key)},isEmptyObject:function(obj){for(var name in obj){return false}return true},error:function(msg){throw msg},parseJSON:function(data){if(typeof data!=="string"||!data){return null}data=jQuery.trim(data);if(/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return window.JSON&&window.JSON.parse?window.JSON.parse(data):(new Function("return "+data))()}else{jQuery.error("Invalid JSON: "+data)}},noop:function(){},globalEval:function(data){if(data&&rnotwhite.test(data)){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.support.scriptEval){script.appendChild(document.createTextNode(data))}else{script.text=data}head.insertBefore(script,head.firstChild);head.removeChild(script)}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()===name.toUpperCase()},each:function(object,callback,args){var name,i=0,length=object.length,isObj=length===undefined||jQuery.isFunction(object);if(args){if(isObj){for(name in object){if(callback.apply(object[name],args)===false){break}}}else{for(;i<length;){if(callback.apply(object[i++],args)===false){break}}}}else{if(isObj){for(name in object){if(callback.call(object[name],name,object[name])===false){break}}}else{for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}}return object},trim:function(text){return(text||"").replace(rtrim,"")},makeArray:function(array,results){var ret=results||[];if(array!=null){if(array.length==null||typeof array==="string"||jQuery.isFunction(array)||(typeof array!=="function"&&array.setInterval)){push.call(ret,array)}else{jQuery.merge(ret,array)}}return ret},inArray:function(elem,array){if(array.indexOf){return array.indexOf(elem)}for(var i=0,length=array.length;i<length;i++){if(array[i]===elem){return i}}return -1},merge:function(first,second){var i=first.length,j=0;if(typeof second.length==="number"){for(var l=second.length;j<l;j++){first[i++]=second[j]}}else{while(second[j]!==undefined){first[i++]=second[j++]}}first.length=i;return first},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++){if(!inv!==!callback(elems[i],i)){ret.push(elems[i])}}return ret},map:function(elems,callback,arg){var ret=[],value;for(var i=0,length=elems.length;i<length;i++){value=callback(elems[i],i,arg);if(value!=null){ret[ret.length]=value}}return ret.concat.apply([],ret)},guid:1,proxy:function(fn,proxy,thisObject){if(arguments.length===2){if(typeof proxy==="string"){thisObject=fn;fn=thisObject[proxy];proxy=undefined}else{if(proxy&&!jQuery.isFunction(proxy)){thisObject=proxy;proxy=undefined}}}if(!proxy&&fn){proxy=function(){return fn.apply(thisObject||this,arguments)}}if(fn){proxy.guid=fn.guid=fn.guid||proxy.guid||jQuery.guid++}return proxy},uaMatch:function(ua){ua=ua.toLowerCase();var match=/(webkit)[ \/]([\w.]+)/.exec(ua)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua)||/(msie) ([\w.]+)/.exec(ua)||!/compatible/.test(ua)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua)||[];return{browser:match[1]||"",version:match[2]||"0"}},browser:{}});browserMatch=jQuery.uaMatch(userAgent);if(browserMatch.browser){jQuery.browser[browserMatch.browser]=true;jQuery.browser.version=browserMatch.version}if(jQuery.browser.webkit){jQuery.browser.safari=true}if(indexOf){jQuery.inArray=function(elem,array){return indexOf.call(array,elem)}}rootjQuery=jQuery(document);if(document.addEventListener){DOMContentLoaded=function(){document.removeEventListener("DOMContentLoaded",DOMContentLoaded,false);jQuery.ready()}}else{if(document.attachEvent){DOMContentLoaded=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",DOMContentLoaded);jQuery.ready()}}}}function doScrollCheck(){if(jQuery.isReady){return}try{document.documentElement.doScroll("left")}catch(error){setTimeout(doScrollCheck,1);return}jQuery.ready()}function evalScript(i,elem){if(elem.src){jQuery.ajax({url:elem.src,async:false,dataType:"script"})}else{jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"")}if(elem.parentNode){elem.parentNode.removeChild(elem)}}function access(elems,key,value,exec,fn,pass){var length=elems.length;if(typeof key==="object"){for(var k in key){access(elems,k,key[k],exec,fn,value)}return elems}if(value!==undefined){exec=!pass&&exec&&jQuery.isFunction(value);for(var i=0;i<length;i++){fn(elems[i],key,exec?value.call(elems[i],i,fn(elems[i],key)):value,pass)}return elems}return length?fn(elems[0],key):undefined}function now(){return(new Date).getTime()}(function(){jQuery.support={};var root=document.documentElement,script=document.createElement("script"),div=document.createElement("div"),id="script"+now();div.style.display="none";div.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var all=div.getElementsByTagName("*"),a=div.getElementsByTagName("a")[0];if(!all||!all.length||!a){return}jQuery.support={leadingWhitespace:div.firstChild.nodeType===3,tbody:!div.getElementsByTagName("tbody").length,htmlSerialize:!!div.getElementsByTagName("link").length,style:/red/.test(a.getAttribute("style")),hrefNormalized:a.getAttribute("href")==="/a",opacity:/^0.55$/.test(a.style.opacity),cssFloat:!!a.style.cssFloat,checkOn:div.getElementsByTagName("input")[0].value==="on",optSelected:document.createElement("select").appendChild(document.createElement("option")).selected,parentNode:div.removeChild(div.appendChild(document.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};script.type="text/javascript";try{script.appendChild(document.createTextNode("window."+id+"=1;"))}catch(e){}root.insertBefore(script,root.firstChild);if(window[id]){jQuery.support.scriptEval=true;delete window[id]}try{delete script.test}catch(e){jQuery.support.deleteExpando=false}root.removeChild(script);if(div.attachEvent&&div.fireEvent){div.attachEvent("onclick",function click(){jQuery.support.noCloneEvent=false;div.detachEvent("onclick",click)});div.cloneNode(true).fireEvent("onclick")}div=document.createElement("div");div.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";var fragment=document.createDocumentFragment();fragment.appendChild(div.firstChild);jQuery.support.checkClone=fragment.cloneNode(true).cloneNode(true).lastChild.checked;jQuery(function(){var div=document.createElement("div");div.style.width=div.style.paddingLeft="1px";document.body.appendChild(div);jQuery.boxModel=jQuery.support.boxModel=div.offsetWidth===2;document.body.removeChild(div).style.display="none";div=null});var eventSupported=function(eventName){var el=document.createElement("div");eventName="on"+eventName;var isSupported=(eventName in el);if(!isSupported){el.setAttribute(eventName,"return;");isSupported=typeof el[eventName]==="function"}el=null;return isSupported};jQuery.support.submitBubbles=eventSupported("submit");jQuery.support.changeBubbles=eventSupported("change");root=script=div=all=a=null})();jQuery.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var expando="jQuery"+now(),uuid=0,windowData={};jQuery.extend({cache:{},expando:expando,noData:{embed:true,object:true,applet:true},data:function(elem,name,data){if(elem.nodeName&&jQuery.noData[elem.nodeName.toLowerCase()]){return}elem=elem==window?windowData:elem;var id=elem[expando],cache=jQuery.cache,thisCache;if(!id&&typeof name==="string"&&data===undefined){return null}if(!id){id=++uuid}if(typeof name==="object"){elem[expando]=id;thisCache=cache[id]=jQuery.extend(true,{},name)}else{if(!cache[id]){elem[expando]=id;cache[id]={}}}thisCache=cache[id];if(data!==undefined){thisCache[name]=data}return typeof name==="string"?thisCache[name]:thisCache},removeData:function(elem,name){if(elem.nodeName&&jQuery.noData[elem.nodeName.toLowerCase()]){return}elem=elem==window?windowData:elem;var id=elem[expando],cache=jQuery.cache,thisCache=cache[id];if(name){if(thisCache){delete thisCache[name];if(jQuery.isEmptyObject(thisCache)){jQuery.removeData(elem)}}}else{if(jQuery.support.deleteExpando){delete elem[jQuery.expando]}else{if(elem.removeAttribute){elem.removeAttribute(jQuery.expando)}}delete cache[id]}}});jQuery.fn.extend({data:function(key,value){if(typeof key==="undefined"&&this.length){return jQuery.data(this[0])}else{if(typeof key==="object"){return this.each(function(){jQuery.data(this,key)})}}var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length){data=jQuery.data(this[0],key)}return data===undefined&&parts[1]?this.data(parts[0]):data}else{return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value)})}},removeData:function(key){return this.each(function(){jQuery.removeData(this,key)})}});jQuery.extend({queue:function(elem,type,data){if(!elem){return}type=(type||"fx")+"queue";var q=jQuery.data(elem,type);if(!data){return q||[]}if(!q||jQuery.isArray(data)){q=jQuery.data(elem,type,jQuery.makeArray(data))}else{q.push(data)}return q},dequeue:function(elem,type){type=type||"fx";var queue=jQuery.queue(elem,type),fn=queue.shift();if(fn==="inprogress"){fn=queue.shift()}if(fn){if(type==="fx"){queue.unshift("inprogress")}fn.call(elem,function(){jQuery.dequeue(elem,type)})}}});jQuery.fn.extend({queue:function(type,data){if(typeof type!=="string"){data=type;type="fx"}if(data===undefined){return jQuery.queue(this[0],type)}return this.each(function(i,elem){var queue=jQuery.queue(this,type,data);if(type==="fx"&&queue[0]!=="inprogress"){jQuery.dequeue(this,type)}})},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type)})},delay:function(time,type){time=jQuery.fx?jQuery.fx.speeds[time]||time:time;type=type||"fx";return this.queue(type,function(){var elem=this;setTimeout(function(){jQuery.dequeue(elem,type)},time)})},clearQueue:function(type){return this.queue(type||"fx",[])}});var rclass=/[\n\t]/g,rspace=/\s+/,rreturn=/\r/g,rspecialurl=/href|src|style/,rtype=/(button|input)/i,rfocusable=/(button|input|object|select|textarea)/i,rclickable=/^(a|area)$/i,rradiocheck=/radio|checkbox/;jQuery.fn.extend({attr:function(name,value){return access(this,name,value,true,jQuery.attr)},removeAttr:function(name,fn){return this.each(function(){jQuery.attr(this,name,"");if(this.nodeType===1){this.removeAttribute(name)}})},addClass:function(value){if(jQuery.isFunction(value)){return this.each(function(i){var self=jQuery(this);self.addClass(value.call(this,i,self.attr("class")))})}if(value&&typeof value==="string"){var classNames=(value||"").split(rspace);for(var i=0,l=this.length;i<l;i++){var elem=this[i];if(elem.nodeType===1){if(!elem.className){elem.className=value}else{var className=" "+elem.className+" ",setClass=elem.className;for(var c=0,cl=classNames.length;c<cl;c++){if(className.indexOf(" "+classNames[c]+" ")<0){setClass+=" "+classNames[c]}}elem.className=jQuery.trim(setClass)}}}}return this},removeClass:function(value){if(jQuery.isFunction(value)){return this.each(function(i){var self=jQuery(this);self.removeClass(value.call(this,i,self.attr("class")))})}if((value&&typeof value==="string")||value===undefined){var classNames=(value||"").split(rspace);for(var i=0,l=this.length;i<l;i++){var elem=this[i];if(elem.nodeType===1&&elem.className){if(value){var className=(" "+elem.className+" ").replace(rclass," ");for(var c=0,cl=classNames.length;c<cl;c++){className=className.replace(" "+classNames[c]+" "," ")}elem.className=jQuery.trim(className)}else{elem.className=""}}}}return this},toggleClass:function(value,stateVal){var type=typeof value,isBool=typeof stateVal==="boolean";if(jQuery.isFunction(value)){return this.each(function(i){var self=jQuery(this);self.toggleClass(value.call(this,i,self.attr("class"),stateVal),stateVal)})}return this.each(function(){if(type==="string"){var className,i=0,self=jQuery(this),state=stateVal,classNames=value.split(rspace);while((className=classNames[i++])){state=isBool?state:!self.hasClass(className);self[state?"addClass":"removeClass"](className)}}else{if(type==="undefined"||type==="boolean"){if(this.className){jQuery.data(this,"__className__",this.className)}this.className=this.className||value===false?"":jQuery.data(this,"__className__")||""}}})},hasClass:function(selector){var className=" "+selector+" ";for(var i=0,l=this.length;i<l;i++){if((" "+this[i].className+" ").replace(rclass," ").indexOf(className)>-1){return true}}return false},val:function(value){if(value===undefined){var elem=this[0];if(elem){if(jQuery.nodeName(elem,"option")){return(elem.attributes.value||{}).specified?elem.value:elem.text}if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type==="select-one";if(index<0){return null}for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery(option).val();if(one){return value}values.push(value)}}return values}if(rradiocheck.test(elem.type)&&!jQuery.support.checkOn){return elem.getAttribute("value")===null?"on":elem.value}return(elem.value||"").replace(rreturn,"")}return undefined}var isFunction=jQuery.isFunction(value);return this.each(function(i){var self=jQuery(this),val=value;if(this.nodeType!==1){return}if(isFunction){val=value.call(this,i,self.val())}if(typeof val==="number"){val+=""}if(jQuery.isArray(val)&&rradiocheck.test(this.type)){this.checked=jQuery.inArray(self.val(),val)>=0}else{if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(val);jQuery("option",this).each(function(){this.selected=jQuery.inArray(jQuery(this).val(),values)>=0});if(!values.length){this.selectedIndex=-1}}else{this.value=val}}})}});jQuery.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(elem,name,value,pass){if(!elem||elem.nodeType===3||elem.nodeType===8){return undefined}if(pass&&name in jQuery.attrFn){return jQuery(elem)[name](value)}var notxml=elem.nodeType!==1||!jQuery.isXMLDoc(elem),set=value!==undefined;name=notxml&&jQuery.props[name]||name;if(elem.nodeType===1){var special=rspecialurl.test(name);if(name==="selected"&&!jQuery.support.optSelected){var parent=elem.parentNode;if(parent){parent.selectedIndex;if(parent.parentNode){parent.parentNode.selectedIndex}}}if(name in elem&&notxml&&!special){if(set){if(name==="type"&&rtype.test(elem.nodeName)&&elem.parentNode){jQuery.error("type property can't be changed")}elem[name]=value}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name)){return elem.getAttributeNode(name).nodeValue}if(name==="tabIndex"){var attributeNode=elem.getAttributeNode("tabIndex");return attributeNode&&attributeNode.specified?attributeNode.value:rfocusable.test(elem.nodeName)||rclickable.test(elem.nodeName)&&elem.href?0:undefined}return elem[name]}if(!jQuery.support.style&&notxml&&name==="style"){if(set){elem.style.cssText=""+value}return elem.style.cssText}if(set){elem.setAttribute(name,""+value)}var attr=!jQuery.support.hrefNormalized&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr}return jQuery.style(elem,name,value)}});var rnamespaces=/\.(.*)$/,fcleanup=function(nm){return nm.replace(/[^\w\s\.\|`]/g,function(ch){return"\\"+ch})};jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType===3||elem.nodeType===8){return}if(elem.setInterval&&(elem!==window&&!elem.frameElement)){elem=window}var handleObjIn,handleObj;if(handler.handler){handleObjIn=handler;handler=handleObjIn.handler}if(!handler.guid){handler.guid=jQuery.guid++}var elemData=jQuery.data(elem);if(!elemData){return}var events=elemData.events=elemData.events||{},eventHandle=elemData.handle,eventHandle;if(!eventHandle){elemData.handle=eventHandle=function(){return typeof jQuery!=="undefined"&&!jQuery.event.triggered?jQuery.event.handle.apply(eventHandle.elem,arguments):undefined}}eventHandle.elem=elem;types=types.split(" ");var type,i=0,namespaces;while((type=types[i++])){handleObj=handleObjIn?jQuery.extend({},handleObjIn):{handler:handler,data:data};if(type.indexOf(".")>-1){namespaces=type.split(".");type=namespaces.shift();handleObj.namespace=namespaces.slice(0).sort().join(".")}else{namespaces=[];handleObj.namespace=""}handleObj.type=type;handleObj.guid=handler.guid;var handlers=events[type],special=jQuery.event.special[type]||{};if(!handlers){handlers=events[type]=[];if(!special.setup||special.setup.call(elem,data,namespaces,eventHandle)===false){if(elem.addEventListener){elem.addEventListener(type,eventHandle,false)}else{if(elem.attachEvent){elem.attachEvent("on"+type,eventHandle)}}}}if(special.add){special.add.call(elem,handleObj);if(!handleObj.handler.guid){handleObj.handler.guid=handler.guid}}handlers.push(handleObj);jQuery.event.global[type]=true}elem=null},global:{},remove:function(elem,types,handler,pos){if(elem.nodeType===3||elem.nodeType===8){return}var ret,type,fn,i=0,all,namespaces,namespace,special,eventType,handleObj,origType,elemData=jQuery.data(elem),events=elemData&&elemData.events;if(!elemData||!events){return}if(types&&types.type){handler=types.handler;types=types.type}if(!types||typeof types==="string"&&types.charAt(0)==="."){types=types||"";for(type in events){jQuery.event.remove(elem,type+types)}return}types=types.split(" ");while((type=types[i++])){origType=type;handleObj=null;all=type.indexOf(".")<0;namespaces=[];if(!all){namespaces=type.split(".");type=namespaces.shift();namespace=new RegExp("(^|\\.)"+jQuery.map(namespaces.slice(0).sort(),fcleanup).join("\\.(?:.*\\.)?")+"(\\.|$)")}eventType=events[type];if(!eventType){continue}if(!handler){for(var j=0;j<eventType.length;j++){handleObj=eventType[j];if(all||namespace.test(handleObj.namespace)){jQuery.event.remove(elem,origType,handleObj.handler,j);eventType.splice(j--,1)}}continue}special=jQuery.event.special[type]||{};for(var j=pos||0;j<eventType.length;j++){handleObj=eventType[j];if(handler.guid===handleObj.guid){if(all||namespace.test(handleObj.namespace)){if(pos==null){eventType.splice(j--,1)}if(special.remove){special.remove.call(elem,handleObj)}}if(pos!=null){break}}}if(eventType.length===0||pos!=null&&eventType.length===1){if(!special.teardown||special.teardown.call(elem,namespaces)===false){removeEvent(elem,type,elemData.handle)}ret=null;delete events[type]}}if(jQuery.isEmptyObject(events)){var handle=elemData.handle;if(handle){handle.elem=null}delete elemData.events;delete elemData.handle;if(jQuery.isEmptyObject(elemData)){jQuery.removeData(elem)}}},trigger:function(event,data,elem){var type=event.type||event,bubbling=arguments[3];if(!bubbling){event=typeof event==="object"?event[expando]?event:jQuery.extend(jQuery.Event(type),event):jQuery.Event(type);if(type.indexOf("!")>=0){event.type=type=type.slice(0,-1);event.exclusive=true}if(!elem){event.stopPropagation();if(jQuery.event.global[type]){jQuery.each(jQuery.cache,function(){if(this.events&&this.events[type]){jQuery.event.trigger(event,data,this.handle.elem)}})}}if(!elem||elem.nodeType===3||elem.nodeType===8){return undefined}event.result=undefined;event.target=elem;data=jQuery.makeArray(data);data.unshift(event)}event.currentTarget=elem;var handle=jQuery.data(elem,"handle");if(handle){handle.apply(elem,data)}var parent=elem.parentNode||elem.ownerDocument;try{if(!(elem&&elem.nodeName&&jQuery.noData[elem.nodeName.toLowerCase()])){if(elem["on"+type]&&elem["on"+type].apply(elem,data)===false){event.result=false}}}catch(e){}if(!event.isPropagationStopped()&&parent){jQuery.event.trigger(event,data,parent,true)}else{if(!event.isDefaultPrevented()){var target=event.target,old,isClick=jQuery.nodeName(target,"a")&&type==="click",special=jQuery.event.special[type]||{};if((!special._default||special._default.call(elem,event)===false)&&!isClick&&!(target&&target.nodeName&&jQuery.noData[target.nodeName.toLowerCase()])){try{if(target[type]){old=target["on"+type];if(old){target["on"+type]=null}jQuery.event.triggered=true;target[type]()}}catch(e){}if(old){target["on"+type]=old}jQuery.event.triggered=false}}}},handle:function(event){var all,handlers,namespaces,namespace,events;event=arguments[0]=jQuery.event.fix(event||window.event);event.currentTarget=this;all=event.type.indexOf(".")<0&&!event.exclusive;if(!all){namespaces=event.type.split(".");event.type=namespaces.shift();namespace=new RegExp("(^|\\.)"+namespaces.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}var events=jQuery.data(this,"events"),handlers=events[event.type];if(events&&handlers){handlers=handlers.slice(0);for(var j=0,l=handlers.length;j<l;j++){var handleObj=handlers[j];if(all||namespace.test(handleObj.namespace)){event.handler=handleObj.handler;event.data=handleObj.data;event.handleObj=handleObj;var ret=handleObj.handler.apply(this,arguments);if(ret!==undefined){event.result=ret;if(ret===false){event.preventDefault();event.stopPropagation()}}if(event.isImmediatePropagationStopped()){break}}}}return event.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(event){if(event[expando]){return event}var originalEvent=event;event=jQuery.Event(originalEvent);for(var i=this.props.length,prop;i;){prop=this.props[--i];event[prop]=originalEvent[prop]}if(!event.target){event.target=event.srcElement||document}if(event.target.nodeType===3){event.target=event.target.parentNode}if(!event.relatedTarget&&event.fromElement){event.relatedTarget=event.fromElement===event.target?event.toElement:event.fromElement}if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc&&doc.clientLeft||body&&body.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc&&doc.clientTop||body&&body.clientTop||0)}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode)){event.which=event.charCode||event.keyCode}if(!event.metaKey&&event.ctrlKey){event.metaKey=event.ctrlKey}if(!event.which&&event.button!==undefined){event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)))}return event},guid:100000000,proxy:jQuery.proxy,special:{ready:{setup:jQuery.bindReady,teardown:jQuery.noop},live:{add:function(handleObj){jQuery.event.add(this,handleObj.origType,jQuery.extend({},handleObj,{handler:liveHandler}))},remove:function(handleObj){var remove=true,type=handleObj.origType.replace(rnamespaces,"");jQuery.each(jQuery.data(this,"events").live||[],function(){if(type===this.origType.replace(rnamespaces,"")){remove=false;return false}});if(remove){jQuery.event.remove(this,handleObj.origType,liveHandler)}}},beforeunload:{setup:function(data,namespaces,eventHandle){if(this.setInterval){this.onbeforeunload=eventHandle}return false},teardown:function(namespaces,eventHandle){if(this.onbeforeunload===eventHandle){this.onbeforeunload=null}}}}};var removeEvent=document.removeEventListener?function(elem,type,handle){elem.removeEventListener(type,handle,false)}:function(elem,type,handle){elem.detachEvent("on"+type,handle)};jQuery.Event=function(src){if(!this.preventDefault){return new jQuery.Event(src)}if(src&&src.type){this.originalEvent=src;this.type=src.type}else{this.type=src}this.timeStamp=now();this[expando]=true};function returnFalse(){return false}function returnTrue(){return true}jQuery.Event.prototype={preventDefault:function(){this.isDefaultPrevented=returnTrue;var e=this.originalEvent;if(!e){return}if(e.preventDefault){e.preventDefault()}e.returnValue=false},stopPropagation:function(){this.isPropagationStopped=returnTrue;var e=this.originalEvent;if(!e){return}if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue;this.stopPropagation()},isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse};var withinElement=function(event){var parent=event.relatedTarget;try{while(parent&&parent!==this){parent=parent.parentNode}if(parent!==this){event.type=event.data;jQuery.event.handle.apply(this,arguments)}}catch(e){}},delegate=function(event){event.type=event.data;jQuery.event.handle.apply(this,arguments)};jQuery.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(orig,fix){jQuery.event.special[orig]={setup:function(data){jQuery.event.add(this,fix,data&&data.selector?delegate:withinElement,orig)},teardown:function(data){jQuery.event.remove(this,fix,data&&data.selector?delegate:withinElement)}}});if(!jQuery.support.submitBubbles){jQuery.event.special.submit={setup:function(data,namespaces){if(this.nodeName.toLowerCase()!=="form"){jQuery.event.add(this,"click.specialSubmit",function(e){var elem=e.target,type=elem.type;if((type==="submit"||type==="image")&&jQuery(elem).closest("form").length){return trigger("submit",this,arguments)}});jQuery.event.add(this,"keypress.specialSubmit",function(e){var elem=e.target,type=elem.type;if((type==="text"||type==="password")&&jQuery(elem).closest("form").length&&e.keyCode===13){return trigger("submit",this,arguments)}})}else{return false}},teardown:function(namespaces){jQuery.event.remove(this,".specialSubmit")}}}if(!jQuery.support.changeBubbles){var formElems=/textarea|input|select/i,changeFilters,getVal=function(elem){var type=elem.type,val=elem.value;if(type==="radio"||type==="checkbox"){val=elem.checked}else{if(type==="select-multiple"){val=elem.selectedIndex>-1?jQuery.map(elem.options,function(elem){return elem.selected}).join("-"):""}else{if(elem.nodeName.toLowerCase()==="select"){val=elem.selectedIndex}}}return val},testChange=function testChange(e){var elem=e.target,data,val;if(!formElems.test(elem.nodeName)||elem.readOnly){return}data=jQuery.data(elem,"_change_data");val=getVal(elem);if(e.type!=="focusout"||elem.type!=="radio"){jQuery.data(elem,"_change_data",val)}if(data===undefined||val===data){return}if(data!=null||val){e.type="change";return jQuery.event.trigger(e,arguments[1],elem)}};jQuery.event.special.change={filters:{focusout:testChange,click:function(e){var elem=e.target,type=elem.type;if(type==="radio"||type==="checkbox"||elem.nodeName.toLowerCase()==="select"){return testChange.call(this,e)}},keydown:function(e){var elem=e.target,type=elem.type;if((e.keyCode===13&&elem.nodeName.toLowerCase()!=="textarea")||(e.keyCode===32&&(type==="checkbox"||type==="radio"))||type==="select-multiple"){return testChange.call(this,e)}},beforeactivate:function(e){var elem=e.target;jQuery.data(elem,"_change_data",getVal(elem))}},setup:function(data,namespaces){if(this.type==="file"){return false}for(var type in changeFilters){jQuery.event.add(this,type+".specialChange",changeFilters[type])}return formElems.test(this.nodeName)},teardown:function(namespaces){jQuery.event.remove(this,".specialChange");return formElems.test(this.nodeName)}};changeFilters=jQuery.event.special.change.filters}function trigger(type,elem,args){args[0].type=type;return jQuery.event.handle.apply(elem,args)}if(document.addEventListener){jQuery.each({focus:"focusin",blur:"focusout"},function(orig,fix){jQuery.event.special[fix]={setup:function(){this.addEventListener(orig,handler,true)},teardown:function(){this.removeEventListener(orig,handler,true)}};function handler(e){e=jQuery.event.fix(e);e.type=fix;return jQuery.event.handle.call(this,e)}})}jQuery.each(["bind","one"],function(i,name){jQuery.fn[name]=function(type,data,fn){if(typeof type==="object"){for(var key in type){this[name](key,data,type[key],fn)}return this}if(jQuery.isFunction(data)){fn=data;data=undefined}var handler=name==="one"?jQuery.proxy(fn,function(event){jQuery(this).unbind(event,handler);return fn.apply(this,arguments)}):fn;if(type==="unload"&&name!=="one"){this.one(type,data,fn)}else{for(var i=0,l=this.length;i<l;i++){jQuery.event.add(this[i],type,handler,data)}}return this}});jQuery.fn.extend({unbind:function(type,fn){if(typeof type==="object"&&!type.preventDefault){for(var key in type){this.unbind(key,type[key])}}else{for(var i=0,l=this.length;i<l;i++){jQuery.event.remove(this[i],type,fn)}}return this},delegate:function(selector,types,data,fn){return this.live(types,data,fn,selector)},undelegate:function(selector,types,fn){if(arguments.length===0){return this.unbind("live")}else{return this.die(types,null,fn,selector)}},trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this)})},triggerHandler:function(type,data){if(this[0]){var event=jQuery.Event(type);event.preventDefault();event.stopPropagation();jQuery.event.trigger(event,data,this[0]);return event.result}},toggle:function(fn){var args=arguments,i=1;while(i<args.length){jQuery.proxy(fn,args[i++])}return this.click(jQuery.proxy(fn,function(event){var lastToggle=(jQuery.data(this,"lastToggle"+fn.guid)||0)%i;jQuery.data(this,"lastToggle"+fn.guid,lastToggle+1);event.preventDefault();return args[lastToggle].apply(this,arguments)||false}))},hover:function(fnOver,fnOut){return this.mouseenter(fnOver).mouseleave(fnOut||fnOver)}});var liveMap={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};jQuery.each(["live","die"],function(i,name){jQuery.fn[name]=function(types,data,fn,origSelector){var type,i=0,match,namespaces,preType,selector=origSelector||this.selector,context=origSelector?this:jQuery(this.context);if(jQuery.isFunction(data)){fn=data;data=undefined}types=(types||"").split(" ");while((type=types[i++])!=null){match=rnamespaces.exec(type);namespaces="";if(match){namespaces=match[0];type=type.replace(rnamespaces,"")}if(type==="hover"){types.push("mouseenter"+namespaces,"mouseleave"+namespaces);continue}preType=type;if(type==="focus"||type==="blur"){types.push(liveMap[type]+namespaces);type=type+namespaces}else{type=(liveMap[type]||type)+namespaces}if(name==="live"){context.each(function(){jQuery.event.add(this,liveConvert(type,selector),{data:data,selector:selector,handler:fn,origType:type,origHandler:fn,preType:preType})})}else{context.unbind(liveConvert(type,selector),fn)}}return this}});function liveHandler(event){var stop,elems=[],selectors=[],args=arguments,related,match,handleObj,elem,j,i,l,data,events=jQuery.data(this,"events");if(event.liveFired===this||!events||!events.live||event.button&&event.type==="click"){return}event.liveFired=this;var live=events.live.slice(0);for(j=0;j<live.length;j++){handleObj=live[j];if(handleObj.origType.replace(rnamespaces,"")===event.type){selectors.push(handleObj.selector)}else{live.splice(j--,1)}}match=jQuery(event.target).closest(selectors,event.currentTarget);for(i=0,l=match.length;i<l;i++){for(j=0;j<live.length;j++){handleObj=live[j];if(match[i].selector===handleObj.selector){elem=match[i].elem;related=null;if(handleObj.preType==="mouseenter"||handleObj.preType==="mouseleave"){related=jQuery(event.relatedTarget).closest(handleObj.selector)[0]}if(!related||related!==elem){elems.push({elem:elem,handleObj:handleObj})}}}}for(i=0,l=elems.length;i<l;i++){match=elems[i];event.currentTarget=match.elem;event.data=match.handleObj.data;event.handleObj=match.handleObj;if(match.handleObj.origHandler.apply(match.elem,args)===false){stop=false;break}}return stop}function liveConvert(type,selector){return"live."+(type&&type!=="*"?type+".":"")+selector.replace(/\./g,"`").replace(/ /g,"&")}jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error").split(" "),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name)};if(jQuery.attrFn){jQuery.attrFn[name]=true}});if(window.attachEvent&&!window.addEventListener){window.attachEvent("onunload",function(){for(var id in jQuery.cache){if(jQuery.cache[id].handle){try{jQuery.event.remove(jQuery.cache[id].handle.elem)}catch(e){}}}});
/*
 * Sizzle CSS Selector Engine - v1.0
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
}(function(){var chunker=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,done=0,toString=Object.prototype.toString,hasDuplicate=false,baseHasDuplicate=true;[0,0].sort(function(){baseHasDuplicate=false;return 0});var Sizzle=function(selector,context,results,seed){results=results||[];var origContext=context=context||document;if(context.nodeType!==1&&context.nodeType!==9){return[]}if(!selector||typeof selector!=="string"){return results}var parts=[],m,set,checkSet,extra,prune=true,contextXML=isXML(context),soFar=selector;while((chunker.exec(""),m=chunker.exec(soFar))!==null){soFar=m[3];parts.push(m[1]);if(m[2]){extra=m[3];break}}if(parts.length>1&&origPOS.exec(selector)){if(parts.length===2&&Expr.relative[parts[0]]){set=posProcess(parts[0]+parts[1],context)}else{set=Expr.relative[parts[0]]?[context]:Sizzle(parts.shift(),context);while(parts.length){selector=parts.shift();if(Expr.relative[selector]){selector+=parts.shift()}set=posProcess(selector,set)}}}else{if(!seed&&parts.length>1&&context.nodeType===9&&!contextXML&&Expr.match.ID.test(parts[0])&&!Expr.match.ID.test(parts[parts.length-1])){var ret=Sizzle.find(parts.shift(),context,contextXML);context=ret.expr?Sizzle.filter(ret.expr,ret.set)[0]:ret.set[0]}if(context){var ret=seed?{expr:parts.pop(),set:makeArray(seed)}:Sizzle.find(parts.pop(),parts.length===1&&(parts[0]==="~"||parts[0]==="+")&&context.parentNode?context.parentNode:context,contextXML);set=ret.expr?Sizzle.filter(ret.expr,ret.set):ret.set;if(parts.length>0){checkSet=makeArray(set)}else{prune=false}while(parts.length){var cur=parts.pop(),pop=cur;if(!Expr.relative[cur]){cur=""}else{pop=parts.pop()}if(pop==null){pop=context}Expr.relative[cur](checkSet,pop,contextXML)}}else{checkSet=parts=[]}}if(!checkSet){checkSet=set}if(!checkSet){Sizzle.error(cur||selector)}if(toString.call(checkSet)==="[object Array]"){if(!prune){results.push.apply(results,checkSet)}else{if(context&&context.nodeType===1){for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&(checkSet[i]===true||checkSet[i].nodeType===1&&contains(context,checkSet[i]))){results.push(set[i])}}}else{for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&checkSet[i].nodeType===1){results.push(set[i])}}}}}else{makeArray(checkSet,results)}if(extra){Sizzle(extra,origContext,results,seed);Sizzle.uniqueSort(results)}return results};Sizzle.uniqueSort=function(results){if(sortOrder){hasDuplicate=baseHasDuplicate;results.sort(sortOrder);if(hasDuplicate){for(var i=1;i<results.length;i++){if(results[i]===results[i-1]){results.splice(i--,1)}}}}return results};Sizzle.matches=function(expr,set){return Sizzle(expr,null,null,set)};Sizzle.find=function(expr,context,isXML){var set,match;if(!expr){return[]}for(var i=0,l=Expr.order.length;i<l;i++){var type=Expr.order[i],match;if((match=Expr.leftMatch[type].exec(expr))){var left=match[1];match.splice(1,1);if(left.substr(left.length-1)!=="\\"){match[1]=(match[1]||"").replace(/\\/g,"");set=Expr.find[type](match,context,isXML);if(set!=null){expr=expr.replace(Expr.match[type],"");break}}}}if(!set){set=context.getElementsByTagName("*")}return{set:set,expr:expr}};Sizzle.filter=function(expr,set,inplace,not){var old=expr,result=[],curLoop=set,match,anyFound,isXMLFilter=set&&set[0]&&isXML(set[0]);while(expr&&set.length){for(var type in Expr.filter){if((match=Expr.leftMatch[type].exec(expr))!=null&&match[2]){var filter=Expr.filter[type],found,item,left=match[1];anyFound=false;match.splice(1,1);if(left.substr(left.length-1)==="\\"){continue}if(curLoop===result){result=[]}if(Expr.preFilter[type]){match=Expr.preFilter[type](match,curLoop,inplace,result,not,isXMLFilter);if(!match){anyFound=found=true}else{if(match===true){continue}}}if(match){for(var i=0;(item=curLoop[i])!=null;i++){if(item){found=filter(item,match,i,curLoop);var pass=not^!!found;if(inplace&&found!=null){if(pass){anyFound=true}else{curLoop[i]=false}}else{if(pass){result.push(item);anyFound=true}}}}}if(found!==undefined){if(!inplace){curLoop=result}expr=expr.replace(Expr.match[type],"");if(!anyFound){return[]}break}}}if(expr===old){if(anyFound==null){Sizzle.error(expr)}else{break}}old=expr}return curLoop};Sizzle.error=function(msg){throw"Syntax error, unrecognized expression: "+msg};var Expr=Sizzle.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(elem){return elem.getAttribute("href")}},relative:{"+":function(checkSet,part){var isPartStr=typeof part==="string",isTag=isPartStr&&!/\W/.test(part),isPartStrNotTag=isPartStr&&!isTag;if(isTag){part=part.toLowerCase()}for(var i=0,l=checkSet.length,elem;i<l;i++){if((elem=checkSet[i])){while((elem=elem.previousSibling)&&elem.nodeType!==1){}checkSet[i]=isPartStrNotTag||elem&&elem.nodeName.toLowerCase()===part?elem||false:elem===part}}if(isPartStrNotTag){Sizzle.filter(part,checkSet,true)}},">":function(checkSet,part){var isPartStr=typeof part==="string";if(isPartStr&&!/\W/.test(part)){part=part.toLowerCase();for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){var parent=elem.parentNode;checkSet[i]=parent.nodeName.toLowerCase()===part?parent:false}}}else{for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){checkSet[i]=isPartStr?elem.parentNode:elem.parentNode===part}}if(isPartStr){Sizzle.filter(part,checkSet,true)}}},"":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(typeof part==="string"&&!/\W/.test(part)){var nodeCheck=part=part.toLowerCase();checkFn=dirNodeCheck}checkFn("parentNode",part,doneName,checkSet,nodeCheck,isXML)},"~":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(typeof part==="string"&&!/\W/.test(part)){var nodeCheck=part=part.toLowerCase();checkFn=dirNodeCheck}checkFn("previousSibling",part,doneName,checkSet,nodeCheck,isXML)}},find:{ID:function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?[m]:[]}},NAME:function(match,context){if(typeof context.getElementsByName!=="undefined"){var ret=[],results=context.getElementsByName(match[1]);for(var i=0,l=results.length;i<l;i++){if(results[i].getAttribute("name")===match[1]){ret.push(results[i])}}return ret.length===0?null:ret}},TAG:function(match,context){return context.getElementsByTagName(match[1])}},preFilter:{CLASS:function(match,curLoop,inplace,result,not,isXML){match=" "+match[1].replace(/\\/g,"")+" ";if(isXML){return match}for(var i=0,elem;(elem=curLoop[i])!=null;i++){if(elem){if(not^(elem.className&&(" "+elem.className+" ").replace(/[\t\n]/g," ").indexOf(match)>=0)){if(!inplace){result.push(elem)}}else{if(inplace){curLoop[i]=false}}}}return false},ID:function(match){return match[1].replace(/\\/g,"")},TAG:function(match,curLoop){return match[1].toLowerCase()},CHILD:function(match){if(match[1]==="nth"){var test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(match[2]==="even"&&"2n"||match[2]==="odd"&&"2n+1"||!/\D/.test(match[2])&&"0n+"+match[2]||match[2]);match[2]=(test[1]+(test[2]||1))-0;match[3]=test[3]-0}match[0]=done++;return match},ATTR:function(match,curLoop,inplace,result,not,isXML){var name=match[1].replace(/\\/g,"");if(!isXML&&Expr.attrMap[name]){match[1]=Expr.attrMap[name]}if(match[2]==="~="){match[4]=" "+match[4]+" "}return match},PSEUDO:function(match,curLoop,inplace,result,not){if(match[1]==="not"){if((chunker.exec(match[3])||"").length>1||/^\w/.test(match[3])){match[3]=Sizzle(match[3],null,null,curLoop)}else{var ret=Sizzle.filter(match[3],curLoop,inplace,true^not);if(!inplace){result.push.apply(result,ret)}return false}}else{if(Expr.match.POS.test(match[0])||Expr.match.CHILD.test(match[0])){return true}}return match},POS:function(match){match.unshift(true);return match}},filters:{enabled:function(elem){return elem.disabled===false&&elem.type!=="hidden"},disabled:function(elem){return elem.disabled===true},checked:function(elem){return elem.checked===true},selected:function(elem){elem.parentNode.selectedIndex;return elem.selected===true},parent:function(elem){return !!elem.firstChild},empty:function(elem){return !elem.firstChild},has:function(elem,i,match){return !!Sizzle(match[3],elem).length},header:function(elem){return/h\d/i.test(elem.nodeName)},text:function(elem){return"text"===elem.type},radio:function(elem){return"radio"===elem.type},checkbox:function(elem){return"checkbox"===elem.type},file:function(elem){return"file"===elem.type},password:function(elem){return"password"===elem.type},submit:function(elem){return"submit"===elem.type},image:function(elem){return"image"===elem.type},reset:function(elem){return"reset"===elem.type},button:function(elem){return"button"===elem.type||elem.nodeName.toLowerCase()==="button"},input:function(elem){return/input|select|textarea|button/i.test(elem.nodeName)}},setFilters:{first:function(elem,i){return i===0},last:function(elem,i,match,array){return i===array.length-1},even:function(elem,i){return i%2===0},odd:function(elem,i){return i%2===1},lt:function(elem,i,match){return i<match[3]-0},gt:function(elem,i,match){return i>match[3]-0},nth:function(elem,i,match){return match[3]-0===i},eq:function(elem,i,match){return match[3]-0===i}},filter:{PSEUDO:function(elem,match,i,array){var name=match[1],filter=Expr.filters[name];if(filter){return filter(elem,i,match,array)}else{if(name==="contains"){return(elem.textContent||elem.innerText||getText([elem])||"").indexOf(match[3])>=0}else{if(name==="not"){var not=match[3];for(var i=0,l=not.length;i<l;i++){if(not[i]===elem){return false}}return true}else{Sizzle.error("Syntax error, unrecognized expression: "+name)}}}},CHILD:function(elem,match){var type=match[1],node=elem;switch(type){case"only":case"first":while((node=node.previousSibling)){if(node.nodeType===1){return false}}if(type==="first"){return true}node=elem;case"last":while((node=node.nextSibling)){if(node.nodeType===1){return false}}return true;case"nth":var first=match[2],last=match[3];if(first===1&&last===0){return true}var doneName=match[0],parent=elem.parentNode;if(parent&&(parent.sizcache!==doneName||!elem.nodeIndex)){var count=0;for(node=parent.firstChild;node;node=node.nextSibling){if(node.nodeType===1){node.nodeIndex=++count}}parent.sizcache=doneName}var diff=elem.nodeIndex-last;if(first===0){return diff===0}else{return(diff%first===0&&diff/first>=0)}}},ID:function(elem,match){return elem.nodeType===1&&elem.getAttribute("id")===match},TAG:function(elem,match){return(match==="*"&&elem.nodeType===1)||elem.nodeName.toLowerCase()===match},CLASS:function(elem,match){return(" "+(elem.className||elem.getAttribute("class"))+" ").indexOf(match)>-1},ATTR:function(elem,match){var name=match[1],result=Expr.attrHandle[name]?Expr.attrHandle[name](elem):elem[name]!=null?elem[name]:elem.getAttribute(name),value=result+"",type=match[2],check=match[4];return result==null?type==="!=":type==="="?value===check:type==="*="?value.indexOf(check)>=0:type==="~="?(" "+value+" ").indexOf(check)>=0:!check?value&&result!==false:type==="!="?value!==check:type==="^="?value.indexOf(check)===0:type==="$="?value.substr(value.length-check.length)===check:type==="|="?value===check||value.substr(0,check.length+1)===check+"-":false},POS:function(elem,match,i,array){var name=match[2],filter=Expr.setFilters[name];if(filter){return filter(elem,i,match,array)}}}};var origPOS=Expr.match.POS;for(var type in Expr.match){Expr.match[type]=new RegExp(Expr.match[type].source+/(?![^\[]*\])(?![^\(]*\))/.source);Expr.leftMatch[type]=new RegExp(/(^(?:.|\r|\n)*?)/.source+Expr.match[type].source.replace(/\\(\d+)/g,function(all,num){return"\\"+(num-0+1)}))}var makeArray=function(array,results){array=Array.prototype.slice.call(array,0);if(results){results.push.apply(results,array);return results}return array};try{Array.prototype.slice.call(document.documentElement.childNodes,0)[0].nodeType}catch(e){makeArray=function(array,results){var ret=results||[];if(toString.call(array)==="[object Array]"){Array.prototype.push.apply(ret,array)}else{if(typeof array.length==="number"){for(var i=0,l=array.length;i<l;i++){ret.push(array[i])}}else{for(var i=0;array[i];i++){ret.push(array[i])}}}return ret}}var sortOrder;if(document.documentElement.compareDocumentPosition){sortOrder=function(a,b){if(!a.compareDocumentPosition||!b.compareDocumentPosition){if(a==b){hasDuplicate=true}return a.compareDocumentPosition?-1:1}var ret=a.compareDocumentPosition(b)&4?-1:a===b?0:1;if(ret===0){hasDuplicate=true}return ret}}else{if("sourceIndex" in document.documentElement){sortOrder=function(a,b){if(!a.sourceIndex||!b.sourceIndex){if(a==b){hasDuplicate=true}return a.sourceIndex?-1:1}var ret=a.sourceIndex-b.sourceIndex;if(ret===0){hasDuplicate=true}return ret}}else{if(document.createRange){sortOrder=function(a,b){if(!a.ownerDocument||!b.ownerDocument){if(a==b){hasDuplicate=true}return a.ownerDocument?-1:1}var aRange=a.ownerDocument.createRange(),bRange=b.ownerDocument.createRange();aRange.setStart(a,0);aRange.setEnd(a,0);bRange.setStart(b,0);bRange.setEnd(b,0);var ret=aRange.compareBoundaryPoints(Range.START_TO_END,bRange);if(ret===0){hasDuplicate=true}return ret}}}}function getText(elems){var ret="",elem;for(var i=0;elems[i];i++){elem=elems[i];if(elem.nodeType===3||elem.nodeType===4){ret+=elem.nodeValue}else{if(elem.nodeType!==8){ret+=getText(elem.childNodes)}}}return ret}(function(){var form=document.createElement("div"),id="script"+(new Date).getTime();form.innerHTML="<a name='"+id+"'/>";var root=document.documentElement;root.insertBefore(form,root.firstChild);if(document.getElementById(id)){Expr.find.ID=function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?m.id===match[1]||typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id").nodeValue===match[1]?[m]:undefined:[]}};Expr.filter.ID=function(elem,match){var node=typeof elem.getAttributeNode!=="undefined"&&elem.getAttributeNode("id");return elem.nodeType===1&&node&&node.nodeValue===match}}root.removeChild(form);root=form=null})();(function(){var div=document.createElement("div");div.appendChild(document.createComment(""));if(div.getElementsByTagName("*").length>0){Expr.find.TAG=function(match,context){var results=context.getElementsByTagName(match[1]);if(match[1]==="*"){var tmp=[];for(var i=0;results[i];i++){if(results[i].nodeType===1){tmp.push(results[i])}}results=tmp}return results}}div.innerHTML="<a href='#'></a>";if(div.firstChild&&typeof div.firstChild.getAttribute!=="undefined"&&div.firstChild.getAttribute("href")!=="#"){Expr.attrHandle.href=function(elem){return elem.getAttribute("href",2)}}div=null})();if(document.querySelectorAll){(function(){var oldSizzle=Sizzle,div=document.createElement("div");div.innerHTML="<p class='TEST'></p>";if(div.querySelectorAll&&div.querySelectorAll(".TEST").length===0){return}Sizzle=function(query,context,extra,seed){context=context||document;if(!seed&&context.nodeType===9&&!isXML(context)){try{return makeArray(context.querySelectorAll(query),extra)}catch(e){}}return oldSizzle(query,context,extra,seed)};for(var prop in oldSizzle){Sizzle[prop]=oldSizzle[prop]}div=null})()}(function(){var div=document.createElement("div");div.innerHTML="<div class='test e'></div><div class='test'></div>";if(!div.getElementsByClassName||div.getElementsByClassName("e").length===0){return}div.lastChild.className="e";if(div.getElementsByClassName("e").length===1){return}Expr.order.splice(1,0,"CLASS");Expr.find.CLASS=function(match,context,isXML){if(typeof context.getElementsByClassName!=="undefined"&&!isXML){return context.getElementsByClassName(match[1])}};div=null})();function dirNodeCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break}if(elem.nodeType===1&&!isXML){elem.sizcache=doneName;elem.sizset=i}if(elem.nodeName.toLowerCase()===cur){match=elem;break}elem=elem[dir]}checkSet[i]=match}}}function dirCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break}if(elem.nodeType===1){if(!isXML){elem.sizcache=doneName;elem.sizset=i}if(typeof cur!=="string"){if(elem===cur){match=true;break}}else{if(Sizzle.filter(cur,[elem]).length>0){match=elem;break}}}elem=elem[dir]}checkSet[i]=match}}}var contains=document.compareDocumentPosition?function(a,b){return !!(a.compareDocumentPosition(b)&16)}:function(a,b){return a!==b&&(a.contains?a.contains(b):true)};var isXML=function(elem){var documentElement=(elem?elem.ownerDocument||elem:0).documentElement;return documentElement?documentElement.nodeName!=="HTML":false};var posProcess=function(selector,context){var tmpSet=[],later="",match,root=context.nodeType?[context]:context;while((match=Expr.match.PSEUDO.exec(selector))){later+=match[0];selector=selector.replace(Expr.match.PSEUDO,"")}selector=Expr.relative[selector]?selector+"*":selector;for(var i=0,l=root.length;i<l;i++){Sizzle(selector,root[i],tmpSet)}return Sizzle.filter(later,tmpSet)};jQuery.find=Sizzle;jQuery.expr=Sizzle.selectors;jQuery.expr[":"]=jQuery.expr.filters;jQuery.unique=Sizzle.uniqueSort;jQuery.text=getText;jQuery.isXMLDoc=isXML;jQuery.contains=contains;return;window.Sizzle=Sizzle})();var runtil=/Until$/,rparentsprev=/^(?:parents|prevUntil|prevAll)/,rmultiselector=/,/,slice=Array.prototype.slice;var winnow=function(elements,qualifier,keep){if(jQuery.isFunction(qualifier)){return jQuery.grep(elements,function(elem,i){return !!qualifier.call(elem,i,elem)===keep})}else{if(qualifier.nodeType){return jQuery.grep(elements,function(elem,i){return(elem===qualifier)===keep})}else{if(typeof qualifier==="string"){var filtered=jQuery.grep(elements,function(elem){return elem.nodeType===1});if(isSimple.test(qualifier)){return jQuery.filter(qualifier,filtered,!keep)}else{qualifier=jQuery.filter(qualifier,filtered)}}}}return jQuery.grep(elements,function(elem,i){return(jQuery.inArray(elem,qualifier)>=0)===keep})};jQuery.fn.extend({find:function(selector){var ret=this.pushStack("","find",selector),length=0;for(var i=0,l=this.length;i<l;i++){length=ret.length;jQuery.find(selector,this[i],ret);if(i>0){for(var n=length;n<ret.length;n++){for(var r=0;r<length;r++){if(ret[r]===ret[n]){ret.splice(n--,1);break}}}}}return ret},has:function(target){var targets=jQuery(target);return this.filter(function(){for(var i=0,l=targets.length;i<l;i++){if(jQuery.contains(this,targets[i])){return true}}})},not:function(selector){return this.pushStack(winnow(this,selector,false),"not",selector)},filter:function(selector){return this.pushStack(winnow(this,selector,true),"filter",selector)},is:function(selector){return !!selector&&jQuery.filter(selector,this).length>0},closest:function(selectors,context){if(jQuery.isArray(selectors)){var ret=[],cur=this[0],match,matches={},selector;if(cur&&selectors.length){for(var i=0,l=selectors.length;i<l;i++){selector=selectors[i];if(!matches[selector]){matches[selector]=jQuery.expr.match.POS.test(selector)?jQuery(selector,context||this.context):selector}}while(cur&&cur.ownerDocument&&cur!==context){for(selector in matches){match=matches[selector];if(match.jquery?match.index(cur)>-1:jQuery(cur).is(match)){ret.push({selector:selector,elem:cur});delete matches[selector]}}cur=cur.parentNode}}return ret}var pos=jQuery.expr.match.POS.test(selectors)?jQuery(selectors,context||this.context):null;return this.map(function(i,cur){while(cur&&cur.ownerDocument&&cur!==context){if(pos?pos.index(cur)>-1:jQuery(cur).is(selectors)){return cur}cur=cur.parentNode}return null})},index:function(elem){if(!elem||typeof elem==="string"){return jQuery.inArray(this[0],elem?jQuery(elem):this.parent().children())}return jQuery.inArray(elem.jquery?elem[0]:elem,this)},add:function(selector,context){var set=typeof selector==="string"?jQuery(selector,context||this.context):jQuery.makeArray(selector),all=jQuery.merge(this.get(),set);return this.pushStack(isDisconnected(set[0])||isDisconnected(all[0])?all:jQuery.unique(all))},andSelf:function(){return this.add(this.prevObject)}});function isDisconnected(node){return !node||!node.parentNode||node.parentNode.nodeType===11}jQuery.each({parent:function(elem){var parent=elem.parentNode;return parent&&parent.nodeType!==11?parent:null},parents:function(elem){return jQuery.dir(elem,"parentNode")},parentsUntil:function(elem,i,until){return jQuery.dir(elem,"parentNode",until)},next:function(elem){return jQuery.nth(elem,2,"nextSibling")},prev:function(elem){return jQuery.nth(elem,2,"previousSibling")},nextAll:function(elem){return jQuery.dir(elem,"nextSibling")},prevAll:function(elem){return jQuery.dir(elem,"previousSibling")},nextUntil:function(elem,i,until){return jQuery.dir(elem,"nextSibling",until)},prevUntil:function(elem,i,until){return jQuery.dir(elem,"previousSibling",until)},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem)},children:function(elem){return jQuery.sibling(elem.firstChild)},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)}},function(name,fn){jQuery.fn[name]=function(until,selector){var ret=jQuery.map(this,fn,until);if(!runtil.test(name)){selector=until}if(selector&&typeof selector==="string"){ret=jQuery.filter(selector,ret)}ret=this.length>1?jQuery.unique(ret):ret;if((this.length>1||rmultiselector.test(selector))&&rparentsprev.test(name)){ret=ret.reverse()}return this.pushStack(ret,name,slice.call(arguments).join(","))}});jQuery.extend({filter:function(expr,elems,not){if(not){expr=":not("+expr+")"}return jQuery.find.matches(expr,elems)},dir:function(elem,dir,until){var matched=[],cur=elem[dir];while(cur&&cur.nodeType!==9&&(until===undefined||cur.nodeType!==1||!jQuery(cur).is(until))){if(cur.nodeType===1){matched.push(cur)}cur=cur[dir]}return matched},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir]){if(cur.nodeType===1&&++num===result){break}}return cur},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType===1&&n!==elem){r.push(n)}}return r}});var rinlinejQuery=/ jQuery\d+="(?:\d+|null)"/g,rleadingWhitespace=/^\s+/,rxhtmlTag=/(<([\w:]+)[^>]*?)\/>/g,rselfClosing=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,rtagName=/<([\w:]+)/,rtbody=/<tbody/i,rhtml=/<|&#?\w+;/,rnocache=/<script|<object|<embed|<option|<style/i,rchecked=/checked\s*(?:[^=]|=\s*.checked.)/i,fcloseTag=function(all,front,tag){return rselfClosing.test(tag)?all:front+"></"+tag+">"},wrapMap={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};wrapMap.optgroup=wrapMap.option;wrapMap.tbody=wrapMap.tfoot=wrapMap.colgroup=wrapMap.caption=wrapMap.thead;wrapMap.th=wrapMap.td;if(!jQuery.support.htmlSerialize){wrapMap._default=[1,"div<div>","</div>"]}jQuery.fn.extend({text:function(text){if(jQuery.isFunction(text)){return this.each(function(i){var self=jQuery(this);self.text(text.call(this,i,self.text()))})}if(typeof text!=="object"&&text!==undefined){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text))}return jQuery.text(this)},wrapAll:function(html){if(jQuery.isFunction(html)){return this.each(function(i){jQuery(this).wrapAll(html.call(this,i))})}if(this[0]){var wrap=jQuery(html,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){wrap.insertBefore(this[0])}wrap.map(function(){var elem=this;while(elem.firstChild&&elem.firstChild.nodeType===1){elem=elem.firstChild}return elem}).append(this)}return this},wrapInner:function(html){if(jQuery.isFunction(html)){return this.each(function(i){jQuery(this).wrapInner(html.call(this,i))})}return this.each(function(){var self=jQuery(this),contents=self.contents();if(contents.length){contents.wrapAll(html)}else{self.append(html)}})},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html)})},unwrap:function(){return this.parent().each(function(){if(!jQuery.nodeName(this,"body")){jQuery(this).replaceWith(this.childNodes)}}).end()},append:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType===1){this.appendChild(elem)}})},prepend:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType===1){this.insertBefore(elem,this.firstChild)}})},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this)})}else{if(arguments.length){var set=jQuery(arguments[0]);set.push.apply(set,this.toArray());return this.pushStack(set,"before",arguments)}}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this.nextSibling)})}else{if(arguments.length){var set=this.pushStack(this,"after",arguments);set.push.apply(set,jQuery(arguments[0]).toArray());return set}}},remove:function(selector,keepData){for(var i=0,elem;(elem=this[i])!=null;i++){if(!selector||jQuery.filter(selector,[elem]).length){if(!keepData&&elem.nodeType===1){jQuery.cleanData(elem.getElementsByTagName("*"));jQuery.cleanData([elem])}if(elem.parentNode){elem.parentNode.removeChild(elem)}}}return this},empty:function(){for(var i=0,elem;(elem=this[i])!=null;i++){if(elem.nodeType===1){jQuery.cleanData(elem.getElementsByTagName("*"))}while(elem.firstChild){elem.removeChild(elem.firstChild)}}return this},clone:function(events){var ret=this.map(function(){if(!jQuery.support.noCloneEvent&&!jQuery.isXMLDoc(this)){var html=this.outerHTML,ownerDocument=this.ownerDocument;if(!html){var div=ownerDocument.createElement("div");div.appendChild(this.cloneNode(true));html=div.innerHTML}return jQuery.clean([html.replace(rinlinejQuery,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(rleadingWhitespace,"")],ownerDocument)[0]}else{return this.cloneNode(true)}});if(events===true){cloneCopyEvent(this,ret);cloneCopyEvent(this.find("*"),ret.find("*"))}return ret},html:function(value){if(value===undefined){return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(rinlinejQuery,""):null}else{if(typeof value==="string"&&!rnocache.test(value)&&(jQuery.support.leadingWhitespace||!rleadingWhitespace.test(value))&&!wrapMap[(rtagName.exec(value)||["",""])[1].toLowerCase()]){value=value.replace(rxhtmlTag,fcloseTag);try{for(var i=0,l=this.length;i<l;i++){if(this[i].nodeType===1){jQuery.cleanData(this[i].getElementsByTagName("*"));this[i].innerHTML=value}}}catch(e){this.empty().append(value)}}else{if(jQuery.isFunction(value)){this.each(function(i){var self=jQuery(this),old=self.html();self.empty().append(function(){return value.call(this,i,old)})})}else{this.empty().append(value)}}}return this},replaceWith:function(value){if(this[0]&&this[0].parentNode){if(jQuery.isFunction(value)){return this.each(function(i){var self=jQuery(this),old=self.html();self.replaceWith(value.call(this,i,old))})}if(typeof value!=="string"){value=jQuery(value).detach()}return this.each(function(){var next=this.nextSibling,parent=this.parentNode;jQuery(this).remove();if(next){jQuery(next).before(value)}else{jQuery(parent).append(value)}})}else{return this.pushStack(jQuery(jQuery.isFunction(value)?value():value),"replaceWith",value)}},detach:function(selector){return this.remove(selector,true)},domManip:function(args,table,callback){var results,first,value=args[0],scripts=[],fragment,parent;if(!jQuery.support.checkClone&&arguments.length===3&&typeof value==="string"&&rchecked.test(value)){return this.each(function(){jQuery(this).domManip(args,table,callback,true)})}if(jQuery.isFunction(value)){return this.each(function(i){var self=jQuery(this);args[0]=value.call(this,i,table?self.html():undefined);self.domManip(args,table,callback)})}if(this[0]){parent=value&&value.parentNode;if(jQuery.support.parentNode&&parent&&parent.nodeType===11&&parent.childNodes.length===this.length){results={fragment:parent}}else{results=buildFragment(args,this,scripts)}fragment=results.fragment;if(fragment.childNodes.length===1){first=fragment=fragment.firstChild}else{first=fragment.firstChild}if(first){table=table&&jQuery.nodeName(first,"tr");for(var i=0,l=this.length;i<l;i++){callback.call(table?root(this[i],first):this[i],i>0||results.cacheable||this.length>1?fragment.cloneNode(true):fragment)}}if(scripts.length){jQuery.each(scripts,evalScript)}}return this;function root(elem,cur){return jQuery.nodeName(elem,"table")?(elem.getElementsByTagName("tbody")[0]||elem.appendChild(elem.ownerDocument.createElement("tbody"))):elem}}});function cloneCopyEvent(orig,ret){var i=0;ret.each(function(){if(this.nodeName!==(orig[i]&&orig[i].nodeName)){return}var oldData=jQuery.data(orig[i++]),curData=jQuery.data(this,oldData),events=oldData&&oldData.events;if(events){delete curData.handle;curData.events={};for(var type in events){for(var handler in events[type]){jQuery.event.add(this,type,events[type][handler],events[type][handler].data)}}}})}function buildFragment(args,nodes,scripts){var fragment,cacheable,cacheresults,doc=(nodes&&nodes[0]?nodes[0].ownerDocument||nodes[0]:document);if(args.length===1&&typeof args[0]==="string"&&args[0].length<512&&doc===document&&!rnocache.test(args[0])&&(jQuery.support.checkClone||!rchecked.test(args[0]))){cacheable=true;cacheresults=jQuery.fragments[args[0]];if(cacheresults){if(cacheresults!==1){fragment=cacheresults}}}if(!fragment){fragment=doc.createDocumentFragment();jQuery.clean(args,doc,fragment,scripts)}if(cacheable){jQuery.fragments[args[0]]=cacheresults?fragment:1}return{fragment:fragment,cacheable:cacheable}}jQuery.fragments={};jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(selector){var ret=[],insert=jQuery(selector),parent=this.length===1&&this[0].parentNode;if(parent&&parent.nodeType===11&&parent.childNodes.length===1&&insert.length===1){insert[original](this[0]);return this}else{for(var i=0,l=insert.length;i<l;i++){var elems=(i>0?this.clone(true):this).get();jQuery.fn[original].apply(jQuery(insert[i]),elems);ret=ret.concat(elems)}return this.pushStack(ret,name,insert.selector)}}});jQuery.extend({clean:function(elems,context,fragment,scripts){context=context||document;if(typeof context.createElement==="undefined"){context=context.ownerDocument||context[0]&&context[0].ownerDocument||document}var ret=[];for(var i=0,elem;(elem=elems[i])!=null;i++){if(typeof elem==="number"){elem+=""}if(!elem){continue}if(typeof elem==="string"&&!rhtml.test(elem)){elem=context.createTextNode(elem)}else{if(typeof elem==="string"){elem=elem.replace(rxhtmlTag,fcloseTag);var tag=(rtagName.exec(elem)||["",""])[1].toLowerCase(),wrap=wrapMap[tag]||wrapMap._default,depth=wrap[0],div=context.createElement("div");div.innerHTML=wrap[1]+elem+wrap[2];while(depth--){div=div.lastChild}if(!jQuery.support.tbody){var hasBody=rtbody.test(elem),tbody=tag==="table"&&!hasBody?div.firstChild&&div.firstChild.childNodes:wrap[1]==="<table>"&&!hasBody?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j){if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length){tbody[j].parentNode.removeChild(tbody[j])}}}if(!jQuery.support.leadingWhitespace&&rleadingWhitespace.test(elem)){div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]),div.firstChild)}elem=div.childNodes}}if(elem.nodeType){ret.push(elem)}else{ret=jQuery.merge(ret,elem)}}if(fragment){for(var i=0;ret[i];i++){if(scripts&&jQuery.nodeName(ret[i],"script")&&(!ret[i].type||ret[i].type.toLowerCase()==="text/javascript")){scripts.push(ret[i].parentNode?ret[i].parentNode.removeChild(ret[i]):ret[i])}else{if(ret[i].nodeType===1){ret.splice.apply(ret,[i+1,0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))))}fragment.appendChild(ret[i])}}}return ret},cleanData:function(elems){var data,id,cache=jQuery.cache,special=jQuery.event.special,deleteExpando=jQuery.support.deleteExpando;for(var i=0,elem;(elem=elems[i])!=null;i++){id=elem[jQuery.expando];if(id){data=cache[id];if(data.events){for(var type in data.events){if(special[type]){jQuery.event.remove(elem,type)}else{removeEvent(elem,type,data.handle)}}}if(deleteExpando){delete elem[jQuery.expando]}else{if(elem.removeAttribute){elem.removeAttribute(jQuery.expando)}}delete cache[id]}}}});var rexclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,ralpha=/alpha\([^)]*\)/,ropacity=/opacity=([^)]*)/,rfloat=/float/i,rdashAlpha=/-([a-z])/ig,rupper=/([A-Z])/g,rnumpx=/^-?\d+(?:px)?$/i,rnum=/^-?\d/,cssShow={position:"absolute",visibility:"hidden",display:"block"},cssWidth=["Left","Right"],cssHeight=["Top","Bottom"],getComputedStyle=document.defaultView&&document.defaultView.getComputedStyle,styleFloat=jQuery.support.cssFloat?"cssFloat":"styleFloat",fcamelCase=function(all,letter){return letter.toUpperCase()};jQuery.fn.css=function(name,value){return access(this,name,value,true,function(elem,name,value){if(value===undefined){return jQuery.curCSS(elem,name)}if(typeof value==="number"&&!rexclude.test(name)){value+="px"}jQuery.style(elem,name,value)})};jQuery.extend({style:function(elem,name,value){if(!elem||elem.nodeType===3||elem.nodeType===8){return undefined}if((name==="width"||name==="height")&&parseFloat(value)<0){value=undefined}var style=elem.style||elem,set=value!==undefined;if(!jQuery.support.opacity&&name==="opacity"){if(set){style.zoom=1;var opacity=parseInt(value,10)+""==="NaN"?"":"alpha(opacity="+value*100+")";var filter=style.filter||jQuery.curCSS(elem,"filter")||"";style.filter=ralpha.test(filter)?filter.replace(ralpha,opacity):opacity}return style.filter&&style.filter.indexOf("opacity=")>=0?(parseFloat(ropacity.exec(style.filter)[1])/100)+"":""}if(rfloat.test(name)){name=styleFloat}name=name.replace(rdashAlpha,fcamelCase);if(set){style[name]=value}return style[name]},css:function(elem,name,force,extra){if(name==="width"||name==="height"){var val,props=cssShow,which=name==="width"?cssWidth:cssHeight;function getWH(){val=name==="width"?elem.offsetWidth:elem.offsetHeight;if(extra==="border"){return}jQuery.each(which,function(){if(!extra){val-=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0}if(extra==="margin"){val+=parseFloat(jQuery.curCSS(elem,"margin"+this,true))||0}else{val-=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0}})}if(elem.offsetWidth!==0){getWH()}else{jQuery.swap(elem,props,getWH)}return Math.max(0,Math.round(val))}return jQuery.curCSS(elem,name,force)},curCSS:function(elem,name,force){var ret,style=elem.style,filter;if(!jQuery.support.opacity&&name==="opacity"&&elem.currentStyle){ret=ropacity.test(elem.currentStyle.filter||"")?(parseFloat(RegExp.$1)/100)+"":"";return ret===""?"1":ret}if(rfloat.test(name)){name=styleFloat}if(!force&&style&&style[name]){ret=style[name]}else{if(getComputedStyle){if(rfloat.test(name)){name="float"}name=name.replace(rupper,"-$1").toLowerCase();var defaultView=elem.ownerDocument.defaultView;if(!defaultView){return null}var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle){ret=computedStyle.getPropertyValue(name)}if(name==="opacity"&&ret===""){ret="1"}}else{if(elem.currentStyle){var camelCase=name.replace(rdashAlpha,fcamelCase);ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!rnumpx.test(ret)&&rnum.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=camelCase==="fontSize"?"1em":(ret||0);ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft}}}}return ret},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name]}callback.call(elem);for(var name in options){elem.style[name]=old[name]}}});if(jQuery.expr&&jQuery.expr.filters){jQuery.expr.filters.hidden=function(elem){var width=elem.offsetWidth,height=elem.offsetHeight,skip=elem.nodeName.toLowerCase()==="tr";return width===0&&height===0&&!skip?true:width>0&&height>0&&!skip?false:jQuery.curCSS(elem,"display")==="none"};jQuery.expr.filters.visible=function(elem){return !jQuery.expr.filters.hidden(elem)}}var jsc=now(),rscript=/<script(.|\s)*?\/script>/gi,rselectTextarea=/select|textarea/i,rinput=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,jsre=/=\?(&|$)/,rquery=/\?/,rts=/(\?|&)_=.*?(&|$)/,rurl=/^(\w+:)?\/\/([^\/?#]+)/,r20=/%20/g,_load=jQuery.fn.load;jQuery.fn.extend({load:function(url,params,callback){if(typeof url!=="string"){return _load.call(this,url)}else{if(!this.length){return this}}var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off)}var type="GET";if(params){if(jQuery.isFunction(params)){callback=params;params=null}else{if(typeof params==="object"){params=jQuery.param(params,jQuery.ajaxSettings.traditional);type="POST"}}}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status==="success"||status==="notmodified"){self.html(selector?jQuery("<div />").append(res.responseText.replace(rscript,"")).find(selector):res.responseText)}if(callback){self.each(callback,[res.responseText,status,res])}}});return this},serialize:function(){return jQuery.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?jQuery.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||rselectTextarea.test(this.nodeName)||rinput.test(this.type))}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:jQuery.isArray(val)?jQuery.map(val,function(val,i){return{name:elem.name,value:val}}):{name:elem.name,value:val}}).get()}});jQuery.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f)}});jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){type=type||callback;callback=data;data=null}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type})},getScript:function(url,callback){return jQuery.get(url,null,callback,"script")},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json")},post:function(url,data,callback,type){if(jQuery.isFunction(data)){type=type||callback;callback=data;data={}}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type})},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:window.XMLHttpRequest&&(window.location.protocol!=="file:"||!window.ActiveXObject)?function(){return new window.XMLHttpRequest()}:function(){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(origSettings){var s=jQuery.extend(true,{},jQuery.ajaxSettings,origSettings);var jsonp,status,data,callbackContext=origSettings&&origSettings.context||s,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!=="string"){s.data=jQuery.param(s.data,s.traditional)}if(s.dataType==="jsonp"){if(type==="GET"){if(!jsre.test(s.url)){s.url+=(rquery.test(s.url)?"&":"?")+(s.jsonp||"callback")+"=?"}}else{if(!s.data||!jsre.test(s.data)){s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?"}}s.dataType="json"}if(s.dataType==="json"&&(s.data&&jsre.test(s.data)||jsre.test(s.url))){jsonp=s.jsonpCallback||("jsonp"+jsc++);if(s.data){s.data=(s.data+"").replace(jsre,"="+jsonp+"$1")}s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=window[jsonp]||function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp]}catch(e){}if(head){head.removeChild(script)}}}if(s.dataType==="script"&&s.cache===null){s.cache=false}if(s.cache===false&&type==="GET"){var ts=now();var ret=s.url.replace(rts,"$1_="+ts+"$2");s.url=ret+((ret===s.url)?(rquery.test(s.url)?"&":"?")+"_="+ts:"")}if(s.data&&type==="GET"){s.url+=(rquery.test(s.url)?"&":"?")+s.data}if(s.global&&!jQuery.active++){jQuery.event.trigger("ajaxStart")}var parts=rurl.exec(s.url),remote=parts&&(parts[1]&&parts[1]!==location.protocol||parts[2]!==location.host);if(s.dataType==="script"&&type==="GET"&&remote){var head=document.getElementsByTagName("head")[0]||document.documentElement;var script=document.createElement("script");script.src=s.url;if(s.scriptCharset){script.charset=s.scriptCharset}if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){done=true;success();complete();script.onload=script.onreadystatechange=null;if(head&&script.parentNode){head.removeChild(script)}}}}head.insertBefore(script,head.firstChild);return undefined}var requestDone=false;var xhr=s.xhr();if(!xhr){return}if(s.username){xhr.open(type,s.url,s.async,s.username,s.password)}else{xhr.open(type,s.url,s.async)}try{if(s.data||origSettings&&origSettings.contentType){xhr.setRequestHeader("Content-Type",s.contentType)}if(s.ifModified){if(jQuery.lastModified[s.url]){xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url])}if(jQuery.etag[s.url]){xhr.setRequestHeader("If-None-Match",jQuery.etag[s.url])}}if(!remote){xhr.setRequestHeader("X-Requested-With","XMLHttpRequest")}xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default)}catch(e){}if(s.beforeSend&&s.beforeSend.call(callbackContext,xhr,s)===false){if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop")}xhr.abort();return false}if(s.global){trigger("ajaxSend",[xhr,s])}var onreadystatechange=xhr.onreadystatechange=function(isTimeout){if(!xhr||xhr.readyState===0||isTimeout==="abort"){if(!requestDone){complete()}requestDone=true;if(xhr){xhr.onreadystatechange=jQuery.noop}}else{if(!requestDone&&xhr&&(xhr.readyState===4||isTimeout==="timeout")){requestDone=true;xhr.onreadystatechange=jQuery.noop;status=isTimeout==="timeout"?"timeout":!jQuery.httpSuccess(xhr)?"error":s.ifModified&&jQuery.httpNotModified(xhr,s.url)?"notmodified":"success";var errMsg;if(status==="success"){try{data=jQuery.httpData(xhr,s.dataType,s)}catch(err){status="parsererror";errMsg=err}}if(status==="success"||status==="notmodified"){if(!jsonp){success()}}else{jQuery.handleError(s,xhr,status,errMsg)}complete();if(isTimeout==="timeout"){xhr.abort()}if(s.async){xhr=null}}}};try{var oldAbort=xhr.abort;xhr.abort=function(){if(xhr){oldAbort.call(xhr)}onreadystatechange("abort")}}catch(e){}if(s.async&&s.timeout>0){setTimeout(function(){if(xhr&&!requestDone){onreadystatechange("timeout")}},s.timeout)}try{xhr.send(type==="POST"||type==="PUT"||type==="DELETE"?s.data:null)}catch(e){jQuery.handleError(s,xhr,null,e);complete()}if(!s.async){onreadystatechange()}function success(){if(s.success){s.success.call(callbackContext,data,status,xhr)}if(s.global){trigger("ajaxSuccess",[xhr,s])}}function complete(){if(s.complete){s.complete.call(callbackContext,xhr,status)}if(s.global){trigger("ajaxComplete",[xhr,s])}if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop")}}function trigger(type,args){(s.context?jQuery(s.context):jQuery.event).trigger(type,args)}return xhr},handleError:function(s,xhr,status,e){if(s.error){s.error.call(s.context||s,xhr,status,e)}if(s.global){(s.context?jQuery(s.context):jQuery.event).trigger("ajaxError",[xhr,s,e])}},active:0,httpSuccess:function(xhr){try{return !xhr.status&&location.protocol==="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status===304||xhr.status===1223||xhr.status===0}catch(e){}return false},httpNotModified:function(xhr,url){var lastModified=xhr.getResponseHeader("Last-Modified"),etag=xhr.getResponseHeader("Etag");if(lastModified){jQuery.lastModified[url]=lastModified}if(etag){jQuery.etag[url]=etag}return xhr.status===304||xhr.status===0},httpData:function(xhr,type,s){var ct=xhr.getResponseHeader("content-type")||"",xml=type==="xml"||!type&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.nodeName==="parsererror"){jQuery.error("parsererror")}if(s&&s.dataFilter){data=s.dataFilter(data,type)}if(typeof data==="string"){if(type==="json"||!type&&ct.indexOf("json")>=0){data=jQuery.parseJSON(data)}else{if(type==="script"||!type&&ct.indexOf("javascript")>=0){jQuery.globalEval(data)}}}return data},param:function(a,traditional){var s=[];if(traditional===undefined){traditional=jQuery.ajaxSettings.traditional}if(jQuery.isArray(a)||a.jquery){jQuery.each(a,function(){add(this.name,this.value)})}else{for(var prefix in a){buildParams(prefix,a[prefix])}}return s.join("&").replace(r20,"+");function buildParams(prefix,obj){if(jQuery.isArray(obj)){jQuery.each(obj,function(i,v){if(traditional||/\[\]$/.test(prefix)){add(prefix,v)}else{buildParams(prefix+"["+(typeof v==="object"||jQuery.isArray(v)?i:"")+"]",v)}})}else{if(!traditional&&obj!=null&&typeof obj==="object"){jQuery.each(obj,function(k,v){buildParams(prefix+"["+k+"]",v)})}else{add(prefix,obj)}}}function add(key,value){value=jQuery.isFunction(value)?value():value;s[s.length]=encodeURIComponent(key)+"="+encodeURIComponent(value)}}});var elemdisplay={},rfxtypes=/toggle|show|hide/,rfxnum=/^([+-]=)?([\d+-.]+)(.*)$/,timerId,fxAttrs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];jQuery.fn.extend({show:function(speed,callback){if(speed||speed===0){return this.animate(genFx("show",3),speed,callback)}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");this[i].style.display=old||"";if(jQuery.css(this[i],"display")==="none"){var nodeName=this[i].nodeName,display;if(elemdisplay[nodeName]){display=elemdisplay[nodeName]}else{var elem=jQuery("<"+nodeName+" />").appendTo("body");display=elem.css("display");if(display==="none"){display="block"}elem.remove();elemdisplay[nodeName]=display}jQuery.data(this[i],"olddisplay",display)}}for(var j=0,k=this.length;j<k;j++){this[j].style.display=jQuery.data(this[j],"olddisplay")||""}return this}},hide:function(speed,callback){if(speed||speed===0){return this.animate(genFx("hide",3),speed,callback)}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");if(!old&&old!=="none"){jQuery.data(this[i],"olddisplay",jQuery.css(this[i],"display"))}}for(var j=0,k=this.length;j<k;j++){this[j].style.display="none"}return this}},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){var bool=typeof fn==="boolean";if(jQuery.isFunction(fn)&&jQuery.isFunction(fn2)){this._toggle.apply(this,arguments)}else{if(fn==null||bool){this.each(function(){var state=bool?fn:jQuery(this).is(":hidden");jQuery(this)[state?"show":"hide"]()})}else{this.animate(genFx("toggle",3),fn,fn2)}}return this},fadeTo:function(speed,to,callback){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:to},speed,callback)},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);if(jQuery.isEmptyObject(prop)){return this.each(optall.complete)}return this[optall.queue===false?"each":"queue"](function(){var opt=jQuery.extend({},optall),p,hidden=this.nodeType===1&&jQuery(this).is(":hidden"),self=this;for(p in prop){var name=p.replace(rdashAlpha,fcamelCase);if(p!==name){prop[name]=prop[p];delete prop[p];p=name}if(prop[p]==="hide"&&hidden||prop[p]==="show"&&!hidden){return opt.complete.call(this)}if((p==="height"||p==="width")&&this.style){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow}if(jQuery.isArray(prop[p])){(opt.specialEasing=opt.specialEasing||{})[p]=prop[p][1];prop[p]=prop[p][0]}}if(opt.overflow!=null){this.style.overflow="hidden"}opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(rfxtypes.test(val)){e[val==="toggle"?hidden?"show":"hide":val](prop)}else{var parts=rfxnum.exec(val),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!=="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit}if(parts[1]){end=((parts[1]==="-="?-1:1)*end)+start}e.custom(start,end,unit)}else{e.custom(start,val,"")}}});return true})},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue){this.queue([])}this.each(function(){for(var i=timers.length-1;i>=0;i--){if(timers[i].elem===this){if(gotoEnd){timers[i](true)}timers.splice(i,1)}}});if(!gotoEnd){this.dequeue()}return this}});jQuery.each({slideDown:genFx("show",1),slideUp:genFx("hide",1),slideToggle:genFx("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(name,props){jQuery.fn[name]=function(speed,callback){return this.animate(props,speed,callback)}});jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&typeof speed==="object"?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&!jQuery.isFunction(easing)&&easing};opt.duration=jQuery.fx.off?0:typeof opt.duration==="number"?opt.duration:jQuery.fx.speeds[opt.duration]||jQuery.fx.speeds._default;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false){jQuery(this).dequeue()}if(jQuery.isFunction(opt.old)){opt.old.call(this)}};return opt},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum}},timers:[],fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig){options.orig={}}}});jQuery.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(force){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;var self=this;function t(gotoEnd){return self.step(gotoEnd)}t.elem=this.elem;if(t()&&jQuery.timers.push(t)&&!timerId){timerId=setInterval(jQuery.fx.tick,13)}},show:function(){this.options.orig[this.prop]=jQuery.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());jQuery(this.elem).show()},hide:function(){this.options.orig[this.prop]=jQuery.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(gotoEnd){var t=now(),done=true;if(gotoEnd||t>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var i in this.options.curAnim){if(this.options.curAnim[i]!==true){done=false}}if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;var old=jQuery.data(this.elem,"olddisplay");this.elem.style.display=old?old:this.options.display;if(jQuery.css(this.elem,"display")==="none"){this.elem.style.display="block"}}if(this.options.hide){jQuery(this.elem).hide()}if(this.options.hide||this.options.show){for(var p in this.options.curAnim){jQuery.style(this.elem,p,this.options.orig[p])}}this.options.complete.call(this.elem)}return false}else{var n=t-this.startTime;this.state=n/this.options.duration;var specialEasing=this.options.specialEasing&&this.options.specialEasing[this.prop];var defaultEasing=this.options.easing||(jQuery.easing.swing?"swing":"linear");this.pos=jQuery.easing[specialEasing||defaultEasing](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};jQuery.extend(jQuery.fx,{tick:function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++){if(!timers[i]()){timers.splice(i--,1)}}if(!timers.length){jQuery.fx.stop()}},stop:function(){clearInterval(timerId);timerId=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(fx){jQuery.style(fx.elem,"opacity",fx.now)},_default:function(fx){if(fx.elem.style&&fx.elem.style[fx.prop]!=null){fx.elem.style[fx.prop]=(fx.prop==="width"||fx.prop==="height"?Math.max(0,fx.now):fx.now)+fx.unit}else{fx.elem[fx.prop]=fx.now}}}});if(jQuery.expr&&jQuery.expr.filters){jQuery.expr.filters.animated=function(elem){return jQuery.grep(jQuery.timers,function(fn){return elem===fn.elem}).length}}function genFx(type,num){var obj={};jQuery.each(fxAttrs.concat.apply([],fxAttrs.slice(0,num)),function(){obj[this]=type});return obj}if("getBoundingClientRect" in document.documentElement){jQuery.fn.offset=function(options){var elem=this[0];if(options){return this.each(function(i){jQuery.offset.setOffset(this,options,i)})}if(!elem||!elem.ownerDocument){return null}if(elem===elem.ownerDocument.body){return jQuery.offset.bodyOffset(elem)}var box=elem.getBoundingClientRect(),doc=elem.ownerDocument,body=doc.body,docElem=doc.documentElement,clientTop=docElem.clientTop||body.clientTop||0,clientLeft=docElem.clientLeft||body.clientLeft||0,top=box.top+(self.pageYOffset||jQuery.support.boxModel&&docElem.scrollTop||body.scrollTop)-clientTop,left=box.left+(self.pageXOffset||jQuery.support.boxModel&&docElem.scrollLeft||body.scrollLeft)-clientLeft;return{top:top,left:left}}}else{jQuery.fn.offset=function(options){var elem=this[0];if(options){return this.each(function(i){jQuery.offset.setOffset(this,options,i)})}if(!elem||!elem.ownerDocument){return null}if(elem===elem.ownerDocument.body){return jQuery.offset.bodyOffset(elem)}jQuery.offset.initialize();var offsetParent=elem.offsetParent,prevOffsetParent=elem,doc=elem.ownerDocument,computedStyle,docElem=doc.documentElement,body=doc.body,defaultView=doc.defaultView,prevComputedStyle=defaultView?defaultView.getComputedStyle(elem,null):elem.currentStyle,top=elem.offsetTop,left=elem.offsetLeft;while((elem=elem.parentNode)&&elem!==body&&elem!==docElem){if(jQuery.offset.supportsFixedPosition&&prevComputedStyle.position==="fixed"){break}computedStyle=defaultView?defaultView.getComputedStyle(elem,null):elem.currentStyle;top-=elem.scrollTop;left-=elem.scrollLeft;if(elem===offsetParent){top+=elem.offsetTop;left+=elem.offsetLeft;if(jQuery.offset.doesNotAddBorder&&!(jQuery.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(elem.nodeName))){top+=parseFloat(computedStyle.borderTopWidth)||0;left+=parseFloat(computedStyle.borderLeftWidth)||0}prevOffsetParent=offsetParent,offsetParent=elem.offsetParent}if(jQuery.offset.subtractsBorderForOverflowNotVisible&&computedStyle.overflow!=="visible"){top+=parseFloat(computedStyle.borderTopWidth)||0;left+=parseFloat(computedStyle.borderLeftWidth)||0}prevComputedStyle=computedStyle}if(prevComputedStyle.position==="relative"||prevComputedStyle.position==="static"){top+=body.offsetTop;left+=body.offsetLeft}if(jQuery.offset.supportsFixedPosition&&prevComputedStyle.position==="fixed"){top+=Math.max(docElem.scrollTop,body.scrollTop);left+=Math.max(docElem.scrollLeft,body.scrollLeft)}return{top:top,left:left}}}jQuery.offset={initialize:function(){var body=document.body,container=document.createElement("div"),innerDiv,checkDiv,table,td,bodyMarginTop=parseFloat(jQuery.curCSS(body,"marginTop",true))||0,html="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";jQuery.extend(container.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});container.innerHTML=html;body.insertBefore(container,body.firstChild);innerDiv=container.firstChild;checkDiv=innerDiv.firstChild;td=innerDiv.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(checkDiv.offsetTop!==5);this.doesAddBorderForTableAndCells=(td.offsetTop===5);checkDiv.style.position="fixed",checkDiv.style.top="20px";this.supportsFixedPosition=(checkDiv.offsetTop===20||checkDiv.offsetTop===15);checkDiv.style.position=checkDiv.style.top="";innerDiv.style.overflow="hidden",innerDiv.style.position="relative";this.subtractsBorderForOverflowNotVisible=(checkDiv.offsetTop===-5);this.doesNotIncludeMarginInBodyOffset=(body.offsetTop!==bodyMarginTop);body.removeChild(container);body=container=innerDiv=checkDiv=table=td=null;jQuery.offset.initialize=jQuery.noop},bodyOffset:function(body){var top=body.offsetTop,left=body.offsetLeft;jQuery.offset.initialize();if(jQuery.offset.doesNotIncludeMarginInBodyOffset){top+=parseFloat(jQuery.curCSS(body,"marginTop",true))||0;left+=parseFloat(jQuery.curCSS(body,"marginLeft",true))||0}return{top:top,left:left}},setOffset:function(elem,options,i){if(/static/.test(jQuery.curCSS(elem,"position"))){elem.style.position="relative"}var curElem=jQuery(elem),curOffset=curElem.offset(),curTop=parseInt(jQuery.curCSS(elem,"top",true),10)||0,curLeft=parseInt(jQuery.curCSS(elem,"left",true),10)||0;if(jQuery.isFunction(options)){options=options.call(elem,i,curOffset)}var props={top:(options.top-curOffset.top)+curTop,left:(options.left-curOffset.left)+curLeft};if("using" in options){options.using.call(elem,props)}else{curElem.css(props)}}};jQuery.fn.extend({position:function(){if(!this[0]){return null}var elem=this[0],offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].nodeName)?{top:0,left:0}:offsetParent.offset();offset.top-=parseFloat(jQuery.curCSS(elem,"marginTop",true))||0;offset.left-=parseFloat(jQuery.curCSS(elem,"marginLeft",true))||0;parentOffset.top+=parseFloat(jQuery.curCSS(offsetParent[0],"borderTopWidth",true))||0;parentOffset.left+=parseFloat(jQuery.curCSS(offsetParent[0],"borderLeftWidth",true))||0;return{top:offset.top-parentOffset.top,left:offset.left-parentOffset.left}},offsetParent:function(){return this.map(function(){var offsetParent=this.offsetParent||document.body;while(offsetParent&&(!/^body|html$/i.test(offsetParent.nodeName)&&jQuery.css(offsetParent,"position")==="static")){offsetParent=offsetParent.offsetParent}return offsetParent})}});jQuery.each(["Left","Top"],function(i,name){var method="scroll"+name;jQuery.fn[method]=function(val){var elem=this[0],win;if(!elem){return null}if(val!==undefined){return this.each(function(){win=getWindow(this);if(win){win.scrollTo(!i?val:jQuery(win).scrollLeft(),i?val:jQuery(win).scrollTop())}else{this[method]=val}})}else{win=getWindow(elem);return win?("pageXOffset" in win)?win[i?"pageYOffset":"pageXOffset"]:jQuery.support.boxModel&&win.document.documentElement[method]||win.document.body[method]:elem[method]}}});function getWindow(elem){return("scrollTo" in elem&&elem.document)?elem:elem.nodeType===9?elem.defaultView||elem.parentWindow:false}jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],type,false,"padding"):null};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],type,false,margin?"margin":"border"):null};jQuery.fn[type]=function(size){var elem=this[0];if(!elem){return size==null?null:this}if(jQuery.isFunction(size)){return this.each(function(i){var self=jQuery(this);self[type](size.call(this,i,self[type]()))})}return("scrollTo" in elem&&elem.document)?elem.document.compatMode==="CSS1Compat"&&elem.document.documentElement["client"+name]||elem.document.body["client"+name]:(elem.nodeType===9)?Math.max(elem.documentElement["client"+name],elem.body["scroll"+name],elem.documentElement["scroll"+name],elem.body["offset"+name],elem.documentElement["offset"+name]):size===undefined?jQuery.css(elem,type):this.css(type,typeof size==="string"?size:size+"px")}});window.jQuery=window.$=jQuery})(window);
/*
 * jQuery UI 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||function(c){c.ui={version:"1.8.1",plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode){for(var e=0;e<b.length;e++){a.options[b[e][0]]&&b[e][1].apply(a.element,d)}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")=="hidden"){return false}b=b&&b=="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0){return true}a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,f,g){return c.ui.isOverAxis(a,d,f)&&c.ui.isOverAxis(b,e,g)},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none")},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==undefined){return this.css("zIndex",a)}if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b=="absolute"||b=="relative"||b=="fixed"){b=parseInt(a.css("zIndex"));if(!isNaN(b)&&b!=0){return b}}a=a.parent()}}return 0}});c.extend(c.expr[":"],{data:function(a,b,d){return !!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b||"area"==b?a.href||!isNaN(d):!isNaN(d))&&!c(a)["area"==b?"parents":"closest"](":hidden").length},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}})}(jQuery);
/*
 * jQuery UI Widget 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b){var j=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c){if(!a||b.filter(a,[this]).length){b("*",this).add(this).each(function(){b(this).triggerHandler("remove")})}}return j.call(b(this),a,c)})};b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return !!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend({},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.substring(0,1)==="_"){return h}e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==undefined){h=i;return false}}):this.each(function(){var g=b.data(this,a);if(g){d&&g.option(d);g._init()}else{b.data(this,a,new c(d,this))}});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){this.element=b(c).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(c)[this.widgetName],a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a,e=this;if(arguments.length===0){return b.extend({},e.options)}if(typeof a==="string"){if(c===undefined){return this.options[a]}d={};d[a]=c}b.each(d,function(f,h){e._setOption(f,h)});return e},_setOption:function(a,c){this.options[a]=c;if(a==="disabled"){this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return !(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
/*
 * jQuery UI Mouse 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Mouse
 *
 * Depends:
 *	jquery.ui.widget.js
 */
(function(c){c.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(b){return a._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(a._preventClickEvent){a._preventClickEvent=false;b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var b=this,e=a.which==1,f=typeof this.options.cancel=="string"?c(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}this._mouseMoveDelegate=function(d){return b._mouseMove(d)};this._mouseUpDelegate=function(d){return b._mouseUp(d)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);c.browser.safari||a.preventDefault();return a.originalEvent.mouseHandled=true}},_mouseMove:function(a){if(c.browser.msie&&!a.button){return this._mouseUp(a)}if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a)}return !this._mouseStarted},_mouseUp:function(a){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=a.target==this._mouseDownEvent.target;this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);(function(c){c.ui=c.ui||{};var m=/left|center|right/,n=/top|center|bottom/,p=c.fn.position,q=c.fn.offset;c.fn.position=function(a){if(!a||!a.of){return p.apply(this,arguments)}a=c.extend({},a);var b=c(a.of),d=(a.collision||"flip").split(" "),e=a.offset?a.offset.split(" "):[0,0],g,h,i;if(a.of.nodeType===9){g=b.width();h=b.height();i={top:0,left:0}}else{if(a.of.scrollTo&&a.of.document){g=b.width();h=b.height();i={top:b.scrollTop(),left:b.scrollLeft()}}else{if(a.of.preventDefault){a.at="left top";g=h=0;i={top:a.of.pageY,left:a.of.pageX}}else{g=b.outerWidth();h=b.outerHeight();i=b.offset()}}}c.each(["my","at"],function(){var f=(a[this]||"").split(" ");if(f.length===1){f=m.test(f[0])?f.concat(["center"]):n.test(f[0])?["center"].concat(f):["center","center"]}f[0]=m.test(f[0])?f[0]:"center";f[1]=n.test(f[1])?f[1]:"center";a[this]=f});if(d.length===1){d[1]=d[0]}e[0]=parseInt(e[0],10)||0;if(e.length===1){e[1]=e[0]}e[1]=parseInt(e[1],10)||0;if(a.at[0]==="right"){i.left+=g}else{if(a.at[0]==="center"){i.left+=g/2}}if(a.at[1]==="bottom"){i.top+=h}else{if(a.at[1]==="center"){i.top+=h/2}}i.left+=e[0];i.top+=e[1];return this.each(function(){var f=c(this),k=f.outerWidth(),l=f.outerHeight(),j=c.extend({},i);if(a.my[0]==="right"){j.left-=k}else{if(a.my[0]==="center"){j.left-=k/2}}if(a.my[1]==="bottom"){j.top-=l}else{if(a.my[1]==="center"){j.top-=l/2}}j.left=parseInt(j.left);j.top=parseInt(j.top);c.each(["left","top"],function(o,r){c.ui.position[d[o]]&&c.ui.position[d[o]][r](j,{targetWidth:g,targetHeight:h,elemWidth:k,elemHeight:l,offset:e,my:a.my,at:a.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(j,{using:a.using}))})};c.ui.position={fit:{left:function(a,b){var d=c(window);b=a.left+b.elemWidth-d.width()-d.scrollLeft();a.left=b>0?a.left-b:Math.max(0,a.left)},top:function(a,b){var d=c(window);b=a.top+b.elemHeight-d.height()-d.scrollTop();a.top=b>0?a.top-b:Math.max(0,a.top)}},flip:{left:function(a,b){if(b.at[0]!=="center"){var d=c(window);d=a.left+b.elemWidth-d.width()-d.scrollLeft();var e=b.my[0]==="left"?-b.elemWidth:b.my[0]==="right"?b.elemWidth:0,g=-2*b.offset[0];a.left+=a.left<0?e+b.targetWidth+g:d>0?e-b.targetWidth+g:0}},top:function(a,b){if(b.at[1]!=="center"){var d=c(window);d=a.top+b.elemHeight-d.height()-d.scrollTop();var e=b.my[1]==="top"?-b.elemHeight:b.my[1]==="bottom"?b.elemHeight:0,g=b.at[1]==="top"?b.targetHeight:-b.targetHeight,h=-2*b.offset[1];a.top+=a.top<0?e+b.targetHeight+h:d>0?e+g+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(a,b){if(/static/.test(c.curCSS(a,"position"))){a.style.position="relative"}var d=c(a),e=d.offset(),g=parseInt(c.curCSS(a,"top",true),10)||0,h=parseInt(c.curCSS(a,"left",true),10)||0;e={top:b.top-e.top+g,left:b.left-e.left+h};"using" in b?b.using.call(a,e):d.css(e)};c.fn.offset=function(a){var b=this[0];if(!b||!b.ownerDocument){return null}if(a){return this.each(function(){c.offset.setOffset(this,a)})}return q.call(this)}}})(jQuery);(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var b=this,a=this.options;this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");a.disabled&&this.element.addClass("ui-slider-disabled ui-disabled");this.range=d([]);if(a.range){if(a.range===true){this.range=d("<div></div>");if(!a.values){a.values=[this._valueMin(),this._valueMin()]}if(a.values.length&&a.values.length!==2){a.values=[a.values[0],a.values[0]]}}else{this.range=d("<div></div>")}this.range.appendTo(this.element).addClass("ui-slider-range");if(a.range==="min"||a.range==="max"){this.range.addClass("ui-slider-range-"+a.range)}this.range.addClass("ui-widget-header")}d(".ui-slider-handle",this.element).length===0&&d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");if(a.values&&a.values.length){for(;d(".ui-slider-handle",this.element).length<a.values.length;){d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle")}}this.handles=d(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(c){c.preventDefault()}).hover(function(){a.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(a.disabled){d(this).blur()}else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(c){d(this).data("index.ui-slider-handle",c)});this.handles.keydown(function(c){var e=true,f=d(this).data("index.ui-slider-handle"),g,h,i;if(!b.options.disabled){switch(c.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:e=false;if(!b._keySliding){b._keySliding=true;d(this).addClass("ui-state-active");g=b._start(c,f);if(g===false){return}}break}i=b.options.step;g=b.options.values&&b.options.values.length?(h=b.values(f)):(h=b.value());switch(c.keyCode){case d.ui.keyCode.HOME:h=b._valueMin();break;case d.ui.keyCode.END:h=b._valueMax();break;case d.ui.keyCode.PAGE_UP:h=g+(b._valueMax()-b._valueMin())/5;break;case d.ui.keyCode.PAGE_DOWN:h=g-(b._valueMax()-b._valueMin())/5;break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(g===b._valueMax()){return}h=g+i;break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(g===b._valueMin()){return}h=g-i;break}b._slide(c,f,h);return e}}).keyup(function(c){var e=d(this).data("index.ui-slider-handle");if(b._keySliding){b._keySliding=false;b._stop(c,e);b._change(c,e);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(b){var a=this.options,c,e,f,g,h,i;if(a.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c={x:b.pageX,y:b.pageY};e=this._normValueFromMouse(c);f=this._valueMax()-this._valueMin()+1;h=this;this.handles.each(function(j){var k=Math.abs(e-h.values(j));if(f>k){f=k;g=d(this);i=j}});if(a.range===true&&this.values(1)===a.min){i+=1;g=d(this.handles[i])}if(this._start(b,i)===false){return false}this._mouseSliding=true;h._handleIndex=i;g.addClass("ui-state-active").focus();a=g.offset();this._clickOffset=!d(b.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:b.pageX-a.left-g.width()/2,top:b.pageY-a.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)};e=this._normValueFromMouse(c);this._slide(b,i,e);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(b){var a=this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b,this._handleIndex,a);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(b){var a;if(this.orientation==="horizontal"){a=this.elementSize.width;b=b.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{a=this.elementSize.height;b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}a=b/a;if(a>1){a=1}if(a<0){a=0}if(this.orientation==="vertical"){a=1-a}b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+a*b)},_start:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}return this._trigger("start",b,c)},_slide:function(b,a,c){var e;if(this.options.values&&this.options.values.length){e=this.values(a?0:1);if(this.options.values.length===2&&this.options.range===true&&(a===0&&c>e||a===1&&c<e)){c=e}if(c!==this.values(a)){e=this.values();e[a]=c;b=this._trigger("slide",b,{handle:this.handles[a],value:c,values:e});this.values(a?0:1);b!==false&&this.values(a,c,true)}}else{if(c!==this.value()){b=this._trigger("slide",b,{handle:this.handles[a],value:c});b!==false&&this.value(c)}}},_stop:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("stop",b,c)},_change:function(b,a){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("change",b,c)}},value:function(b){if(arguments.length){this.options.value=this._trimAlignValue(b);this._refreshValue();this._change(null,0)}return this._value()},values:function(b,a){var c,e,f;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(a);this._refreshValue();this._change(null,b)}if(arguments.length){if(d.isArray(arguments[0])){c=this.options.values;e=arguments[0];for(f=0;f<c.length;f+=1){c[f]=this._trimAlignValue(e[f]);this._change(null,f)}this._refreshValue()}else{return this.options.values&&this.options.values.length?this._values(b):this.value()}}else{return this._values()}},_setOption:function(b,a){var c,e=0;if(d.isArray(this.options.values)){e=this.options.values.length}d.Widget.prototype._setOption.apply(this,arguments);switch(b){case"disabled":if(a){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");this.element.addClass("ui-disabled")}else{this.handles.removeAttr("disabled");this.element.removeClass("ui-disabled")}break;case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case"value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case"values":this._animateOff=true;this._refreshValue();for(c=0;c<e;c+=1){this._change(null,c)}this._animateOff=false;break}},_value:function(){var b=this.options.value;return b=this._trimAlignValue(b)},_values:function(b){var a,c;if(arguments.length){a=this.options.values[b];return a=this._trimAlignValue(a)}else{a=this.options.values.slice();for(c=0;c<a.length;c+=1){a[c]=this._trimAlignValue(a[c])}return a}},_trimAlignValue:function(b){if(b<this._valueMin()){return this._valueMin()}if(b>this._valueMax()){return this._valueMax()}var a=this.options.step,c=b%a;b=b-c;if(c>=a/2){b+=a}return parseFloat(b.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,a=this.options,c=this,e=!this._animateOff?a.animate:false,f,g={},h,i,j,k;if(this.options.values&&this.options.values.length){this.handles.each(function(l){f=(c.values(l)-c._valueMin())/(c._valueMax()-c._valueMin())*100;g[c.orientation==="horizontal"?"left":"bottom"]=f+"%";d(this).stop(1,1)[e?"animate":"css"](g,a.animate);if(c.options.range===true){if(c.orientation==="horizontal"){if(l===0){c.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},a.animate)}if(l===1){c.range[e?"animate":"css"]({width:f-h+"%"},{queue:false,duration:a.animate})}}else{if(l===0){c.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},a.animate)}if(l===1){c.range[e?"animate":"css"]({height:f-h+"%"},{queue:false,duration:a.animate})}}}h=f})}else{i=this.value();j=this._valueMin();k=this._valueMax();f=k!==j?(i-j)/(k-j)*100:0;g[c.orientation==="horizontal"?"left":"bottom"]=f+"%";this.handle.stop(1,1)[e?"animate":"css"](g,a.animate);if(b==="min"&&this.orientation==="horizontal"){this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},a.animate)}if(b==="max"&&this.orientation==="horizontal"){this.range[e?"animate":"css"]({width:100-f+"%"},{queue:false,duration:a.animate})}if(b==="min"&&this.orientation==="vertical"){this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},a.animate)}if(b==="max"&&this.orientation==="vertical"){this.range[e?"animate":"css"]({height:100-f+"%"},{queue:false,duration:a.animate})}}}});d.extend(d.ui.slider,{version:"1.8.1"})})(jQuery);(function(d){function J(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass="ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:false,showMonthAfterYear:false,yearSuffix:""};this._defaults={showOn:"focus",showAnim:"show",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,yearRange:"c-10:c+10",showOtherMonths:false,selectOtherMonths:false,showWeek:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"_default",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:true,showButtonPanel:false,autoSize:false};d.extend(this._defaults,this.regional[""]);this.dpDiv=d('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>')}function E(a,b){d.extend(a,b);for(var c in b){if(b[c]==null||b[c]==undefined){a[c]=b[c]}}return a}d.extend(d.ui,{datepicker:{version:"1.8.1"}});var y=(new Date).getTime();d.extend(J.prototype,{markerClassName:"hasDatepicker",log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){E(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){a.id="dp"+ ++this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input"){this._connectDatepicker(a,i)}else{f&&this._inlineDatepicker(a,i)}},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c=="focus"||c=="both"){a.focus(this._showDatepicker)}if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++){if(f[g].length>h){h=f[g].length;i=g}}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b)}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){a="dp"+ ++this.uuid;this._dialogInput=d('<input type="text" id="'+a+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}E(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos){this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)]}this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else{if(e=="div"||e=="span"){b.removeClass(this.markerClassName).empty()}}}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else{if(e=="div"||e=="span"){b.children("."+this._inlineClass).children().removeClass("ui-state-disabled")}}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else{if(e=="div"||e=="span"){b.children("."+this._inlineClass).children().addClass("ui-state-disabled")}}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a){return false}for(var b=0;b<this._disabledInputs.length;b++){if(this._disabledInputs[b]==a){return true}}return false},_getInst:function(a){try{return d.data(a,"datepicker")}catch(b){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(a,b,c){var e=this._getInst(a);if(arguments.length==2&&typeof b=="string"){return b=="defaults"?d.extend({},d.datepicker._defaults):e?b=="all"?d.extend({},e.settings):this._get(e,b):null}var f=b||{};if(typeof b=="string"){f={};f[b]=c}if(e){this._curInst==e&&this._hideDatepicker();var h=this._getDateDatepicker(a,true);E(e.settings,f);this._attachments(d(a),e);this._autoSize(e);this._setDateDatepicker(a,h);this._updateDatepicker(e)}},_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){(a=this._getInst(a))&&this._updateDatepicker(a)},_setDateDatepicker:function(a,b){if(a=this._getInst(a)){this._setDate(a,b);this._updateDatepicker(a);this._updateAlternate(a)}},_getDateDatepicker:function(a,b){(a=this._getInst(a))&&!a.inline&&this._setDateFromField(a,b);return a?this._getDate(a):null},_doKeyDown:function(a){var b=d.datepicker._getInst(a.target),c=true,e=b.dpDiv.is(".ui-datepicker-rtl");b._keyEvent=true;if(d.datepicker._datepickerShowing){switch(a.keyCode){case 9:d.datepicker._hideDatepicker();c=false;break;case 13:c=d("td."+d.datepicker._dayOverClass,b.dpDiv).add(d("td."+d.datepicker._currentClass,b.dpDiv));c[0]?d.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,c[0]):d.datepicker._hideDatepicker();return false;case 27:d.datepicker._hideDatepicker();break;case 33:d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M");break;case 34:d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 35:if(a.ctrlKey||a.metaKey){d.datepicker._clearDate(a.target)}c=a.ctrlKey||a.metaKey;break;case 36:if(a.ctrlKey||a.metaKey){d.datepicker._gotoToday(a.target)}c=a.ctrlKey||a.metaKey;break;case 37:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,e?+1:-1,"D")}c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey){d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M")}break;case 38:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,-7,"D")}c=a.ctrlKey||a.metaKey;break;case 39:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,e?-1:+1,"D")}c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey){d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M")}break;case 40:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,+7,"D")}c=a.ctrlKey||a.metaKey;break;default:c=false}}else{if(a.keyCode==36&&a.ctrlKey){d.datepicker._showDatepicker(this)}else{c=false}}if(c){a.preventDefault();a.stopPropagation()}},_doKeyPress:function(a){var b=d.datepicker._getInst(a.target);if(d.datepicker._get(b,"constrainInput")){b=d.datepicker._possibleChars(d.datepicker._get(b,"dateFormat"));var c=String.fromCharCode(a.charCode==undefined?a.keyCode:a.charCode);return a.ctrlKey||c<" "||!b||b.indexOf(c)>-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal){try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input"){a=d("input",a.parentNode)[0]}if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);d.datepicker._curInst&&d.datepicker._curInst!=b&&d.datepicker._curInst.dpDiv.stop(true,true);var c=d.datepicker._get(b,"beforeShow");E(b.settings,c?c.apply(a,[a,b]):{});b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog){a.value=""}if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return !e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b);c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){d.datepicker._datepickerShowing=true;var i=d.datepicker._getBorders(b.dpDiv);b.dpDiv.find("iframe.ui-datepicker-cover").css({left:-i[0],top:-i[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})};b.dpDiv.zIndex(d(a).zIndex()+1);d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f){h()}b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}},_updateDatepicker:function(a){var b=this,c=d.datepicker._getBorders(a.dpDiv);a.dpDiv.empty().append(this._generateHTML(a)).find("iframe.ui-datepicker-cover").css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}).end().find("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a").bind("mouseout",function(){d(this).removeClass("ui-state-hover");this.className.indexOf("ui-datepicker-prev")!=-1&&d(this).removeClass("ui-datepicker-prev-hover");this.className.indexOf("ui-datepicker-next")!=-1&&d(this).removeClass("ui-datepicker-next-hover")}).bind("mouseover",function(){if(!b._isDisabledDatepicker(a.inline?a.dpDiv.parent()[0]:a.input[0])){d(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");d(this).addClass("ui-state-hover");this.className.indexOf("ui-datepicker-prev")!=-1&&d(this).addClass("ui-datepicker-prev-hover");this.className.indexOf("ui-datepicker-next")!=-1&&d(this).addClass("ui-datepicker-next-hover")}}).end().find("."+this._dayOverClass+" a").trigger("mouseover").end();c=this._getNumberOfMonths(a);var e=c[1];e>1?a.dpDiv.addClass("ui-datepicker-multi-"+e).css("width",17*e+"em"):a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");a.dpDiv[(c[0]!=1||c[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input.focus()},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(),h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),k=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>k&&k>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b=this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1);){a=a[b?"previousSibling":"nextSibling"]}a=d(a).offset();return[a.left,a.top]},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker"))){if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b);this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();if(a=this._get(b,"onClose")){a.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b])}this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e._selectingMonthYear=false;e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_clickMonthYear:function(a){a=this._getInst(d(a)[0]);a.input&&a._selectingMonthYear&&!d.browser.msie&&a.input.focus();a._selectingMonthYear=!a._selectingMonthYear},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c){c.apply(a.input?a.input[0]:null,[b,a])}else{a.input&&a.input.trigger("change")}if(a.inline){this._updateDatepicker(a)}else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/86400000)/7)+1},parseDate:function(a,b,c){if(a==null||b==null){throw"Invalid arguments"}b=typeof b=="object"?b.toString():b+"";if(b==""){return null}for(var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff,f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,k=c=-1,l=-1,u=-1,j=false,o=function(p){(p=z+1<a.length&&a.charAt(z+1)==p)&&z++;return p},m=function(p){o(p);p=new RegExp("^\\d{1,"+(p=="@"?14:p=="!"?20:p=="y"?4:p=="o"?3:2)+"}");p=b.substring(s).match(p);if(!p){throw"Missing number at position "+s}s+=p[0].length;return parseInt(p[0],10)},n=function(p,w,G){p=o(p)?G:w;for(w=0;w<p.length;w++){if(b.substr(s,p[w].length)==p[w]){s+=p[w].length;return w+1}}throw"Unknown name at position "+s},r=function(){if(b.charAt(s)!=a.charAt(z)){throw"Unexpected literal at position "+s}s++},s=0,z=0;z<a.length;z++){if(j){if(a.charAt(z)=="'"&&!o("'")){j=false}else{r()}}else{switch(a.charAt(z)){case"d":l=m("d");break;case"D":n("D",f,h);break;case"o":u=m("o");break;case"m":k=m("m");break;case"M":k=n("M",i,g);break;case"y":c=m("y");break;case"@":var v=new Date(m("@"));c=v.getFullYear();k=v.getMonth()+1;l=v.getDate();break;case"!":v=new Date((m("!")-this._ticksTo1970)/10000);c=v.getFullYear();k=v.getMonth()+1;l=v.getDate();break;case"'":if(o("'")){r()}else{j=true}break;default:r()}}}if(c==-1){c=(new Date).getFullYear()}else{if(c<100){c+=(new Date).getFullYear()-(new Date).getFullYear()%100+(c<=e?0:-100)}}if(u>-1){k=1;l=u;do{e=this._getDaysInMonth(c,k-1);if(l<=e){break}k++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,k-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=k||v.getDate()!=l){throw"Invalid date"}return v},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*10000000,formatDate:function(a,b,c){if(!b){return""}var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames:null)||this._defaults.monthNames;var i=function(o){(o=j+1<a.length&&a.charAt(j+1)==o)&&j++;return o},g=function(o,m,n){m=""+m;if(i(o)){for(;m.length<n;){m="0"+m}}return m},k=function(o,m,n,r){return i(o)?r[m]:n[m]},l="",u=false;if(b){for(var j=0;j<a.length;j++){if(u){if(a.charAt(j)=="'"&&!i("'")){u=false}else{l+=a.charAt(j)}}else{switch(a.charAt(j)){case"d":l+=g("d",b.getDate(),2);break;case"D":l+=k("D",b.getDay(),e,f);break;case"o":l+=g("o",(b.getTime()-(new Date(b.getFullYear(),0,0)).getTime())/86400000,3);break;case"m":l+=g("m",b.getMonth()+1,2);break;case"M":l+=k("M",b.getMonth(),h,c);break;case"y":l+=i("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case"@":l+=b.getTime();break;case"!":l+=b.getTime()*10000+this._ticksTo1970;break;case"'":if(i("'")){l+="'"}else{u=true}break;default:l+=a.charAt(j)}}}}return l},_possibleChars:function(a){for(var b="",c=false,e=function(h){(h=f+1<a.length&&a.charAt(f+1)==h)&&f++;return h},f=0;f<a.length;f++){if(c){if(a.charAt(f)=="'"&&!e("'")){c=false}else{b+=a.charAt(f)}}else{switch(a.charAt(f)){case"d":case"m":case"y":case"@":b+="0123456789";break;case"D":case"M":return null;case"'":if(e("'")){b+="'"}else{c=true}break;default:b+=a.charAt(f)}}}return b},_get:function(a,b){return a.settings[b]!==undefined?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()!=a.lastVal){var c=this._get(a,"dateFormat"),e=a.lastVal=a.input?a.input.val():null,f,h;f=h=this._getDefaultDate(a);var i=this._getFormatConfig(a);try{f=this.parseDate(c,e,i)||h}catch(g){this.log(g);e=b?"":e}a.selectedDay=f.getDate();a.drawMonth=a.selectedMonth=f.getMonth();a.drawYear=a.selectedYear=f.getFullYear();a.currentDay=e?f.getDate():0;a.currentMonth=e?f.getMonth():0;a.currentYear=e?f.getFullYear():0;this._adjustInstDate(a)}},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var e=function(h){var i=new Date;i.setDate(i.getDate()+h);return i},f=function(h){try{return d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),h,d.datepicker._getFormatConfig(a))}catch(i){}var g=(h.toLowerCase().match(/^c/)?d.datepicker._getDate(a):null)||new Date,k=g.getFullYear(),l=g.getMonth();g=g.getDate();for(var u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,j=u.exec(h);j;){switch(j[2]||"d"){case"d":case"D":g+=parseInt(j[1],10);break;case"w":case"W":g+=parseInt(j[1],10)*7;break;case"m":case"M":l+=parseInt(j[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(k,l));break;case"y":case"Y":k+=parseInt(j[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(k,l));break}j=u.exec(h)}return new Date(k,l,g)};if(b=(b=b==null?c:typeof b=="string"?f(b):typeof b=="number"?isNaN(b)?c:e(b):b)&&b.toString()=="Invalid Date"?c:b){b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0)}return this._daylightSavingAdjust(b)},_daylightSavingAdjust:function(a){if(!a){return null}a.setHours(a.getHours()>12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c){this._notifyChange(a)}this._adjustInstDate(a);if(a.input){a.input.val(e?"":this._formatDate(a))}},_getDate:function(a){return !a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),k=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay?new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),j=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=j&&n<j?j:n;this._daylightSavingAdjust(new Date(m,g,1))>n;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-k,1)),this._getFormatConfig(a));n=this._canAdjustMonth(a,-1,m,g)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._adjustDate('#"+a.id+"', -"+k+", 'M');\" title=\""+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>":f?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>";var r=this._get(a,"nextText");r=!h?r:this.formatDate(r,this._daylightSavingAdjust(new Date(m,g+k,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._adjustDate('#"+a.id+"', +"+k+", 'M');\" title=\""+r+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+r+"</span></a>":f?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+r+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+r+"</span></a>";k=this._get(a,"currentText");r=this._get(a,"gotoCurrent")&&a.currentDay?u:b;k=!h?k:this.formatDate(k,r,this._getFormatConfig(a));h=!a.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_'+y+'.datepicker._hideDatepicker();">'+this._get(a,"closeText")+"</button>":"";e=e?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?h:"")+(this._isInRange(a,r)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._gotoToday('#"+a.id+"');\">"+k+"</button>":"")+(c?"":h)+"</div>":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;k=this._get(a,"showWeek");r=this._get(a,"dayNames");this._get(a,"dayNamesShort");var s=this._get(a,"dayNamesMin"),z=this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),w=this._get(a,"showOtherMonths"),G=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var K=this._getDefaultDate(a),H="",C=0;C<i[0];C++){for(var L="",D=0;D<i[1];D++){var M=this._daylightSavingAdjust(new Date(m,g,a.selectedDay)),t=" ui-corner-all",x="";if(l){x+='<div class="ui-datepicker-group';if(i[1]>1){switch(D){case 0:x+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-1:x+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:x+=" ui-datepicker-group-middle";t="";break}}x+='">'}x+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+t+'">'+(/all|left/.test(t)&&C==0?c?f:n:"")+(/all|right/.test(t)&&C==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,j,o,C>0||D>0,z,v)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var A=k?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(t=0;t<7;t++){var q=(t+h)%7;A+="<th"+((t+h+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+r[q]+'">'+s[q]+"</span></th>"}x+=A+"</tr></thead><tbody>";A=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth){a.selectedDay=Math.min(a.selectedDay,A)}t=(this._getFirstDayOfMonth(m,g)-h+7)%7;A=l?6:Math.ceil((t+A)/7);q=this._daylightSavingAdjust(new Date(m,g,1-t));for(var N=0;N<A;N++){x+="<tr>";var O=!k?"":'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(q)+"</td>";for(t=0;t<7;t++){var F=p?p.apply(a.input?a.input[0]:null,[q]):[true,""],B=q.getMonth()!=g,I=B&&!G||!F[0]||j&&q<j||o&&q>o;O+='<td class="'+((t+h+6)%7>=5?" ui-datepicker-week-end":"")+(B?" ui-datepicker-other-month":"")+(q.getTime()==M.getTime()&&g==a.selectedMonth&&a._keyEvent||K.getTime()==q.getTime()&&K.getTime()==M.getTime()?" "+this._dayOverClass:"")+(I?" "+this._unselectableClass+" ui-state-disabled":"")+(B&&!w?"":" "+F[1]+(q.getTime()==u.getTime()?" "+this._currentClass:"")+(q.getTime()==b.getTime()?" ui-datepicker-today":""))+'"'+((!B||w)&&F[2]?' title="'+F[2]+'"':"")+(I?"":' onclick="DP_jQuery_'+y+".datepicker._selectDay('#"+a.id+"',"+q.getMonth()+","+q.getFullYear()+', this);return false;"')+">"+(B&&!w?"&#xa0;":I?'<span class="ui-state-default">'+q.getDate()+"</span>":'<a class="ui-state-default'+(q.getTime()==b.getTime()?" ui-state-highlight":"")+(q.getTime()==u.getTime()?" ui-state-active":"")+(B?" ui-priority-secondary":"")+'" href="#">'+q.getDate()+"</a>")+"</td>";q.setDate(q.getDate()+1);q=this._daylightSavingAdjust(q)}x+=O+"</tr>"}g++;if(g>11){g=0;m++}x+="</tbody></table>"+(l?"</div>"+(i[0]>0&&D==i[1]-1?'<div class="ui-datepicker-row-break"></div>':""):"");L+=x}H+=L}H+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':"");a._keyEvent=false;return H},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var k=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),j='<div class="ui-datepicker-title">',o="";if(h||!k){o+='<span class="ui-datepicker-month">'+i[b]+"</span>"}else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='<select class="ui-datepicker-month" onchange="DP_jQuery_'+y+".datepicker._selectMonthYear('#"+a.id+"', this, 'M');\" onclick=\"DP_jQuery_"+y+".datepicker._clickMonthYear('#"+a.id+"');\">";for(var n=0;n<12;n++){if((!i||n>=e.getMonth())&&(!m||n<=f.getMonth())){o+='<option value="'+n+'"'+(n==b?' selected="selected"':"")+">"+g[n]+"</option>"}}o+="</select>"}u||(j+=o+(h||!(k&&l)?"&#xa0;":""));if(h||!l){j+='<span class="ui-datepicker-year">'+c+"</span>"}else{g=this._get(a,"yearRange").split(":");var r=(new Date).getFullYear();i=function(s){s=s.match(/c[+-].*/)?c+parseInt(s.substring(1),10):s.match(/[+-].*/)?r+parseInt(s,10):parseInt(s,10);return isNaN(s)?r:s};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b,e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(j+='<select class="ui-datepicker-year" onchange="DP_jQuery_'+y+".datepicker._selectMonthYear('#"+a.id+"', this, 'Y');\" onclick=\"DP_jQuery_"+y+".datepicker._clickMonthYear('#"+a.id+"');\">";b<=g;b++){j+='<option value="'+b+'"'+(b==c?' selected="selected"':"")+">"+b+"</option>"}j+="</select>"}j+=this._get(a,"yearSuffix");if(u){j+=(h||!(k&&l)?"&#xa0;":"")+o}j+="</div>";return j},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c=="Y"?b:0),f=a.drawMonth+(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y"){this._notifyChange(a)}},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&b<c?c:b;return b=a&&b>a?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");if(b){b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])}},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);c=this._daylightSavingAdjust(new Date(c,e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=function(a){if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget")){return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b))}if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string"){return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b))}return this.each(function(){typeof a=="string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new J;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.1";window["DP_jQuery_"+y]=d})(jQuery);jQuery.effects||function(f){function k(c){var a;if(c&&c.constructor==Array&&c.length==3){return c}if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c)){return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)]}if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c)){return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55]}if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c)){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c)){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}if(/rgba\(0, 0, 0, 0\)/.exec(c)){return l.transparent}return l[f.trim(c).toLowerCase()]}function q(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body")){break}a="backgroundColor"}while(c=c.parentNode);return k(b)}function m(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,a={},b,d;if(c&&c.length&&c[0]&&c[c[0]]){for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}}else{for(b in c){if(typeof c[b]==="string"){a[b]=c[b]}}}return a}function n(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in r||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b))){delete c[a]}}return c}function s(c,a){var b={_:0},d;for(d in a){if(c[d]!=a[d]){b[d]=a[d]}}return b}function j(c,a,b,d){if(typeof c=="object"){d=a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(f.isFunction(b)){d=b;b=null}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:f.fx.speeds[b]||f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=q(b.elem,a);b.end=k(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var l={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},o=["add","remove","toggle"],r={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,d){if(f.isFunction(b)){d=b;b=null}return this.each(function(){var e=f(this),g=e.attr("style")||" ",h=n(m.call(this)),p,t=e.attr("className");f.each(o,function(u,i){c[i]&&e[i+"Class"](c[i])});p=n(m.call(this));e.attr("className",t);e.animate(s(h,p),a,b,function(){f.each(o,function(u,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else{e.attr("style",g)}d&&d.apply(this,arguments)})})};f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===undefined?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.1",save:function(c,a){for(var b=0;b<a.length;b++){a[b]!==null&&c.data("ec.storage."+a[b],c[0].style[a[b]])}},restore:function(c,a){for(var b=0;b<a.length;b++){a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))}},setMode:function(c,a){if(a=="toggle"){a=c.is(":hidden")?"show":"hide"}return a},getBaseline:function(c,a){var b;switch(c[0]){case"top":b=0;break;case"middle":b=0.5;break;case"bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case"left":c=0;break;case"center":c=0.5;break;case"right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper")){return c.parent()}var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});c.wrap(b);b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(d,e){a[e]=c.css(e);if(isNaN(parseInt(a[e],10))){a[e]="auto"}});c.css({position:"relative",top:0,left:0})}return b.css(a).show()},removeWrapper:function(c){if(c.parent().is(".ui-effects-wrapper")){return c.parent().replaceWith(c)}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0){d[g]=unit[0]*b+unit[1]}});return d}});f.fn.extend({effect:function(c){var a=j.apply(this,arguments);a={options:a[1],duration:a[2],callback:a[3]};var b=f.effects[c];return b&&!f.fx.off?b.call(this,a):this},_show:f.fn.show,show:function(c){if(!c||typeof c=="number"||f.fx.speeds[c]){return this._show.apply(this,arguments)}else{var a=j.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(!c||typeof c=="number"||f.fx.speeds[c]){return this._hide.apply(this,arguments)}else{var a=j.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(!c||typeof c=="number"||f.fx.speeds[c]||typeof c=="boolean"||f.isFunction(c)){return this.__toggle.apply(this,arguments)}else{var a=j.apply(this,arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0){b=[parseFloat(a),e]}});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return -d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1){return d/2*a*a+b}return -d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1){return d/2*a*a*a+b}return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return -d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1){return d/2*a*a*a*a+b}return -d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1){return d/2*a*a*a*a*a+b}return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return -d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return -d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0){return b}if(a==e){return b+d}if((a/=e/2)<1){return d/2*Math.pow(2,10*(a-1))+b}return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return -d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1){return -d/2*(Math.sqrt(1-a*a)-1)+b}return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0){return b}if((a/=e)==1){return b+d}g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else{c=g/(2*Math.PI)*Math.asin(d/h)}return -(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0){return b}if((a/=e)==1){return b+d}g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else{c=g/(2*Math.PI)*Math.asin(d/h)}return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0){return b}if((a/=e/2)==2){return b+d}g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else{c=g/(2*Math.PI)*Math.asin(d/h)}if(a<1){return -0.5*h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b}return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==undefined){g=1.70158}return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==undefined){g=1.70158}return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,a,b,d,e,g){if(g==undefined){g=1.70158}if((a/=e/2)<1){return d/2*a*a*(((g*=1.525)+1)*a-g)+b}return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2){return f.easing.easeInBounce(c,a*2,0,d,e)*0.5+b}return f.easing.easeOutBounce(c,a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);jQuery.extend({__stringPrototype:{JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"},escapeHTML:function(s){s=this.s(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");return this.r(arguments,0,s)},startsWith:function(pattern,s){return this.s(s).indexOf(pattern)===0},strip:function(s){s=jQuery.trim(this.s(s));return this.r(arguments,0,s)},stripTags:function(s){s=this.s(s).replace(/<\/?[^>]+>/gi,"");return this.r(arguments,0,s)},times:function(count,s){var i=0;s=this.s(s);var newS="";for(i=0;i<count;i++){newS+=s}return this.r(arguments,1,newS)},toQueryParams:function(separator,s){s=this.s(s);var paramsList=s.substring(s.indexOf("?")+1).split("#")[0].split(separator||"&"),params={},i,key,value,pair;for(i=0;i<paramsList.length;i++){pair=paramsList[i].split("=");key=decodeURIComponent(pair[0]);value=(pair[1])?decodeURIComponent(pair[1]):undefined;if(params[key]){if(typeof params[key]=="string"){params[key]=[params[key]]}params[key].push(value)}else{params[key]=value}}return params},truncate:function(length,truncation,s){s=this.s(s);length=length||30;truncation=(!truncation)?"...":truncation;s=(s.length>length)?jQuery.trim(s.slice(0,length-truncation.length))+truncation:String(s);return this.r(arguments,2,s)},unescapeHTML:function(s){s=this.stripTags(this.s(s)).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");return this.r(arguments,0,s)},r:function(args,size,s){if(args.length>size||this.str===undefined){return s}else{this.str=""+s;return this}},s:function(s){if(s===""||s){return s}if(this.str===""||this.str){return this.str}return this}},string:function(str){if(str===String.prototype){jQuery.extend(String.prototype,jQuery.__stringPrototype)}else{return jQuery.extend({str:str},jQuery.__stringPrototype)}}});jQuery.__stringPrototype.parseQuery=jQuery.__stringPrototype.toQueryParams;$.string(String.prototype);(function(e,b){function d(){}function t(C){c=[C]}function m(C){f.insertBefore(C,f.firstChild)}function l(E,C,D){return E&&E.apply(C.context||C,D)}function k(C){return/\?/.test(C)?"&":"?"}var n="async",s="charset",q="",A="error",r="_jqjsp",w="on",o=w+"click",p=w+A,a=w+"load",i=w+"readystatechange",z="removeChild",g="<script/>",v="success",y="timeout",x=e.browser,f=e("head")[0]||document.documentElement,u={},j=0,c,h={callback:r,url:location.href};function B(C){C=e.extend({},h,C);var Q=C.complete,E=C.dataFilter,M=C.callbackParameter,R=C.callback,G=C.cache,J=C.pageCache,I=C.charset,D=C.url,L=C.data,P=C.timeout,O,K=0,H=d;C.abort=function(){!K++&&H()};if(l(C.beforeSend,C,[C])===false||K){return C}D=D||q;L=L?((typeof L)=="string"?L:e.param(L,C.traditional)):q;D+=L?(k(D)+L):q;M&&(D+=k(D)+escape(M)+"=?");!G&&!J&&(D+=k(D)+"_"+(new Date()).getTime()+"=");D=D.replace(/=\?(&|$)/,"="+R+"$1");function N(S){!K++&&b(function(){H();J&&(u[D]={s:[S]});E&&(S=E.apply(C,[S]));l(C.success,C,[S,v]);l(Q,C,[C,v])},0)}function F(S){!K++&&b(function(){H();J&&S!=y&&(u[D]=S);l(C.error,C,[C,S]);l(Q,C,[C,S])},0)}J&&(O=u[D])?(O.s?N(O.s[0]):F(O)):b(function(T,S,U){if(!K){U=P>0&&b(function(){F(y)},P);H=function(){U&&clearTimeout(U);T[i]=T[o]=T[a]=T[p]=null;f[z](T);S&&f[z](S)};window[R]=t;T=e(g)[0];T.id=r+j++;if(I){T[s]=I}function V(W){(T[o]||d)();W=c;c=undefined;W?N(W[0]):F(A)}if(x.msie){T.event=o;T.htmlFor=T.id;T[i]=function(){T.readyState=="loaded"&&V()}}else{T[p]=T[a]=V;x.opera?((S=e(g)[0]).text="jQuery('#"+T.id+"')[0]."+p+"()"):T[n]=n}T.src=D;m(T);S&&m(S)}},0);return C}B.setup=function(C){e.extend(h,C)};e.jsonp=B})(jQuery,setTimeout);jQuery.JSON={};jQuery.JSON.stringify=function(obj){var t=typeof(obj);if(t!="object"||obj===null){if(t=="string"){obj='"'+obj+'"'}return String(obj)}else{var n,v,json=[],arr=(obj&&obj.constructor==Array);for(n in obj){v=obj[n];t=typeof(v);if(t=="string"){v='"'+v+'"'}else{if(t=="object"&&v!==null){v=JSON.stringify(v)}}json.push((arr?"":'"'+n+'":')+String(v))}return(arr?"[":"{")+String(json)+(arr?"]":"}")}};jQuery.Hashtable=function(){this.items=[];this.itemsCount=0;this.set=function(key,value){if(this.containsKey(key)){this.remove(key);this.items[key]=value}else{this.items[key]=value;this.itemsCount++}};this.get=function(key){if(this.containsKey(key)){return this.items[key]}else{return null}};this.remove=function(key){if(this.containsKey(key)){delete this.items[key];this.itemsCount--}else{throw"key '"+key+"' does not exist."}};this.containsKey=function(key){return typeof(this.items[key])!="undefined"};this.clear=function(){this.items=[];this.itemsCount=0};this.size=function(){return this.itemsCount}};jQuery.clearSelection=function(){var sel;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(window.getSelection){sel=window.getSelection();if(sel&&sel.removeAllRanges){sel.removeAllRanges()}}}};jQuery.copterRequest=function(url,options,noExt){var fragments=url.split("/");var last=fragments[fragments.length-1];if(!last.match(/\.[a-z]+$/)&&!noExt){url+=".json"}if(typeof options.data=="undefined"){options.data={}}var requestDomain=window.location.href.replace("http://","").split("/")[0].toLowerCase();var responseDomain=url.replace("http://","").split("/")[0].toLowerCase();var useAjax=(requestDomain==responseDomain||responseDomain.length==0);options.data.api_key=(options.data.api_key||window.application.getModel("Prefs").apiKey);options.data.api_version=(options.data.api_version||window.application.getModel("Prefs").apiVersion);var request_context,errMsg="Sorry. The site is currently experiencing difficulties. Please try refreshing your page to see if that fixes the problem.";if(useAjax){request_context=$.extend({url:url,type:"get",dataType:"json",cache:false,timeout:(20*1000),success:function(response,statusText){},error:function(request,statusText,error){if(window.console&&window.console.log){window.console.log(errMsg,statusText)}},complete:function(request,statusText){}},options);$.ajax(request_context)}else{request_context=$.extend({url:url,callbackParameter:"callback",traditional:false,data:null,cache:false,pageCache:false,success:function(data,status){},error:function(xOptions,status){if(window.console&&window.console.log){window.console.log("Error when requesting "+xOptions.url);window.console.log(errMsg)}}},options);$.jsonp(request_context)}};jQuery.keyCount=function(o){var n=0,i;for(i in o){n++}return n};jQuery.sortBy=function(field,reverse,primer){reverse=(reverse)?-1:1;return function(a,b){a=a[field];b=b[field];if(typeof(primer)!="undefined"){a=primer(a);b=primer(b)}if(typeof a=="unknown"){a=""}if(typeof b=="unknown"){b=""}if(a<b){return(reverse*-1)}if(a>b){return(reverse*1)}return 0}};
/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
$.fn.outerHTML=function(){var elem=this[0],tmp,div;return !elem?null:typeof(tmp=elem.outerHTML)==="string"?tmp:(div=div||$("<div/>")).html(this.eq(0).clone()).html()};jQuery.hasFlash=function(){var hasFlash=false;try{var fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(fo){hasFlash=true}}catch(e){if(navigator.mimeTypes["application/x-shockwave-flash"]!=undefined){hasFlash=true}}return hasFlash};(function(jQuery){jQuery.cookie=function(name,value,options){if(typeof value!="undefined"){options=options||{};if(value===null){value="";options.expires=-1}var expires="";if(options.expires&&(typeof options.expires=="number"||options.expires.toUTCString)){var date;if(typeof options.expires=="number"){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires="; expires="+date.toUTCString()}var path=options.path?"; path="+(options.path):"";var domain=options.domain?"; domain="+(options.domain):"";var secure=options.secure?"; secure":"";document.cookie=[name,"=",encodeURIComponent(value),expires,path,domain,secure].join("")}else{var cookieValue=null;if(document.cookie&&document.cookie!=""){var cookies=document.cookie.split(";");for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+"=")){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}}})(jQuery);(function($){function Application(){this.id=("app-"+(new Date()).getTime());this.locationMonitorInterval=null;this.locationMonitorDelay=150;this.locationFrame=null;this.currentLocation=null;this.controllers=[];this.routeMappings=[];this.models={cache:{},classes:{}};this.views={cache:{},classes:{}};this.locationEvent=null;$(this).bind("locationchange",this.proxyCallback(this.onLocationChange))}Application.prototype.addClass=function(target,value){var constructor=value.constructor;var className;if(constructor==Function){className=value.toString().match(new RegExp("^function\\s+([^\\s\\(]+)","i"))[1];target.classes[className]=value}else{className=value.constructor.toString().match(new RegExp("^function\\s+([^\\s\\(]+)","i"))[1];target.classes[className]=value.constructor;target.cache[className]=value}};Application.prototype.addController=function(controller){this.controllers.push(controller)};Application.prototype.addModel=function(model){this.addClass(this.models,model)};Application.prototype.addView=function(view){this.addClass(this.views,view)};Application.prototype.ajax=function(options){var self=this;var ajaxOptions=$.extend({type:"get",dataType:"json",normalizeJSON:false,cache:false,timeout:(10*1000),success:function(response,statusText){},error:function(request,statusText,error){self.log("Sorry. The site is currently experiencing difficulties. Please try refreshing your page to see if that fixes the problem.")},complete:function(request,statusText){}},options);if(ajaxOptions.normalizeJSON&&(ajaxOptions.dataType=="json")&&options.success){var targetSuccess=options.success;ajaxOptions.success=function(response,statusText){targetSuccess(self.normalizeJSON(response))}}$.ajax(ajaxOptions)};Application.prototype.getURLHash=function(){return(window.location.href.toString().split("#")[1]||"")};Application.prototype.checkLocationForChange=function(){var liveLocation=this.normalizeHash(this.getURLHash());if((this.currentLocation===null)||(this.currentLocation!=liveLocation)){if(this.locationFrame){this.locationFrame.attr("src","ie_back_button.html?_="+(new Date()).getTime()+"&hash="+liveLocation)}this.setURL(liveLocation)}};Application.prototype.getClass=function(target,className,initArguments){try{if(target.cache[className]){return(target.cache[className])}else{var newInstance=new (target.classes[className])();target.classes[className].apply(newInstance,initArguments);return(newInstance)}}catch(err){this.log(className+" is undefined");return undefined}};Application.prototype.getFromTemplate=function(template,model){var templateData=template.html();if(model){templateData=templateData.replace(new RegExp("\\$\\{([^\\}]+)\\}","gi"),function($0,$1){var m=model;var placeHolder=$1.split(".");$.each(placeHolder,function(i,v){if(v in m){m=(m[v]||"")}else{m=$0;return false}});return m});return($(templateData).data("model",model))}else{return templateData}};Application.prototype.getModel=function(className,initArguments){return(this.getClass(this.models,className,initArguments))};Application.prototype.getView=function(className,initArguments){return(this.getClass(this.views,className,initArguments))};Application.prototype.initClasses=function(classes){$.each(classes,function(index,instance){if(instance.init){instance.init()}})};Application.prototype.initControllers=function(){this.initClasses(this.controllers)};Application.prototype.initLocationMonitor=function(){if(document.all){this.locationFrame=$('<iframe src="about:black" style="display: none ;" />').appendTo(document.body)}};Application.prototype.initModels=function(){this.initClasses(this.models.cache)};Application.prototype.initViews=function(){this.initClasses(this.views.cache)};Application.prototype.log=function(str){if(window.console&&window.console.log){window.console.log(str)}};Application.prototype.normalizeHash=function(hash){return(hash.replace(new RegExp("^[#/]+|/$","g"),""))};Application.prototype.normalizeJSON=function(object){var self=this;if((typeof(object)=="boolean")||(typeof(object)=="string")||(typeof(object)=="number")||$.isFunction(object)){return(object)}var normalizedObject;if($.isArray(object)){normalizedObject=[];$.each(object,function(index,value){normalizedObject[index]=self.normalizeJSON(value)})}else{normalizedObject={};$.each(object,function(key,value){normalizedObject[key.toLowerCase()]=self.normalizeJSON(value)})}return(normalizedObject)};Application.prototype.onLocationChange=function(locationChangeEvent){var self=this;var keepRouting=true;this.stopLocationMonitor();$.each(this.routeMappings,function(index,mapping){var matches=null;if(!keepRouting){return}var eventContext={application:self,fromLocation:locationChangeEvent.fromLocation,toLocation:locationChangeEvent.toLocation,parameters:$.extend({},locationChangeEvent.parameters)};if(matches=locationChangeEvent.toLocation.match(mapping.test)){matches.shift();$.each(matches,function(index,value){eventContext.parameters[mapping.parameters[index]]=value});if(mapping.controller.preHandler){mapping.controller.preHandler(eventContext)}var result=mapping.handler.apply(mapping.controller,[eventContext].concat(matches));if(mapping.controller.postHandler){mapping.controller.postHandler(eventContext)}if((typeof(result)=="boolean")&&!result){keepRouting=false}}});this.startLocationMonitor()};Application.prototype.proxyCallback=function(callback){var self=this;return(function(){return(callback.apply(self,arguments))})};Application.prototype.relocateTo=function(newLocation,parameters){this.setURL(newLocation,parameters)};Application.prototype.run=function(){this.initModels();this.initViews();this.initControllers();this.initLocationMonitor();this.startLocationMonitor()};Application.prototype.setURL=function(location,parameters){location=this.normalizeHash(location);var oldLocation=this.currentLocation;var newLocation=location;this.currentLocation=location;window.location.hash=("#/"+location);$(this).trigger({type:"locationchange",fromLocation:oldLocation,toLocation:newLocation,parameters:parameters})};Application.prototype.startLocationMonitor=function(){var self=this;this.locationMonitorInterval=setInterval(function(){self.checkLocationForChange()},this.locationMonitorDelay)};Application.prototype.stopLocationMonitor=function(){clearInterval(this.locationMonitorInterval)};Application.prototype.Controller=function(){};Application.prototype.Controller.prototype={route:function(path,handler){path=application.normalizeHash(path);var parameters=[];var pattern=path.replace(new RegExp("(/):([^/]+)","gi"),function($0,$1,$2){parameters.push($2);return($1+"([^/]+)")});application.routeMappings.push({controller:this,parameters:parameters,test:new RegExp(("^"+pattern+"$"),"i"),handler:handler})}};window.application=new Application();$(function(){window.application.run()});return(window.application)})(jQuery);window.application.addController((function($,application){function Controller(){this.route("/",this.index);this.route("/search/:type/:qs",this.results);this.route("/home/:qs",this.index);this.route("/ratrix/:qs",this.index);this.route("/map/:qs",this.mapUX);this.route("/qu/:qs",this.quUX);this.route("/hilton/:qs",this.hiltonUX);this.currentView=null;this.autofillView=null;this.searchResultsView=null;this.filtersView=null;this.mapView=null;this.filterModel=null;this.locationModel=null;this.hotelModel=null}Controller.prototype=new application.Controller();Controller.prototype.init=function(){this.autofillView=application.getView("Autofill");this.searchResultsView=application.getView("SearchResults");this.filtersView=application.getView("Filters");this.hotelView=application.getView("Hotel");this.lightboxView=application.getView("Lightbox");this.mapView=application.getView("Map");this.filterModel=application.getModel("Filters");this.locationModel=application.getModel("Location");this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.showWrapper()};Controller.prototype.showWrapper=function(){if($("#c0pt3r-results").length==0){$("#c0pt3r").append(application.getFromTemplate($("#wrapper-template"),{footerScript:$.extend({},this.prefsModel.footerScript)}))}};Controller.prototype.index=function(event,qs){if(this.prefsModel.singleLocation){this.results(null,"n","ld="+this.prefsModel.singleDisplayName+"&lt=single")}else{this.autofillView.show(qs)}};Controller.prototype.mapUX=function(event,qs){if(application.getView("MapUX")){var queryParams=qs.toQueryParams();this.locationModel.showMap=false;this.locationModel.noMapPin=true;if(queryParams.ln){this.autofillView.display_name=queryParams.ln}this.results(null,"n",qs);application.getView("MapUX").show(qs)}};Controller.prototype.quUX=function(event,qs){if(application.getView("QuUX")){application.getView("QuUX").show(qs)}};Controller.prototype.hiltonUX=function(event,qs){if(application.getView("HiltonUX")){application.getView("HiltonUX").show(qs)}};Controller.prototype.results=function(event,type,qs){if(this.locationModel.display_name.length==0){this.searchResultsView.show();if(this.prefsModel.singleLocation){this.locationModel.display_name=this.prefsModel.singleDisplayName}else{this.locationModel.display_name=(this.autofillView.display_name||"your chosen location")}this.filterModel.setFromQueryString(qs);this.searchResultsView.displayLocation(qs)}else{if(type!="x"){this.searchResultsView.show();if(type!="r"){this.filtersView.applyFilterChangeInit()}}this.filterModel.setFromQueryString(qs);if(type=="n"){this.searchResultsView.getResults(true)}else{if(type=="r"){$.event.trigger("c0pt3rRatesPollingComplete")}else{if(type=="x"){this.hotelView.openOrClose();this.lightboxView.openOrClose()}}}}};return(new Controller())})(jQuery,window.application));window.application.addModel((function($,application){function Prefs(){this.site="";this.siteURL=window.location.protocol+"//"+window.location.host;this.mapIconImage="shared/img/map-icon.png";this.mapIconLandmarkImage="shared/img/map-icon-landmark.png";this.apiKey="3CoqSe9VB04rGjC002f129iS";this.apiVersion="0.9";this.apijUrl="http://api.hotelicopter.com/events";this.apijVersion="1.5.1";this.urlroot="http://peach.dev.c0pt3r.com";this.logoUrlRoot="http://koi.hotelicopter.com/logos";this.singleLocation=false;this.singleDisplayName="";this.autofillPhotos=true;this.autofillGoogleLookUp=true;this.autofillIncludeAirports=false;this.autofillIncludeHotels=true;this.currency="usd";this.hotelSetSize=100;this.allowUnavailablePhoneNumberDisplay=false;this.filterCounterThresholds=[{threshold:3,text:"few or no"},{threshold:20,text:"a small set of"},{threshold:50,text:"a large set of"},{threshold:1000000,text:"a very large set of"}];this.initialRows={gallery:4,summary:15,list:20};this.rowIncrement={gallery:2,summary:5,list:10};this.sidebar=false;this.sidebarWidth=218;this.cardHeight={gallery:{summary:255,amenities:305,booking:305,location:305},list:{summary:15,amenities:30,booking:30,location:30},summary:{summary:152,amenities:152,booking:152,location:152}};this.summaryShadowWidth=16;this.summaryContentWrapperPadding=10;this.summaryImageDivWidth=136;this.summaryPriceDivWidth=177;this.premiumPlacementLabel="Sponsored Listing";this.maxBrands=10;this.specifiedBrands=null;this.locationAverages=false;this.includeUnavailable=false;this.animateImageBorder=true;this.imageBorderColour="#fff";this.imageBorderHoverColour="#4f4f4f";this.galleryTray=false;this.indivDateGuestRoom=false;this.priceFilterBufferPercent=10;this.ratePollCount=12;this.ratePollDelay=500;this.overlayOpacity=0.75;this.footerScript={};this.increaseShortHotelNameFontSize=true;this.hotelNameMaxGalleryLength=42;this.defaultSort="rank";this.dropdowns={bucket:{display:false,defaultSetting:"all",options:[],width:225,height:105},view:{display:false,defaultSetting:"gallery",options:[{value:"gallery",label:"Gallery"},{value:"summary",label:"Summary"},{value:"list",label:"List"}],width:120,height:80},focusSetting:{display:false,defaultSetting:"",options:[{value:"summary",label:"Hotel Summary"},{value:"amenities",label:"Amenities"},{value:"booking",label:"Booking Options"},{value:"location",label:"Location"}],width:150,height:105},sort:{display:true,defaultSort:"rank",defaultSortDirection:"desc",options:[{value:"rank-desc",label:"Hotel Rank"},{value:"name_partial-asc",label:"Hotel Name (A-Z)"},{value:"name_partial-desc",label:"Hotel Name (Z-A)"},{value:"rate-asc",label:"Price (Lo-Hi)"},{value:"rate-desc",label:"Price (Hi-Lo)"},{value:"stars-asc",label:"Star Rating (Lo-Hi)"},{value:"stars-desc",label:"Star Rating (Hi-Lo)"}],width:160,height:180}}}Prefs.prototype.init=function(){};Prefs.prototype.currSym=function(){var s;switch(this.currency){case"usd":s="$";break;case"gbp":s="&pound;";break;case"eur":s="&euro;";break}return s};Prefs.prototype.cardWidth=function(cardType,rowWidth){var w;switch(cardType){case"gallery":w=235;break;case"summary":w=rowWidth;break;case"list":w=rowWidth;break}return w};Prefs.prototype.getCardHeight=function(){var filtersModel=application.getModel("Filters");var focusSetting=(filtersModel.focusSetting.length==0)?"summary":filtersModel.focusSetting;return(this.cardHeight[filtersModel.cardType][focusSetting])};Prefs.prototype.getDropdownLabel=function(dropdown,value){var label=null;$.each(this.dropdowns[dropdown].options,function(i,option){if(option.value==value){label=option.label}});return label};return(new Prefs())})(jQuery,window.application));window.application.addModel((function($,application){function SitePrefs(){}SitePrefs.prototype.init=function(){var prefsModel=application.getModel("Prefs");prefsModel.site="hotelicopter";prefsModel.apiKey="3CoqSe9VB04rGjC002f129iS";prefsModel.apiVersion="0.9";prefsModel.urlroot="/peach";prefsModel.mapIconImage="img/map/hotel-pin.png";prefsModel.mapIconLandmarkImage="img/map/default-pin.png";prefsModel.mapIconGeo="img/map/geo-pin.png";prefsModel.sidebar=false;prefsModel.sidebarWidth=0;prefsModel.maxBrands=10;prefsModel.locationAverages=false;prefsModel.hotelSetSize=100;prefsModel.initialRows={gallery:5,summary:15,list:20};prefsModel.rowIncrement={gallery:3,summary:10,list:10};prefsModel.dropdowns={bucket:{display:false,defaultSetting:"all",options:[],width:225,height:105},view:{display:false,defaultSetting:"gallery",options:[{value:"gallery",label:"Gallery"},{value:"summary",label:"Summary"},{value:"list",label:"List"}],width:120,height:80},focusSetting:{display:false,defaultSetting:"",options:[{value:"summary",label:"Hotel Summary"},{value:"amenities",label:"Amenities"},{value:"booking",label:"Booking Options"},{value:"location",label:"Location"}],width:150,height:105},sort:{display:true,defaultSort:"rank",defaultSortDirection:"desc",options:[{value:"rank-desc",label:"Automagically"},{value:"name_partial-asc",label:"Name (A-Z)"},{value:"name_partial-desc",label:"Name (Z-A)"},{value:"rate-asc",label:"Price (Lo-Hi)"},{value:"rate-desc",label:"Price (Hi-Lo)"},{value:"stars-asc",label:"Stars (Lo-Hi)"},{value:"stars-desc",label:"Stars (Hi-Lo)"}],width:160,height:180}}};return(new SitePrefs())})(jQuery,window.application));window.application.addModel((function($,application){function Location(){this.display_name="";this.tid="";this.geo={lat:null,lng:null};this.locationHotel=null;this.showMap=false;this.data={}}Location.prototype.init=function(){this.reset();this.prefsModel=application.getModel("Prefs");this.hotelModel=application.getModel("Hotel")};Location.prototype.reset=function(){this.display_name="";this.tid="";this.geo={lat:null,lng:null};this.locationHotel=null;this.data={}};Location.prototype.getLocation=function(onSuccess){var self=this;this.buildURL();$.copterRequest(this.url,{success:function(response){if(response.display_name){self.display_name=response.display_name}self.data=response;self.organisePropertyTypes();self.organiseBrands();self.organiseAmenities();self.hotelModel.base_image_url=response.base_image_url;$.event.trigger("locationObtained");onSuccess()},error:function(opts,status){application.log("Error while trying to fetch location data.")}})};Location.prototype.buildURL=function(){if(this.tid=="geo"){this.url=this.prefsModel.urlroot+"/locations/geolocation/"+this.geo.lat+"/"+this.geo.lng}else{if(this.tid=="single"){this.url=this.prefsModel.urlroot+"/locations"}else{this.url=this.prefsModel.urlroot+"/locations/"+this.tid}}};Location.prototype.getAmText=function(id){var amText="";$.each(this.data.amenities,function(i,amenity){if(amenity.id==id){amText=amenity.name}});return amText};Location.prototype.getPropText=function(id){var propText="";$.each(this.data.property_types,function(i,propertyType){if(propertyType.id==id){propText=propertyType.name}});return propText};Location.prototype.getBrandText=function(id){var brandText="";$.each(this.data.brands,function(i,brand){if(brand.id==id){brandText=brand.name}});return brandText};Location.prototype.organisePropertyTypes=function(){$.each(this.data.property_types,function(i,propType){if(propType.id=="VAC"){propType.name="Vacation Rentals"}if(propType.id=="INC"){propType.name="All-Incl. Resort"}})};Location.prototype.organiseAmenities=function(){$.each(this.data.amenities,function(i,am){if(am.id=="REST"){am.name="Restaurant"}})};Location.prototype.organiseBrands=function(){var self=this;var brands=[],allBrands=[];if(self.prefsModel.specifiedBrands){$.each(this.data.brands,function(i,brand){if($.inArray(brand.id,self.prefsModel.specifiedBrands)>=0){brands.push(brand)}allBrands.push(brand)})}else{this.data.brands.sort($.sortBy("num_hotels",true));$.each(this.data.brands,function(i,brand){if(i<self.prefsModel.maxBrands){brands.push(brand)}allBrands.push(brand)})}brands.sort($.sortBy("name",false,function(a){return a.toUpperCase()}));allBrands.sort($.sortBy("name",false,function(a){return a.toUpperCase()}));self.data.brands=brands;self.data.all_brands=allBrands};return(new Location())})(jQuery,window.application));window.application.addModel((function($,application){function Hotel(){this.url="";this.hotels={};this.premiumPlacements={};this.filteredHotels=[];this.total_matches=0;this.page=0;this.base_image_url=null;this.random_key=null}Hotel.prototype.init=function(){this.reset();this.filterModel=application.getModel("Filters");this.ratesModel=application.getModel("Rates");this.prefsModel=application.getModel("Prefs");this.locationModel=application.getModel("Location");this.partnersModel=application.getModel("Partners")};Hotel.prototype.reset=function(){this.url="";this.hotels={};this.filteredHotels=[];this.total_matches=0;this.page=0;this.base_image_url=null;this.random_key=null};Hotel.prototype.buildURL=function(countOnly){var location=application.getModel("Location");if(location.tid=="geo"){this.url=this.prefsModel.urlroot+"/hotels/geolocation/"+location.geo.lat+"/"+location.geo.lng}else{if(location.tid=="single"){this.url=this.prefsModel.urlroot+"/hotels"}else{this.url=this.prefsModel.urlroot+"/locations/"+location.tid+"/hotels"}}if(countOnly){this.url+="/count"}};Hotel.prototype.getSponsoredListings=function(){var self=this;$.each(self.locationModel.data.sponsored_listings,function(i,hotel){self.addHotel(hotel,1)})};Hotel.prototype.getPremiumPlacements=function(filters,cb){var self=this;if(filters.sort_field!="rank"&&filters.sort_field!="random"){self.premiumPlacements={}}if(this.page==1&&(filters.sort_field=="rank"||filters.sort_field=="random")){self.premiumPlacements={};filters.sort_field="random";filters.random_key=Math.floor(Math.random()*100000000);filters.premium_placements=true;$.copterRequest(this.url,{data:filters,success:function(response){$.each(response.hotels,function(i,hotel){hotel.premium_placement=true;self.premiumPlacements[hotel.tid]=hotel;self.hotels[hotel.tid]=hotel});cb()}})}else{cb()}};Hotel.prototype.getHotels=function(onSuccess,filters,countOnly,requestId){var self=this;if(!countOnly){this.page++}if(!filters){filters=this.filterModel.data}filters=$.extend({},filters);if(this.useCachedHotels()){if(countOnly){onSuccess({hotel_count:this.filterCount(filters)})}else{this.filterModel.data=filters;this.getPremiumPlacements(filters,function(){onSuccess(self.populateHotelsFromCache())})}}else{var nonBufferedPriceMin,nonBufferedPriceMax;if(self.isCachedLocation()&&!countOnly){filters.star_min=1;filters.star_max=5;filters.price_min=nonBufferedPriceMin=self.locationModel.data.minrate.usd;filters.price_max=nonBufferedPriceMax=self.locationModel.data.maxrate.usd;filters.user_min=0;filters.user_max=10;filters.incl_no_rating=true;filters.amenities=[];filters.brands=[];filters.property_types=[];filters.sub_locations=[]}else{if(self.ratesModel.isDatedSearch()){nonBufferedPriceMin=filters.price_min;nonBufferedPriceMax=filters.price_max;filters.price_min=parseInt(filters.price_min)-parseInt(filters.price_min*(self.prefsModel.priceFilterBufferPercent/100));filters.price_max=parseInt(filters.price_max)+parseInt(filters.price_max*(self.prefsModel.priceFilterBufferPercent/100))}}filters.price_min=(filters.price_min<0)?0:filters.price_min;filters.page=this.page;filters.per_page=this.prefsModel.hotelSetSize;if(requestId){filters.request_id=requestId}if(filters.sort_field=="random"){if(self.random_key==null){self.random_key=Math.floor(Math.random()*100000000)}filters.random_key=self.random_key}this.buildURL(countOnly);$.copterRequest(this.url,{data:filters,success:function(response){if(countOnly){onSuccess(response)}else{self.total_matches=response.hotel_count;self.base_image_url=response.base_image_url;filters.price_min=nonBufferedPriceMin;filters.price_max=nonBufferedPriceMax;self.getPremiumPlacements(filters,function(){onSuccess(self.populateHotelsFromResponse(response.hotels))})}}})}};Hotel.prototype.populateHotelsFromResponse=function(responseData){var self=this;$.each(responseData,function(i,hotel){self.addHotel(hotel,self.page)});self.filterHotels();return(self.filteredHotels)};Hotel.prototype.addHotel=function(hotel,page){var self=this;var rndLo=page*10000000;var rndHi=((page+1)*10000000)-1;hotel.rnd=Math.round(Math.random()*(rndHi-rndLo))+rndLo;if(hotel.partners.BNB){delete hotel.partners.BNB}if($.keyCount(hotel.partners)==0){hotel.rate.lowest=null}if(!self.hotels[hotel.tid]){self.hotels[hotel.tid]=hotel}};Hotel.prototype.populateHotelsFromCache=function(){var self=this;self.filterHotels();self.total_matches=this.filteredHotels.length;return(self.filteredHotels)};Hotel.prototype.filterHotels=function(){var self=this;self.filteredHotels=[];$.each(self.hotels,function(hotelTID,hotel){if(self.isFilteredHotel(hotel)){self.filteredHotels.push(hotel)}});self.sortFilteredHotels();var premiumPlacements=[];$.each(self.premiumPlacements,function(i,hotel){premiumPlacements.push(hotel)});self.filteredHotels=premiumPlacements.concat(self.filteredHotels)};Hotel.prototype.filterCount=function(filters){var self=this;var count=0;$.each(self.hotels,function(i,hotel){if(self.isFilteredHotel(hotel,filters)){count++}});return count};Hotel.prototype.isFilteredHotel=function(hotel,filters){var self=this,filterData=(filters||this.filterModel.data),rate,minRate=filterData.price_min,maxRate=filterData.price_max,isFiltered=true;if(self.ratesModel.rates[hotel.tid]){rate=self.ratesModel.lowestHotelRate(hotel.tid).rate}else{rate=hotel.rate.lowest}if(minRate==this.locationModel.data.minrate.usd){minRate=0}if(maxRate==this.locationModel.data.maxrate.usd){maxRate=1000000}if((parseFloat(rate)<minRate)||(parseFloat(rate)>maxRate)){isFiltered=false}if((parseInt(hotel.stars)<filterData.star_min)||(parseInt(hotel.stars)>filterData.star_max)){isFiltered=false}if(filterData.amenities){$.each(filterData.amenities,function(i,selectedAmenity){var hasAmenity=false;$.each(hotel.amenities,function(i,amenity){if(amenity.code==selectedAmenity){hasAmenity=true}});if(!hasAmenity){isFiltered=false}})}if(filterData.property_types){var hasPropertyType=false;$.each(filterData.property_types,function(i,selectedPropertyType){if(hotel.property_type.code==selectedPropertyType){hasPropertyType=true}});if(!hasPropertyType&&filterData.property_types.length>0){isFiltered=false}}if(filterData.brands){var hasBrand=false;$.each(filterData.brands,function(i,selectedBrand){if(hotel.brand.code==selectedBrand){hasBrand=true}});if(!hasBrand&&filterData.brands.length>0){isFiltered=false}}if(self.ratesModel.isDatedSearch()&&!self.ratesModel.rates[hotel.tid]&&!self.ratesModel.includeUnavailable&&self.displayableRatelessPartners(hotel.tid).length==0&&!self.isCallToBook(hotel.tid)){isFiltered=false}if(self.premiumPlacements[hotel.tid]){isFiltered=false}return isFiltered};Hotel.prototype.sortFilteredHotels=function(){var self=this;var reverse=(self.filterModel.data.sort_direction=="desc");switch(self.filterModel.data.sort_field){case"random":reverse=(reverse)?-1:1;self.filteredHotels.sort(function(a,b){var rndA=(a.rank<=100)?999999999:a.rnd,rndB=(b.rank<=100)?999999999:b.rnd;if(rndA<rndB){return reverse*-1}if(rndA>rndB){return reverse*1}return 0});break;case"rank":reverse=(reverse)?-1:1;self.filteredHotels.sort(function(a,b){var rankA=a.rank,rankB=b.rank;if(!self.ratesModel.includeUnavailable){if(self.ratesModel.isDatedSearch()&&!self.ratesModel.rates[a.tid]&&self.displayableRatelessPartners(a.tid).length>0){rankA=101}if(self.ratesModel.isDatedSearch()&&!self.ratesModel.rates[b.tid]&&self.displayableRatelessPartners(b.tid).length>0){rankB=101}}if(rankA<rankB){return reverse*-1}if(rankA>rankB){return reverse*1}if(a.name.toUpperCase()<b.name.toUpperCase()){return reverse*-1}if(a.name.toUpperCase()>b.name.toUpperCase()){return reverse*1}return 0});break;case"name_partial":self.filteredHotels.sort($.sortBy("name",reverse,function(a){return a.toUpperCase()}));break;case"rate":if(self.ratesModel.checkInDate.length>0&&self.ratesModel.hotelsWithRate>0){self.sortByLiveRate()}else{self.filteredHotels.sort(function(a,b){var returnVal;if(!reverse){returnVal=((a.rate.lowest<b.rate.lowest)?-1:((a.rate.lowest>b.rate.lowest)?1:0))}else{returnVal=((a.rate.lowest<b.rate.lowest)?1:((a.rate.lowest>b.rate.lowest)?-1:0))}if(a.rate.lowest==0){returnVal=1}if(b.rate.lowest==0){returnVal=-1}return returnVal})}break;case"stars":self.filteredHotels.sort($.sortBy("stars",reverse));break}};Hotel.prototype.sortByLiveRate=function(){var self=this;if(self.ratesModel.checkInDate.length>0&&self.filterModel.data.sort_field=="rate"&&self.ratesModel.hotelsWithRate>0){self.filteredHotels.sort(function(a,b){var rateA=null,rateB=null,returnVal;if(self.ratesModel.rates[a.tid]){rateA=self.ratesModel.lowestHotelRate(a.tid).rate}if(self.ratesModel.rates[b.tid]){rateB=self.ratesModel.lowestHotelRate(b.tid).rate}if($.inArray(a.tid,self.ratesModel.unavailableHotels)>=0){rateA=a.rate.lowest}if($.inArray(b.tid,self.ratesModel.unavailableHotels)>=0){rateB=b.rate.lowest}if(rateA==0){rateA=null}if(rateB==0){rateB=null}if(rateA==null&&rateB==null){returnVal=0}else{if(rateA==null){returnVal=1}else{if(rateB==null){returnVal=-1}else{if(self.filterModel.data.sort_direction=="asc"){returnVal=((rateA<rateB)?-1:((rateA>rateB)?1:0))}else{returnVal=((rateA<rateB)?1:((rateA>rateB)?-1:0))}}}}return returnVal});return true}else{return false}};Hotel.prototype.useCachedHotels=function(){var hotelsLen=$.keyCount(this.hotels);return(hotelsLen>0&&this.isCachedLocation())};Hotel.prototype.isCachedLocation=function(){return(this.locationModel.data.num_hotels<=this.prefsModel.hotelSetSize)};Hotel.prototype.getHotelDetails=function(tid,onSuccess){var self=this;var url=this.prefsModel.urlroot+"/hotels/"+tid;$.copterRequest(url,{success:onSuccess})};Hotel.prototype.buildImageUrl=function(imageObj,width,height,big){var url="shared/img/noimage/"+width+"x"+height+".jpg";if(imageObj&&imageObj.sizes){var sizeMatched=false;if(!big){$.each(imageObj.sizes,function(i,sizeObj){if(sizeObj.width==width&&sizeObj.height==height){sizeMatched=true}})}if(sizeMatched||big){var sizeFolder;if(big){sizeFolder="big"}else{sizeFolder="x"+width+"y"+height}url=this.base_image_url+imageObj.tid+"/"+sizeFolder+"/"+imageObj.file_name}}return url};Hotel.prototype.imageHasDimensions=function(imageObj,width,height){if(imageObj.sizes){var sizeMatched=false;$.each(imageObj.sizes,function(i,sizeObj){if(sizeObj.width==width&&sizeObj.height==height){sizeMatched=true}});return sizeMatched}else{return false}};Hotel.prototype.maxImageSize=function(imageObj){if(imageObj.sizes){var sizeObj=imageObj.sizes[imageObj.sizes.length-1];return sizeObj}else{return false}};Hotel.prototype.bookDirectLogo=function(brand,partnerCode,isBookDirect,w,h){var logo=this.partnersModel.partnerLogo(partnerCode,w,h);if(brand.code&&isBookDirect){logo=this.prefsModel.logoUrlRoot+"/brands/"+w+"x"+h+"/"+brand.code+".png"}return logo};Hotel.prototype.bookDirectPartner=function(brand,partner,isBookDirect){if(isBookDirect){return(brand.name||partner)}else{return partner}};Hotel.prototype.partners=function(hotelTID){var partners=[];if(this.hotels[hotelTID]&&this.hotels[hotelTID].partners){$.each(this.hotels[hotelTID].partners,function(key,partner){partner.key=key;partners.push(partner)})}return partners};Hotel.prototype.displayableRatelessPartners=function(hotelTID){var partners=[];if(this.hotels[hotelTID]&&this.hotels[hotelTID].partners){$.each(this.hotels[hotelTID].partners,function(key,partner){if((key=="RATRIXLISTING"||!partner.has_rates)&&partner.rate_from&&partner.link){partner.key=key;partners.push(partner)}})}return partners};Hotel.prototype.displayablePartners=function(hotelTID){var self=this,partners=[];if(this.hotels[hotelTID]&&this.hotels[hotelTID].partners){$.each(this.hotels[hotelTID].partners,function(key,partner){if(((key=="RATRIXLISTING"||!partner.has_rates)&&partner.rate_from&&partner.link)||(self.ratesModel.isDatedSearch()&&self.ratesModel.rates[hotelTID]&&self.ratesModel.rates[hotelTID].rates[partner.code])||(!self.ratesModel.isDatedSearch()&&partner.has_rates)){partners.push(partner)}})}return partners};Hotel.prototype.isCallToBook=function(hotelTID){var isCallToBook=(this.prefsModel.allowUnavailablePhoneNumberDisplay&&this.hotels[hotelTID].tel)?true:false;if(this.partners(hotelTID).length>0){isCallToBook=false}return isCallToBook};return(new Hotel())})(jQuery,window.application));window.application.addModel((function($,application){function Filters(){this.data={}}Filters.prototype.init=function(){this.reset();this.locationModel=application.getModel("Location");this.ratesModel=application.getModel("Rates");this.prefsModel=application.getModel("Prefs");this.focusSetting=this.prefsModel.dropdowns.focusSetting.defaultSetting;this.cardType=this.prefsModel.dropdowns.view.defaultSetting;this.hotelLightbox="";this.hotelLightboxRoomRates=0;this.photoLightbox="";this.photoLightboxPosition=0};Filters.prototype.reset=function(){this.data={}};Filters.prototype.setFilters=function(filters){this.data=filters};Filters.prototype.getFilters=function(){return this.data};Filters.prototype.resetFilters=function(){this.data={}};Filters.prototype.defaultSort=function(){return(this.locationModel.tid=="geo")?"distance":this.prefsModel.dropdowns.sort.defaultSort};Filters.prototype.defaultSortDirection=function(){return(this.locationModel.tid=="geo")?"asc":this.prefsModel.dropdowns.sort.defaultSortDirection};Filters.prototype.getAsQueryString=function(){var qs="";if(this.locationModel.tid&&!this.prefsModel.singleLocation){qs+="&lt="+encodeURI(this.locationModel.tid)}if(this.locationModel.geo.lat){qs+="&l1="+encodeURI(this.locationModel.geo.lat)}if(this.locationModel.geo.lng){qs+="&l2="+encodeURI(this.locationModel.geo.lng)}if(this.ratesModel.checkInDate.length>0){qs+="&d1="+encodeURI(this.ratesModel.checkInDate)}if(this.ratesModel.checkOutDate.length>0){qs+="&d2="+encodeURI(this.ratesModel.checkOutDate)}if(this.ratesModel.numGuests){qs+="&gs="+encodeURI(this.ratesModel.numGuests)}if(this.ratesModel.numRooms){qs+="&rm="+encodeURI(this.ratesModel.numRooms)}if(this.data.sort_field){qs+="&sf="+this.data.sort_field}if(this.data.sort_direction){qs+="&sd="+this.data.sort_direction}if(this.data.star_min||this.data.star_min==0){qs+="&s1="+this.data.star_min}if(this.data.star_max||this.data.star_max==0){qs+="&s2="+this.data.star_max}if(this.data.price_min||this.data.price_min==0){qs+="&p1="+this.data.price_min}if(this.data.price_max||this.data.price_max==0){qs+="&p2="+this.data.price_max}if(this.data.incl_no_rating){qs+="&nr="+this.data.incl_no_rating}if(this.data.hotel_name_contains&&this.data.hotel_name_contains.length>0){qs+="&nm="+encodeURI(this.data.hotel_name_contains)}if(this.data.amenities){qs+="&am="+encodeURI(this.data.amenities.toString())}if(this.data.property_types){qs+="&pt="+encodeURI(this.data.property_types.toString())}if(this.data.brands){qs+="&hb="+encodeURI(this.data.brands.toString())}if(this.data.sub_locations){qs+="&su="+encodeURI(this.data.sub_locations.toString())}if(this.focusSetting.length>0){qs+="&fo="+encodeURI(this.focusSetting)}qs+="&ct="+encodeURI(this.cardType);if(this.hotelLightbox.length>0){qs+="&hl="+encodeURI(this.hotelLightbox);qs+="&rr="+encodeURI(this.hotelLightboxRoomRates)}if(this.photoLightbox.length>0){qs+="&pl="+encodeURI(this.photoLightbox);qs+="&pp="+encodeURI(this.photoLightboxPosition)}qs=qs.substr(1);return qs};Filters.prototype.setFromQueryString=function(qs){qs=qs.toQueryParams();if(this.prefsModel.singleLocation&&qs.lt!="geo"){this.locationModel.tid="single"}else{this.locationModel.tid=(qs.lt||"")}this.locationModel.geo.lat=(qs.l1||null);this.locationModel.geo.lng=(qs.l2||null);if(qs.pn){this.locationModel.display_name=qs.pn.escapeHTML()}this.ratesModel.checkInDate=(qs.d1||"");this.ratesModel.checkOutDate=(qs.d2||"");this.ratesModel.numGuests=(qs.gs||1);this.ratesModel.numRooms=(qs.rm||1);this.data.sort_field=(qs.sf||this.defaultSort());this.data.sort_direction=(qs.sd||this.defaultSortDirection());if(qs.s1){this.data.star_min=qs.s1}if(qs.s2){this.data.star_max=qs.s2}if(qs.p1){this.data.price_min=qs.p1}if(qs.p2){this.data.price_max=qs.p2}this.data.incl_no_rating=qs.nr;this.data.hotel_name_contains=qs.nm;this.data.amenities=(qs.am)?qs.am.split(","):[];this.data.property_types=(qs.pt)?qs.pt.split(","):[];this.data.brands=(qs.hb)?qs.hb.split(","):[];this.data.sub_locations=(qs.su)?qs.su.split(","):[];this.focusSetting=(qs.fo||"");if(qs.ct){this.cardType=qs.ct}this.hotelLightbox=(qs.hl||"");this.hotelLightboxRoomRates=(qs.rr||0);this.photoLightbox=(qs.pl||"");this.photoLightboxPosition=(qs.pp||0)};return(new Filters())})(jQuery,window.application));window.application.addModel((function($,application){function FilterBuckets(){this.buckets=[];this.selectedBucket=null}FilterBuckets.prototype.init=function(){this.reset();this.locationModel=application.getModel("Location");this.filterModel=application.getModel("Filters");this.prefsModel=application.getModel("Prefs")};FilterBuckets.prototype.reset=function(){this.buckets=[];this.selectedBucket=null};FilterBuckets.prototype.initFilterBuckets=function(){var self=this;this.buckets=this.getPresetBuckets();$.each(this.getCustomBuckets(),function(i,v){self.buckets.push(v)});if(!this.filterModel.data.price_min){$.each(this.buckets,function(i,v){if(v.default_bucket){self.selectBucket(i);return false}})}};FilterBuckets.prototype.getFilterBuckets=function(onComplete){var self=this;var hotelModel=application.getModel("Hotel");if(this.prefsModel.dropdowns.bucket.display){$.each(this.buckets,function(i,bucket){hotelModel.getHotels(function(response){bucket.hotel_count=response.hotel_count;self.checkHotelCount(onComplete)},bucket.filters,true)})}else{onComplete(this)}};FilterBuckets.prototype.checkHotelCount=function(onComplete){var countComplete=true;$.each(this.buckets,function(i,bucket){if(bucket.hotel_count==null){countComplete=false;return false}});if(countComplete){onComplete(this)}};FilterBuckets.prototype.selectBucket=function(i,sort){this.selectedBucket=i;var filters=this.buckets[i].filters;if(sort){filters.sort_field=sort.field;filters.sort_direction=sort.direction}this.filterModel.setFilters(filters)};FilterBuckets.prototype.getPresetBuckets=function(){var data=this.locationModel.data;return([{name:"All Properties",default_bucket:this.isDefault("all"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:1,star_max:5,price_min:data.minrate.usd,price_max:data.maxrate.usd,user_min:0,user_max:10,incl_no_rating:true},custom:false},{name:"Our Selections",default_bucket:this.isDefault("our"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:2,star_max:5,price_min:data.avgrate.usd-((data.avgrate.usd-data.minrate.usd)/2),price_max:data.avgrate.usd+((data.maxrate.usd-data.avgrate.usd)/2),user_min:0,user_max:10,incl_no_rating:true},custom:false},{name:"Best Quality Available in Area",default_bucket:this.isDefault("quality"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:1,star_max:5,price_min:data.avgrate.usd+((data.maxrate.usd-data.avgrate.usd)/2),price_max:data.maxrate.usd,user_min:0,user_max:10,incl_no_rating:true},custom:false},{name:"Best Bargains Available in Area",default_bucket:this.isDefault("bargains"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:1,star_max:5,price_min:data.minrate.usd,price_max:data.avgrate.usd-((data.avgrate.usd-data.minrate.usd)/2),user_min:0,user_max:10,incl_no_rating:true},custom:false},{name:"Luxury Properties",default_bucket:this.isDefault("luxury"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:4,star_max:5,price_min:data.minrate.usd,price_max:data.maxrate.usd,user_min:6,user_max:10,incl_no_rating:false,property_types:["CHN","IND","RES","VAC"]},custom:false},{name:"Business Properties",default_bucket:this.isDefault("business"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:3,star_max:4,price_min:data.minrate.usd,price_max:data.maxrate.usd,user_min:data.minuser,user_max:data.maxuser,incl_no_rating:true,amenities:["INT","BUSIN"],property_types:["CHN","IND","MOT"]},custom:false},{name:"Budget Hotels & Motels",default_bucket:this.isDefault("budget"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:1,star_max:2,price_min:data.minrate.usd,price_max:data.maxrate.usd,user_min:data.minuser,user_max:data.maxuser,incl_no_rating:true,property_types:["CHN","IND","MOT","RES"]},custom:false},{name:"Shoestring Hostels & B&Bs",default_bucket:this.isDefault("shoestring"),hotel_count:null,filters:{sort_field:this.filterModel.defaultSort(),sort_direction:this.filterModel.defaultSortDirection(),star_min:1,star_max:5,price_min:data.minrate.usd,price_max:data.maxrate.usd,user_min:data.minuser,user_max:data.maxuser,incl_no_rating:true,property_types:["HOS","BED"]},custom:false}])};FilterBuckets.prototype.getCustomBuckets=function(){return([])};FilterBuckets.prototype.addCustomBucket=function(bucketName){var filters=application.getModel("Filters");this.buckets.push({name:bucketName,"default":false,filters:filters,custom:true})};FilterBuckets.prototype.isDefault=function(bucketID){return(bucketID==this.prefsModel.dropdowns.bucket.defaultSetting)};return(new FilterBuckets())})(jQuery,window.application));window.application.addModel((function($,application){function Rates(){this.checkInDate="";this.checkOutDate="";this.numRooms=1;this.numGuests=1;this.rates={};this.unavailableHotels=[];this.hotelsWithRate=0;this.poller=null;this.currentSearchId=null;this.nights=null;this.numPollingErrors=0;this.numInitErrors=0;this.isPolling=false;this.includeUnavailable=null}Rates.prototype.init=function(){this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.locationModel=application.getModel("Location");this.filtersModel=application.getModel("Filters");this.reset()};Rates.prototype.reset=function(){this.checkInDate="";this.checkOutDate="";this.numRooms=1;this.numGuests=1;this.rates={};this.unavailableHotels=[];this.hotelsWithRate=0;this.poller=null;this.currentSearchId=null;this.nights=null;this.numPollingErrors=0;this.numInitErrors=0;this.isPolling=false;this.includeUnavailable=this.prefsModel.includeUnavailable};Rates.prototype.isDatedSearch=function(){return(this.checkInDate.length>0)};Rates.prototype.initPollingFilteredHotels=function(pollingUpdated){var self=this,hotelTIDs=[],counter=0;$.each(this.hotelModel.hotels,function(hotelTID,hotel){if(!self.rates[hotelTID]&&($.inArray(hotelTID,self.unavailableHotels)<0)){hotelTIDs.push(hotelTID)}if(counter==self.prefsModel.hotelSetSize){return false}counter++});if(hotelTIDs.length>0){this.initPolling(hotelTIDs,pollingUpdated)}else{$.event.trigger("c0pt3rRatesPollingComplete")}};Rates.prototype.initPollingHotels=function(hotels,pollingUpdated){var self=this,hotelTIDs=[],counter=0,hotelLightboxTID=self.filtersModel.hotelLightbox;$.each(hotels,function(i,hotel){if(!self.rates[hotel.tid]&&($.inArray(hotel.tid,self.unavailableHotels)<0)){hotelTIDs.push(hotel.tid)}if(hotelTIDs.length==self.prefsModel.hotelSetSize){return false}counter++});if(hotelLightboxTID.length>0&&($.inArray(hotelLightboxTID,hotelTIDs)<0)){hotelTIDs.push(hotelLightboxTID)}if(hotelTIDs.length>0){this.initPolling(hotelTIDs,pollingUpdated);$.event.trigger("c0pt3rRatesPolled")}else{$.event.trigger("c0pt3rRatesPollingComplete")}};Rates.prototype.initPolling=function(hotelTIDs,pollingUpdated){var self=this;$.event.trigger("c0pt3rRatesPollingInit");this.isPolling=true;this.numPollingErrors=0;if(this.poller!=null){window.clearTimeout(this.poller)}var url=this.prefsModel.urlroot+"/search";var data={};data.check_in=this.checkInDate;data.check_out=this.checkOutDate;data.guests=this.numGuests;data.rooms=this.numRooms;data.hotel_tids=hotelTIDs;$.each(hotelTIDs,function(i,hotelTID){self.unavailableHotels.push(hotelTID)});var request_context={type:"post",data:data,success:function(response){self.currentSearchId=response.search_id;self.poll(1,response.response_uri,response.search_id,pollingUpdated)},error:function(xhr){application.log("ERROR: An error occurred while trying to initialize a search for hotel rates. ["+(xhr.status||"Unknown status")+"]");self.numInitErrors++;if(self.numInitErrors<=3){window.setTimeout(function(){self.initPolling(hotelTIDs,pollingUpdated)},2000)}else{application.log("ERROR: Initialising rate search failed after three attempts.");self.pollingComplete(pollingUpdated)}}};$.copterRequest(url,request_context)};Rates.prototype.poll=function(version,url,searchId,pollingUpdated){var self=this;if(searchId==this.currentSearchId){var request_context={data:{version:version},success:function(response){self.nights=response.nights;$.each(response.changed.new_hotels,function(i,hotelTID){self.rates[hotelTID]=response.hotel_results[hotelTID];self.unavailableHotels=$.grep(self.unavailableHotels,function(value){return value!=hotelTID});self.hotelsWithRate++});$.each(response.changed.updated_hotels,function(i,hotelTID){var hotelRates=response.hotel_results[hotelTID];if(self.rates[hotelTID]){delete self.rates[hotelTID]}self.rates[hotelTID]=hotelRates});version++;if(version<=self.prefsModel.ratePollCount){self.poller=window.setTimeout(function(){self.poll(version,url,searchId,pollingUpdated);version=null;url=null;searchId=null;pollingUpdated=null},self.prefsModel.ratePollDelay);if(pollingUpdated){pollingUpdated(false)}if(response.changed.new_hotels.length>0||response.changed.updated_hotels.length>0){$.event.trigger("c0pt3rRatesPolled")}}else{self.pollingComplete(pollingUpdated)}},error:function(xhr,textStatus){var status500=false;try{status500=(parseInt(xhr.status)==500)}catch(e){status500=false}if(status500){self.numPollingErrors++;if(self.numPollingErrors<=10){self.poller=window.setTimeout(function(){self.poll(version,url,searchId,pollingUpdated);version=null;url=null;searchId=null;pollingUpdated=null},self.prefsModel.ratePollDelay)}else{application.log("ERROR: An error occurred while searching for hotel rates and availability.");self.pollingComplete(pollingUpdated)}}else{application.log("ERROR: An unforeseen error has occurred while searching for hotel rates and availability.");self.pollingComplete(pollingUpdated)}}};$.copterRequest(url,request_context)}};Rates.prototype.pollingComplete=function(pollingUpdated){var self=this;$.each(self.rates,function(hotelTID,rateObj){rateObj.pollingCompleted=true});self.isPolling=false;if(pollingUpdated){pollingUpdated(true)}$.event.trigger("c0pt3rRatesPollingComplete")};Rates.prototype.clear=function(){this.rates={};this.unavailableHotels=[];this.hotelsWithRate=0;this.numPollingErrors=0;this.numInitErrors=0;this.isPolling=false};Rates.prototype.numHotelPartners=function(tid){if(this.rates[tid]){var size=0,key;for(key in this.rates[tid].rates){size++}return size}else{return 0}};Rates.prototype.lowestHotelRate=function(tid){var self=this;if(this.rates[tid]){var obj={rate:this.rates[tid].lowest_rate,inclTaxesFees:this.rates[tid].lowest_rate_is_inclusive,partnerCode:this.rates[tid].lowest_rate_partner,rateTID:this.rates[tid].lowest_rate_tid};if(!obj.inclTaxesFees){var bestInclusiveRate;$.each(this.rates[tid].rates,function(partnerCode,partnerRates){var lowestPartnerRate=self.lowestHotelPartnerRateDetails(tid,partnerCode);if(partnerRates.rates[0].av_nightly_rate_is_inclusive&&(!bestInclusiveRate||lowestPartnerRate.rate<bestInclusiveRate)){obj={rate:lowestPartnerRate.rate,inclTaxesFees:lowestPartnerRate.inclTaxesFees,partnerCode:partnerCode,rateTID:lowestPartnerRate.rateTID};bestInclusiveRate=lowestPartnerRate.rate}})}return obj}else{return false}};Rates.prototype.lowestHotelRateDetails=function(tid){if(this.rates[tid]){var lowestRate=this.lowestHotelRate(tid);return this.rateDetails(tid,lowestRate.partnerCode,lowestRate.rateTID)}else{return false}};Rates.prototype.lowestHotelPartnerRateDetails=function(tid,partnerCode){if(this.rates[tid]){var rateTID=this.rates[tid].rates[partnerCode].lowest_rate_tid;return this.rateDetails(tid,partnerCode,rateTID)}else{return false}};Rates.prototype.rateDetails=function(hotelTID,partnerCode,rateTID){var obj={};var rateDetails=this.rates[hotelTID].rates[partnerCode];var rateIndex=null;$.each(rateDetails.rates,function(i,rate){if(rate.rate_tid==rateTID){rateIndex=i;return false}});if(rateIndex==null){return false}else{obj.rate=rateDetails.rates[rateIndex].av_nightly_rate;obj.inclTaxesFees=rateDetails.rates[rateIndex].av_nightly_rate_is_inclusive;obj.taxesFees=rateDetails.rates[rateIndex].av_nightly_taxes_and_fees;obj.policies=[];var policyProperties=["policy_immediate_charge","policy_preauth","policy_pre_pay","policy_extra_charges","policy_cancellation","policy_cancel"];$.each(policyProperties,function(i,propertyName){if(rateDetails.rates[rateIndex][propertyName]){obj.policies.push(rateDetails.rates[rateIndex][propertyName])}});obj.rateTID=rateTID;obj.partnerCode=partnerCode;obj.roomDesc=(rateDetails.rates[rateIndex].room_description||false);obj.roomType=(rateDetails.rates[rateIndex].room_type||false);obj.bookingUrl=(rateDetails.rates[rateIndex].booking_url||false);if(obj.bookingUrl){obj.bookingUrl+="&api_key="+this.prefsModel.apiKey+"&api_version="+this.prefsModel.apiVersion}return obj}};Rates.prototype.hotelRatesByRoomType=function(tid){var self=this;if(this.rates[tid]){var hotelRates=this.rates[tid];var roomTypeRates={};$.each(hotelRates.rates,function(partner,partnerRates){$.each(partnerRates.rates,function(i,rateDetails){if(!roomTypeRates[rateDetails.room_type]){roomTypeRates[rateDetails.room_type]=[]}var obj={};obj.rate_inc=(rateDetails.av_nightly_rate_is_inclusive)?rateDetails.av_nightly_rate:((rateDetails.av_nightly_taxes_and_fees)?(rateDetails.av_nightly_rate+rateDetails.av_nightly_taxes_and_fees):null);obj.rate_exc=(rateDetails.av_nightly_rate_is_inclusive)?(rateDetails.av_nightly_rate-rateDetails.av_nightly_taxes_and_fees):rateDetails.av_nightly_rate;obj.inclTaxesFees=rateDetails.av_nightly_rate_is_inclusive;obj.partner_code=partner;obj.desc=rateDetails.room_description;obj.booking_url=rateDetails.booking_url+"&api_key="+self.prefsModel.apiKey+"&api_version="+self.prefsModel.apiVersion;roomTypeRates[rateDetails.room_type].push(obj)})});$.each(roomTypeRates,function(i,roomTypeRateObj){roomTypeRateObj.sort(function(a,b){return(a.rate_inc||999999999)-(b.rate_inc||999999999)})});return roomTypeRates}else{return false}};return(new Rates())})(jQuery,window.application));window.application.addModel((function($,application){function Partners(){this.data={}}Partners.prototype.init=function(){this.prefsModel=application.getModel("Prefs")};Partners.prototype.getPartners=function(){var self=this;var url=this.prefsModel.urlroot+"/partners";$.copterRequest(url,{success:function(response){self.data=response},error:function(opts,status){application.log("Error while trying to fetch partner data.")}})};Partners.prototype.partnerLogo=function(partnerCode,w,h){return this.prefsModel.logoUrlRoot+"/partners/"+w+"x"+h+"/"+partnerCode+".png"};return(new Partners())})(jQuery,window.application));window.application.addModel((function($,application){function Tracking(){this.actionCounter=0}Tracking.prototype.init=function(){this.prefsModel=application.getModel("Prefs");this.url=this.prefsModel.apijUrl;this.apiKey=this.prefsModel.apiKey;this.apiVersion=this.prefsModel.apijVersion};Tracking.prototype.record=function(eventType,data,cb){data=(data||{});data.event_type=eventType;data._method="POST";data.api_key=this.apiKey;data.api_version=this.apiVersion;data.action_counter=++this.actionCounter;$.copterRequest(this.url,{data:data,success:function(){if(cb){cb()}},error:function(){if(cb){cb()}}},true)};return(new Tracking())})(jQuery,window.application));window.application.addView((function($,application){function Autofill(){this.div=null;this.textfieldId=null;this.textfield=null;this.minCharsBeforeRequest=1;this.divPosId=null;this.keypressTimeout=null;this.cache=new $.Hashtable();this.preselect=null;this.caching=true;this.keyDelay=200;this.slots=null;this.maxSlots=10;this.locUrl=null;this.hotelUrl=null;this.json=null;this.selectedJson=null;this.urlHash=null;this.submitOnEnter=false;this.currentQuery=""}Autofill.prototype.init=function(){var self=this;this.div=$("#c0pt3r-homepage");this.display_name=null;this.prefsModel=application.getModel("Prefs");this.locationModel=application.getModel("Location");this.hotelModel=application.getModel("Hotel");this.ratesModel=application.getModel("Rates");this.filterBucketsModel=application.getModel("FilterBuckets");this.filterModel=application.getModel("Filters");this.trackingModel=application.getModel("Tracking");this.hotelView=application.getView("Hotel");this.lightboxView=application.getView("Lightbox");this.includePhotos=this.prefsModel.autofillPhotos;this.googleLookUp=this.prefsModel.autofillGoogleLookUp;this.includeAirports=this.prefsModel.autofillIncludeAirports;this.includeHotels=this.prefsModel.autofillIncludeHotels;this.locationImages={"2EAq5QCnW04r5Vk05g9kmcuB":"amsterdam","49PAIK9UO04r5EL05g9kmK6k":"aspen","19ox1M2RS04rDl8002PnTi25":"atlanta","4IgBv62RQ04rDl8002PnTi25":"austin","1qBA9o9UO04r5EL05g9kmK6k":"boston","1LTobQ5UP04rBth002f129iS":"charlottesville","4GGUsq9UO04r5EL05g9kmK6k":"chicago","2zUrOCDnd04r1im05g9koODy":"dubai","4KOWmG2RS04rDl8002PnTi25":"lasvegas","3N4nMO9UO04r5EL05g9kmK6k":"london","2JsduK2RR04rDl8002PnTi25":"losangeles","1FxHMWFAx04rC0c05g9koODy":"mexicocity","3S5CnA9UO04r5EL05g9kmK6k":"miami","0DbqHQ9UP04r5EL05g9kmK6k":"newyork","4US0cyCkN04r5JG05g9kmcuB":"paris","1QmpUW9UO04r5EL05g9kmK6k":"philadelphia","28PWEK2RS04rDl8002PnTi25":"portland","2YVzxAFAy04rC0c05g9koODy":"riodejaneiro","1M2UgiFAx04rC0c05g9koODy":"rome","10N1c02RS04rDl8002PnTi25":"sandiego","33vpyK2RS04rDl8002PnTi25":"sanfrancisco","27d7bM2RR04rDl8002PnTi25":"seattle","4HSIWu9iU04r0lP05g9klYqf":"toronto","1YqFWK2RS04rDl8002PnTi25":"washington"};$(window).resize(function(){self.hideAutoComplete(false)})};Autofill.prototype.show=function(qs){var self=this;this.hotelView.close("hoteldetails");this.lightboxView.close("lightbox");this.display_name=null;$("html, body").removeClass("c0pt3r-results").addClass("c0pt3r-home");this.textfieldId="location";this.textfield=$("#"+this.textfieldId);if($(this.textfieldId+"-wrapper").length==0){$("#c0pt3r-homepage").append(application.getFromTemplate($("#home-template")));this.textfield.keyup(function(e){self.lookUpInit(e)});$("html, body").click(function(e){self.hideAutoComplete(true)});if(!$("#search-btn").is("input")){$("#search-btn").click(function(e){e.preventDefault();e.stopPropagation();self.search()})}$("#searchform").submit(function(e){e.preventDefault();e.stopPropagation();self.search()});this.initTextBox();this.prefillTextBox(qs);$("body").trigger("c0pt3rHomepageRendered")}$("#c0pt3r-homepage").show();$("#c0pt3r-footer").show();$("#c0pt3r-results").hide().empty();this.textfield.select();this.textfieldWidth=this.textfield.width()};Autofill.prototype.initTextBox=function(){var self=this;this.preselect=$('<div class="autofill" style="color:silver" id="'+this.textfieldId+'-preselect" />');this.textfield.keydown(function(e){var k=$.ui.keyCode;if(e.keyCode!=k.LEFT&&e.keyCode!=k.RIGHT&&e.keyCode!=k.HOME&&e.keyCode!=k.END&&e.keyCode!=k.PAGE_UP&&e.keyCode!=k.PAGE_DOWN){if(e.keyCode==k.DELETE||e.keyCode==k.BACKSPACE){self.preselect.html("")}if(self.preselect.children().first().is("span")&&e.keyCode>=32&&e.keyCode<127){if(String.fromCharCode(e.keyCode).toLowerCase()==String.fromCharCode(self.preselect.html().stripTags().charCodeAt(self.textfield.val().length)).toLowerCase()){var preselectHTML='<span style="color:#fff">'+self.preselect.html().stripTags().substring(0,self.textfield.val().length)+"</span>"+self.preselect.html().stripTags().substring(self.textfield.val().length,self.preselect.html().stripTags().length);self.preselect.html(preselectHTML);var ch=String.fromCharCode(self.preselect.html().stripTags().charCodeAt(self.textfield.val().length));e.preventDefault();self.textfield.val(self.textfield.val()+ch)}else{self.preselect.html("");self.disableSearch()}}if(e.keyCode==k.TAB){e.preventDefault();if(self.urlHash==null){self.selectLocation();self.expandControls()}else{$("#checkin").focus()}}if(e.keyCode==k.ENTER){e.preventDefault();if(self.urlHash==null){self.selectLocation();if(self.submitOnEnter){self.search()}else{self.expandControls()}}else{self.selectLocation();self.search()}}if(e.keyCode==k.DOWN){e.preventDefault();self.cursorMove("down")}if(e.keyCode==k.UP){e.preventDefault();self.cursorMove("up")}}});this.textfield.keyup(function(e){if(self.textfield.val().length==0){self.disableSearch();self.hideControls()}});this.textfield.click(function(e){self.lookUp(self.textfield.val());e.stopPropagation()});this.divPosId=this.textfieldId+"-wrapper";if($("#"+this.divPosId).length==0){this.textfield.wrap($('<div id="'+this.divPosId+'" class="autofillwrap" />'));this.textfield.after(this.preselect);this.textfield.addClass("autofillfloat")}};Autofill.prototype.prefillTextBox=function(qs){var self=this;if(qs){qs=qs.toQueryParams();if(qs.af){$("#"+this.textfieldId).val(qs.af);this.lookUpRequest(qs.af,function(){if(self.json.locations.length>0){var result=self.json.locations[0];self.selectedJson=result;self.display_name=result.display_name;self.textfield.val(result.display_name);self.textfield.focus();if(result.tid=="geo"){self.locationModel.showMap=true;self.urlHash="#/search/n/"+self.buildHash(result.tid,result.geo)}else{self.urlHash="#/search/n/"+self.buildHash(result.tid)}self.expandControls();if(qs.d1){try{$("#checkin").val($.datepicker.formatDate("mm/dd/yy",$.datepicker.parseDate("yy-mm-dd",qs.d1)))}catch(e){}}if(qs.d2){try{$("#checkout").val($.datepicker.formatDate("mm/dd/yy",$.datepicker.parseDate("yy-mm-dd",qs.d2)))}catch(e){}}if(qs.rm&&!isNaN(qs.rm)&&qs.rm>=1&&qs.rm<=4){$("#numrooms").val(qs.rm);self.populateGuests()}if(qs.gs&&!isNaN(qs.gs)&&qs.gs>=1&&qs.gs<=16){$("#numguests").val(qs.gs)}}})}}};Autofill.prototype.cursorMove=function(direction){if($("#autofill-"+this.textfieldId).length>0){var self=this,sel=$("#autofill-"+this.textfieldId+" .afresultsel"),newsel;if(direction=="down"){newsel=sel.nextAll(".afresult:first")}else{newsel=sel.prevAll(".afresult:first")}if(newsel.length==0){if(direction=="down"){newsel=$("#autofill-"+this.textfieldId+" .afresult:first")}else{newsel=$("#autofill-"+this.textfieldId+" .afresult:last")}}self.unhiliteResult(sel);self.hiliteResult(newsel)}};Autofill.prototype.hiliteResult=function(el){if($(el).length>0){$(el).removeClass("afresult").addClass("afresultsel");var displayname=$(el).find("div.afdisplayname").html();if(displayname.toLowerCase().startsWith(this.textfield.val().toLowerCase())){this.setPreselect(displayname)}else{this.preselect.html("")}}};Autofill.prototype.unhiliteResult=function(el){$(el).removeClass("afresultsel").addClass("afresult")};Autofill.prototype.showSpinner=function(fade){if($("#afspinner").length==0){$("#location").css({width:($("#location").width()-24)+"px"});var html='<div id="afspinner" class="afindicator"></div>';$("#location-wrapper").append(html);if(fade){$("#afspinner").hide().fadeIn(250)}}};Autofill.prototype.hideSpinner=function(fade){if($("#afspinner").length>0){if(fade){$("#afspinner").fadeOut(250,function(){$(this).remove()})}else{$("#afspinner").remove()}$("#location").css({width:this.textfieldWidth+"px"})}};Autofill.prototype.showDDIcon=function(){var self=this;if($("#afdropdown").length==0){var html='<div id="afdropdown" class="afindicator"><img src="shared/img/icons/dropdown16x16.png" /></div>';$("#"+this.divPosId).append(html);$("#afdropdown").hide().fadeIn(250);$("#afdropdown").click(function(e){if($("#autofill-"+self.textfieldId).length==0){self.lookUp(self.textfield.val());e.preventDefault()}})}};Autofill.prototype.hideDDIcon=function(){if($("#afdropdown")){$("#afdropdown").remove()}};Autofill.prototype.lookUpInit=function(e){var self=this,k=$.ui.keyCode;if(((e.keyCode>=32&&e.keyCode<=126)||(e.keyCode==k.DELETE)||(e.keyCode==k.BACKSPACE))&&e.keyCode!=k.DOWN&&e.keyCode!=k.UP&&e.keyCode!=k.LEFT&&e.keyCode!=k.RIGHT){if(typeof self.keypressTimeout=="number"){window.clearTimeout(self.keypressTimeout)}self.slots=self.maxSlots;self.hideDDIcon();var lookUpValue=self.textfield.val();if(lookUpValue.length>=self.minCharsBeforeRequest){self.showSpinner(true);self.keypressTimeout=window.setTimeout(function(){self.lookUp(lookUpValue);self=null;lookUpValue=null},self.keyDelay)}if(lookUpValue.length==0){self.hideAutoComplete(false);self.hideSpinner(true)}}};Autofill.prototype.lookUp=function(v){var self=this;if(v.length>0){self.slots=self.maxSlots;self.hotelUrl=null;self.locUrl=null;self.json=null;if(self.cache.get(v.toLowerCase())){self.json=self.cache.get(v.toLowerCase());self.parse();self.hideSpinner(true)}else{self.lookUpRequest(v,function(){self.parse()})}}};Autofill.prototype.lookUpRequest=function(v,cb){var self=this;if(v.length>0){self.currentQuery=v;$.copterRequest(self.prefsModel.urlroot+"/autofill",{data:{query:v},success:function(data){if(self.currentQuery==data.query){self.json=data;if(self.json.query==self.textfield.val()){if((self.json.locations.length)==0&&self.googleLookUp){var geocoder=new google.maps.Geocoder();geocoder.geocode({address:self.textfield.val()},function(results){$.each(results,function(i,googleResult){if(self.isGoogleLocationOK(googleResult)){self.json.locations.push({tid:"geo",img:null,display_name:googleResult.formatted_address,geo:{lat:googleResult.geometry.location.lat(),lng:googleResult.geometry.location.lng()},types:googleResult.types})}});if(self.caching){self.cache.set(self.textfield.val().toLowerCase(),self.json)}if(cb){cb()}})}else{if(self.caching){self.cache.set(self.textfield.val().toLowerCase(),self.json)}if(cb){cb()}}}self.hideSpinner(true)}}})}};Autofill.prototype.isGoogleLocationOK=function(googleResult){var locationOK=false,locationTypes=googleResult.types,addressComponents=googleResult.address_components,permittedLocationTypes=["street_address","route","intersection","administrative_area_level_3","locality","sublocality","neighborhood","premise","subpremise","postal_code","natural_feature","airport","park","point_of_interest"],disallowedWords=["hotel","motel"];$.each(locationTypes,function(i,locationType){if($.inArray(locationType,permittedLocationTypes)>=0){locationOK=true;return false}});$.each(disallowedWords,function(i,disallowedWord){if(googleResult.formatted_address.toLowerCase().indexOf(disallowedWord)>=0){locationOK=false;return false}});if(addressComponents.length>0&&$.inArray(locationTypes,"establishment")>=0){$.each(this.json.hotels,function(i,hotel){if(hotel.display_name.indexOf(addressComponents[0].short_name)>=0||hotel.display_name.indexOf(addressComponents[0].long_name)>=0){locationOK=false;return false}})}return locationOK};Autofill.prototype.parse=function(){var self=this;if((this.json.locations.length+this.json.airports.length+this.json.hotels.length)==0){this.hideAutoComplete(false);this.hideDDIcon()}else{var airport_slots=0,hotel_slots=0;this.showAutoComplete();this.clearAutoComplete();if(this.includeAirports){if(this.json.airports.length>0){airport_slots=1}}if(this.includeHotels){if(this.textfield.val().length>2){hotel_slots=this.json.hotels.length;if(this.json.hotels.length>=4){hotel_slots=4}}}this.slots-=(airport_slots+hotel_slots);if(this.json.locations.length>0){this.setPreselect(this.json.locations[0].display_name);var locationHeadingHtml='<div class="afheading"><div class="label">Places</div>';if(this.prefsModel.locationAverages){locationHeadingHtml+='<div class="avg">Average Hotel</div>'}locationHeadingHtml+='<div class="c0pt3r-clear" /></div>';$("#autofill-"+this.textfieldId).append(locationHeadingHtml);$.each(this.json.locations,function(i,p){self.showLocation(p,i,self.json.locations.length)})}if(this.includeAirports){if(this.json.airports.length>0){this.slots+=airport_slots;if(this.slots>0){if(this.slots<=this.maxSlots){this.setPreselect(this.json.airports[0].display_name);$("#autofill-"+this.textfieldId).append('<div class="afheading"><div class="label">Airports</div><div class="avg">Average Hotel</div><div class="c0pt3r-clear" /></div>');this.showAirport(this.json.airports[0])}}}}if(this.includeHotels){if(this.json.hotels.length>0){this.slots+=hotel_slots;if(this.slots>0){if(this.slots<=this.maxSlots){this.setPreselect(this.json.hotels[0].display_name);$("#autofill-"+this.textfieldId).append('<div class="afheading"><div class="label">Hotels</div><div class="avg">Stars &amp; Avg. Rate</div><div class="c0pt3r-clear" /></div>');$.each(this.json.hotels,function(i,p){self.showHotel(p,i)})}}}}$("#autofill-"+this.textfieldId).children(":first").addClass("first");$("#autofill-"+this.textfieldId).children(":last").addClass("last");var div_clear=$('<div class="c0pt3r-clear" />');$("#autofill-"+this.textfieldId).append(div_clear);this.cursorMove("down");var div_container=$(".autofill-dd");var scrollTop=Math.round((div_container.position().top+div_container.height())-$(window).height());if(scrollTop>$(document).scrollTop()){$("html,body").animate({scrollTop:scrollTop+10},500)}else{if(div_container.position().top<$(document).scrollTop()){$("html,body").animate({scrollTop:scrollTop-10},500)}}}};Autofill.prototype.setPreselect=function(str){if(str.toLowerCase().startsWith(this.textfield.val().toLowerCase())){str=str.unescapeHTML();var preselectHTML='<span style="color:#fff">'+str.substring(0,this.textfield.val().length)+"</span>"+str.substring(this.textfield.val().length,str.length);this.preselect.html(preselectHTML);this.textfield.val(str.substring(0,this.textfield.val().length))}};Autofill.prototype.showAutoComplete=function(){if($("#autofill-"+this.textfieldId).length==0){var div_container=$('<div id="autofill-'+this.textfieldId+'" class="autofill-dd" />');div_container.css({left:Math.round($("#"+this.divPosId).offset().left)+"px",top:((Math.round($("#"+this.divPosId).offset().top)+Math.round($("#"+this.divPosId).outerHeight()))-1)+"px",width:(Math.round($("#"+this.divPosId).outerWidth())-2)+"px"});$("body").append(div_container)}};Autofill.prototype.hideAutoComplete=function(fade){if($("#autofill-"+this.textfieldId).length>0){if(fade){$("#autofill-"+this.textfieldId).fadeOut(250,function(){$(this).remove()})}else{$("#autofill-"+this.textfieldId).remove()}if(this.preselect){this.preselect.html("")}}};Autofill.prototype.clearAutoComplete=function(){if($("#autofill-"+this.textfieldId).length>0){$("#autofill-"+this.textfieldId).children().remove()}};Autofill.prototype.starPrice=function(star,price){return'<div style="float:right;line-height:12px;font-weight:bold;padding-right:10px;">'+('<div class="left starsmall" />').times(star)+' <div class="left" style="padding:2px 0 0 5px;width:25px;font-size:12px;text-align:right;">$'+price+'</div><div class="c0pt3r-clear" /></div>'};Autofill.prototype.showLocation=function(p,i,totalLen){var self=this;if(this.slots>0){var html="";var div_container=$('<div id="locations-'+i+'" class="afresult" />');$("#autofill-"+this.textfieldId).append(div_container);if(self.locationImages[p.tid]){p.img=self.locationImages[p.tid]+".jpg"}if(!self.includePhotos){p.img=null}var a;var card_type="A";if(i==0&&p.img!=null){card_type="B";if(totalLen==1&&p.sub_locations.length>0){card_type="C"}}switch(card_type){case"A":this.slots-=1;var d=p.display_name.truncate(45);a='<span style="font-size:15px">'+d.replace(/,/i,"</span>, ");if(a.indexOf("</span>")>=0){a+="</span>"}html+='<div class="afaddress" style="width:565px;height:18px;">'+a+'</span></div><div class="afdisplayname">'+p.display_name+"</div>";break;case"B":this.slots-=2;html+='<div class="afimgb" style="background-image:url(shared/img/locations/50x50/'+p.img+')"></div>';a='<div class="afaddressB1">'+p.display_name.replace(/,/i,'</div><div class="afaddressB2">');html+='<div class="afaddress" style="width:505px;height:46px;">'+a+'</div></div><div class="afdisplayname">'+p.display_name+"</div>";break;case"C":this.slots-=3;html+='<div class="afimgc" style="background-image:url(shared/img/locations/85x85/'+p.img+')" />';a='<div class="afaddressC1">'+p.display_name.replace(/,/i,'</div><div class="afaddressC2">');html+='<div class="afaddress">'+a+"</div>";if(p.sub_locations.length>0){html+='<div style="color:#c7c7c7;font-size:11px;font-style:italic;padding-top:25px;">(Popular '+p.sub_locations[0].type.toLowerCase()+"s shown below)</div>"}html+='</div><div class="afdisplayname">'+p.display_name+"</div>";if(p.sub_locations.length>0){$.each(p.sub_locations,function(subloc_i,subloc){self.showSubLocation(subloc,subloc_i,i)})}break}html+='<div class="c0pt3r-clear" />';div_container.append(html);this.setResultEventHandlers(div_container)}};Autofill.prototype.showAirport=function(p){if(this.slots>0){var html="";var div_container=$('<div id="airports-0" class="afresult" />');$("#autofill-"+this.textfieldId).append(div_container);var a='<span style="font-size:15px">'+p.display_name.replace(/,/i,"</span>, ");if(a.indexOf("</span>")>=0){a+="</span>"}html+='<div class="afaddress">'+a+'</span></div><div class="afdisplayname">'+p.display_name+"</div>";html+='<div class="c0pt3r-clear" />';div_container.append(html);this.slots-=1;this.setResultEventHandlers(div_container)}};Autofill.prototype.showHotel=function(p,i){if(this.slots>0&&p.lat&&p.lng){var html="";var div_container=$('<div id="hotels-'+i+'" class="afresult" />');$("#autofill-"+this.textfieldId).append(div_container);if(this.json.locations.length>0&&this.locationImages[this.json.locations[0].tid]){p.image=null}if(!this.includePhotos){p.image=null}if(p.image&&i==0){html+='<div class="afimgb" style="background-image:url('+p.image+')" />';this.slots-=1}var a,d=p.display_name.truncate(45);if(p.image&&i==0){if(p.address!=null){d+=(", "+p.address.truncate(65))}a='<div class="afaddressB1">'+d.replace(/,/i,'</div><div class="afaddressB2">');html+='<div class="afaddress" style="width:390px;height:50px;">'+a+'</div></div><div class="afdisplayname">'+p.display_name+"</div>"}else{if(p.address!=null){var addrSplit=p.address.split(",");var addr=(addrSplit.length>1)?p.address.replace((addrSplit[0]+","),""):p.address;d+=", "+addr}d=d.truncate(65);a='<span style="font-size:15px">'+d.replace(/,/i,"</span>, ");if(a.indexOf("</span>")>=0){a+="</span>"}html+='<div class="afaddress" style="width:450px;height:18px;">'+a+'</span></div><div class="afdisplayname">'+p.display_name+"</div>"}html+=this.starPrice(p.stars,p.rate.lowest);html+='<div class="c0pt3r-clear" />';div_container.append(html);this.slots-=1;this.setResultEventHandlers(div_container)}};Autofill.prototype.showSubLocation=function(p,i,iParent){if(this.slots>0){var html="";this.slots-=0.5;var div_container=$('<div id="sublocs-'+i+"-"+iParent+'" class="afresult" />');$("#autofill-"+this.textfieldId).append(div_container);html+='<div class="afaddress"><span style="font-size:11px">'+p.name+'</span></div><div class="afdisplayname">'+p.display_name+"</div>";html+=this.starPrice(p.star,p.rate);html+='<div class="c0pt3r-clear" />';div_container.append(html);this.setResultEventHandlers(div_container)}};Autofill.prototype.setResultEventHandlers=function(result){var self=this;result.mouseover(function(e){self.unhiliteResult($("div.afresultsel:first"));self.hiliteResult(result)});result.click(function(e){self.selectLocation();self.expandControls()})};Autofill.prototype.resetModels=function(){this.filterBucketsModel.reset();this.filterModel.reset();this.locationModel.reset();this.hotelModel.reset();this.ratesModel.reset()};Autofill.prototype.selectLocation=function(){var result=$("div.afresultsel:first");if(result.length>0){this.resetModels();var resultjson,idarr=result.attr("id").split("-"),textTyped=this.textfield.val();if(idarr[0]=="sublocs"){resultjson=this.json.locations[idarr[2]].sub_locations[idarr[1]]}else{resultjson=this.json[idarr[0]][idarr[1]]}this.selectedJson=resultjson;this.textfield.val(resultjson.display_name);this.preselect.html("");this.hideAutoComplete(false);this.display_name=resultjson.display_name;this.locationModel.locationHotel=null;if(resultjson.tid=="geo"){this.locationModel.showMap=true;this.urlHash="#/search/n/"+this.buildHash(resultjson.tid,resultjson.geo);this.trackingModel.record("autofill-google",{text_typed:textTyped,location_name:resultjson.display_name,lat:resultjson.geo.lat,lng:resultjson.geo.lng})}else{if(idarr[0]=="hotels"){this.selectedJson.isHotel=true;this.locationModel.locationHotel=resultjson.tid;this.urlHash="#/search/x/"+this.buildHash("geo",{lat:resultjson.lat,lng:resultjson.lng},resultjson.tid);this.trackingModel.record("autofill-hotel",{text_typed:textTyped,hotel_name:resultjson.display_name,hotel_tid:resultjson.tid})}else{this.urlHash="#/search/n/"+this.buildHash(resultjson.tid);this.trackingModel.record("autofill-location",{text_typed:textTyped,location_tid:resultjson.tid,location_name:resultjson.display_name})}}}};Autofill.prototype.buildHash=function(tid,geo,hotelTID){var qs="";if(tid){qs+="&lt="+encodeURI(tid)}if(geo){qs+="&l1="+encodeURI(geo.lat);qs+="&l2="+encodeURI(geo.lng)}if(hotelTID){qs+="&hl="+encodeURI(hotelTID)}return qs};Autofill.prototype.search=function(){var urlHash=this.urlHash;if(urlHash!=null){var checkIn=encodeURI($.datepicker.formatDate("yy-mm-dd",$("#checkin").datepicker("getDate"))),checkOut=encodeURI($.datepicker.formatDate("yy-mm-dd",$("#checkout").datepicker("getDate"))),rooms=$("#numrooms").val(),guests=$("#numguests").val(),trackingData={};if($("#checkin").val().length==0||$("#checkin").val()!="mm/dd/yyyy"){urlHash+="&d1="+checkIn;urlHash+="&d2="+checkOut;urlHash+="&rm="+rooms;urlHash+="&gs="+guests;trackingData={check_in:checkIn,check_out:checkOut,rooms:rooms,guests:guests}}window.location.hash=urlHash;if(this.selectedJson.tid=="geo"){trackingData.lat=this.selectedJson.geo.lat;trackingData.lng=this.selectedJson.geo.lng}else{if(this.selectedJson.isHotel){trackingData.hotel_tid=this.selectedJson.tid}else{trackingData.location_tid=this.selectedJson.tid}}this.trackingModel.record("autofill-search",trackingData)}};Autofill.prototype.expandControls=function(){var self=this;if($("#dest-help").length>0){this.enableSearch();$("#dest-help").hide();$("#search").animate({height:"206px"},250);$("#sub-controls").fadeIn(250);$("#checkin").datepicker({dateFormat:"mm/dd/yy",numberOfMonths:2,minDate:0,showAnim:"fadeIn",onSelect:function(dateText,inst){var dt=$("#checkin").datepicker("getDate");dt.setDate(dt.getDate()+1);$("#checkout").datepicker("setDate",dt);$("#checkout").datepicker("option","minDate",dt)}});$("#checkout").datepicker({dateFormat:"mm/dd/yy",numberOfMonths:2,minDate:0,showAnim:"fadeIn",onSelect:function(dateText,inst){if($("#checkin").val().length==0||$("#checkin").val()=="mm/dd/yyyy"){var dt=$("#checkout").datepicker("getDate");dt.setDate(dt.getDate()-1);$("#checkin").datepicker("setDate",dt)}}});$("#checkincal").click(function(){if($("#checkin").datepicker("widget").css("display")=="none"||$("#checkin").datepicker("widget").html().length==0){$("#checkin").datepicker("show")}else{$("#checkin").datepicker("hide")}});$("#checkoutcal").click(function(){if($("#checkout").datepicker("widget").css("display")=="none"||$("#checkout").datepicker("widget").html().length==0){$("#checkout").datepicker("show")}else{$("#checkout").datepicker("hide")}});$("#numrooms").change(function(){self.populateGuests()})}};Autofill.prototype.populateGuests=function(){var numRooms=$("#numrooms").val(),numGuests=numRooms*4,html="";for(var i=numRooms;i<=numGuests;i++){html+='<option value="'+i+'">'+i+"</option>"}$("#numguests").html(html)};Autofill.prototype.enableSearch=function(){$("#btn-disabled").hide();$("#btn-wrapper").show()};Autofill.prototype.disableSearch=function(){this.urlHash=null;$("#btn-wrapper").hide();$("#btn-disabled").show()};Autofill.prototype.hideControls=function(){$("#dest-help").show();$("#sub-controls").hide();$("#search").animate({height:"176px"},250)};Autofill.prototype.locationIdentified=function(input,locationli){expandControls();signupAfterAutocomplete(input,locationli)};return(new Autofill())})(jQuery,window.application));window.application.addView((function($,application){function SearchResults(){this.locationTemplate=null;this.filterTemplate=null;this.hotelsPerRow=null;this.displayNum=0}SearchResults.prototype.init=function(){var self=this;this.locationModel=application.getModel("Location");this.partnersModel=application.getModel("Partners");this.filterBucketsModel=application.getModel("FilterBuckets");this.filterModel=application.getModel("Filters");this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.ratesModel=application.getModel("Rates");this.trackingModel=application.getModel("Tracking");this.filterView=application.getView("Filters");this.filterHandlerView=application.getView("FilterHandlers");this.lightboxView=application.getView("Lightbox");this.hotelView=application.getView("Hotel");this.rateBubbleView=application.getView("RateBubble");this.mapView=application.getView("Map");$(window).resize(function(){self.resize()});$("body").click(function(){self.hideMoreCardOptions()});self.applicationEvents();$("#c0pt3r-footer").hide()};SearchResults.prototype.show=function(){$("html, body").removeClass("c0pt3r-home").addClass("c0pt3r-results");$("#c0pt3r-results").show();$("#c0pt3r-footer").hide();$("#c0pt3r-homepage").hide()};SearchResults.prototype.resize=function(){var w=(this.prefsModel.sidebar)?($("#c0pt3r-filterresults").width()-this.prefsModel.sidebarWidth):($("#c0pt3r-filterresults").width());$("#c0pt3r-hotelcards").width(w);this.calcHotelsPerRow()};SearchResults.prototype.scrollTop=function(){$("html,body").animate({scrollTop:0},500)};SearchResults.prototype.displayLocation=function(qs){var self=this;this.locationModel.getLocation(function(){if(self.locationModel.locationHotel){self.ratesModel.includeUnavailable=true}if(self.locationModel.data.sponsored_listings.length>0){self.prefsModel.sidebar=true}self.partnersModel.getPartners();$("#c0pt3r-results").empty();self.filterBucketsModel.initFilterBuckets();if(qs){self.filterModel.setFromQueryString(qs)}self.filterView.displayFilters();self.hidePropertyCount();self.showLoadingCards();self.getResults(true);self.filterView.bucketsDropdown();if(self.locationModel.data.sponsored_listings.length>0){self.hotelModel.getSponsoredListings();self.showSponsoredListings()}})};SearchResults.prototype.getResults=function(isNew){var self=this;$("#c0pt3r-footer").hide().show();if(isNew){this.calcHotelsPerRow();this.displayNum=(this.hotelsPerRow*this.prefsModel.initialRows[this.filterModel.cardType]);if(this.prefsModel.hotelSetSize<this.displayNum){this.prefsModel.hotelSetSize=this.displayNum}}if(self.ratesModel.isDatedSearch()&&!self.ratesModel.includeUnavailable){self.hotelModel.getHotels(function(hotels){if(isNew){self.hotelView.openOrClose();self.lightboxView.openOrClose()}self.ratesModel.initPollingHotels(self.hotelModel.hotels);if(self.locationModel.showMap){self.locationModel.showMap=false;self.mapView.createMap(self.hotelModel.filteredHotels)}})}else{this.hotelModel.getHotels(function(hotels){if(isNew){self.hotelView.openOrClose();self.lightboxView.openOrClose()}self.createCards();if(self.ratesModel.isDatedSearch()){self.ratesModel.initPollingHotels(self.hotelModel.hotels)}else{self.pagingPreload();$("."+self.filterModel.cardType+"loadingcard").remove();self.showPropertyCount();if($("."+self.filterModel.cardType+"card").length==0){self.noResults()}}if(self.locationModel.showMap){self.locationModel.showMap=false;self.mapView.createMap(self.hotelModel.filteredHotels)}})}};SearchResults.prototype.showSponsoredListings=function(){var self=this;$.each(self.locationModel.data.sponsored_listings,function(i,hotel){var hotelObj=$.extend({},hotel);hotelObj.stars=self.stars(hotelObj.stars,true,"small");hotelObj.name=hotelObj.name.truncate(self.prefsModel.hotelNameMaxGalleryLength);var card=$(application.getFromTemplate($("#sponsored-card-template"),hotelObj));$("#c0pt3r-resultssidebar").append(card);if(!hotelObj.rate.lowest||hotelObj.rate.lowest<=0){var buttonLabel=(self.hotelModel.isCallToBook(hotelObj.tid))?"Call to Book":"Booking Unavailable";card.find(".ratebtn").addClass("ratebtn-norate c0pt3r-secondarylink");card.find(".ratebtn .label").html(buttonLabel).removeClass("c0pt3r-primarylink");card.find(".ratebtn .rate").empty();card.find(".check-avail-btn").remove()}if(self.ratesModel.isDatedSearch()){card.find(".check-avail-btn").remove();if(!self.ratesModel.rates[card.data("tid")]&&($.inArray(card.data("tid"),self.ratesModel.unavailableHotels)<0)){card.find(".ratebtnsearch").show();card.find(".ratebtn").hide()}else{self.showBestRate(card)}}card.data("tid",hotelObj.tid).data("img",self.hotelModel.buildImageUrl(hotelObj.image,168,126)).data("alt",hotelObj.name.escapeHTML()).data("image_count",hotelObj.image_count).data("lowest_rate",hotelObj.rate.lowest).data("url",hotelObj.url).data("img_w",168).data("img_h",126);self.cardImage(card)})};SearchResults.prototype.hidePropertyCount=function(){var numbersWait=$('<div id="numberswait">Searching for matching properties...</div>');$("#numbers").after(numbersWait);$("#numbers").hide()};SearchResults.prototype.showPropertyCount=function(){this.filterView.setCount();$("#numberswait").remove();$("#numbers").show()};SearchResults.prototype.showLoadingRatesMsg=function(){$("#numberswait").remove();var numbersWait=$('<div id="numberswait">Retrieving live rates and availability...</div>');$("#numbers").after(numbersWait);$("#numbers").hide()};SearchResults.prototype.showLoadingCards=function(){var hotelCardHtml=application.getFromTemplate($("#"+this.filterModel.cardType+"-loading-template"));$("#c0pt3r-hotelcards").empty().append(hotelCardHtml.times(this.hotelsPerRow*this.prefsModel.initialRows[this.filterModel.cardType]));if(this.filterModel.cardType!="gallery"){$("."+this.filterModel.cardType+"loadingcard .content").width(($("#c0pt3r-filterresults").width()-this.prefsModel.sidebarWidth)-16)}$("."+this.filterModel.cardType+"loadingcard .content").height(this.prefsModel.getCardHeight());$("."+this.filterModel.cardType+"loadingcard img.cardspinner").css("top",((this.prefsModel.getCardHeight()-32)/2)+"px");this.prefsModel.getCardHeight()};SearchResults.prototype.createCards=function(){var self=this;$("#numbers").css("visibility","visible");$.each(self.hotelModel.filteredHotels,function(filteredHotelIndex,hotel){if(filteredHotelIndex>self.displayNum){return false}self.createCard(filteredHotelIndex,hotel)});self.cardEvents();self.filterView.setCount();if(!self.ratesModel.isPolling){self.mapView.createMarkers(self.hotelModel.filteredHotels)}$("#c0pt3r-footer").hide().show()};SearchResults.prototype.createCard=function(filteredHotelIndex,hotel){var self=this;var card;if($("#hotelcard_"+hotel.tid).length==0){var numHotelCards=$("div[id^='hotelcard_']").length;var hotelObj=$.extend({},hotel);var starsRightAligned=(self.filterModel.cardType=="gallery");hotelObj.stars=self.stars(hotelObj.stars,starsRightAligned,"small");hotelObj.focus=self.focusHTML(hotelObj);if(self.filterModel.cardType=="gallery"){hotelObj.name=hotelObj.name.truncate(self.prefsModel.hotelNameMaxGalleryLength)}card=$(application.getFromTemplate($("#"+self.filterModel.cardType+"-card-template"),hotelObj));if(filteredHotelIndex==0){$("#c0pt3r-hotelcards").prepend(card)}else{$("#hotelcard_"+self.hotelModel.filteredHotels[filteredHotelIndex-1].tid).after(card)}if(hotelObj.premium_placement){card.addClass("premium");card.append('<div class="sponsored">'+self.prefsModel.premiumPlacementLabel+"</div>")}if(hotelObj.name.length<=22&&self.prefsModel.increaseShortHotelNameFontSize){card.find("div.name").addClass("bigname")}if(!hotelObj.rate.lowest||hotelObj.rate.lowest<=0){var buttonLabel=(self.hotelModel.isCallToBook(hotelObj.tid))?"Call to Book":"Booking Unavailable";card.find(".ratebtn").addClass("ratebtn-norate c0pt3r-secondarylink");card.find(".ratebtn .label").html(buttonLabel).removeClass("c0pt3r-primarylink");card.find(".ratebtn .rate").empty();card.find(".check-avail-btn").remove()}if(!hotelObj.description||hotelObj.description.length==0){card.find(".desc .fulldetails").remove()}if(self.filterModel.cardType!="gallery"){var contentWidth=($("#c0pt3r-filterresults").width()-this.prefsModel.sidebarWidth)-this.prefsModel.summaryShadowWidth,contentWrapperWidth=contentWidth-this.prefsModel.summaryImageDivWidth-this.prefsModel.summaryContentWrapperPadding,contentLeftWidth=contentWrapperWidth-this.prefsModel.summaryPriceDivWidth;$("#c0pt3r-hotelcards").width($("#c0pt3r-filterresults").width()-this.prefsModel.sidebarWidth);card.find("div.content").width(contentWidth);card.find("div.contentwrapper").width(contentWrapperWidth);card.find("div.contentwrapper .content-left").width(contentLeftWidth)}card.find("div.content").height(self.prefsModel.getCardHeight());if(self.filterModel.cardType=="gallery"&&self.prefsModel.galleryTray){card.find(".bottom").append(application.getFromTemplate($("#gallery-tray-template"),hotelObj))}if(self.ratesModel.isDatedSearch()){card.find(".check-avail-btn").remove();if(!self.ratesModel.rates[card.data("tid")]&&($.inArray(card.data("tid"),self.ratesModel.unavailableHotels)<0)){card.find(".ratebtnsearch").show();card.find(".ratebtn").hide()}else{self.showBestRate(card)}}card.data("tid",hotelObj.tid).data("img",self.hotelModel.buildImageUrl(hotelObj.image,200,150)).data("alt",hotelObj.name.escapeHTML()).data("image_count",hotelObj.image_count).data("lowest_rate",hotelObj.rate.lowest).data("url",hotelObj.url).data("img_w",200).data("img_h",150);if(numHotelCards>=self.displayNum){$("."+self.filterModel.cardType+"card:last").remove();self.paginationCard()}$("."+self.filterModel.cardType+"loadingcard:last").remove();card.show();self.cardImage(card)}else{card=$("#hotelcard_"+hotel.tid);if(filteredHotelIndex==0){$("#c0pt3r-hotelcards").prepend(card)}else{$("#hotelcard_"+self.hotelModel.filteredHotels[filteredHotelIndex-1].tid).after(card)}}};SearchResults.prototype.noResults=function(){$("#numbers").show().css("visibility","hidden");$("#numberswait").remove();$("#c0pt3r-hotelcards").empty();$("#c0pt3r-hotelcards").append('<div class="no-results"><p class="bold">Uh-oh!  No properties match what you\'re looking for.</p><p>Try using the filters to broaden your search a little.</p></div>')};SearchResults.prototype.applicationEvents=function(){var self=this;$("body").unbind("c0pt3rRatesPolled");$("body").unbind("c0pt3rRatesPollingComplete");$("body").bind("c0pt3rRatesPolled",function(){self.hotelModel.filterHotels();if(self.hotelModel.filteredHotels.length>=self.hotelsPerRow*2){self.createCards()}$("."+self.filterModel.cardType+"card, .sponsoredcard").each(function(i,card){var hotelTID=$(card).data("tid");$(card).find(".ratebtnsearch").show();$(card).find(".ratebtn").hide();if(self.ratesModel.rates[hotelTID]){var rateData=self.ratesModel.lowestHotelRate(hotelTID);if(self.ratesModel.rates[hotelTID].pollingCompleted){self.showBestRate(card)}else{var rateHTML="Best So Far: $"+rateData.rate;if(!rateData.inclTaxesFees){rateHTML+="*"}$(card).find(".ratebtnsearch .label").html(rateHTML)}}});self.hotelView.updateLiveRates(false);if(self.mapView.displayed){self.mapView.createMap()}});$("body").bind("c0pt3rRatesPollingComplete",function(){self.hotelModel.filterHotels();self.createCards();self.pagingPreload();$("."+self.filterModel.cardType+"loadingcard").remove();var cards=$("."+self.filterModel.cardType+"card, .sponsoredcard");if(cards.length==0){$("#c0pt3r-hotelcards").empty();self.noResults()}cards.each(function(i,card){self.showBestRate(card);self.showPropertyCount()});self.hotelView.updateLiveRates(true);if(self.mapView.displayed){self.mapView.removeMap();self.mapView.createMap(self.hotelModel.filteredHotels)}})};SearchResults.prototype.cardEvents=function(){var self=this,currentTraySlideOut,currentImageBorderFade,currentArrowFade,card;$("#c0pt3r-hotelcards, #c0pt3r-resultssidebar").unbind();$("#c0pt3r-hotelcards, #c0pt3r-resultssidebar").mouseover(function(e){e.stopPropagation();var target=$(e.target),imgdiv;if(target.is("div.img .carousel img")){card=target.parents("div.gallerycard, div.summarycard, div.sponsoredcard");$(".gallerycard .img, .summarycard .img, .sponsoredcard .img").css("background-color","#fff");if(card.data("image_count")>1){imgdiv=$(e.target).parents("div.img");window.clearTimeout(currentImageBorderFade);window.clearTimeout(currentArrowFade);currentImageBorderFade=window.setTimeout(function(){self.hiliteGalleryImage(imgdiv);imgdiv=null},250)}}if(target.is(".gallerycard .imgprevwrapper, .gallerycard .imgnextwrapper, .sponsoredcard .imgprevwrapper, .sponsoredcard .imgnextwrapper")){card=target.parents("div.gallerycard, div.summarycard, div.sponsoredcard");var arrow=target.children(".imgprev, .imgnext");imgdiv=$(e.target).siblings("div.img");if(!arrow.is(":visible")){window.clearTimeout(currentImageBorderFade);window.clearTimeout(currentArrowFade);currentArrowFade=window.setTimeout(function(){self.hiliteGalleryImage(imgdiv);var carouselDiv=card.find("div.img .carousel");if(target.is(".gallerycard .imgnextwrapper, .sponsoredcard .imgnextwrapper")||(target.is(".gallerycard .imgprevwrapper, .sponsoredcard .imgprevwrapper")&&carouselDiv.position().left<0)){if($.browser.msie){arrow.show()}else{arrow.fadeIn(250)}}arrow=null;imgdiv=null},250)}}if(target.is(".ratebtn, .ratebtn *")){if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}target.find(".c0pt3r-primarylink").removeClass("c0pt3r-primarylink").addClass("c0pt3r-primarylinkhover")}if(target.is(".ratebtn-norate, .ratebtn-norate *")&&self.filterModel.cardType=="gallery"){if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}}if($(e.target).is(".tray .shortlist")){$(e.target).siblings(".label").html("Add to Shortlist").fadeIn("fast")}if($(e.target).is(".tray .remove")){$(e.target).siblings(".label").html("Remove from results").fadeIn("fast")}if($(e.target).is(".tray .dropdown")){$(e.target).siblings(".label").html("View more options!").fadeIn("fast")}});$("#c0pt3r-hotelcards, #c0pt3r-resultssidebar").mouseout(function(e){e.stopPropagation();var card,target=$(e.target);var imgCssSelector=".gallerycard .carousel img, .summarycard .carousel img, .sponsoredcard .carousel img, .gallerycard .imgprev, .gallerycard .imgnext, .gallerycard .imgprevwrapper, .gallerycard .imgnextwrapper, .sponsoredcard .imgprev, .sponsoredcard .imgnext, .sponsoredcard .imgprevwrapper, .sponsoredcard .imgnextwrapper";if($(e.target).is(imgCssSelector)){var remove=true;if(($(e.target).parents("div.gallerycard, div.summarycard, div.sponsoredcard").attr("id")==$(e.relatedTarget).parents("div.gallerycard, div.summarycard, div.sponsoredcard").attr("id"))){remove=false;if(!$(e.relatedTarget).is(imgCssSelector)){remove=true}}if(remove){var imgdiv=$(e.target).parents("div.gallerycard, div.summarycard, div.sponsoredcard").find("div.img:first");imgdiv.stop();window.clearTimeout(currentImageBorderFade);window.clearTimeout(currentArrowFade);if(self.prefsModel.animateImageBorder){imgdiv.animate({"background-color":self.prefsModel.imageBorderColour},400)}else{imgdiv.removeClass("imghover")}}}if(target.is(".gallerycard .imgprev, .gallerycard .imgnext, .sponsoredcard .imgprev, .sponsoredcard .imgnext")){if(target.is(":visible")){window.clearTimeout(currentArrowFade);target.hide()}}if($(e.target).is(".ratebtn, .ratebtn *")){if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}target.find(".c0pt3r-primarylinkhover").removeClass("c0pt3r-primarylinkhover").addClass("c0pt3r-primarylink");target.find("span.default").show();target.find("span.hover").hide()}if(target.is(".ratebtn-norate, .ratebtn-norate *")){if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}}if($(e.target).is(".tray a")){$(e.target).siblings(".label").html("").hide()}});$("#c0pt3r-hotelcards, #c0pt3r-resultssidebar").click(function(e){var target=$(e.target),card=target.parents("div.gallerycard, div.summarycard, div.sponsoredcard"),trackingData={hotel_tid:card.data("tid")};$.each(["gallery","summary","sponsored"],function(i,v){if(card.is("."+v+"card")){trackingData.card_type=v}});trackingData.card_position=$("."+trackingData.card_type+"card").index(card)+1;if($(e.target).is(".carousel img")){e.preventDefault();e.stopPropagation();self.trackingModel.record("sr-img",$.extend(trackingData,{image_filename:(function(){var a=target.attr("src").split("/");return a[a.length-1]}()),image_position:(parseInt(target.attr("id").replace((card.data("tid")+"_img_"),""))+1)}));self.hotelView.show(card.data("tid"))}if($(e.target).is("div.imgnext")){e.preventDefault();e.stopPropagation();self.trackingModel.record("sr-img-next",trackingData);self.loadGalleryImages(card)}if($(e.target).is("div.imgprev")){e.preventDefault();e.stopPropagation();var carouselDiv=card.find("div.img .carousel");carouselDiv.stop(true,true);if(carouselDiv.position().left<0){self.trackingModel.record("sr-img-prev",trackingData);carouselDiv.animate({left:(carouselDiv.position().left+card.find("div.img .wrapper").width())+"px"},600)}}if($(e.target).is("a.fulldetails")){e.preventDefault();e.stopPropagation();var trackingCode=($(e.target).parent().is(".name"))?"sr-name":"sr-full";self.trackingModel.record(trackingCode,trackingData);self.hotelView.show(card.data("tid"))}self.filterHandlerView.editSearch();if($(e.target).is(".ratebtn, .ratebtn *")){e.preventDefault();e.stopPropagation();if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}self.rateBubbleView.bestHotelRate(target,card.data("tid"),trackingData)}$.clearSelection()});$("#c0pt3r-hotelcards, #c0pt3r-resultssidebar").dblclick(function(e){e.preventDefault();e.stopPropagation();$.clearSelection()})};SearchResults.prototype.hiliteGalleryImage=function(imgdiv){imgdiv.stop();if(this.prefsModel.animateImageBorder){imgdiv.animate({"background-color":this.prefsModel.imageBorderHoverColour},250)}else{imgdiv.addClass("imghover")}};SearchResults.prototype.loadGalleryImages=function(galleryCard){var self=this;var carouselDiv=galleryCard.find("div.img .carousel");var failimg="shared/img/noimage/200x150.jpg";var imgWidth=galleryCard.find("div.img .wrapper").width();carouselDiv.stop(true,true);if(carouselDiv.children("div.placeholder").length>1){if((0-carouselDiv.position().left)<(carouselDiv.width()-imgWidth)){carouselDiv.animate({left:(carouselDiv.position().left-imgWidth)+"px"},600)}else{carouselDiv.animate({left:"0px"},600)}}else{self.hotelModel.getHotelDetails(galleryCard.data("tid"),function(hotelDetails){$.each(hotelDetails.images,function(i,img){if(i>0){carouselDiv.width(carouselDiv.width()+imgWidth);self.showCardImage(failimg,carouselDiv,galleryCard.data("tid")+"_img_"+i,self.hotelModel.buildImageUrl(img,200,150),img.caption,function(){if(i==1){carouselDiv.animate({left:(carouselDiv.position().left-imgWidth)+"px"},600)}})}})})}};SearchResults.prototype.showCardTray=function(tray){tray.stop();tray.animate({top:"-9px"},250)};SearchResults.prototype.hideMoreCardOptions=function(){$("div.card-dropdown:visible").parent().find("div.tray").animate({top:"-36px"},350);$("div.card-dropdown:visible").hide()};SearchResults.prototype.showBestRate=function(card){if(this.ratesModel.isDatedSearch()){var hotelTID=$(card).data("tid");$(card).find(".ratebtnsearch").hide();$(card).find(".ratebtn").show();if(this.hotelModel.displayablePartners(hotelTID).length>0){var rateAmount;if(this.ratesModel.rates[hotelTID]){var rateData=this.ratesModel.lowestHotelRate(hotelTID);rateAmount=rateData.rate;if(!rateData.inclTaxesFees){rateAmount+="*"}if(this.hotelModel.hotels[hotelTID].premium_placement&&((parseFloat(rateData.rate)<this.filterModel.data.price_min)||(parseFloat(rateData.rate)>this.filterModel.data.price_max))){rateAmount=$(card).data("lowest_rate")}}else{rateAmount=$(card).data("lowest_rate")+"*"}$(card).find(".ratebtn").removeClass("ratebtn-dateless ratebtn-norate").addClass("ratebtn-liverate");$(card).find(".ratebtn .label").html("View Rates");$(card).find(".ratebtn .rate").html("$"+rateAmount).addClass("c0pt3r-primarylink")}else{$(card).find(".ratebtn").removeClass("ratebtn-dateless").addClass("ratebtn-norate c0pt3r-secondarylink");var buttonLabel=(this.hotelModel.isCallToBook(hotelTID))?"Call to Book":"Booking Unavailable";$(card).find(".ratebtn .label").html(buttonLabel).removeClass("c0pt3r-primarylink").addClass("c0pt3r-secondarylink");$(card).find(".ratebtn .rate .ratelabel, .ratebtn .rate .rateamount").empty()}}};SearchResults.prototype.cardImage=function(card){if(card.find("div.img .carousel img").length==0){var imgdiv=card.find("div.img .carousel");var failimg="shared/img/noimage/200x150.jpg";var imgsrc;if(card.data("img")==null||card.data("img").length==0){imgsrc=failimg}else{imgsrc=card.data("img")}this.showCardImage(failimg,imgdiv,(card.data("tid")+"_img_0"),imgsrc,card.data("alt"))}};SearchResults.prototype.showCardImage=function(failimg,imgdiv,id,src,alt,onSuccess){var self=this;var placeholderDiv=$('<div class="placeholder" />');imgdiv.find(".c0pt3r-clear").before(placeholderDiv);var img=$("<img />");img.load(function(){placeholderDiv.append(img);$(this).show();if(onSuccess){onSuccess()}}).error(function(){$(this).attr("src",failimg).show()}).attr({src:src,alt:alt,id:id})};SearchResults.prototype.calcHotelsPerRow=function(){var rowWidth=(this.prefsModel.sidebar)?($("#c0pt3r-filterresults").width()-this.prefsModel.sidebarWidth):($("#c0pt3r-filterresults").width());var cardWidth=this.prefsModel.cardWidth(this.filterModel.cardType,rowWidth);if(cardWidth>0){this.hotelsPerRow=Math.floor(rowWidth/cardWidth)}$("#c0pt3r-hotelcards").width(rowWidth)};SearchResults.prototype.paginationCard=function(){var self=this;var numCards=this.hotelModel.filteredHotels.length;var existedAlready=true;if(this.displayNum<numCards){if($("#morehotelscard").length==0){$("."+self.filterModel.cardType+"card:last").remove();this.displayNum--;this.filterView.setCount();existedAlready=false}$("#morehotelscard").remove();$("#c0pt3r-hotelcards").append(application.getFromTemplate($("#"+this.filterModel.cardType+"-more-hotels-template")));$("#morehotelscard .content, #morehotelscard .preview").height(self.prefsModel.getCardHeight());this.paginationHandler();this.paginationPreview();if(this.hotelModel.useCachedHotels()){$("#morehotelscard .number").html(this.hotelModel.filteredHotels.length-this.displayNum);$("#morehotelscard .label").html("more hotels...")}else{if(!this.ratesModel.isDatedSearch()){$("#morehotelscard .number").html(this.hotelModel.total_matches-this.displayNum);$("#morehotelscard .label").html("more hotels...")}else{$("#morehotelscard .number").html("");$("#morehotelscard .label").html("More hotels...")}}if(existedAlready){$("#morehotelscard").show()}else{$("#morehotelscard").fadeIn(250)}}};SearchResults.prototype.paginationPreview=function(){var self=application.getView("SearchResults"),i;var html="";for(i=self.displayNum;i<self.displayNum+4;i++){var hotel=self.hotelModel.filteredHotels[i];if(hotel){var imgsrc=self.hotelModel.buildImageUrl(hotel.image,100,75);html+='<div class="previewimg"><img src="'+imgsrc+'" alt="'+hotel.name.escapeHTML()+'" title="'+hotel.name.escapeHTML()+'" /></div>'}}$("#morehotelscard .preview").append('<div class="previewimages">'+html+'<div class="c0pt3r-clear" /></div>')};SearchResults.prototype.paginationHandler=function(){var self=this;$("#morehotels").bind("click",function(e){e.preventDefault();self.trackingModel.record("sr-pagination",{num_cards:$("div[id^='hotelcard_']").length});$("#morehotelscard").remove();self.calcHotelsPerRow();self.displayNum+=self.calcNewHotels();if(self.ratesModel.isDatedSearch()){self.ratesModel.initPollingHotels(self.hotelModel.hotels)}else{self.createCards();$("#morehotelscard .link").show();$("#morehotelscard .spinner").hide();self.pagingPreload()}})};SearchResults.prototype.calcNewHotels=function(){var numCards=this.hotelModel.filteredHotels.length;var numVisibleCards=this.displayNum;var newHotels=this.hotelsPerRow-(numVisibleCards%this.hotelsPerRow);newHotels+=(this.hotelsPerRow*this.prefsModel.rowIncrement[this.filterModel.cardType]);if((numCards<(numVisibleCards+newHotels+this.hotelsPerRow))&&(this.hotelModel.filteredHotels.length>=this.hotelModel.total_matches)){newHotels=(numCards-numVisibleCards)}return newHotels};SearchResults.prototype.pagingPreload=function(){var self=this;var numFilteredHotels=this.hotelModel.filteredHotels.length;if(((this.displayNum+this.calcNewHotels())>numFilteredHotels)&&($.keyCount(this.hotelModel.hotels)<this.hotelModel.total_matches)){$("#morehotelscard .link").hide();$("#morehotelscard .spinner").show();self.getResults(false)}else{$("#morehotelscard .link").show();$("#morehotelscard .spinner").hide()}};SearchResults.prototype.stars=function(star,alignRight,starClass){star=Math.round(star);if(star>5){star=5}if(star<1){star=1}starClass="star"+starClass;var starLeftHTML=('<div class="left '+starClass+'" />').times(star)+'<div class="c0pt3r-clear" />';var starRightHTML=('<div class="right '+starClass+'" />').times(star)+'<div class="c0pt3r-clear" />';return(alignRight)?starRightHTML:starLeftHTML};SearchResults.prototype.focusHTML=function(hotel){var html="";switch(this.filterModel.focusSetting){case"amenities":html='<div class="focuscontent">Amenities Focus</div>';break;case"booking":html='<div class="focuscontent">Booking Focus</div>';break;case"location":html='<div class="focuscontent">Location Focus</div>';break}return html};return(new SearchResults())})(jQuery,window.application));window.application.addView((function($,application){function Filters(){this.filterTemplate=null;this.controlsHidden=false;this.controlsPinned=false}Filters.prototype.init=function(){this.locationModel=application.getModel("Location");this.filterBucketsModel=application.getModel("FilterBuckets");this.filterModel=application.getModel("Filters");this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.ratesModel=application.getModel("Rates");this.trackingModel=application.getModel("Tracking");this.searchResultsView=application.getView("SearchResults");this.filterHandlerView=application.getView("FilterHandlers");this.bubbleView=application.getView("Bubble");this.hotelView=application.getView("Hotel")};Filters.prototype.leadingZero=function(num){if(num.toString().length==1){num="0"+num.toString()}return num};Filters.prototype.displayFilters=function(){var locationObj=$.extend({},this.locationModel);locationObj.display_name=locationObj.display_name.truncate(60);$("#c0pt3r-results").append(application.getFromTemplate($("#sr-header-template"),locationObj));var h1Text=(this.locationModel.tid=="geo")?"Hotels nearest ":"Hotels in ";$("#c0pt3r-locationdata h1").prepend(h1Text);if(!this.prefsModel.locationAverages){$("#c0pt3r-locationdata .averages").remove()}if(!this.prefsModel.sidebar){$("#c0pt3r-resultssidebar").remove()}if(this.prefsModel.dropdowns.bucket.display){$("#dropdowns").append(application.getFromTemplate($("#bucket-control-template"),this.locationModel))}if(this.prefsModel.dropdowns.view.display){$("#dropdowns").append(application.getFromTemplate($("#view-control-template"),this.locationModel))}if(this.prefsModel.dropdowns.focusSetting.display){$("#dropdowns").append(application.getFromTemplate($("#focus-control-template"),this.locationModel))}if(this.prefsModel.dropdowns.sort.display){$("#dropdowns").append(application.getFromTemplate($("#sort-control-template"),this.locationModel))}$("#dropdowns").append('<div class="c0pt3r-clear" />');this.createDatePickers();this.searchResultsView.resize();this.setFilters();this.filterHandlerView.create()};Filters.prototype.createDatePickers=function(){var self=this;$("body").append('<div class="datepop1"><div class="datepicker"></div></div><div class="datepop2"><div class="datepicker"></div></div>');$(".datepop1").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:2,minDate:0,onSelect:function(dateText,inst){var checkOutDate=$(".datepop1").datepicker("getDate");checkOutDate.setDate(checkOutDate.getDate()+1);var checkOutDateText=checkOutDate.getFullYear()+"-"+self.leadingZero(checkOutDate.getMonth()+1)+"-"+self.leadingZero(checkOutDate.getDate());self.ratesModel.includeUnavailable=true;if($("#editsearch").length==0){self.ratesModel.clear();self.ratesModel.checkInDate=dateText;self.ratesModel.checkOutDate=checkOutDateText}$(".datepop2").datepicker("setDate",checkOutDate);$(".datepop2").datepicker("option","minDate",checkOutDate);self.setDateFilter(dateText,checkOutDateText);$(".datepop1").fadeOut("fast");if($("#editsearch").length==0){$("#c0pt3r-locationdata .dateless").remove();$("#c0pt3r-locationdata .dated").show();self.applyFilterChange()}}});$(".datepop2").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:2,minDate:0,onSelect:function(dateText,inst){if($("#editsearch").length==0){self.ratesModel.clear();self.ratesModel.checkOutDate=dateText}self.setDateFilter("",dateText);$(".datepop2").fadeOut("fast");if($("#editsearch").length==0){self.applyFilterChange()}}})};Filters.prototype.displayMenuPopup=function(control,popup){control.addClass("on");popup.css("left",control.offset().left+"px");popup.css("top",(control.offset().top+(control.outerHeight()-1))+"px");popup.fadeIn("fast")};Filters.prototype.closeAllFilterPopups=function(){$(".customselect").hide();this.closeDateFilterPopups();this.setFilters()};Filters.prototype.closeDateFilterPopups=function(){$(".datepop1").hide();$(".datepop2").hide();this.bubbleView.removeAll();$("#c0pt3r-locationdata .control").removeClass("on")};Filters.prototype.idInArray=function(id,arr){if(arr){$.each(arr,function(i,v){if(v.id==id){return v}})}};Filters.prototype.objectVal=function(value,obj){if(obj){return obj[value]}};Filters.prototype.applyFilterChangeInit=function(){this.hotelModel.reset();this.searchResultsView.showLoadingCards();this.setFilters()};Filters.prototype.applyFilterChange=function(reDrawOnly){if(reDrawOnly){$("#c0pt3r-hotelcards").empty();this.setFilters();application.setURL("#/search/r/"+this.filterModel.getAsQueryString())}else{application.setURL("#/search/n/"+this.filterModel.getAsQueryString())}};Filters.prototype.setCount=function(){var numCards=$("div[id^='hotelcard_']").length;$("#displaynum").html(numCards);if(this.hotelModel.useCachedHotels()){var matchNum=(numCards>this.hotelModel.filteredHotels.length)?numCards:this.hotelModel.filteredHotels.length;$("#matchnum").html(" of "+matchNum)}else{if(!this.ratesModel.isDatedSearch()){$("#matchnum").html(" of "+this.hotelModel.total_matches)}else{$("#matchnum").html("");if($("#morehotelscard").length>0){$("#displaynum").html("initial "+numCards)}else{$("#displaynum").html(numCards+" of "+numCards)}}}};Filters.prototype.bucketsDropdown=function(){var self=this;this.filterBucketsModel.getFilterBuckets(function(filterBuckets){$.each(filterBuckets.buckets,self.addBucketOption);self.setBucket(self.filterBucketsModel.selectedBucket);$("#c0pt3r-controlswrapper").fadeIn("fast")})};Filters.prototype.addBucketOption=function(i,v){if(v.hotel_count>0){application.getModel("Prefs").dropdowns.bucket.options.push({value:i,label:v.name+" ("+v.hotel_count+")"})}};Filters.prototype.getSort=function(value){var sortValues=value.split("-");return{field:sortValues[0],direction:sortValues[1]}};Filters.prototype.filterCounterText=function(n){var counterText;if(this.hotelModel.useCachedHotels()||this.ratesModel.checkInDate.length==0){counterText=(n==1)?n+" property":n+" properties"}else{$.each(this.prefsModel.filterCounterThresholds,function(i,obj){if(n<obj.threshold){counterText=obj.text;return false}})}return counterText};Filters.prototype.setFilters=function(){this.setDateFilter(this.ratesModel.checkInDate,this.ratesModel.checkOutDate);this.setRoomFilter(this.ratesModel.numRooms);this.setGuestFilter(this.ratesModel.numGuests);this.setPriceFilter(this.filterModel.data.price_min,this.filterModel.data.price_max);this.setStarFilter(this.filterModel.data.star_min,this.filterModel.data.star_max);this.setAmFilter(this.filterModel.data.amenities);this.setPropFilter(this.filterModel.data.property_types);this.setBrandFilter(this.filterModel.data.brands);this.setBucket(this.filterBucketsModel.selectedBucket);this.setCardType(this.filterModel.cardType);this.setFocus(this.filterModel.focusSetting);this.setSort(this.filterModel.data.sort_field,this.filterModel.data.sort_direction)};Filters.prototype.showFilter=function(filterName,display,displayOptions,apply,cancel,trackingData){var self=this,popupId=filterName+"filterpopup",controlId=filterName+"control";if($("#"+popupId).length==0){self.trackingModel.record("sr-filter-"+filterName+"-open",trackingData);var html=application.getFromTemplate($("#filter-popup-template"),{popupId:popupId,controlId:controlId});$("body").prepend(html);if(!self.hotelModel.isCachedLocation()&&self.ratesModel.isDatedSearch()){$("#"+popupId+" div.count").empty().css({display:"block",height:"1px"})}var filters=$.extend({},self.filterModel.data);filters.page=0;filters.per_page=self.prefsModel.hotelSetSize;self.hotelModel.getHotels(function(response){$("#"+popupId+" div.count span").html(self.filterCounterText(response.hotel_count))},filters,true);display(popupId,controlId,displayOptions);$("#"+popupId+" a.apply").bind("click",function(event){event.preventDefault();apply(controlId,trackingData);self.applyFilterChange();self.closeAllFilterPopups()});$("#"+popupId+" a.cancel").bind("click",function(event){event.preventDefault();cancel(trackingData);self.closeAllFilterPopups()})}else{this.setFilters()}this.bubbleView.create($("#"+popupId),(filterName+"-filter-bubble"),$("#filter"+filterName),displayOptions.width,displayOptions.height,[{top:Math.round($("#filter"+filterName).offset().top+$("#filter"+filterName).outerHeight()-5),left:Math.round($("#filter"+filterName).offset().left+35),alignment:"bottom",arrowPos:35}])};Filters.prototype.sliderControl=function(popupId,controlId,options){var self=application.getView("Filters");$("#"+controlId).slider({animate:true,range:true,step:1,min:options.min,max:options.max,values:[self.filterModel.data[options.val0],self.filterModel.data[options.val1]],slide:function(event,ui){options.set(ui.values[0],ui.values[1]);self.setSliderLabels(popupId,ui.values[0],ui.values[1],options.min,options.max)},start:function(event,ui){},stop:function(event,ui){self.setSliderLabels(popupId,ui.values[0],ui.values[1],options.min,options.max)},change:function(event,ui){options.set(ui.values[0],ui.values[1]);self.setSliderLabels(popupId,ui.values[0],ui.values[1],options.min,options.max);var filters=$.extend({},self.filterModel.data);filters[options.val0]=ui.values[0];filters[options.val1]=ui.values[1];filters.page=0;filters.per_page=self.prefsModel.hotelSetSize;self.hotelModel.getHotels(function(response){$("#"+popupId+" div.count span").html(self.filterCounterText(response.hotel_count))},filters,true)}});$("#"+popupId).prepend($('<div class="sliderlabel sliderlabelmin"></div><div class="sliderlabel sliderlabelmax"></div>'));self.setSliderLabels(popupId,self.filterModel.data[options.val0],self.filterModel.data[options.val1],options.min,options.max)};Filters.prototype.setSliderLabels=function(popupId,lo,hi,min,max){var self=this;var label1,label2;if(popupId=="pricefilterpopup"){label1="$"+lo;label2="$"+hi;if(lo==self.locationModel.data.minrate.usd){label1="$0"}if(hi==self.locationModel.data.maxrate.usd){label2+="+"}}else{if(popupId=="starfilterpopup"){label1='<div class="left">'+lo+((lo==1)?" star":" stars")+'</div><div class="starsmall"></div><div class="c0pt3r-clear" />';label2='<div class="left">'+hi+((hi==1)?" star":" stars")+'</div><div class="starsmall"></div><div class="c0pt3r-clear" />'}}$("#"+popupId+" .sliderlabelmin").html(label1);$("#"+popupId+" .sliderlabelmax").html(label2);var minPos=12,maxPos=((280+12)+($("#"+popupId+" .ui-slider-handle").width()))-$("#"+popupId+" .sliderlabelmax").width(),pos1=(((lo-min)*(280/(max-min)))+minPos)-($("#"+popupId+" .sliderlabelmin").width()/2)+3,pos2=(((hi-min)*(280/(max-min)))+minPos+$("#"+popupId+" .ui-slider-handle").width()/2)-($("#"+popupId+" .sliderlabelmax").width()/2)-3;if(pos1<minPos){pos1=minPos}if(pos2>maxPos){pos2=maxPos}if((pos1+$("#"+popupId+" .sliderlabelmin").width())>=(pos2-20)){$("#"+popupId+" .sliderlabelmax").css("left","0px");if(popupId=="pricefilterpopup"){$("#"+popupId+" .sliderlabelmax").html(label1+" to "+label2)}else{if(popupId=="starfilterpopup"){label1='<div class="left">'+lo+((lo==1)?" star":" stars")+'</div><div class="starsmall"></div><div class="c0pt3r-clear" />';$("#"+popupId+" .sliderlabelmax").html(label1+'<div class="left">&nbsp;to&nbsp;</div>'+label2);$("#"+popupId+" .sliderlabelmax .c0pt3r-clear").remove();$("#"+popupId+" .sliderlabelmax").append('<div class="c0pt3r-clear"></div>')}}$("#"+popupId+" .sliderlabelmin").html("");maxPos=((280+12)+($("#"+popupId+" .ui-slider-handle").width()/2))-$("#"+popupId+" .sliderlabelmax").width();pos2=(pos2-((pos2-pos1)/2))-($("#"+popupId+" .sliderlabelmax").width()/3.5);if(pos2>maxPos){pos2=maxPos}if(pos2<minPos){pos2=minPos}}$("#"+popupId+" .sliderlabelmin").css("left",Math.round(pos1)+"px");$("#"+popupId+" .sliderlabelmax").css("left",Math.round(pos2)+"px")};Filters.prototype.checkboxControl=function(popupId,controlId,options){var self=application.getView("Filters");var html='<div class="checkboxrow"><div class="left"><input type="checkbox" id="'+controlId+'-any" value="any"';if(self.filterModel.data[options.arr]){if(self.filterModel.data[options.arr].length==0){html+='checked="checked"'}}else{html+='checked="checked"'}html+='/></div><div class="checkboxlabel left">Any</div><div class="c0pt3r-clear" /></div>';$.each(options.checkboxes,function(i,v){html+='<div class="checkboxrow"><div class="left">';if(options.image){html+='<img src="'+v.id.toLowerCase()+'.png" />'}html+='<input type="checkbox" id="'+controlId+"-"+v.id.toLowerCase()+'" value="'+v.id.toUpperCase()+'" class="item" ';if(self.filterModel.data[options.arr]){if($.inArray(v.id,self.filterModel.data[options.arr])>=0){html+='checked="checked"'}}html+='/></div><div class="checkboxlabel left">'+v.name;if(self.hotelModel.useCachedHotels()||self.ratesModel.checkInDate.length==0){html+='<!-- (<span class="checkbox-num">'+v.num_hotels+"</span>)-->"}html+='</div><div class="c0pt3r-clear" /></div>'});$("#"+controlId).append(html);$("#"+controlId+"-any").click(function(){$(this).attr("checked",true);$("#"+controlId+" input.item").attr("checked",false);self.checkboxCount(popupId,controlId,options)});$("#"+controlId+" input.item").click(function(){$("#"+controlId+"-any").attr("checked",false);if($("#"+controlId+" input.item:checked").length==0){$("#"+controlId+"-any").attr("checked",true)}self.checkboxCount(popupId,controlId,options)})};Filters.prototype.checkboxCount=function(popupId,controlId,options){var self=this;var filters=$.extend({},self.filterModel.data);filters.page=0;filters.per_page=self.prefsModel.hotelSetSize;filters[options.arr]=[];$("#"+controlId+" input.item:checked").each(function(i,el){filters[options.arr].push($(el).val())});self.hotelModel.getHotels(function(response){$("#"+popupId+" div.count span").html(self.filterCounterText(response.hotel_count))},filters,true);options.set(filters[options.arr])};Filters.prototype.applyPrice=function(controlId,trackingData){var self=application.getView("SearchResults");self.filterModel.data.price_min=$("#"+controlId).slider("values",0);self.filterModel.data.price_max=$("#"+controlId).slider("values",1);self.trackingModel.record("sr-filter-price",$.extend(trackingData,{new_price_filter_lo:self.filterModel.data.price_min,new_price_filter_hi:self.filterModel.data.price_max}))};Filters.prototype.cancelPrice=function(trackingData){var self=application.getView("Filters");self.setPriceFilter(self.filterModel.data.price_min,self.filterModel.data.price_max);self.trackingModel.record("sr-filter-price-close",trackingData)};Filters.prototype.applyStar=function(controlId,trackingData){var self=application.getView("Filters");self.filterModel.data.star_min=$("#"+controlId).slider("values",0);self.filterModel.data.star_max=$("#"+controlId).slider("values",1);self.trackingModel.record("sr-filter-star",$.extend(trackingData,{new_star_filter_lo:self.filterModel.data.star_min,new_star_filter_hi:self.filterModel.data.star_max}))};Filters.prototype.cancelStar=function(trackingData){var self=application.getView("Filters");self.setStarFilter(self.filterModel.data.star_min,self.filterModel.data.star_max);self.trackingModel.record("sr-filter-star-close",trackingData)};Filters.prototype.applyAms=function(controlId,trackingData){var self=application.getView("Filters");self.filterModel.data.amenities=[];if($("#"+controlId+"-any:checked").length==0){$("#"+controlId+" input.item:checked").each(function(i,el){self.filterModel.data.amenities.push($(el).val())})}self.setAmFilter(self.filterModel.data.amenities);self.trackingModel.record("sr-filter-am",$.extend(trackingData,{new_amenities:(self.filterModel.data.amenities.length==0)?"Any":self.filterModel.data.amenities.join(",")}))};Filters.prototype.cancelAms=function(trackingData){var self=application.getView("Filters");self.setAmFilter(self.filterModel.data.amenities);self.trackingModel.record("sr-filter-am-close",trackingData)};Filters.prototype.applyProp=function(controlId,trackingData){var self=application.getView("Filters");self.filterModel.data.property_types=[];if($("#"+controlId+"-any:checked").length==0){$("#"+controlId+" input.item:checked").each(function(i,el){self.filterModel.data.property_types.push($(el).val())})}self.setPropFilter(self.filterModel.data.property_types);self.trackingModel.record("sr-filter-prop",$.extend(trackingData,{new_property_types:(self.filterModel.data.property_types.length==0)?"Any":self.filterModel.data.property_types.join(",")}))};Filters.prototype.cancelProp=function(trackingData){var self=application.getView("Filters");self.setPropFilter(self.filterModel.data.property_types);self.trackingModel.record("sr-filter-prop-close",trackingData)};Filters.prototype.applyBrand=function(controlId,trackingData){var self=application.getView("Filters");self.filterModel.data.brands=[];if($("#"+controlId+"-any:checked").length==0){$("#"+controlId+" input.item:checked").each(function(i,el){self.filterModel.data.brands.push($(el).val())})}self.setBrandFilter(self.filterModel.data.brands);self.trackingModel.record("sr-filter-brand",$.extend(trackingData,{new_brands:(self.filterModel.data.brands.length==0)?"Any":self.filterModel.data.brands.join(",")}))};Filters.prototype.cancelBrand=function(trackingData){var self=application.getView("Filters");self.setBrandFilter(self.filterModel.data.brands);self.trackingModel.record("sr-filter-brand-close",trackingData)};Filters.prototype.setDateFilter=function(d1,d2){var weekday=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var monthname=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];if(d1.length>0){var d1Arr=d1.split("-");var d1Date=new Date(d1Arr[0],(d1Arr[1]-1),d1Arr[2]);var d1Text=weekday[d1Date.getDay()]+". "+monthname[d1Date.getMonth()]+" "+d1Date.getDate()+", "+d1Date.getFullYear();if($("#editsearch").length==0){$(".dates .checkin").html(d1Text)}else{$("#edit-search-d1").val(d1Text);$("#edit-search-d1").data("date",d1)}}var d2Arr=d2.split("-");var d2Date=new Date(d2Arr[0],(d2Arr[1]-1),d2Arr[2]);var d2Text=weekday[d2Date.getDay()]+". "+monthname[d2Date.getMonth()]+" "+d2Date.getDate()+", "+d2Date.getFullYear();if($("#editsearch").length==0){$(".dates .checkout").html(d2Text)}else{$("#edit-search-d2").val(d2Text);$("#edit-search-d2").data("date",d2)}};Filters.prototype.setGuestFilter=function(num){if($("#editsearch").length==0){var html=num+" Guest";if(num>1){html+="s"}$(".dates .guests").html(html)}else{$("#edit-search-guests").val(num).change()}};Filters.prototype.setRoomFilter=function(num){if($("#editsearch").length==0){var html=num+" Room";if(num>1){html+="s"}$(".dates .rooms").html(html)}else{$("#edit-search-rooms").val(num).change()}};Filters.prototype.setBucket=function(v){$("#bucket .selected").html(this.prefsModel.getDropdownLabel("bucket",v))};Filters.prototype.setCardType=function(v){$("#view .selected").html(this.prefsModel.getDropdownLabel("view",v));var html=(v=="gallery")?"summary":"gallery";$("#viewtoggle").removeClass().addClass(v).children("a").html(html);$("#view-radio-"+v).attr("checked","checked");$("#viewcontrol label").removeClass("selected");$("#label-view-radio-"+v).addClass("selected")};Filters.prototype.setFocus=function(v){if(v.length==0){v="summary"}$("#focusSetting .selected").html(this.prefsModel.getDropdownLabel("focusSetting",v))};Filters.prototype.setSort=function(sortField,sortDirection){var self=this,sortVal=sortField+"-"+sortDirection;$("#sort .selected").html(function(){return(sortVal=="distance-asc")?"Nearest":self.prefsModel.getDropdownLabel("sort",sortVal)}())};Filters.prototype.setPriceFilter=function(lo,hi){var self=application.getView("Filters"),html="$"+Math.round(lo)+" to $"+Math.round(hi),displayXIcon=true;if(self.locationModel.tid.length>0){if(lo==self.locationModel.data.minrate.usd&&hi==self.locationModel.data.maxrate.usd){html="Any";displayXIcon=false}else{if(lo==self.locationModel.data.minrate.usd){html="$0 to $"+Math.round(hi);displayXIcon=true}else{if(hi==self.locationModel.data.maxrate.usd){html="$"+Math.round(lo)+" to $"+Math.round(hi)+"+";displayXIcon=true}}}}$("#pricerange").html(html);self.xIcon(displayXIcon,$("#filterprice"),$("#pricerange"),"sr-filter-price-reset",{current_price_filter_lo:self.filterModel.data.price_min,current_price_filter_hi:self.filterModel.data.price_max},function(){self.filterModel.data.price_min=self.locationModel.data.minrate.usd;self.filterModel.data.price_max=self.locationModel.data.maxrate.usd})};Filters.prototype.setStarFilter=function(lo,hi){var self=application.getView("Filters"),displayXIcon=true;var html=Math.round(lo)+" to "+Math.round(hi);if(self.locationModel.tid.length>0){if(lo==1&&hi==5){html="Any";displayXIcon=false}else{if(lo==hi){html=(lo==1)?"1 star":(lo+" stars")}}}$("#starrange").html(html);self.xIcon(displayXIcon,$("#filterstar"),$("#starrange"),"sr-filter-star-reset",{current_star_filter_lo:self.filterModel.data.star_min,current_star_filter_hi:self.filterModel.data.star_max},function(){self.filterModel.data.star_min=1;self.filterModel.data.star_max=5})};Filters.prototype.setAmFilter=function(ams){var self=application.getView("Filters"),html="",displayXIcon=true;if(!ams){html="Any";displayXIcon=false}else{if(ams.length==0){html="Any";displayXIcon=false}else{if(ams.length==1){html=self.locationModel.getAmText(ams[0]);displayXIcon=true}else{html=ams.length+" selected";displayXIcon=true}}}$("#amsummary").html(html);self.xIcon(displayXIcon,$("#filteram"),$("#amsummary"),"sr-filter-am-reset",{current_amenities:(self.filterModel.data.amenities)?self.filterModel.data.amenities.join(","):[]},function(){self.filterModel.data.amenities=[]})};Filters.prototype.setPropFilter=function(props){var self=application.getView("Filters"),html="",displayXIcon=true;if(!props){html="Any";displayXIcon=false}else{if(props.length==0){html="Any";displayXIcon=false}else{if(props.length==1){html=self.locationModel.getPropText(props[0]);displayXIcon=true}else{html=props.length+" selected";displayXIcon=true}}}$("#propsummary").html(html);self.xIcon(displayXIcon,$("#filterprop"),$("#propsummary"),"sr-filter-prop-reset",{current_property_types:(self.filterModel.data.property_types)?self.filterModel.data.property_types.join(","):[]},function(){self.filterModel.data.property_types=[]})};Filters.prototype.setBrandFilter=function(brands){var self=application.getView("Filters"),html="",displayXIcon=true;if(!brands){html="Any";displayXIcon=false}else{if(brands.length==0){html="Any";displayXIcon=false}else{if(brands.length==1){html=self.locationModel.getBrandText(brands[0]);displayXIcon=true}else{html=brands.length+" selected";displayXIcon=true}}}$("#brandsummary").html(html);self.xIcon(displayXIcon,$("#filterbrand"),$("#brandsummary"),"sr-filter-brand-reset",{current_brands:(self.filterModel.data.brands)?self.filterModel.data.brands.join(","):[]},function(){self.filterModel.data.brands=[]})};Filters.prototype.xIcon=function(displayXIcon,filterEl,textEl,trackingId,trackingData,resetFilters){var self=this,xIconEl=filterEl.find(".remove");if(!displayXIcon){xIconEl.remove()}if(displayXIcon&&xIconEl.length==0){xIconEl=$('<span class="remove">Remove</span>');textEl.append(xIconEl);xIconEl.hover(function(e){filterEl.addClass("nohover")},function(){filterEl.removeClass("nohover")});xIconEl.click(function(e){e.stopPropagation();e.preventDefault();self.trackingModel.record(trackingId,trackingData);resetFilters();self.applyFilterChange();filterEl.removeClass("nohover")})}};return(new Filters())})(jQuery,window.application));window.application.addView((function($,application){function FilterHandlers(){this.filterTemplate=null}FilterHandlers.prototype.init=function(){this.locationModel=application.getModel("Location");this.filterBucketsModel=application.getModel("FilterBuckets");this.filterModel=application.getModel("Filters");this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.ratesModel=application.getModel("Rates");this.trackingModel=application.getModel("Tracking");this.searchResultsView=application.getView("SearchResults");this.mapView=application.getView("Map");this.filtersView=application.getView("Filters");this.bubbleView=application.getView("Bubble");this.body()};FilterHandlers.prototype.body=function(){var self=this;$("body").click(function(){self.filtersView.closeAllFilterPopups()})};FilterHandlers.prototype.create=function(){this.datePickers();if(this.prefsModel.indivDateGuestRoom){this.guestRoom("Guest");this.guestRoom("Room")}this.editSearch();this.dropdowns();this.price();this.star();this.amenity();this.propertyType();this.brand();this.map();this.viewControl()};FilterHandlers.prototype.datePickers=function(){var self=this;$(".datepop1, .datepop2").click(function(e){e.stopPropagation()});if(this.ratesModel.checkInDate.length==0){$("#c0pt3r-locationdata .dated").hide();if(this.prefsModel.indivDateGuestRoom){$("#c0pt3r-locationdata .dateless .control").click(function(e){e.stopPropagation();if($(".datepop1:visible").length==0){self.filtersView.closeAllFilterPopups();self.filtersView.displayMenuPopup($(e.target),$(".datepop1"))}else{$(e.target).removeClass("on");$(".datepop1").fadeOut("fast")}})}}else{$("#c0pt3r-locationdata .dateless").remove()}if(this.prefsModel.indivDateGuestRoom){$("#c0pt3r-locationdata .checkin").click(function(e){e.stopPropagation();if(self.ratesModel.checkInDate.length>0){$(".datepop1").datepicker("setDate",self.ratesModel.checkInDate)}$(".datepop1").datepicker("option","minDate",0);if($(".datepop1:visible").length==0){self.filtersView.closeAllFilterPopups();self.filtersView.displayMenuPopup($(e.target),$(".datepop1"))}else{$(e.target).removeClass("on");$(".datepop1").fadeOut("fast")}});$("#c0pt3r-locationdata .checkout").click(function(e){e.stopPropagation();if(self.ratesModel.checkInDate.length>0){$(".datepop2").datepicker("setDate",self.ratesModel.checkOutDate);$(".datepop2").datepicker("option","minDate",self.ratesModel.checkOutDate)}else{$(".datepop2").datepicker("option","minDate",0)}if($(".datepop2:visible").length==0){self.filtersView.closeAllFilterPopups();self.filtersView.displayMenuPopup($(e.target),$(".datepop2"))}else{$(e.target).removeClass("on");$(".datepop2").fadeOut("fast")}})}};FilterHandlers.prototype.guestRoom=function(controlID){var self=this,controlIDLower=controlID.toLowerCase()+"s",controlIDSingular=controlID;controlID=controlID+"s";$("#c0pt3r-locationdata ."+controlIDLower).click(function(e){e.stopPropagation();var control=$(e.target),i;if($("#"+controlIDLower+"list:visible").length==0){self.filtersView.closeAllFilterPopups();control.addClass("on");if($("#"+controlIDLower+"list").length==0){var html='<div id="'+controlIDLower+'list" class="customselect">';var iStart,iMax;if(controlIDSingular.toLowerCase()=="room"){iStart=1;iMax=4}else{iStart=parseInt($(".dates .rooms").html());iMax=iStart*4}for(i=iStart;i<=iMax;i++){var plural=(i==1)?"":"s";var className=(i==self.ratesModel["num"+controlID])?"option selected":"option";html+='<a class="'+className+'" href="#">'+i+" "+controlIDSingular+plural+"</a>"}html+="</div>";$("body").append(html);$("#"+controlIDLower+"list a.option").click(function(e){e.stopPropagation();e.preventDefault();$("#"+controlIDLower+"list a.selected").removeClass("selected");$(e.target).addClass("selected");control.removeClass("on");self.ratesModel.clear();var controlNum=parseInt($(e.target).html());self.ratesModel["num"+controlID]=controlNum;if(controlIDSingular.toLowerCase()=="room"){self.ratesModel.numGuests=controlNum}self.filtersView.applyFilterChange();$("#"+controlIDLower+"list").fadeOut("fast")})}self.filtersView.displayMenuPopup(control,$("#"+controlIDLower+"list"))}else{control.removeClass("on");$("#"+controlIDLower+"list").fadeOut("fast")}})};FilterHandlers.prototype.editSearch=function(){var self=this;$(".edit-search-link").unbind();$(".edit-search-link").click(function(e){e.stopPropagation();e.preventDefault();self.trackingModel.record("sr-edit-search");self.filtersView.closeAllFilterPopups();var location=(self.prefsModel.singleDisplayName.length==0)?(self.locationModel.data.name||self.locationModel.display_name):self.prefsModel.singleDisplayName,html=application.getFromTemplate($("#edit-search-template"),{location:location.truncate(30)});if(self.locationModel.tid=="geo"){$(html).find(".header").prepend("Search Hotels near ")}else{$(html).find(".header").prepend("Search Hotels in ")}var bubble=self.bubbleView.centeredDialog($(html),"edit-search-bubble",460,260,true);bubble.click(function(e){e.stopPropagation();$(".datepop1").hide();$(".datepop2").hide()});self.editSearchForm("sr",{})})};FilterHandlers.prototype.editSearchForm=function(targetType,trackingData){var self=this,singleMonth=(targetType!="sr"),trackingCode,i;self.editSearchDatePickers(singleMonth);$("#edit-search-rooms").change(function(e){var minNumGuests=$(this).val();var maxNumGuests=minNumGuests*4;var html="";for(i=minNumGuests;i<=maxNumGuests;i++){html+='<option value="'+i+'">'+i+"</option>"}$("#edit-search-guests").html(html)});$("#editsearch a.apply").click(function(e){e.preventDefault();if($("#edit-search-d1").data("date")&&$("#edit-search-d2").data("date")){var isDatedSearch=self.ratesModel.isDatedSearch();self.ratesModel.clear();self.ratesModel.checkInDate=$("#edit-search-d1").data("date");self.ratesModel.checkOutDate=$("#edit-search-d2").data("date");self.ratesModel.numRooms=$("#edit-search-rooms").val();self.ratesModel.numGuests=$("#edit-search-guests").val();trackingCode=targetType+"-search";self.trackingModel.record(trackingCode,$.extend(trackingData,{check_in:self.ratesModel.checkInDate,check_out:self.ratesModel.checkOutDate,rooms:self.ratesModel.numRooms,guests:self.ratesModel.numGuests}));self.searchResultsView.showLoadingRatesMsg();self.filtersView.closeAllFilterPopups();$("#c0pt3r-locationdata .dateless").remove();$("#c0pt3r-locationdata .dated").show();if(isDatedSearch){self.filtersView.applyFilterChange()}else{self.filtersView.setFilters();self.ratesModel.initPollingHotels(self.hotelModel.hotels);$("#c0pt3r-hotelcards .ratebtnsearch .label, #c0pt3r-resultssidebar .ratebtnsearch .label").html("Checking Rates...");$("#c0pt3r-hotelcards .ratebtnsearch, #c0pt3r-resultssidebar .ratebtnsearch").show();$("#c0pt3r-hotelcards .ratebtn, #c0pt3r-resultssidebar .ratebtn").hide();application.setURL("#/search/x/"+self.filterModel.getAsQueryString())}}else{alert("Please select some travel dates")}});$("#editsearch a.cancel, #editsearch .close a").click(function(e){e.preventDefault();self.trackingModel.record(targetType+"-search-close",trackingData);self.filtersView.closeAllFilterPopups()});if(self.ratesModel.checkInDate.length>0){self.filtersView.setDateFilter(self.ratesModel.checkInDate,self.ratesModel.checkOutDate);self.filtersView.setRoomFilter(self.ratesModel.numRooms);self.filtersView.setGuestFilter(self.ratesModel.numGuests)}};FilterHandlers.prototype.editSearchDatePickers=function(singleMonth){var self=this;if(self.ratesModel.checkInDate.length>0){$(".datepop1").datepicker("setDate",self.ratesModel.checkInDate);$(".datepop2").datepicker("setDate",self.ratesModel.checkOutDate);$(".datepop2").datepicker("option","minDate",self.ratesModel.checkOutDate)}if(singleMonth){$(".datepop1, .datepop2").datepicker("option","numberOfMonths",1)}else{$(".datepop1, .datepop2").datepicker("option","numberOfMonths",2)}$("#edit-search-d1").click(function(e){e.stopPropagation();e.preventDefault();$(".datepop2").hide();$(".datepop1").datepicker("option","minDate",0);if($(".datepop1:visible").length==0){self.filtersView.displayMenuPopup($(e.target),$(".datepop1"))}else{$(".datepop1").fadeOut("fast")}});$("#edit-search-d2").click(function(e){e.stopPropagation();e.preventDefault();$(".datepop1").hide();if($("#edit-search-d1").val().length==0){$(".datepop2").datepicker("option","minDate",1)}else{var checkOutDate=$(".datepop1").datepicker("getDate");checkOutDate.setDate(checkOutDate.getDate()+1);$(".datepop2").datepicker("option","minDate",checkOutDate)}if($(".datepop2:visible").length==0){self.filtersView.displayMenuPopup($(e.target),$(".datepop2"))}else{$(".datepop2").fadeOut("fast")}})};FilterHandlers.prototype.dropdowns=function(){var self=this;$("#dropdowns .dropdown").click(function(e){e.stopPropagation();var dropdown=$(this),dropdownId=$(this).attr("id"),dropdownPrefs=self.prefsModel.dropdowns[dropdownId],inclDistance=(self.locationModel.tid=="geo"&&dropdownId=="sort");var html='<div class="dropdown-options">';if(inclDistance){var selected=($("#"+dropdownId+" .selected").html()=="Nearest")?'class="selected"':"";html+='<div id="'+dropdownId+'-option-distance" '+selected+">Nearest</div>"}$.each(dropdownPrefs.options,function(i,option){var selected=(option.label==$("#"+dropdownId+" .selected").html())?'class="selected"':"";html+='<div id="'+dropdownId+"-option-"+i+'" '+selected+">"+option.label+"</div>"});html+="</div>";self.bubbleView.create($(html),(dropdown.attr("id")+"-bubble"),dropdown,dropdownPrefs.width,null,[{top:Math.round(dropdown.offset().top+dropdown.outerHeight()-5),left:Math.round(dropdown.offset().left+35),alignment:"bottom",arrowPos:35}]);var trackingData={};if(dropdownId=="sort"){trackingData.current_sort_field=self.filterModel.data.sort_field;trackingData.current_sort_direction=self.filterModel.data.sort_direction;self.trackingModel.record(("sr-"+dropdownId+"-open"),trackingData)}if(inclDistance){$("#"+dropdownId+"-option-distance").click(function(e){e.stopPropagation();self.selectDropdownOption(dropdownId,"distance-asc")})}$.each(self.prefsModel.dropdowns[dropdownId].options,function(i,option){$("#"+dropdownId+"-option-"+i).click(function(e){e.stopPropagation();self.selectDropdownOption(dropdownId,option.value,trackingData)})})})};FilterHandlers.prototype.selectDropdownOption=function(dropdown,value,trackingData){var self=this;switch(dropdown){case"bucket":self.filterBucketsModel.selectBucket(value);self.filtersView.applyFilterChange();break;case"view":self.filterModel.cardType=value;self.filtersView.setCardType(value);if($("#morehotelscard").length>0){self.searchResultsView.displayNum++}self.filtersView.applyFilterChange(true);break;case"focusSetting":self.filterModel.focusSetting=value;self.filtersView.applyFilterChange(true);break;case"sort":var sort=self.filtersView.getSort(value);self.filterModel.data.sort_field=sort.field;self.filterModel.data.sort_direction=sort.direction;self.filtersView.applyFilterChange();self.trackingModel.record(("sr-sort"),$.extend(trackingData,{new_sort_field:self.filterModel.data.sort_field,new_sort_direction:self.filterModel.data.sort_direction}));break}this.bubbleView.removeAll()};FilterHandlers.prototype.price=function(){var self=this;$("#filterprice").bind("click",function(event){event.preventDefault();event.stopPropagation();var currentLo=self.filterModel.data.price_min,currentHi=self.filterModel.data.price_max,trackingData=(currentLo==self.locationModel.data.minrate.usd&&currentHi==self.locationModel.data.maxrate.usd)?{}:{current_price_filter_lo:currentLo,current_price_filter_hi:currentHi};self.filtersView.showFilter("price",self.filtersView.sliderControl,{width:null,height:null,min:self.locationModel.data.minrate.usd,max:self.locationModel.data.maxrate.usd,val0:"price_min",val1:"price_max",set:self.filtersView.setPriceFilter},self.filtersView.applyPrice,self.filtersView.cancelPrice,trackingData)})};FilterHandlers.prototype.star=function(){var self=this;$("#filterstar").bind("click",function(event){event.preventDefault();event.stopPropagation();var trackingData={current_star_filter_lo:(self.filterModel.data.star_min||1),current_star_filter_hi:(self.filterModel.data.star_max||5)};self.filtersView.showFilter("star",self.filtersView.sliderControl,{width:null,height:null,min:1,max:5,val0:"star_min",val1:"star_max",set:self.filtersView.setStarFilter},self.filtersView.applyStar,self.filtersView.cancelStar,trackingData)})};FilterHandlers.prototype.amenity=function(){var self=this;$("#filteram").bind("click",function(event){event.preventDefault();event.stopPropagation();var trackingData=(self.filterModel.data.amenities.length==0)?{current_amenities:"Any"}:{current_amenities:self.filterModel.data.amenities.join(",")};var amenities=[];$.each(self.locationModel.data.amenities,function(i,amenity){amenity.checked=(self.filtersView.idInArray(amenity.id,self.filterModel.data.amenities))?true:false;if(amenity.rank==1){amenities.push(amenity)}});self.filtersView.showFilter("am",self.filtersView.checkboxControl,{width:null,height:null,image:false,arr:"amenities",set:self.filtersView.setAmFilter,checkboxes:amenities},self.filtersView.applyAms,self.filtersView.cancelAms,trackingData)})};FilterHandlers.prototype.propertyType=function(){var self=this;$("#filterprop").bind("click",function(event){event.preventDefault();event.stopPropagation();var trackingData=(self.filterModel.data.property_types.length==0)?{current_property_types:"Any"}:{current_property_types:self.filterModel.data.property_types.join(",")};var propertyTypes=[];$.each(self.locationModel.data.property_types,function(i,propertyType){if(propertyType.num_hotels>0){propertyType.checked=(self.filtersView.idInArray(propertyType.id,self.filterModel.data.property_types))?true:false;propertyTypes.push(propertyType)}});self.filtersView.showFilter("prop",self.filtersView.checkboxControl,{width:null,height:null,image:false,arr:"property_types",set:self.filtersView.setPropFilter,checkboxes:propertyTypes},self.filtersView.applyProp,self.filtersView.cancelProp,trackingData)})};FilterHandlers.prototype.brand=function(){var self=this;$("#filterbrand").bind("click",function(event){event.preventDefault();event.stopPropagation();var trackingData=(self.filterModel.data.brands.length==0)?{current_brands:"Any"}:{current_brands:self.filterModel.data.brands.join(",")};var brands=[];$.each(self.locationModel.data.brands,function(i,brand){if(brand.num_hotels>0){brand.checked=(self.filtersView.idInArray(brand.id,self.filterModel.data.brands))?true:false;brands.push(brand)}});self.filtersView.showFilter("brand",self.filtersView.checkboxControl,{width:null,height:null,image:false,arr:"brands",set:self.filtersView.setBrandFilter,checkboxes:brands},self.filtersView.applyBrand,self.filtersView.cancelBrand,trackingData)})};FilterHandlers.prototype.map=function(){var self=this;$("#showmap").click(function(e){e.preventDefault();e.stopPropagation();self.filtersView.closeAllFilterPopups();self.mapView.toggleMap(self.hotelModel.filteredHotels)});$("#map-radio-on").click(function(e){e.stopPropagation();self.filtersView.closeAllFilterPopups();self.trackingModel.record("sr-map-on");$("#label-map-radio-on").addClass("selected");$("#label-map-radio-off").removeClass("selected");self.mapView.createMap(self.hotelModel.filteredHotels)});$("#map-radio-off").click(function(e){e.stopPropagation();self.filtersView.closeAllFilterPopups();self.trackingModel.record("sr-map-off");$("#label-map-radio-on").removeClass("selected");$("#label-map-radio-off").addClass("selected");self.mapView.removeMap()});$("#maptoggle a").click(function(e){e.stopPropagation();e.preventDefault();self.filtersView.closeAllFilterPopups();if($(this).parent().is(".map-off")){self.trackingModel.record("sr-map-on");self.mapView.createMap(self.hotelModel.filteredHotels)}else{self.trackingModel.record("sr-map-off");self.mapView.removeMap()}})};FilterHandlers.prototype.viewControl=function(){var self=this;$("[id^='view-radio-']").click(function(e){e.stopPropagation();self.filtersView.closeAllFilterPopups();var selectedView=$(this).attr("id").replace("label-view-radio-","").replace("view-radio-","");self.filterModel.cardType=selectedView;self.filterView.setCardType(selectedView);if($("#morehotelscard").length>0){self.searchResultsView.displayNum++}self.filtersView.applyFilterChange(true)});$("#viewtoggle a").click(function(e){e.stopPropagation();e.preventDefault();self.filtersView.closeAllFilterPopups();var currentView=$(this).parent().attr("class"),selectedView=(currentView=="gallery")?"summary":"gallery";self.trackingModel.record("sr-"+selectedView);self.filterModel.cardType=selectedView;self.filtersView.setCardType(selectedView);if($("#morehotelscard").length>0){self.searchResultsView.displayNum++}self.filtersView.applyFilterChange(true)})};return(new FilterHandlers())})(jQuery,window.application));window.application.addView((function($,application){function Lightbox(){this.images=[];this.shrinkTo=0;this.imgPosition=0;this.hotelTID=null}Lightbox.prototype.init=function(){var self=this;this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.filterModel=application.getModel("Filters");this.trackingModel=application.getModel("Tracking");this.filtersView=application.getView("Filters");this.searchResultsView=application.getView("SearchResults");this.hotelView=application.getView("Hotel");$(window).resize(function(){self.positionLightbox();self.resizeOverlay()})};Lightbox.prototype.show=function(h,imgPosition){if(typeof(h)!="string"){h=h.tid}this.imgPosition=parseInt(imgPosition||0);if(this.filterModel.photoLightbox.length==0){this.filterModel.photoLightbox=h;this.filterModel.photoLightboxPosition=this.imgPosition;application.setURL("#/search/x/"+this.filterModel.getAsQueryString())}};Lightbox.prototype.hide=function(){this.filterModel.photoLightbox="";this.filterModel.photoLightboxPosition=0;application.setURL("#/search/x/"+this.filterModel.getAsQueryString())};Lightbox.prototype.openOrClose=function(){if(this.filterModel.photoLightbox.length>0&&$("#lightbox").length==0){this.slideshowInit(this.filterModel.photoLightbox,this.filterModel.photoLightboxPosition)}else{if($("#lightbox").length>0){this.close("lightbox")}}};Lightbox.prototype.showOverlay=function(id,color,speed,opacity,zIndex){id+="-overlay";var overlay=$('<div id="'+id+'" class="lightboxoverlay" />');$("body").append(overlay);overlay.data("speed",speed);this.resizeOverlay();overlay.css({"background-color":color,"z-index":zIndex,opacity:opacity.toString()}).show()};Lightbox.prototype.hideOverlay=function(id){id+="-overlay";var overlay=$("#"+id);overlay.remove();$(this).remove()};Lightbox.prototype.resizeOverlay=function(){$(".lightboxoverlay").height(1);$(".lightboxoverlay").height($(document).height())};Lightbox.prototype.slideshowInit=function(h,imgPosition){var self=this;this.filtersView.closeAllFilterPopups();if(typeof(h)=="string"){this.hotelModel.getHotelDetails(h,function(hotel){self.slideshow(hotel,imgPosition)})}else{self.slideshow(h,imgPosition)}};Lightbox.prototype.slideshow=function(hotel,imgPosition){var self=this;this.hotelTID=hotel.tid;this.imgPosition=parseInt(imgPosition||0);self.images=hotel.images;var lightboxObj=$.extend({},hotel);lightboxObj.stars=self.searchResultsView.stars(lightboxObj.stars,false,"small");var imgWidth=0,imgHeight=0;$.each(self.images,function(i,image){imgWidth=((self.hotelModel.maxImageSize(image).width||0)>imgWidth)?self.hotelModel.maxImageSize(image).width:imgWidth;imgHeight=((self.hotelModel.maxImageSize(image).height||0)>imgHeight)?self.hotelModel.maxImageSize(image).height:imgHeight});if(imgWidth<250){imgWidth=250}if(imgHeight<250){imgHeight=250}$("body").append(application.getFromTemplate($("#lightbox-template"),lightboxObj));if($("#hoteldetails").length>0){$("#lightbox .hd-link").remove()}var newDimensions=self.slideshowDimensions(imgWidth,imgHeight);imgWidth=newDimensions.width;imgHeight=newDimensions.height;$("#lightbox").css({width:$("#lightbox").width()+"px",height:$("#lightbox").height()+"px"});$("#lightbox").data("scrollTop",$(document).scrollTop());self.positionLightbox();$(document).scrollTop(0);self.showOverlay("lightbox","#000","fast",self.prefsModel.overlayOpacity,10000);if($.browser.msie){$("html").css("overflow-y","hidden")}else{$("html, body").css("overflow","hidden")}$("#lightbox").show();self.showThumbnails(imgWidth);self.showImage();$("#lightbox").unbind();$(document).keydown(function(e){switch(e.which){case 27:self.hide();break;case 37:self.prevImage();break;case 39:self.nextImage();break}});$("#lightbox a.fulldetails").click(function(e){e.preventDefault();e.stopPropagation();self.hide();self.hotelView.show(hotel.tid)});$("#lightbox a.close").click(function(e){e.preventDefault();e.stopPropagation();self.hide();self.trackingModel.record("pl-close",{hotel_tid:hotel.tid})})};Lightbox.prototype.slideshowDimensions=function(imgWidth,imgHeight,noShrink){if(!isNaN(imgWidth)&&!isNaN(imgHeight)){$("#lightbox").show();$("#lightbox div.img, #lightbox div.img img").css({width:imgWidth+"px",height:imgHeight+"px"});$("#lightbox .lb-content").css({width:imgWidth+"px"});$("#lightbox h1").css({width:(imgWidth-$("#lightbox .close1").width())+"px"});if(this.images&&this.images.length<=1){$("#lightbox .thumbnails").remove();$("#lightbox div.img").css({"border-bottom":0,"margin-bottom":0})}$("#lightbox .lb-content").css("height",null);$("#lightbox .lb-content").height(Math.round($("#lightbox .lb-content").height()));$("#lightbox .lb-top, #lightbox .lb-bottom").width($("#lightbox .lb-content").outerWidth());$("#lightbox .lb-left, #lightbox .lb-right").height($("#lightbox .lb-content").outerHeight());var heightDiff=($("#lightbox").height()+20)-$(window).height();if(heightDiff>0&&!noShrink){this.shrinkTo=($("#lightbox div.img").height()-heightDiff)/$("#lightbox div.img").height();var newDimensions=this.slideshowDimensions(parseInt(imgWidth*this.shrinkTo),parseInt(imgHeight*this.shrinkTo),true);imgWidth=newDimensions.width;imgHeight=newDimensions.height}$("#lightbox").hide();return{width:imgWidth,height:imgHeight}}};Lightbox.prototype.positionLightbox=function(){if($("#lightbox").length>0){var lightBoxTop=($(window).height()/2)-($("#lightbox").height()/2);$("#lightbox").css("left",($(window).width()/2)-($("#lightbox").width()/2)+"px");$("#lightbox").css("top",lightBoxTop+"px")}};Lightbox.prototype.showImage=function(){var self=this;var imgDiv=$("#lightbox div.img");imgDiv.empty();var imageSize=this.hotelModel.maxImageSize(this.images[this.imgPosition]);var imageWidth=(this.shrinkTo>0)?parseInt(imageSize.width*this.shrinkTo):imageSize.width;var imageHeight=(this.shrinkTo>0)?parseInt(imageSize.height*this.shrinkTo):imageSize.height;if(imageSize.width<=$("#lightbox div.img").width()&&imageSize.height<=$("#lightbox div.img").height()){imageWidth=imageSize.width;imageHeight=imageSize.height}var src=this.hotelModel.buildImageUrl(this.images[this.imgPosition],imageSize.width,imageSize.height,true);var failImg="shared/img/noimage/206x155.jpg";var imgContainer=$("<div />");imgContainer.css({position:"absolute",left:((imgDiv.width()-imageWidth)/2)+"px",top:(10+((imgDiv.height()-imageHeight)/2))+"px",width:imageWidth+"px",height:imageHeight+"px",display:"none"});var imgPosition=self.imgPosition;var img=$("<img />");this.loadImage(img,src,imageWidth,imageHeight,(this.images[this.imgPosition].caption||""),false,failImg,function(){if(imgPosition==self.imgPosition){var count=parseInt(self.imgPosition)+1;imgContainer.append(img);imgDiv.append(imgContainer);imgDiv.append('<div class="caption">'+(self.images[self.imgPosition].caption||"")+'</div><div class="count">Image '+count+" of "+self.images.length+"</div>");imgContainer.fadeIn("slow",function(){var linkWidth=Math.round(imgContainer.outerWidth()/3);var linkHeight=imgContainer.height();var bgTop=(linkHeight-46)/2;if(count>1){var prevLink=$('<div class="prev" />');prevLink.css({"background-position":"20px "+bgTop+"px",width:linkWidth+"px",height:linkHeight+"px",opacity:0});imgContainer.append(prevLink)}if(count<self.images.length){var nextLink=$('<div class="next" />');nextLink.css({"background-position":(linkWidth-46-20)+"px "+bgTop+"px",width:linkWidth+"px",height:linkHeight+"px",opacity:0});imgContainer.append(nextLink)}self.imageEventHandlers()})}});self.highlightThumbnail()};Lightbox.prototype.highlightThumbnail=function(){var self=this;var thumbnail=$("#lightbox .thumbnails div.thumb").eq(self.imgPosition);var thumbnailsDiv=$("#lightbox .thumbnails");$("#lightbox .thumbnails img").removeClass("selected");thumbnail.find("img").addClass("selected");var thumbnailsWidth=$("#lightbox .thumbnails").width();var containerLeft=parseInt($("#lightbox .thumbnails .container").css("margin-left"));var selThumbLeft=(self.imgPosition*70);if((selThumbLeft+containerLeft)>thumbnailsWidth-60){$("#lightbox .thumbnails .container").animate({"margin-left":"-"+((selThumbLeft+70-thumbnailsWidth))+"px"},"fast",function(){self.thumbArrowEvents()})}if((selThumbLeft+containerLeft)<0){$("#lightbox .thumbnails .container").animate({"margin-left":"-"+(selThumbLeft)+"px"},"fast",function(){self.thumbArrowEvents()})}};Lightbox.prototype.imageEventHandlers=function(){var self=this;$("#lightbox div.img .prev, #lightbox div.img .next").mouseover(function(e){$(this).css("opacity",1)});$("#lightbox div.img .prev, #lightbox div.img .next").mouseout(function(e){$(this).css("opacity",0)});$("#lightbox div.img .prev").click(function(e){self.prevImage()});$("#lightbox div.img .next").click(function(e){self.nextImage()})};Lightbox.prototype.prevImage=function(){if(this.imgPosition>0){this.trackingModel.record("pl-prev",{hotel_tid:this.hotelTID,current_image_position:this.imgPosition+1,current_image_filename:this.images[this.imgPosition].file_name});this.imgPosition--;this.showImage()}};Lightbox.prototype.nextImage=function(){if((this.imgPosition+1)<this.images.length){this.trackingModel.record("pl-next",{hotel_tid:this.hotelTID,current_image_position:this.imgPosition+1,current_image_filename:this.images[this.imgPosition].file_name});this.imgPosition++;this.showImage()}};Lightbox.prototype.showThumbnails=function(imgWidth){var self=this;var failImg="shared/img/noimage/50x50.jpg";$("#lightbox .thumbnails").width(parseInt(imgWidth)-60);$("#lightbox .thumbnails .container").width((self.images.length*70)-10);if($("#lightbox .thumbnails .container").width()<$("#lightbox .thumbnails").width()){$("#lightbox .thumbnails .container").css({"padding-left":(($("#lightbox .thumbnails").width()-$("#lightbox .thumbnails .container").width())/2)+"px"})}$.each(self.images,function(i,image){var src=self.hotelModel.buildImageUrl(image,50,50,false);var thumbnail=$('<div class="thumb" id="thumb'+i+'" />');$("#lightbox .thumbnails .container .c0pt3r-clear").before(thumbnail);var className="";className+=(i==self.imgPosition)?" selected ":"";className+=(i==0)?" first ":"";var img=(className.length==0)?$("<img />"):$('<img class="'+className+'" />');self.loadImage(img,src,50,50,(image.caption||""),true,failImg,function(){var thumbnail=$("#thumb"+i);thumbnail.append(img);img.click(function(){self.trackingModel.record("pl-thumb",{hotel_tid:self.hotelTID,current_image_position:self.imgPosition+1,current_image_filename:self.images[self.imgPosition].file_name,new_image_position:(i+1),new_image_filename:self.images[i].file_name});self.imgPosition=i;self.showImage()});thumbnail.fadeIn("fast")})});if($("#lightbox .thumbnails .container").width()>$("#lightbox .thumbnails").width()){$("#lightbox .lb-content").append('<div class="prev-thumb" /><div class="next-thumb" />');$("#lightbox .prev-thumb").css({left:"10px",top:($("#lightbox .thumbnails").position().top+19)+"px"});$("#lightbox .next-thumb").css({left:($("#lightbox .thumbnails").outerWidth(true)+10-22)+"px",top:($("#lightbox .thumbnails").position().top+19)+"px"});self.thumbArrowEvents()}};Lightbox.prototype.thumbArrowEvents=function(){var self=this;var marginLeft=parseInt($("#lightbox .thumbnails .container").css("margin-left"));var marginLimit=(0-$("#lightbox .thumbnails .container").width())+$("#lightbox .thumbnails").width();$("#lightbox .prev-thumb, #lightbox .next-thumb").unbind();if(marginLeft==0){$("#lightbox .prev-thumb, #lightbox .prev-thumb-disabled").addClass("prev-thumb-disabled");$("#lightbox .prev-thumb-disabled").removeClass("prev-thumb")}else{$("#lightbox .prev-thumb, #lightbox .prev-thumb-disabled").addClass("prev-thumb");$("#lightbox .prev-thumb").removeClass("prev-thumb-disabled");$("#lightbox .prev-thumb").click(function(){var newMarginLeft=marginLeft+$("#lightbox .thumbnails").width();newMarginLeft=(newMarginLeft>0)?0:newMarginLeft;$("#lightbox .thumbnails .container").animate({"margin-left":newMarginLeft+"px"},"slow",function(){self.thumbArrowEvents()});self.trackingModel.record("pl-thumb-prev",{hotel_tid:self.hotelTID})})}if(marginLeft==marginLimit){$("#lightbox .next-thumb, #lightbox .next-thumb-disabled").addClass("next-thumb-disabled");$("#lightbox .next-thumb-disabled").removeClass("next-thumb")}else{$("#lightbox .next-thumb, #lightbox .next-thumb-disabled").addClass("next-thumb");$("#lightbox .next-thumb").removeClass("next-thumb-disabled");$("#lightbox .next-thumb").click(function(){var newMarginLeft=marginLeft-$("#lightbox .thumbnails").width();newMarginLeft=(newMarginLeft<marginLimit)?marginLimit:newMarginLeft;$("#lightbox .thumbnails .container").animate({"margin-left":newMarginLeft+"px"},"slow",function(){self.thumbArrowEvents()});self.trackingModel.record("pl-thumb-next",{hotel_tid:self.hotelTID})})}};Lightbox.prototype.loadImage=function(img,src,w,h,alt,title,failImg,onSuccess){img.load(function(){if(onSuccess){onSuccess()}}).error(function(){$(this).attr("src",failImg).show()}).attr({src:src,alt:alt.escapeHTML()}).css({width:w+"px",height:h+"px"});if(title){img.attr({title:alt.escapeHTML()})}};Lightbox.prototype.vfm=function(hotel){var self=this;var vfmWidth=740,vfmHeight=490;var lightboxObj={name:hotel.name};$("body").append(application.getFromTemplate($("#lightbox-template"),lightboxObj));if($("#hoteldetails").length>0){$("#lightbox .hd-link").remove()}$("#lightbox div.img").append('<iframe class="vfmiframe" src="'+hotel.vfm.url+'"></iframe>').css("padding-bottom","0");var newDimensions=self.slideshowDimensions(vfmWidth,vfmHeight,true);vfmWidth=newDimensions.width;vfmHeight=newDimensions.height;$("#lightbox").css({width:$("#lightbox").width()+"px",height:$("#lightbox").height()+"px"});$("#lightbox").data("scrollTop",$(document).scrollTop());self.positionLightbox();$(document).scrollTop(0);self.showOverlay("lightbox","#000","fast",self.prefsModel.overlayOpacity,10000);if($.browser.msie){$("html").css("overflow-y","hidden")}else{$("html, body").css("overflow","hidden")}$("#lightbox").show();$("#lightbox").unbind();$(document).keydown(function(e){switch(e.which){case 27:self.hide();break}});$("#lightbox a.close").click(function(e){e.preventDefault();e.stopPropagation();self.hide()})};Lightbox.prototype.close=function(id){$(document).unbind("keydown");if($.browser.msie){$("html").css("overflow-y","scroll")}else{$("html, body").css("overflow","visible")}var scrollTop=($("#"+id).data("scrollTop")||0);$("#"+id).remove();this.hideOverlay(id);$(document).scrollTop(scrollTop)};return(new Lightbox())})(jQuery,window.application));window.application.addView((function($,application){function Map(){this.currentBubble=null;this.map=null;this.pins=[];this.displayed=false}Map.prototype.init=function(){this.searchResultsView=application.getView("SearchResults");this.bubbleView=application.getView("Bubble");this.hotelView=application.getView("Hotel");this.locationModel=application.getModel("Location");this.ratesModel=application.getModel("Rates");this.hotelModel=application.getModel("Hotel");this.prefsModel=application.getModel("Prefs");this.trackingModel=application.getModel("Tracking")};Map.prototype.toggleMap=function(hotels){if($("#map").length==0){this.createMap(hotels)}else{this.removeMap()}};Map.prototype.createMap=function(hotels){if(this.ratesModel.isPolling){if($("#map-loading").length==0){$("#maptoggle").removeClass("map-off").addClass("map-on").children("a").html("Off");this.removeMap2();$("#c0pt3r-filterresults").prepend('<div id="map-loading">Loading Map...</div>')}}else{if($("#map").length==0){$("#maptoggle").removeClass("map-off").addClass("map-on").children("a").html("Off");$("#c0pt3r-filterresults").prepend('<div id="map-outer"><div id="map" /></div>');var mapLatLng=new google.maps.LatLng(this.locationModel.data.lat,this.locationModel.data.lng);var mapOptions={center:mapLatLng,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:false,streetViewControl:false,scaleControl:true,zoom:13};var map=this.map=new google.maps.Map(document.getElementById("map"),mapOptions);if(hotels){this.createMarkers(hotels)}}}this.displayed=true};Map.prototype.createMarkers=function(hotels){var self=this;if(self.map!=null){var hotelTIDs=[];$.each(hotels,function(i,hotel){hotelTIDs.push(hotel.tid)});$.each(this.pins,function(i,marker){if($.inArray(marker.hotel_tid,hotelTIDs)<0){self.removeMarker(marker)}});var bounds=new google.maps.LatLngBounds();$.each(hotels,function(i,hotel){if(($("#hotelcard_"+hotel.tid).length>0)&&(hotel.lat!=0||hotel.lng!=0)&&((hotel.lat!=null)&&(hotel.lng!=null))&&$("copter-marker-"+hotel.tid).length==0){var position=new google.maps.LatLng(hotel.lat,hotel.lng);var marker=new google.maps.Marker({position:position,map:self.map,icon:self.prefsModel.mapIconImage});marker.hotel_tid=hotel.tid;self.pins.push(marker);bounds.extend(position);google.maps.event.addListener(marker,"mouseover",function(){self.bubbleView.removeAll();var obj={};obj.index=i;obj.name=hotel.name;obj.img=self.hotelModel.buildImageUrl(hotel.image,50,50);obj.stars=self.searchResultsView.stars(hotel.stars,"small");if(self.ratesModel.rates[hotel.tid]){var rateData=self.ratesModel.lowestHotelRate(hotel.tid);obj.rate=rateData.rate;if(!rateData.inclTaxesFees){obj.rate+="*"}obj.rate_label="Best Rate"}else{obj.rate=hotel.rate.lowest;obj.rate_label="From"}if((!obj.rate||obj.rate==0)||self.hotelModel.displayablePartners(hotel.tid).length==0){obj.rate="";obj.rate_label=""}else{obj.rate="$"+obj.rate}var html=application.getFromTemplate($("#map-card-template"),obj);html=$("<p>").append(html.eq(0).clone()).html();var bubble=new MapBubble(html,{map:self.map});bubble.bindTo("position",marker,"position");self.currentBubble=bubble});google.maps.event.addListener(marker,"mouseout",function(){if(self.currentBubble!=null){self.currentBubble.setMap(null)}});google.maps.event.addListener(marker,"click",function(){self.trackingModel.record("sr-map-hotel-pin",{hotel_tid:hotel.tid});self.hotelView.show(hotel.tid)});if(i==self.searchResultsView.displayNum){return false}}});if(self.prefsModel.singleLocation&&self.locationModel.tid!="geo"){$.each(self.locationModel.data.landmarks,function(i,landmark){var position=new google.maps.LatLng(landmark.lat,landmark.lng);var marker=new google.maps.Marker({position:position,map:self.map,icon:self.prefsModel.mapIconLandmarkImage});self.pins.push(marker);bounds.extend(position);google.maps.event.addListener(marker,"mouseover",function(){self.bubbleView.removeAll();landmark.index=i;var html=application.getFromTemplate($("#map-landmark-card-template"),landmark);var bubble=new MapBubble(html,{map:self.map});bubble.bindTo("position",marker,"position");self.currentBubble=bubble});google.maps.event.addListener(marker,"mouseout",function(){self.currentBubble.setMap(null)})})}if(!self.locationModel.locationHotel&&(self.locationModel.geo.lat&&self.locationModel.geo.lng)&&!self.locationModel.noMapPin){var position=new google.maps.LatLng(self.locationModel.geo.lat,self.locationModel.geo.lng);var marker=new google.maps.Marker({position:position,map:self.map,icon:self.prefsModel.mapIconGeo});self.pins.push(marker);bounds.extend(position);google.maps.event.addListener(marker,"mouseover",function(){self.bubbleView.removeAll();var html=application.getFromTemplate($("#map-landmark-card-template"),{name:self.locationModel.display_name,address:""});var bubble=new MapBubble(html,{map:self.map});bubble.bindTo("position",marker,"position");self.currentBubble=bubble});google.maps.event.addListener(marker,"mouseout",function(){self.currentBubble.setMap(null)})}self.map.fitBounds(bounds)}};Map.prototype.removeAllMarkers=function(){var self=this;$.each(this.pins,function(i,marker){self.removeMarker(marker)})};Map.prototype.removeMarker=function(marker){marker.setMap(null);$(marker).remove()};Map.prototype.removeMap=function(){$("#maptoggle").removeClass("map-on").addClass("map-off").children("a").html("On");$("#map-loading").remove();this.removeMap2()};Map.prototype.removeMap2=function(){this.map=null;this.markers=[];$("#map-outer").remove();this.displayed=false};return(new Map())})(jQuery,window.application));function MapBubble(html,opt_options){this.setValues(opt_options);this.div_=null;this.html=html}MapBubble.prototype=new google.maps.OverlayView();MapBubble.prototype.onAdd=function(){var self=this;this.listeners_=[google.maps.event.addListener(this,"position_changed",function(){self.draw()}),google.maps.event.addListener(this,"text_changed",function(){self.draw()})]};MapBubble.prototype.onRemove=function(){var i=0;$(this.div_).remove();for(i=0,I=this.listeners_.length;i<I;++i){google.maps.event.removeListener(this.listeners_[i])}};MapBubble.prototype.draw=function(){var projection=this.getProjection();var position=projection.fromLatLngToDivPixel(this.get("position"));var relativePosition=projection.fromLatLngToContainerPixel(this.get("position"));var div=$("<div/>");var posLeft={left:position.x-8,top:position.y-22,relativeLeft:relativePosition.x-5,relativeTop:relativePosition.y-22,alignment:"left",arrowPos:30};var posLeft2={left:position.x-8,top:position.y-22,relativeLeft:relativePosition.x-5,relativeTop:relativePosition.y-22,alignment:"left",arrowPos:73};var posBottom={left:position.x,top:position.y,relativeLeft:relativePosition.x,relativeTop:relativePosition.y,alignment:"bottom",arrowPos:30};var posBottom2={left:position.x,top:position.y,relativeLeft:relativePosition.x,relativeTop:relativePosition.y,alignment:"bottom",arrowPos:215};var posTop={left:position.x,top:position.y-40,relativeLeft:relativePosition.x,relativeTop:relativePosition.y-40,alignment:"top",arrowPos:30};var posTop2={left:position.x,top:position.y-40,relativeLeft:relativePosition.x,relativeTop:relativePosition.y-40,alignment:"top",arrowPos:215};var posRight={left:position.x+8,top:position.y-22,relativeLeft:relativePosition.x+5,relativeTop:relativePosition.y-22,alignment:"right",arrowPos:30};var posRight2={left:position.x+8,top:position.y-22,relativeLeft:relativePosition.x+5,relativeTop:relativePosition.y-22,alignment:"right",arrowPos:73};var bubblePositions=[];bubblePositions.push(posRight,posRight2,posBottom,posBottom2,posLeft,posLeft2,posTop,posTop2);var bubble=application.getView("Bubble").build(div,"map-hover-bubble",null,220,78,$("#map"),bubblePositions,false);bubble.css("display","block");this.div_=bubble.get(0);var pane=this.getPanes().floatPane;pane.appendChild(this.div_);$(this.div_).find(".content div:first").html(this.html)};window.application.addView((function($,application){function Hotel(){this.heightDiff=null;this.hotel=null}Hotel.prototype.init=function(){this.hotelModel=application.getModel("Hotel");this.ratesModel=application.getModel("Rates");this.filterModel=application.getModel("Filters");this.partnerModel=application.getModel("Partners");this.prefsModel=application.getModel("Prefs");this.trackingModel=application.getModel("Tracking");this.lightboxView=application.getView("Lightbox");this.searchResultsView=application.getView("SearchResults");this.filtersView=application.getView("Filters");this.filterHandlersView=application.getView("FilterHandlers");this.rateBubbleView=application.getView("RateBubble");this.rateMatrixView=application.getView("RateMatrix")};Hotel.prototype.show=function(hotelTID,showRoomRates){if(this.filterModel.hotelLightbox.length==0){if(!showRoomRates){showRoomRates=0}this.filterModel.hotelLightbox=hotelTID;this.filterModel.hotelLightboxRoomRates=showRoomRates;if($("#map-ux-map").length>0){this.openOrClose()}else{application.setURL("#/search/x/"+this.filterModel.getAsQueryString())}}};Hotel.prototype.hide=function(){this.filterModel.hotelLightbox="";this.filterModel.hotelLightboxRoomRates=0;if($("#map-ux-map").length>0){this.openOrClose()}else{application.setURL("#/search/x/"+this.filterModel.getAsQueryString())}};Hotel.prototype.openOrClose=function(){if(this.filterModel.hotelLightbox.length>0&&$("#hoteldetails").length==0){this.open(this.filterModel.hotelLightbox,this.filterModel.hotelLightboxRoomRates)}else{if(this.filterModel.hotelLightbox.length==0&&$("#hoteldetails").length>0){this.close("hoteldetails")}}};Hotel.prototype.open=function(hotelTID,showRoomRates){var self=this,scrollTop=$(document).scrollTop();this.filtersView.closeAllFilterPopups();this.heightDiff=$(document).height()-$("#c0pt3r").height();this.hotelModel.getHotelDetails(hotelTID,function(hotel){var hotelObj=$.extend({},hotel);self.hotelModel.base_image_url=hotelObj.base_image_url;var hasLogo=false;$.each(hotelObj.partners,function(partnerCode,partner){if(partner.is_book_direct){hotelObj.partner=(partnerCode=="RATRIXLISTING")?partner.name:hotelObj.brand.name;hotelObj.partner_logo=(partnerCode=="RATRIXLISTING")?partner.logo_root+"110x60/"+partner.logo_image:self.prefsModel.logoUrlRoot+"/brands/110x60/"+hotelObj.brand.code+".png";hasLogo=true}});if(!hasLogo){hotelObj.partner="";hotelObj.partner_logo="shared/img/hoteldetails/transparent.gif"}hotelObj.stars=self.searchResultsView.stars(hotelObj.stars,false,"large");var address=hotelObj.add.add1+", "+hotelObj.add.city;address+=(hotelObj.add.region)?(", "+hotelObj.add.region):"";hotelObj.add.address=address;if(!hotelObj.desc){hotelObj.desc=""}if(hotel.images.length>0){var imageHTML="",caption,i;if(hotel.images.length>=3){if(self.hotelModel.imageHasDimensions(hotel.images[0],480,320)){imageHTML+='<div class="hi-res">';for(i=0;i<3;i++){caption=(hotel.images[i].caption||hotel.name);var imgDimensions=(i==0)?{width:480,height:320}:{width:168,height:126};imageHTML+='<div class="img'+i+'"><img src="'+self.hotelModel.buildImageUrl(hotel.images[i],imgDimensions.width,imgDimensions.height)+'" alt="'+caption.escapeHTML()+'" /></div>'}}else{imageHTML+='<div class="lo-res">';for(i=0;i<3;i++){caption=(hotel.images[i].caption||hotel.name);imageHTML+='<div class="img img'+i+'"><img src="'+self.hotelModel.buildImageUrl(hotel.images[i],168,126)+'" alt="'+caption.escapeHTML()+'" /></div>'}}}else{imageHTML+='<div class="lo-res">';for(i=0;i<hotel.images.length;i++){caption=(hotel.images[i].caption||hotel.name);imageHTML+='<div class="img img'+i+'"><img src="'+self.hotelModel.buildImageUrl(hotel.images[i],168,126)+'" alt="'+caption.escapeHTML()+'" /></div>'}}imageHTML+='<div class="c0pt3r-clear" /><div class="view"><a href="#" class="c0pt3r-primary photos">View all photos ('+hotel.images.length+")</a>";if(hotelObj.vfm&&hotelObj.vfm.url&&$.hasFlash()){var vfmLinkText=(hotelObj.vfm.is_rich)?"View multimedia":"View photo tour";imageHTML+='<a href="#" class="c0pt3r-primary vfm">'+vfmLinkText+"</a>"}imageHTML+="</div></div>";hotelObj.images='<div class="images">'+imageHTML+"</div>"}else{hotelObj.images=""}var amenityTypes={};$.each(hotel.amenities,function(i,amenity){if(!amenityTypes[amenity.type]){amenityTypes[amenity.type]=[]}amenityTypes[amenity.type].push(amenity.name)});var amenityHTML="";$.each(amenityTypes,function(amenityType,amenities){amenityHTML+="<h3>"+amenityType+"</h3>";amenityHTML+="<ul>";$.each(amenities,function(i,amenity){amenityHTML+="<li>"+amenity+"</li>"});amenityHTML+='<div class="c0pt3r-clear" /></ul>'});hotelObj.amenities=amenityHTML;if(hotelObj.hotel_tel){hotelObj.tel=hotelObj.hotel_tel}hotelObj.mapicon=(window.location.hostname=="localhost")?"":"icon:"+encodeURI(self.prefsModel.siteURL+"/"+self.prefsModel.mapIconImage)+"|";$("body").append(application.getFromTemplate($("#hotel-details-template"),hotelObj));if(!hasLogo){$("#hoteldetails .hotel-logo").remove()}if(!hotelObj.hotel_tel||hotelObj.hotel_tel==null){$("#hoteldetails .tel").remove();$("#hoteldetails .website").css({padding:0,border:0})}if(!hotelObj.url||hotelObj.url==null){$("#hoteldetails .website").html("&nbsp;").css("border",0);$("#hoteldetails .tel").css({padding:0,border:0})}if(hotelObj.images.length==0){$("#hoteldetails .images").remove()}if(hotelObj.lat==0&&hotelObj.lng==0){$("#hoteldetails img.map").remove();if(hotelObj.desc.length==0){$("#hoteldetails .desc").remove()}}else{if(hotelObj.desc.length==0){$("#hoteldetails .desc h3").remove();$("#hoteldetails img.map").css({"float":"left",margin:"0px"})}}if(hotel.amenities.length==0){$("#hoteldetails .amenities").remove()}self.hotel=hotelObj;self.liveRates(hotelTID);$("#hoteldetails").css("left",($(document).width()/2)-($("#hoteldetails").width()/2)+"px");$("#hoteldetails").data("scrollTop",scrollTop);$(document).scrollTop(0);self.resizeBackground($("#hoteldetails"),75);self.lightboxView.showOverlay("hoteldetails","#000","fast",self.prefsModel.overlayOpacity,9000);if(!self.ratesModel.isDatedSearch()){self.hideRatesSpinner()}$("#hoteldetails").show()})};Hotel.prototype.liveRates=function(hotelTID){this.bookingDetailsBestRates();this.eventHandlers();if(this.filterModel.hotelLightboxRoomRates==1){this.bookingDetailsRoomRates(hotelTID)}if(this.ratesModel.isPolling){this.showRatesSpinner()}};Hotel.prototype.eventHandlers=function(){var self=this,hotel=this.hotel,target;$("#hoteldetails").unbind();$("#hoteldetails .close").unbind();$("#hoteldetails .website a").unbind();$("#hoteldetails a.hotelier-suite").unbind();$(document).keydown(function(e){if(e.which==27&&$("#lightbox").length==0){self.hide("hoteldetails")}});$("#hoteldetails .close").click(function(e){e.preventDefault();e.stopPropagation();self.hide("hoteldetails");self.trackingModel.record("hd-close",{hotel_tid:self.hotel.tid})});$("#hoteldetails .website a").click(function(e){self.trackingModel.record("hd-website",{hotel_tid:self.hotel.tid,website_url:$(e.target).attr("href")})});$("#hoteldetails a.hotelier-suite").click(function(e){self.trackingModel.record("hd-hs",{hotel_tid:self.hotel.tid})});$("#hoteldetails").click(function(e){target=$(e.target);if(target.is(".images img")){e.stopPropagation();e.preventDefault();var imgClass=$(e.target).parent().attr("class").replace("img ","");self.lightboxView.show(hotel,parseInt(imgClass.replace("img","")));self.trackingModel.record("hd-img",{hotel_tid:self.hotel.tid,image_filename:(function(){var a=target.attr("src").split("/");return a[a.length-1]}()),image_position:$("#hoteldetails .images img").index(target)+1})}if(target.is(".images .view a.photos")){e.stopPropagation();e.preventDefault();self.lightboxView.show(hotel,0);self.trackingModel.record("hd-all-photos",{hotel_tid:self.hotel.tid})}if(target.is(".images .view a.vfm")){e.stopPropagation();e.preventDefault();self.lightboxView.vfm(hotel,0);self.trackingModel.record("hd-vfm",{hotel_tid:self.hotel.tid})}});$("#hoteldetails").bind("c0pt3rRatesPollingInit",function(e){self.bookingDetailsBestRates()})};Hotel.prototype.bookingDetailsBestRates=function(){var self=this,hotelObj=this.hotel,hotelTID=hotelObj.tid,datesRoomsGuests=$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkInDate))+" &#8212 "+$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkOutDate))+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numRooms+" Room"+((self.ratesModel.numRooms==1)?"":"s")+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numGuests+" Guest"+((self.ratesModel.numGuests==1)?"":"s")+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="edit-search-link">Edit Search</a>';$("#hoteldetails .booking-options").empty().html(application.getFromTemplate($("#hotel-details-rates-best-template"),{dates_rooms_guests:datesRoomsGuests}));this.filterHandlersView.editSearch();if((this.ratesModel.isDatedSearch()&&this.hotelModel.displayablePartners(hotelTID).length>0)||this.ratesModel.rates[hotelTID]){self.hideRatesSpinner();self.rateMatrixView.create(hotelTID,$("#hd-rates-best .hd-rates .ratematrix"),true,true);if($("#hoteldetails .ratematrix tr").length<=1){self.showRatesSpinner()}}else{self.hideRatesSpinner();$("#hd-rates-best .best-link, .room-link").remove();if(!this.ratesModel.isDatedSearch()){$("#hd-rates-best .dates-rooms-guests").remove()}if(this.hotelModel.displayablePartners(hotelTID).length==0){if(self.prefsModel.allowUnavailablePhoneNumberDisplay&&hotelObj.hotel_tel){$("#hd-rates-best .hd-rates").html(application.getFromTemplate($("#hotel-details-call-to-book-template"),{tel:hotelObj.hotel_tel}));$("#hoteldetails .booking-options .dates-rooms-guests").remove()}else{$("#hd-rates-best .hd-rates").html(application.getFromTemplate($("#hotel-details-no-rates-template")))}$("#hd-rates-best .disclaimer").remove()}else{$("#hd-rates-best .hd-rates").addClass("hd-rates-dateless");$("#hd-rates-best .hd-rates").html(application.getFromTemplate($("#hotel-details-check-rates-template"),hotelObj.rate))}}this.bookingDetailsEventHandlers(hotelTID);self.resizeBackground($("#hoteldetails"),75)};Hotel.prototype.bookingDetailsRoomRates=function(hotelTID){var self=this,roomRatesObj=self.ratesModel.hotelRatesByRoomType(hotelTID),hasRateExc=false,datesRoomsGuests=$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkInDate))+" &#8212 "+$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkOutDate))+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numRooms+" Room"+((self.ratesModel.numRooms==1)?"":"s")+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numGuests+" Guest"+((self.ratesModel.numGuests==1)?"":"s");$("#hd-room-rates").remove();$("#hd-rates-best").hide();$("#hoteldetails .booking-options").append(application.getFromTemplate($("#hotel-details-room-rates-template"),{dates_rooms_guests:datesRoomsGuests}));var roomTypeCounter=0;$.each(roomRatesObj,function(roomType,roomTypeRates){var obj={room_type:roomType.charAt(0).toUpperCase()+roomType.slice(1),lowest_rate:"$"+((roomTypeRates[0].rate_inc)?roomTypeRates[0].rate_inc:roomTypeRates[0].rate_exc+"*"),index:roomTypeCounter+""};$("#hd-room-rates .hd-rates").append(application.getFromTemplate($("#hotel-details-room-rates-container-template"),obj));var roomRateCounter=0;$.each(roomTypeRates,function(i,rateInfo){if(!rateInfo.rate_inc){hasRateExc=true}rateInfo.button_label="Book Now";rateInfo.partner_name=self.hotelModel.bookDirectPartner(self.hotel.brand,self.partnerModel.data[rateInfo.partner_code].name,self.partnerModel.data[rateInfo.partner_code].is_book_direct).escapeHTML();if(self.partnerModel.data[rateInfo.partner_code].is_book_direct){rateInfo.partner_logo=self.hotelModel.bookDirectLogo(self.hotel.brand,rateInfo.partner_code,self.partnerModel.data[rateInfo.partner_code].is_book_direct,110,60);rateInfo.css_class="bookdirect";rateInfo.button_label="Official Site"}else{rateInfo.partner_logo=self.hotelModel.bookDirectLogo(self.hotel.brand,rateInfo.partner_code,self.partnerModel.data[rateInfo.partner_code].is_book_direct,110,30);rateInfo.css_class=""}rateInfo.index=i+"";rateInfo.room_type_index=roomTypeCounter+"";rateInfo.desc=(rateInfo.desc||'<a href="'+rateInfo.booking_url+'" class="booklink secondary" target="_blank">Check '+self.partnerModel.data[rateInfo.partner_code].name+" for details</a>.");rateInfo.rate_exc_numeric=rateInfo.rate_exc;rateInfo.rate_inc_numeric=rateInfo.rate_inc;rateInfo.rate_exc=(rateInfo.rate_inc)?"$"+rateInfo.rate_exc+"&nbsp;":'<span class="italic">$'+rateInfo.rate_exc+"*</span>";rateInfo.rate_inc=(rateInfo.rate_inc)?"$"+rateInfo.rate_inc:'<span class="nobold">&#8212;&nbsp;</span>';$("#room-type-"+roomTypeCounter+" .rates .rows").append(application.getFromTemplate($("#hotel-details-room-rates-row-template"),rateInfo));if(i>=3){$("#room-rate-"+roomTypeCounter+"-"+i).hide()}roomRateCounter++});if(roomRateCounter>3){$("#room-type-"+roomTypeCounter+" .all-room-rates a.all .num").html(roomRateCounter);$("#room-type-"+roomTypeCounter+" .all-room-rates a.best").hide();$("#room-type-"+roomTypeCounter+" .all-room-rates a.all").show()}else{$("#room-type-"+roomTypeCounter+" .all-room-rates").hide()}roomTypeCounter++});self.resizeBackground($("#hoteldetails"),75);$("#hd-room-rates .hd-rates .room-type:last").css("margin-bottom","0px");if(!hasRateExc){$("#hd-room-rates .taxesfees").remove()}self.hideRatesSpinner()};Hotel.prototype.bookingDetailsEventHandlers=function(hotelTID){var self=this;$("#hoteldetails .booking-options").unbind();$("#hoteldetails .booking-options").mouseover(function(e){e.stopPropagation();if($(e.target).is(".ratebtn, .ratebtn *")){var target=$(e.target);if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}target.children(".c0pt3r-primarylink").removeClass("c0pt3r-primarylink").addClass("c0pt3r-primarylinkhover")}});$("#hoteldetails .booking-options").mouseout(function(e){e.stopPropagation();if($(e.target).is(".ratebtn, .ratebtn *")){var target=$(e.target);if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}target.children(".c0pt3r-primarylinkhover").removeClass("c0pt3r-primarylinkhover").addClass("c0pt3r-primarylink")}});$("#hoteldetails .booking-options").click(function(e){self.rateBubbleView.remove();if($(e.target).is(".ratebtn, .ratebtn *")){e.preventDefault();e.stopPropagation();var target=$(e.target);if(!target.is(".ratebtn")){target=target.parents(".ratebtn")}if($("#rates-popup-"+hotelTID).length==0){self.rateBubbleView.createNoRate(target,hotelTID,{hotel_tid:hotelTID})}else{self.rateBubbleView.remove()}}if($(e.target).is(".room-link a")){e.preventDefault();e.stopPropagation();self.bookingDetailsRoomRates(hotelTID);self.trackingModel.record("hd-room-types",{hotel_tid:self.hotel.tid})}if($(e.target).is(".best-link a")){e.preventDefault();e.stopPropagation();$("#hd-rates-best").show();$("#hd-room-rates").remove();self.resizeBackground($("#hoteldetails"),75);self.trackingModel.record("hd-ratrix",{hotel_tid:self.hotel.tid})}if($(e.target).is("#hoteldetails .booking-options .room-type .heading a.hide")){e.preventDefault();e.stopPropagation();$(e.target).parent().parent().next().hide();$(e.target).hide();$(e.target).next().show();self.resizeBackground($("#hoteldetails"),75)}if($(e.target).is("#hoteldetails .booking-options .room-type .heading a.show")){e.preventDefault();e.stopPropagation();$(e.target).parent().parent().next().show();$(e.target).hide();$(e.target).prev().show();self.resizeBackground($("#hoteldetails"),75)}if($(e.target).is("#hoteldetails .booking-options .all-room-rates a.all")){e.preventDefault();e.stopPropagation();$(e.target).parent().prev().children().show();$(e.target).hide();$(e.target).next().show();self.resizeBackground($("#hoteldetails"),75)}if($(e.target).is("#hoteldetails .booking-options .all-room-rates a.best")){e.preventDefault();e.stopPropagation();$(e.target).parent().prev().children("div:gt(2)").hide();$(e.target).hide();$(e.target).prev().show();$(document).scrollTop($(e.target).parent().parent().position().top-10);self.resizeBackground($("#hoteldetails"),75)}$("#hd-room-rates .btn a").click(function(e){var roomType=$(this).parents("div.room-type").data("model"),roomRate=$(this).parents("div.room-rate").data("model");self.trackingModel.record("hd-room-types-book",{hotel_tid:self.hotel.tid,check_in:self.ratesModel.checkInDate,check_out:self.ratesModel.checkOutDate,rooms:self.ratesModel.numRooms,guests:self.ratesModel.numGuests,partner_code:roomRate.partner_code,room_type:roomType.room_type.stripTags(),room_type_lowest_rate:roomType.lowest_rate.replace("$",""),room_type_description:roomRate.desc.stripTags(),rate_exc:(roomRate.rate_exc_numeric||""),rate_inc:(roomRate.rate_inc_numeric||""),room_type_position:roomRate.room_type_index,is_book_direct:(roomRate.css_class.indexOf("bookdirect")>=0)})})})};Hotel.prototype.resizeBackground=function(el,top){var pageHeight=el.outerHeight()+(top*2);var templateDivHeight=pageHeight-this.heightDiff;$("#c0pt3r").height(templateDivHeight).css({overflow:"hidden"});$("#c0pt3r-footer").css("visibility","hidden");this.lightboxView.resizeOverlay()};Hotel.prototype.close=function(id){$(document).unbind("keydown");this.filtersView.closeAllFilterPopups();$("#c0pt3r-footer").css("visibility","visible");$("#c0pt3r").height("").css({overflow:"visible"});this.lightboxView.resizeOverlay();var scrollTop=($("#"+id).data("scrollTop")||0);$(document).scrollTop(scrollTop);$("#"+id).remove();this.lightboxView.hideOverlay(id)};Hotel.prototype.updateLiveRates=function(complete){var hotelTID=this.filterModel.hotelLightbox;if($("#hoteldetails").length>0){if(complete){this.liveRates(hotelTID)}else{this.showRatesSpinner();if(this.ratesModel.rates[hotelTID]){var rateData=this.ratesModel.lowestHotelRate(hotelTID);var rateHTML="Best So Far: $"+rateData.rate;if(!rateData.inclTaxesFees){rateHTML+="*"}$("#hoteldetails .hd-rates-search").html(rateHTML)}}}};Hotel.prototype.showRatesSpinner=function(){$("#hoteldetails .booking-options").show();$("#hoteldetails .hd-rates").hide();$("#hoteldetails .hd-rates-search").show();$("#hd-rates-best .best-link").hide();$("#hd-rates-best .room-link").hide()};Hotel.prototype.hideRatesSpinner=function(){$("#hoteldetails .hd-rates").show();$("#hoteldetails .hd-rates-search").hide();$("#hd-rates-best .best-link").show();$("#hd-rates-best .room-link").show()};return(new Hotel())})(jQuery,window.application));window.application.addView((function($,application){function RateMatrix(){}RateMatrix.prototype.init=function(){this.hotelView=application.getView("Hotel");this.ratesModel=application.getModel("Rates");this.hotelModel=application.getModel("Hotel");this.partnerModel=application.getModel("Partners");this.prefsModel=application.getModel("Prefs");this.trackingModel=application.getModel("Tracking")};RateMatrix.prototype.create=function(tid,container,noMax,fullRoomDesc){var self=this,rates=[],ratesExcl=[],rateless=[],ratelessPartners=null,bookDirectRate=null,bestRate=null,taxesFeesLabel="",totalPartners=0,maxPartners=6,moreBookingOptions=false,brand=(this.hotelModel.hotels[tid])?this.hotelModel.hotels[tid].brand:this.hotelView.hotel.brand;if(this.ratesModel.rates[tid]){$.each(this.ratesModel.rates[tid].rates,function(partnerCode,partnerRate){totalPartners++;var rateDetails=self.ratesModel.lowestHotelPartnerRateDetails(tid,partnerCode);var partner=self.hotelModel.bookDirectPartner(brand,self.partnerModel.data[partnerCode].name,self.partnerModel.data[partnerCode].is_book_direct);var bookingInfo="";$.each(rateDetails.policies,function(i,policy){bookingInfo+=(i>0)?(" - "+policy):policy});bookingInfo=bookingInfo.strip();bookingInfo=(bookingInfo.length==0)?"See "+partner+" web site for booking and cancellation policies.":partner+" Booking & Cancellation Policy: "+bookingInfo;var obj={css_class:"rate",partner:partner.partner,partner_code:partnerCode,partner_logo:self.hotelModel.bookDirectLogo(brand,partnerCode,self.partnerModel.data[partnerCode].is_book_direct,110,30),room_type:(fullRoomDesc)?rateDetails.roomDesc:rateDetails.roomType.substr(0,1).toUpperCase()+rateDetails.roomType.substr(1),room_type_unformatted:rateDetails.roomType.toLowerCase(),rate_numeric:rateDetails.rate,booking_url:rateDetails.bookingUrl,booking_info:bookingInfo.escapeHTML(),button_label:"Book Now"};if(!obj.room_type||obj.room_type.toLowerCase()=="other"){obj.room_type="&#8212;&nbsp;"}if(rateDetails.inclTaxesFees){obj.rate_inc="$"+rateDetails.rate;if(rateDetails.taxesFees){obj.rate_exc="$"+(rateDetails.rate-rateDetails.taxesFees)}else{obj.rate_exc="&#8212;&nbsp;"}if(!bestRate||(rateDetails.rate<bestRate)){bestRate=rateDetails.rate}}else{obj.rate_exc="$"+rateDetails.rate+"<strong>*</strong>";obj.rate_inc="Check Site";obj.css_class="excl";taxesFeesLabel="<strong>*</strong> Starred prices may not include taxes and fees"}if(self.partnerModel.data[partnerCode].is_book_direct){obj.partner_logo=self.hotelModel.bookDirectLogo(brand,partnerCode,self.partnerModel.data[partnerCode].is_book_direct,110,60);obj.button_label="Official Site";obj.css_class="bookdirect";bookDirectRate=obj}else{if(!rateDetails.inclTaxesFees){ratesExcl.push(obj)}else{rates.push(obj)}}});rates.sort(function(a,b){return a.rate_numeric-b.rate_numeric});ratesExcl.sort(function(a,b){return a.rate_numeric-b.rate_numeric})}ratelessPartners=self.hotelModel.displayableRatelessPartners(tid);$.each(ratelessPartners,function(i,ratelessPartner){totalPartners++;var obj={css_class:"rate rateless",partner:ratelessPartner.name,partner_code:ratelessPartner.code,room_type:"&#8212;",room_type_unformatted:"",rate_numeric:null,rate_exc:(ratelessPartner.rate_from)?("From $"+ratelessPartner.rate_from+"<strong>*</strong>"):"Check Site",rate_inc:"Check Site",booking_url:(ratelessPartner.key=="RATRIXLISTING")?ratelessPartner.link:self.ratelessLink(ratelessPartner.link),booking_info:"See "+ratelessPartner.name.escapeHTML()+" web site for booking and cancellation policies.",button_label:"Check Rates"};if(ratelessPartner.is_book_direct){obj.partner_logo=(ratelessPartner.key=="RATRIXLISTING")?(ratelessPartner.logo_root+"110x60/"+ratelessPartner.logo_image):self.hotelModel.bookDirectLogo(brand,ratelessPartner.code,self.partnerModel.data[ratelessPartner.code].is_book_direct,110,60);obj.button_label="Official Site";obj.css_class="rateless bookdirect";bookDirectRate=obj}else{obj.partner_logo=self.hotelModel.bookDirectLogo(brand,ratelessPartner.code,self.partnerModel.data[ratelessPartner.code].is_book_direct,110,30);rateless.push(obj)}});rateless.sort(function(){return Math.random()-0.5});rates=rates.concat(ratesExcl);rates=rates.concat(rateless);if(bookDirectRate){rates.splice(0,0,bookDirectRate)}if(!noMax&&(totalPartners>maxPartners)){rates.splice((maxPartners-1),(totalPartners-maxPartners));moreBookingOptions=true}var rowsHTML="";$.each(rates,function(i,obj){if(obj.css_class!="excl"&&obj.rate_numeric==bestRate&&obj.rate_numeric!=null){obj.css_class+=" bestrate"}rowsHTML+=application.getFromTemplate($("#rate-matrix-row-template"),obj).outerHTML()});container.append(application.getFromTemplate($("#rate-matrix-template"),{table_rows:rowsHTML,taxes_fees_label:taxesFeesLabel}));$.each(rates,function(i,obj){obj=$.extend(obj,{position:i+1,num_rows:rates.length});container.find("table tr").eq(i+1).data("obj",obj)});if(!self.ratesModel.rates[tid]){$("#rates-popup-"+tid+" .roomtypes").remove()}if(!moreBookingOptions){$("#rates-popup-"+tid+" .more").remove()}this.eventHandlers(tid)};RateMatrix.prototype.ratelessLink=function(url){url+="&api_key="+encodeURI(this.prefsModel.apiKey)+"&api_version="+encodeURI(this.prefsModel.apiVersion);if(this.ratesModel.isDatedSearch){var checkInDate=this.ratesModel.checkInDate.split("-"),checkOutDate=this.ratesModel.checkOutDate.split("-");url+="&d1="+encodeURI(checkInDate[2]);url+="&m1="+encodeURI(checkInDate[1]);url+="&y1="+encodeURI(checkInDate[0]);url+="&d2="+encodeURI(checkOutDate[2]);url+="&m2="+encodeURI(checkOutDate[1]);url+="&y2="+encodeURI(checkOutDate[0]);url+="&r="+encodeURI(this.ratesModel.numRooms);url+="&g="+encodeURI(this.ratesModel.numGuests)}return url};RateMatrix.prototype.eventHandlers=function(tid){var self=this;$(".ratematrix .button a").click(function(e){var obj=$(this).parents("tr").data("obj"),trackingCode=($(e.target).parents("#hoteldetails"))?"hd-ratrix-book":"sr-ratrix-book";self.trackingModel.record(trackingCode,{hotel_tid:tid,check_in:self.ratesModel.checkInDate,check_out:self.ratesModel.checkOutDate,rooms:self.ratesModel.numRooms,guests:self.ratesModel.numGuests,partner_code:obj.partner_code,room_type:obj.room_type_unformatted,rate:(obj.rate_numeric||""),ratrix_position:obj.position,is_best_rate:(obj.css_class.indexOf("bestrate")>=0),is_book_direct:(obj.css_class.indexOf("bookdirect")>=0),num_ratrix_rows:obj.num_rows})})};return(new RateMatrix())})(jQuery,window.application));window.application.addView((function($,application){function RateBubble(){}RateBubble.prototype.init=function(){this.ratesModel=application.getModel("Rates");this.hotelModel=application.getModel("Hotel");this.partnerModel=application.getModel("Partners");this.trackingModel=application.getModel("Tracking");this.filterHandlerView=application.getView("FilterHandlers");this.bubbleView=application.getView("Bubble");this.hotelView=application.getView("Hotel");this.rateMatrixView=application.getView("RateMatrix")};RateBubble.prototype.bestHotelRate=function(target,tid,trackingData){var self=this;if($("#rates-popup-"+tid).length==0){self.remove();if((this.ratesModel.isDatedSearch()&&this.hotelModel.displayablePartners(tid).length>0)||this.ratesModel.rates[tid]){if(target.parents(".sponsoredcard").length>0){self.trackingModel.record("sr-sponsored-ratrix",$.extend(trackingData,{displayed_rate:$("#sponsoredcard_"+tid).find(".rate").html().stripTags().replace("$","").replace("*","")}))}else{self.trackingModel.record("sr-ratrix",$.extend(trackingData,{displayed_rate:$("#hotelcard_"+tid).find(".rate").html().stripTags().replace("$","").replace("*","")}))}self.create(target,tid)}else{self.createNoRate(target,tid,trackingData)}}else{self.remove()}};RateBubble.prototype.create=function(target,tid){var self=this,hotelName=self.hotelModel.hotels[tid].name;var bubbleContents=application.getFromTemplate($("#rates-popup-template"),{id:tid,hotel_name:hotelName,dates_rooms_guests:$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkInDate))+" &#8212 "+$.datepicker.formatDate("D. M d, yy",$.datepicker.parseDate("yy-mm-dd",self.ratesModel.checkOutDate))+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numRooms+" Room"+((self.ratesModel.numRooms==1)?"":"s")+"&nbsp;&nbsp;&nbsp;"+self.ratesModel.numGuests+" Guest"+((self.ratesModel.numGuests==1)?"":"s")});$("body").append(bubbleContents);self.rateMatrixView.create(tid,bubbleContents.children(".ratematrix"));self.eventHandlers(tid);self.show(target,null,null)};RateBubble.prototype.createNoRate=function(target,tid,trackingData){var self=this,obj={id:tid},width,height,targetType=(function(){if($(target).parents("#hoteldetails").length>0){return"hd"}else{return"sr-card"}}()),hotel=self.hotelModel.hotels[tid];if(target.hasClass("ratebtn-norate")){self.trackingModel.record((targetType+"-no-rates"),trackingData);if(self.hotelModel.isCallToBook(hotel.tid)){obj.tel=hotel.tel;$("body").append(application.getFromTemplate($("#call-to-book-popup-template"),obj))}else{$("body").append(application.getFromTemplate($("#no-rates-popup-template"),obj))}width=260;height=80}else{if(!this.ratesModel.isDatedSearch()){if(target.parents(".sponsoredcard").length>0){self.trackingModel.record(targetType+"-sponsored-check",$.extend(trackingData,{displayed_rate:$("#sponsoredcard_"+tid).find(".rateamount").html().stripTags().replace("$","").replace("*","")}))}else{self.trackingModel.record(targetType+"-check",$.extend(trackingData,{displayed_rate:$("#hotelcard_"+tid).find(".rateamount").html().stripTags().replace("$","").replace("*","")}))}var noRatesBubbleContents=application.getFromTemplate($("#dateless-rates-popup-template"),obj);$("body").append(noRatesBubbleContents);width=290;height=260;self.filterHandlerView.editSearchForm(targetType,trackingData);noRatesBubbleContents.click(function(e){e.stopPropagation();$(".datepop1,.datepop2").hide()})}}self.eventHandlers(tid);self.show(target,width,height)};RateBubble.prototype.eventHandlers=function(tid){var self=this,trackingData={hotel_tid:tid,num_ratrix_rows:($(".ratematrix tr").length-1)};$(".rates-popup").click(function(e){e.stopPropagation()});$("body").bind("click.ratespop",function(){self.remove()});$(".rates-popup a.roomtypes").click(function(e){e.preventDefault();e.stopPropagation();self.trackingModel.record("sr-ratrix-room",trackingData);self.hotelView.show(tid,1)});$(".rates-popup a.propertydetails, .rates-popup a.more, .no-rates-popup .more a").click(function(e){e.preventDefault();e.stopPropagation();var trackingCode=($(e.target).is("a.propertydetails"))?"sr-ratrix-details":"sr-ratrix-more";self.trackingModel.record(trackingCode,trackingData);self.hotelView.show(tid)});$(".rates-popup .close a, .no-rates-popup .close a").click(function(e){e.preventDefault();e.stopPropagation();self.remove()})};RateBubble.prototype.show=function(target,width,height){if(!width||!height){var el=$(".rates-popup, .no-rates-popup");width=(width||el.outerWidth(true));height=(height||el.outerHeight(true))}var targetRate=target.find(".rate");this.bubbleView.create($(".rates-popup, .no-rates-popup"),"rates-bubble",targetRate,width,height,[{top:targetRate.offset().top+(targetRate.outerHeight()/2),left:targetRate.offset().left+targetRate.outerWidth()-13,alignment:"right",arrowPos:40},{top:targetRate.offset().top+targetRate.outerHeight()+1,left:targetRate.offset().left+(targetRate.width()/2),alignment:"bottom",arrowPos:width-15},{top:targetRate.offset().top+targetRate.outerHeight()+1,left:targetRate.offset().left+(targetRate.width()/2),alignment:"bottom",arrowPos:40}])};RateBubble.prototype.remove=function(){this.bubbleView.removeAll();$(".datepop1,.datepop2").hide();$("body").unbind("click.ratespop")};return(new RateBubble())})(jQuery,window.application));window.application.addView((function($,application){function Bubble(){this.closestPos={};this.arrowBGUrl="img/bubble/bg.png";this.distFromArrowPoint=7;this.borderSize=12}Bubble.prototype.init=function(){var self=this;this.prefsModel=application.getModel("Prefs");$(window).resize(function(){self.resize()})};Bubble.prototype.getTemplate=function(id){return'<div id="'+id+'" class="c0pt3r-reset bubble"><div class="bubble-arrow" /><div class="bubble-inner"><div class="tl" /><div class="t" /><div class="tr" /><div class="c0pt3r-clear" /><div class="l" /><div class="content" /><div class="r" /><div class="c0pt3r-clear" /><div class="bl" /><div class="b" /><div class="br" /><div class="c0pt3r-clear" /></div></div>'};Bubble.prototype.centeredDialog=function(el,id,w,h,overlay){if(overlay){this.showOverlay()}var bubble=$(this.getTemplate(id));bubble.find(".content").css({width:w+"px",height:h+"px"}).append(el);bubble.find(".t, .b").css({width:w+"px"});bubble.find(".l, .r").css({height:h+"px"});var bubbleWidth=(w+(this.borderSize*2)),bubbleHeight=(h+(this.borderSize*2)),bubbleLeft=($(window).width()-bubbleWidth)/2,bubbleTop=($(window).height()-bubbleHeight)/2;bubble.css({top:bubbleTop+"px",left:bubbleLeft+"px",width:bubbleWidth+"px",height:bubbleHeight+"px",position:"fixed"});$("body").append(bubble);bubble.fadeIn("fast");return bubble};Bubble.prototype.create=function(el,id,target,w,h,positions){if($("#"+id).length==0){this.removeAll();var bubble=this.build(el,id,target,w,h,$(document),positions,true);$("body").append(bubble);bubble.fadeIn("fast");$("#"+id+",#"+id+"-arrow").click(function(e){e.stopPropagation()})}else{this.removeAll()}};Bubble.prototype.build=function(el,id,target,w,h,container,positions,scrollIntoView){var self=this,iPos=null;self.closestPos={iPos:null,px:null};if(!w||!h){$("body").append(el);w=(w||el.outerWidth(true));h=(h||el.outerHeight(true))}var html=this.getTemplate(id);$.each(positions,function(i,position){switch(position.alignment){case"top":positions[i].bubbleWidth=w+(self.borderSize*2);positions[i].bubbleHeight=h+(self.borderSize*2)+self.distFromArrowPoint;positions[i].bubbleTop=position.top-positions[i].bubbleHeight;positions[i].bubbleLeft=position.left-position.arrowPos;positions[i].arrowWidth=27;positions[i].arrowHeight=15;positions[i].arrowTop=(h+(self.borderSize*2))-self.distFromArrowPoint-1;positions[i].arrowLeft=position.arrowPos-Math.round(positions[i].arrowWidth/2);positions[i].innerTop=0;positions[i].innerLeft=0;positions[i].arrowBG="url("+self.arrowBGUrl+") no-repeat -15px -27px";break;case"right":positions[i].bubbleWidth=w+(self.borderSize*2)+self.distFromArrowPoint;positions[i].bubbleHeight=h+(self.borderSize*2);positions[i].bubbleTop=position.top-position.arrowPos;positions[i].bubbleLeft=position.left+self.distFromArrowPoint;positions[i].arrowWidth=15;positions[i].arrowHeight=27;positions[i].arrowTop=position.arrowPos-Math.round(positions[i].arrowHeight/2);positions[i].arrowLeft=0;positions[i].innerTop=0;positions[i].innerLeft=self.distFromArrowPoint;positions[i].arrowBG="url("+self.arrowBGUrl+") no-repeat 0px -15px";break;case"bottom":positions[i].bubbleWidth=w+(self.borderSize*2);positions[i].bubbleHeight=h+(self.borderSize*2)+self.distFromArrowPoint;positions[i].bubbleTop=position.top;positions[i].bubbleLeft=position.left-position.arrowPos;positions[i].arrowWidth=27;positions[i].arrowHeight=15;positions[i].arrowTop=0;positions[i].arrowLeft=position.arrowPos-Math.round(positions[i].arrowWidth/2);positions[i].innerTop=self.distFromArrowPoint;positions[i].innerLeft=0;positions[i].arrowBG="url("+self.arrowBGUrl+") no-repeat 0px 0px";break;case"left":positions[i].bubbleWidth=w+(self.borderSize*2)+self.distFromArrowPoint;positions[i].bubbleHeight=h+(self.borderSize*2);positions[i].bubbleTop=position.top-position.arrowPos;positions[i].bubbleLeft=position.left-positions[i].bubbleWidth;positions[i].arrowWidth=15;positions[i].arrowHeight=27;positions[i].arrowTop=position.arrowPos-Math.round(positions[i].arrowHeight/2);positions[i].arrowLeft=(w+(self.borderSize*2))-self.distFromArrowPoint-1;positions[i].innerTop=0;positions[i].innerLeft=0;positions[i].arrowBG="url("+self.arrowBGUrl+") no-repeat -27px 0px";break}var fitsLeft=(positions[i].relativeLeft)?((positions[i].bubbleLeft-positions[i].left)+positions[i].relativeLeft):positions[i].bubbleLeft;var fitsTop=(positions[i].relativeTop)?((positions[i].bubbleTop-positions[i].top)+positions[i].relativeTop):positions[i].bubbleTop;var fit=self.fit(container,fitsLeft,fitsTop,positions[i].bubbleWidth,positions[i].bubbleHeight);if(fit.bubbleFits){iPos=i;return false}else{if((self.closestPos.px==null)||(fit.inaccuracyPx<self.closestPos.px)){self.closestPos.iPos=i;self.closestPos.px=fit.inaccuracyPx}}});if(iPos==null){iPos=self.closestPos.iPos}var bubble=$(html);if(scrollIntoView){var scrollTop=Math.round((positions[iPos].bubbleTop+(h+(self.borderSize*2)))-$(window).height());if(scrollTop>$(document).scrollTop()){$("html,body").animate({scrollTop:scrollTop+10},500)}else{if(positions[iPos].bubbleTop<$(document).scrollTop()){$("html,body").animate({scrollTop:positions[iPos].bubbleTop-10},500)}}}bubble.find(".content").css({width:w+"px",height:h+"px"}).append(el);bubble.find(".t, .b").css({width:w+"px"});bubble.find(".l, .r").css({height:h+"px"});bubble.find(".bubble-arrow").css({top:positions[iPos].arrowTop+"px",left:positions[iPos].arrowLeft+"px",width:positions[iPos].arrowWidth+"px",height:positions[iPos].arrowHeight+"px",background:positions[iPos].arrowBG});bubble.find(".bubble-inner").css({top:positions[iPos].innerTop+"px",left:positions[iPos].innerLeft+"px"});bubble.css({top:positions[iPos].bubbleTop+"px",left:positions[iPos].bubbleLeft+"px",width:positions[iPos].bubbleWidth+"px",height:positions[iPos].bubbleHeight+"px"});if(target){bubble.data("target",target);bubble.data("diffX",(positions[iPos].bubbleLeft-$(target).offset().left));bubble.data("diffY",(positions[iPos].bubbleTop-$(target).offset().top))}return bubble};Bubble.prototype.fit=function(container,l,t,w,h){var fitsLeft=(l>=2);var fitsTop=(t>=2);var fitsRight=((l+w)<=container.width());var fitsBottom=((t+h)<=container.height());var inaccuracyPx=this.minZero(2-l)+this.minZero(2-t)+this.minZero((l+w)-container.width())+this.minZero((t+h)-container.height());return{bubbleFits:(fitsLeft&&fitsTop&&fitsRight&&fitsBottom),inaccuracyPx:inaccuracyPx}};Bubble.prototype.minZero=function(i){return(i<0)?0:i};Bubble.prototype.removeAll=function(){$(".bubble").empty().remove();$(".bubbleoverlay").remove()};Bubble.prototype.showOverlay=function(){var overlay=$('<div class="bubbleoverlay" />');$("body").append(overlay);this.resizeOverlay();overlay.css({"background-color":"#000"}).show().fadeTo("fast",this.prefsModel.overlayOpacity)};Bubble.prototype.resizeOverlay=function(){$(".bubbleoverlay").height(1);$(".bubbleoverlay").height($(document).height())};Bubble.prototype.resize=function(){var target=$(".bubble").data("target"),x,y;if(target){x=$(target).offset().left+$(".bubble").data("diffX");y=$(target).offset().top+$(".bubble").data("diffY")}else{x=($(window).width()-$(".bubble").width())/2;y=($(window).height()-$(".bubble").height())/2}$(".bubble").css({left:x+"px",top:y+"px"})};return(new Bubble())})(jQuery,window.application));window.application.addView((function($,application){function Hotelicopter(){}Hotelicopter.prototype.init=function(){this.advertiserAnim=false;this.advertiserArrowHandlers()};Hotelicopter.prototype.advertiserArrowHandlers=function(){var self=this;$("#advertisers .arrowleft").click(function(e){self.advertiserArrow("left")});$("#advertisers .arrowright").click(function(e){self.advertiserArrow("right")})};Hotelicopter.prototype.advertiserArrow=function(direction){if(!this.advertiserAnim){var self=this,carousel=$("#advertisers .carousel"),carouselLeft=carousel.position().left,carouselWidth=carousel.width(),imgWidth=151,newPos=null;if(direction=="left"&&carouselLeft<0){newPos=(carouselLeft+imgWidth)}else{if(direction=="right"&&(((0-carouselLeft)+imgWidth)<carouselWidth)){newPos=(carouselLeft-imgWidth)}}if(newPos!=null){this.advertiserAnim=true;carousel.animate({left:newPos+"px"},600,function(){self.advertiserAnim=false});$("#advertisers .arrowleft, #advertisers .arrowright").removeClass("disabled");if(newPos==0){$("#advertisers .arrowleft").addClass("disabled")}if(0-(newPos-imgWidth)==carouselWidth){$("#advertisers .arrowright").addClass("disabled")}}}};return(new Hotelicopter())})(jQuery,window.application));
