$(function(){$("body").addClass("js-enabled");if($("#hostel-field-group")[0]){var a='<div class="field-group"><label for="hostel_state_id">State</label><select name="hostel.state_id" id="hostel_state_id">';a+='<option value="all"';if(hostel_state_id=="all"){a+='selected="selected"'}a+=">All States</option>";for(var d=0;d<states.length;d++){a+='<option value="'+states[d][0]+'"';if(hostel_state_id==states[d][0]){a+='selected="selected"'}a+=">"+states[d][1]+"</option>"}a+="</select></div>";$("#hostel-field-group").before(a);$("#hostel_state_id").change(function(){var n=$(this).val();$("#hostel_top_code")[0].selectedIndex=0;$("#hostel_code option").remove();var m='<option value="">Please select</option>';var p=false;if(n=="all"){for(var o=0;o<hostels.length;o++){if(hostels[o][3]==1000&&!p){p=true;m+='<option value="" disabled="disabled">------------------------------</option>'}m+='<option value="'+hostels[o][0]+'">'+hostels[o][1]+"</option>"}}else{for(var o=0;o<state_hostels[n].length;o++){if(state_hostels[n][o][3]==1000&&!p){p=true;m+='<option value="" disabled="disabled">------------------------------</option>'}m+='<option value="'+state_hostels[n][o][0]+'">'+state_hostels[n][o][1]+"</option>"}}$("#hostel_code").html(m)});$("#hostel_top_code").change(function(){$("#hostel_state_id")[0].selectedIndex=0;$("#hostel_code")[0].selectedIndex=0});$("#hostel_code").change(function(){$("#hostel_top_code")[0].selectedIndex=0})}$(".package-description").hide();$(".package-description-icon a").click(function(){var i=$(this).parents(".package-description-icon").attr("id").replace("package-description-icon-","");$("#package-description-"+i).toggle();return false});$('<div id="cvn-instructions-icon"/>').insertBefore("#cvn-instructions").click(function(){$("#cvn-instructions").toggle()});initialise_tabs();if($("body#booking.new")[0]){var k=$("#booking_arrival_date option:selected").attr("value").split("/");var j=parseInt(k[2]);var e=parseInt(k[1]);var l='<select name="booking.arrival_date_month_year" id="booking_arrival_date_month_year">';var f=arrival_date_start;var g,h,c;while(f<=arrival_date_end){g=f.getMonth()+1;h=f.getFullYear();c="";if(h==j&&g==e){c=' selected="selected"'}l+='<option value="'+g+"/"+h+'"'+c+">"+month_abbrev(g)+" "+h+"</option>";f=new Date(f.setMonth(f.getMonth()+1))}l+="</select>";$("#booking_arrival_date").before(l);arrival_date_start=new Date(arrival_date_start.setMonth(arrival_date_start.getMonth()-1));var b=new Date($("#booking_arrival_date_month_year option:selected").attr("value").replace("/","/1/"));build_date_select(b);$("#booking_arrival_date_month_year").change(function(){b=new Date($("#booking_arrival_date_month_year option:selected").attr("value").replace("/","/1/"));build_date_select(b)});$("#booking_arrival_date").remove()}});function build_date_select(a){var f=$("#booking_arrival_date option:selected");if(f.length==0){f=$("#booking_arrival_date_month_year option:selected")}var e=parseInt(f.attr("value").split("/")[0]);$("#booking_arrival_date_date").remove();var b='<select name="booking.arrival_date_date" id="booking_arrival_date_date">';var c;var d="";for(var g=1;g<=days_in_month(a);g++){c=new Date(a.getFullYear(),a.getMonth(),g);if(c<arrival_date_start||c>arrival_date_end){continue}if(c.getDate()==e){d=' selected="selected"'}b+='<option value="'+c.getDate()+'"'+d+">"+day_abbrev(c.getDay())+" "+c.getDate()+"</option>";d=""}b+="</select>";$("#booking_arrival_date_month_year").after(b)}var HIDE_TAB_BUTTON_TEXT=true;var tab_click_callback={};var tab_buttons_initialised={};var tab_replace_anchor={};function initialise_tabs(){var a,c;var b=$(".tabs");b.each(function(d,f){if(tab_buttons_initialised[f.id]){return}$(this).prepend('<ul class="tab-buttons" id="tab-buttons-'+d+'"></ul>');var e=$(this).find(".tab-content");if(e.length==0){return}e.each(function(){if(HIDE_TAB_BUTTON_TEXT){a=$(this).find(".tab-button-text").text();$(this).find(".tab-button-text").hide()}$("#tab-buttons-"+d).append('<li id="tab-buttons-'+$(this)[0].id+'"><a href="#'+tab_text_to_id(a)+'"><span>'+a+"</span></a></li>");$("#tab-buttons-"+$(this)[0].id).click(tab_button_click);$(this).hide();$(this)[0].id="tab-"+$(this)[0].id});c=null;if(location.hash!=""){var g=location.hash.replace("#","")}if(location.hash!=""&&$("#tab-"+g).hasClass("tab-content")){c="tab-"+g}else{if($(this).find(".tab-content.tab-visible").length>0){c=$(this).children(".tab-content.tab-visible")[0].id}else{c=$(this).children(".tab-content")[0].id}}if(c!=null){show_tab(c)}})}function tab_button_click(d){var b=$(this)[0].id.replace("tab-buttons-","");show_tab("tab-"+b);var c=$("#tab-"+b);var a=c.parent(".tabs");if(tab_replace_anchor[a[0].id]){location.href="#"+b}}function show_tab(c){var b=$("#"+c);var a=b.parent(".tabs");a.children(".tab-content:visible").each(function(){$(this).hide()});b.show();$("li.tab-current",a).removeClass("tab-current");$("#tab-buttons-"+c.replace("tab-","")).addClass("tab-current");$("#tab-buttons-"+c.replace("tab-","")).find("a")[0].blur();if(tab_click_callback[a[0].id]!=null){tab_click_callback[a[0].id].call(this,c)}}function tab_text_to_id(a){return a.replace(/[^a-z0-9]+/gi,"-").replace(/-{2,}/gi,"-").toLowerCase()}var month_abbreviations=[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function month_abbrev(a){return month_abbreviations[a]}var month_days=[31,28,31,30,31,30,31,31,30,31,30,31];function days_in_month(a){var b=0;if((a.getFullYear()%400==0&&a.getFullYear()%100!=0)||a.getFullYear()%4==0){b=1}return month_days[a.getMonth()+b]}var day_abbreviations=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function day_abbrev(a){return day_abbreviations[a]};
