$(document).ready(function() { /******** HINT starts *********/ //$("input[title!='']").hint(); /******** HINT ends *********/ /******** Set body calss starts *********/ class_name = get_language_class('en'); $("body").removeClass(); $("body").addClass(class_name); /******** Set body calss ends *********/ /******** FLASH starts ********/ if($(".banner-img-wrapper").length == 0 && typeof $.flash != "undefined") { if(!($.flash.available && $.flash.hasVersion(9.1))) { $("head").append(""); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://bitebankmedia.com/public/css/flash_plugin.css" }); $('.banner').html('

Woops! Please install Adobe Flash Player or download a newer version of Adobe Flash Player to view this content. It\'s easy to install, just click on the button below.

'); } } /******** FLASH ends ********/ /******** ajax refresh starts******/ $("#selectClientLang").change(function () { set_cookie_n_get_page_content($("#selectClientLang").val()); }); //$(".change_language").click(function(){ //var language_text = $(this).text(); //language_text = language_text.toLowerCase(); //set_cookie_n_get_page_content(language_text); //}); /******** ajax refresh ends *******/ /******** newsletter form starts ************/ $("").appendTo("#form_newsletter_sign_up"); $("#form_newsletter_sign_up").submit(function() { $("#form_newsletter_sign_up .error_right ").html(""); }).validate({ rules: { newsletter_email: { required: true, email: true } }, messages: { newsletter_email: { required: "Email is required", email: "Valid email is required" } }, errorElement: "label", errorLabelContainer: $("#form_newsletter_sign_up .error_right ") }); /******** newsletter form ends ************/ /******** newsletter with name form starts ***************/ $("").appendTo("#form_newsletter_with_name_sign_up"); $("#form_newsletter_with_name_sign_up").submit(function() { $("#form_newsletter_with_name_sign_up .error_right ").html(""); }).validate({ onfocusout: false, rules: { newsletter_with_name_email: { required: true, email: true }, newsletter_with_name_name: { required: true } }, messages: { newsletter_with_name_email: { required: "Email is required", email: "Valid email is required" }, newsletter_with_name_name: { required: 'Enter your name' } }, errorElement: "label", errorLabelContainer: $("#form_newsletter_with_name_sign_up .error_right ") }); /******** newsletter with name form ends *****************/ /******** Contact us form starts *************************/ if($("#contact_form").length > 0) { $("").appendTo("#contact_form"); $.validator.addMethod( "invalid_char", function(value, element, pattern) { return value.match(pattern[0]); } ); $("#contact_form").validate({ rules: { name: { required: true }, phone: { invalid_char : ["^([0-9 -.\s])*"] }, email: { required: true, email: true }, message: { required: true }, location: { required: true } }, messages: { name: { required: "Name is required" }, phone: { invalid_char: "Enter phone number" }, email: { required: "Email is required", email: "Valid email is required" }, message: { required: "Enter your message" }, location: { required: "Please select location" } }, //errorClass:"errorMsg" errorElement: "li", errorLabelContainer: $("#contact_form .error-message ul") }); } /************** Contact us form end ***************************/ /************** Appointments form starts **********************/ if($('#form_appointments').length > 0) { $('').appendTo("#form_appointments"); $.validator.addMethod( "invalid_char", function(value, element, pattern) { return value.match(pattern[0]); } ); $.validator.addMethod( "check_appointment_time", function(value, element) { var location_id = document.form_appointments.location.value; if(location_id == "") { return true; } if(location_array.length == 0) { return true; } if($.inArray(location_id, location_array) != -1) { var practice_hours = eval("loc_"+location_id+"_practice_hours"); if(document.form_appointments.year.value == "" || document.form_appointments.month.value == "" || document.form_appointments.date.value == "") { return true; } var sel_year = document.form_appointments.year.value; var sel_month = document.form_appointments.month.value - 1; var sel_day = document.form_appointments.date.value; var sel_hour = document.form_appointments.hr.value; var sel_min = document.form_appointments.minutes.value; var sel_ampm = document.form_appointments.time.value; if(sel_ampm == "PM" && sel_hour != 12) { sel_hour = Number(sel_hour) + 12; } else if(sel_ampm == "AM" && sel_hour == 12) { sel_hour = 0; } var apt_date = new Date(sel_year, sel_month, sel_day, sel_hour, sel_min, 0); var start_time = new Date(sel_year, sel_month, sel_day, 0, 0, 0); var end_time = new Date(sel_year, sel_month, sel_day, 0, 0, 0); week_day = apt_date.getDay(); apt_day = practice_hours[week_day]; apt_day = apt_day.split("#"); apt_start_time = (apt_day[0]).split(":"); apt_end_time = (apt_day[1]).split(":"); if(apt_start_time[0] == 00) { apt_day[0] = '12:'+apt_start_time[1]; } if(apt_end_time[0] == 00) { apt_day[1] = '12:'+apt_end_time[1]; } start_time.setHours(apt_start_time[0]); start_time.setMinutes(apt_start_time[1]); end_time.setHours(apt_end_time[0]); end_time.setMinutes(apt_end_time[1]); if((apt_start_time == "") && (apt_end_time == "")) { jQuery.validator.messages.check_appointment_time = "We are closed on "+weekdays[week_day]+". Please schedule available date."; return false; } if((apt_date >= start_time) && (apt_date <= end_time)) { return true; } else { error_msg = "Our working hours on "+weekdays[week_day]+" are between "; if(apt_start_time[0] > 12 ) { error_msg += (parseInt(apt_start_time[0]) - 12)+":"+apt_start_time[1]+" PM to "; } else if(apt_start_time[0] == 12 ) { error_msg += (parseInt(apt_start_time[0]))+":"+apt_start_time[1]+" PM to "; } else { error_msg += apt_day[0]+" AM to "; } if(apt_end_time[0] > 12 ) { error_msg += (parseInt(apt_end_time[0]) - 12)+":"+apt_end_time[1]+" PM"; } else if(apt_end_time[0] == 12 ) { error_msg += (parseInt(apt_end_time[0]))+":"+apt_end_time[1]+" PM"; } else { error_msg += apt_day[1]+" AM"; } jQuery.validator.messages.check_appointment_time = error_msg; return false; } } else { return true; } } ); $.validator.addMethod( "check_date", function(value, element) { var myDayStr = document.form_appointments.date.value; var myMonthStr = document.form_appointments.month.value - 1; var myYearStr = document.form_appointments.year.value; var myMonth = new Array(); myMonth[0] = "1"; myMonth[1] = "2"; myMonth[2] = "3"; myMonth[3] = "4"; myMonth[4] = "5"; myMonth[5] = "6"; myMonth[6] = "7"; myMonth[7] = "8"; myMonth[8] = "9"; myMonth[9] = "10"; myMonth[10] = "11"; myMonth[11] = "12"; var myDateStr = myDayStr + " " + myMonth[myMonthStr] + " " + myYearStr; var myDate = new Date(); myDate.setFullYear(myYearStr, myMonthStr, myDayStr); var current_date = new Date(); var current_day = current_date.getDate(); var current_month = current_date.getMonth(); var current_year = current_date.getFullYear(); var current_date = new Date(current_year,current_month,current_day); var schedule_date = new Date(myYearStr,myMonthStr,myDayStr); if (myDate.getMonth() != myMonthStr) { return false; } else if(schedule_date < current_date) { return false; } else { return true; } } ); $("#form_appointments").validate({ rules: { first_name: { required: true }, email: { required: true, email: true }, home_phone: { required: true, invalid_char : ["^([0-9 -])*$"] }, work_phone: { invalid_char : ["^([0-9 -])*$"] }, age: { required: true }, year: { required: true }, month: { required: true }, date: { required: true, check_date: true }, hr: { required: true }, minutes: { required: true }, time: { required: true, check_appointment_time: true }, location: { required: true } }, messages: { first_name: { required: "First name is required" }, email: { required: "Email is required", email:"Valid email is required" }, home_phone: { required: "Please enter main phone", invalid_char : "Please enter valid main phone" }, work_phone: { invalid_char : "Please enter valid alternative phone" }, age: { required: "Please select age" }, year: { required: "Please select year" }, month: { required: "Please select month" }, date: { required: "Please select date", check_date: "Please valid date" }, hr: { required: "Please select hour" }, minutes: { required: "Please select minutes" }, time: { required: "Please select time" }, location: { required: "Please select location" } }, errorElement: "li", errorLabelContainer: $("#form_appointments .error-message ul") }); } /************* Appointments form ends ************************/ /************* Blog commemnts form start **********************/ if($('#form_blog_comment').length > 0) { $("").appendTo("#form_blog_comment"); $.validator.addMethod( "invalid_char", function(value, element, pattern) { return value.match(pattern[0]); } ); $("#form_blog_comment").validate({ rules: { name: { required: true }, email: { required: true, email : true }, message: { required: true } }, messages: { name: { required: "Enter name" }, email: { required: "Enter email", email : "Enter valid email" }, message: { required: "Enter message" } }, errorElement: "li", errorLabelContainer: $("#form_blog_comment .error-message ul") }); } /************* Blog commemnts form ends **********************/ /******** search form starts ********/ $("#search_word").hint(); $("#search_submit").attr('disabled','disabled'); //enable search button only if some value added $("#search_word").keyup( function(objEvent) { if(this.value != "") { $("#search_submit").removeAttr('disabled'); } else { $("#search_submit").attr('disabled', 'disabled'); } } ) $("#global_search_form").submit(function() { if($("#search_word").val() == "") { return false; } }); /******** search form ends ********/ }); /******* patient education starts *************/ function redirect_url() { var search = $("#patient_education_search").val(); var page_url = "http://gardensdental.ca/patient-education/search/"; if(search == "Search here") { search = ""; } window.location.href = page_url + search; } /******* patient education ends *************/ /******* get_language_class starts *************/ function get_language_class(active_language) { class_name = ''; default_language = 'en'; if(active_language != default_language) { class_name = 'lang-' + active_language; } return class_name; } /******* get_language_class starts *************/ /******* ajax refresh functions starts ***********/ function set_cookie_n_get_page_content(cookie_name) { class_name = get_language_class(cookie_name); current_banner_xml_file = "data/"+cookie_name+"_data.xml"; $.ajax({ type : "POST", url : "set_cookie.php?cookie="+cookie_name, async : false }); $.ajax({ type : "POST", url : location.href, success : function(response) { title = response.match(//i); title = title[0].replace("", ""); title = title.replace("", ""); //document.title = $("
").html(title).text(); document.title = title; body = response.match(/]*>(\s|.)*<\/body>/i); body = body[0].replace("", ""); body = body.replace("", ""); $("body").html(body); $("head").append('