// JQuery Formalize plugin:
var FORMALIZE=function(a,b,c){var d="placeholder"in c.createElement("input"),e="autofocus"in c.createElement("input"),f=!!a.browser.msie&&parseInt(a.browser.version,10)===6,g=!!a.browser.msie&&parseInt(a.browser.version,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){g&&a("textarea, input.input_full").length&&a("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(f&&a("input, select, textarea").length){var b=/button|submit|reset/,c=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;a("input").each(function(){var d=a(this);this.getAttribute("type").match(b)?(d.addClass("ie6_button"),this.disabled&&d.addClass("ie6_button_disabled")):this.getAttribute("type").match(c)&&(d.addClass("ie6_input"),this.disabled&&d.addClass("ie6_input_disabled"))}),a("textarea, select").each(function(){this.disabled&&a(this).addClass("ie6_input_disabled")})}},autofocus:function(){e||!a(":input[autofocus]").length||a(":input[autofocus]:visible:first").focus()},placeholder:function(){!d&&!!a(":input[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");b.focus(function(){b.val()===c&&b.val("").removeClass("placeholder")}).blur(function(){FORMALIZE.misc.add_placeholder()}),b.closest("form").submit(function(){b.val()===c&&b.val("").removeClass("placeholder")}).bind("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){d||!a(":input[placeholder]").length||a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");(!b.val()||b.val()===c)&&b.val(c).addClass("placeholder")})}}}}(jQuery,this,this.document);

// jQuery preload plugin
(function(a){a.preload=function(){var c=[],b=arguments.length;for(;b--;){c.push(a("<img />").attr("src",arguments[b]));}};})(jQuery);

// jQuery UI Touch Punch 0.2.1
(function(a){function e(a,b){if(a.originalEvent.touches.length>1)return;a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}a.support.touch="ontouchend"in document;if(!a.support.touch)return;var b=a.ui.mouse.prototype,c=b._mouseInit,d;b._touchStart=function(a){var b=this;if(d||!b._mouseCapture(a))return;d=!0,b._touchMoved=!1,e(a,"mouseover"),e(a,"mousemove"),e(a,"mousedown")},b._touchMove=function(a){if(!d)return;this._touchMoved=!0,e(a,"mousemove")},b._touchEnd=function(a){if(!d)return;e(a,"mouseup"),e(a,"mouseout"),this._touchMoved||e(a,"click"),d=!1},b._mouseInit=function(){var b=this;b.element.bind("touchstart",a.proxy(b,"_touchStart")).bind("touchmove",a.proxy(b,"_touchMove")).bind("touchend",a.proxy(b,"_touchEnd")),c.call(b)}})(jQuery);

// VRA:
function getCheckBox(checkBoxName){return $jq("input:checkbox[name='"+checkBoxName+"']");}
function getCheckBoxChecked(checkBoxName){var cb=getCheckBox(checkBoxName);return $jq(cb).attr("checked");}
function setCheckBoxChecked(checkBoxName,tf){var cb=getCheckBox(checkBoxName);if(tf)$jq(cb).attr("checked","checked");else $jq(cb).attr("checked","");}
function circleLoader(element){$jq(element).html(VRA.circleLoaderHtml).show();}
function callPhpMethod(cls,mthd,params,element,callback,feedbackElement,completionMessage,checkMarkSize,datTyp){var phpFile="/includes/functions/ajax_func_user.php";var phpParams={cls:cls,mthd:mthd,vars:params};if(params.indexOf("json=1")>-1){datTyp="json"}if(feedbackElement!=null){circleLoader(feedbackElement);if(callback==null){var callback=function(){ajaxCompletionMessage(feedbackElement,completionMessage,checkMarkSize)}}}if(datTyp==undefined){datTyp="html"}if(element==null){$jq.ajax({type:"POST",url:phpFile,data:phpParams,success:callback,dataType:datTyp})}else{if(params.indexOf("noLoadingFeedback=1")==-1){circleLoader(element)}$jq(element).load(phpFile,phpParams,callback)}}
function incrContactPageVisits(){callPhpMethod(null,"incrPageVisits","param0=contact");}
function ajaxCompletionMessage(element,message,checkMarkSize){if(message==undefined){if(checkMarkSize==undefined)checkMarkSize=16;message=""}if(checkMarkSize>0)message+=getCheckMark(checkMarkSize);$jq(element).hide().html(message).fadeIn("fast")}
function emptyTextInput(ti){ti.value="";}
function pasteInputValue(value,to){$jq('#'+to.replace("[","\\[").replace("]","\\]")).attr("value",value);}
function togFav(propertyID,onFavesPage){var btn = $jq('#favTog'+propertyID);btn.addClass('toggling');circleLoader(btn);$jq.get('/includes/functions/ajax_favorites.php','propertyID='+propertyID,function(returnVars){var includeText = btn.hasClass("t");btn.removeClass('toggling').toggleClass("y",returnVars.isFavorite).attr("title",returnVars.isFavorite ? "Remove from my picks." : "Add to my picks.").html(returnVars.isFavorite ? (includeText ? "remove from picks" : "") : (includeText ? "add to picks" : ""));$jq('.ovalbutton.favlnk > em').html(returnVars.count);if (onFavesPage && !returnVars.isFavorite)$jq('#listing'+propertyID).hide();},"json");}
function matchDatePicker(from,to,def,offset){var fromDate=$jq('#'+from).datepicker("getDate");if(fromDate)var fromTime=fromDate.getTime();var toDate=$jq('#'+to).datepicker("getDate");if(toDate)var toTime=toDate.getTime();if(!toTime||fromTime>=toTime){var toDate=$jq('#'+from).datepicker("getDate");toDate.setDate(toDate.getDate()+offset);if(def)$jq('#'+to).datepicker("option","defaultDate",toDate);else $jq('#'+to).datepicker("setDate",toDate)}}
VRA.showGenericAlert = function(title,message,modal){if(modal==undefined) modal=false;$jq('#ui-dialog-title-genericAlert').html(title);$jq('#genericAlert').dialog("option","modal",modal);$jq('#genericAlert').html(message).dialog('open');}
function popUp(u,n,w,h,l,t,rs,s){var URL=u;var Name=n;var winparams="location=0,menubars=0,toolbars=0,width="+w+",height="+h+",left="+l+",top="+t+",resizable="+rs+",scrollbars="+s;return window.open(URL,Name,winparams);}
function submitContactForm(){if($jq.browser.webkit){if(!formIsValid("#contact_form")){showGenericContactFormError();return false}}var a=$jq("#contact_form").serialize();$jq("input[type=submit]").val("Submitting...");callPhpMethod("contact_pages/ContactAjax","submitForm",a,"#contact_form_container",VRA.contactFormSubmitted);return false};
function showGenericContactFormError() {VRA.showGenericAlert("Check Dates &amp; Rates", 'Please complete all items marked "<span class="required_symbol">*</span>"')}
function rgx(subj,pat){var re=new RegExp(pat);return re.test(subj)}
function regexValidate(inpt,pat){var valid=inputIsValid(inpt,pat);$jq(inpt).toggleClass("valid",valid).toggleClass("invalid",!valid)}
function inputIsValid(inpt,pat){var subj=$jq(inpt).val();return rgx(subj,pat)}
function formIsValid(b){var a=true;$jq(b).find('input[pattern][required="required"]').add('select[required="required"]',$jq(b)).each(function(c){if(($jq(this).attr("pattern")&&!inputIsValid(this,$jq(this).attr("pattern")))||($jq(this).attr("title")&&!inputIsValid(this,$jq(this).attr("title")))){a=false}});return a};
function togglePlaceHolderClass(sel){$jq(sel).toggleClass('placeholder',$jq(sel).children(':selected').first().hasClass('placeholder'));}
function toggleCheckbox(id){setCheckBoxChecked(id,!getCheckBoxChecked(id));}
