$(document).ready(function(){

/* Contact Us form - hides state field if user is not from Australia */
  $('#q17386_q4').change(function () {
    if ( $(this).val() == 'au' ) {
      $('div.form-hide').slideDown();
    }
    if ( $(this).val() != 'au' ) {
      $('div.form-hide').slideUp();
    }
  });

/* Changing the position of content bottom dots on the home page
  var right_height = $('div#right').height();
  if ($("head title:contains('Home')").length == 1 && right_height > 100) {
    $('div#content').height(right_height-16);
  }
*/

/* Changing the days names displaying */
  $(".dayLabel:contains('Monday')").text('Mon');
  $(".dayLabel:contains('Tuesday')").text('Tues');
  $(".dayLabel:contains('Wednesday')").text('Wed');
  $(".dayLabel:contains('Thursday')").text('Thurs');
  $(".dayLabel:contains('Friday')").text('Fri');
  $(".dayLabelWeekend:contains('Saturday')").text('Sat');
  $(".dayLabelWeekend:contains('Sunday')").text('Sun');

/* Remove links from calendar box */
  $('#calendarTable a.dateLink').each(function(){
    $(this).replaceWith('<span>' + $(this).text() + '</span>');
  });

/* Remove background (dots) from the last element */
  $('#calendarTable table tr:last').addClass('bg_none');
  if ( $('#content h1').text() == 'Calendar' || $('#content h1').text() == 'Send to a Friend' || $('#content h1').text() == 'Contact us' || $('#content h1').text() == 'Enquiry Form' ) {
    $('#content').addClass('bg_none');
  }

/* Target blank links */
  $("a[rel*='external']").click(function() {
    this.target = "_blank";
  });

/* Form's client-side validation */
  $('#form_email_17386_submit').click(function(event){
    if ($('input#q17386_q2').val() == 0 || $('input#q17386_q3').val() == 0 || $('input#SQ_SYSTEM_SECURITY_KEY_VALUE').val() == 0 || $('input#q17386_q8').val() == 0) {
      event.preventDefault();
      alert('Please fill out all of the mandatory fields.');
    }
  });
  $('#form_email_19276_submit').click(function(event){
    if ($('input#q19276_q1').val() == 0 || $('input#q19276_q2').val() == 0 || $('input#q19276_q3').val() == 0 || $('input#q19276_q4').val() == 0 || $('input#q19276_q3').val() == 0 || $('input#SQ_SYSTEM_SECURITY_KEY_VALUE').val() == 0) {
      event.preventDefault();
      alert('Please fill out all of the mandatory fields.');
    }
  });

/* Print this page */
  $('a.print').click(function(){
    window.print();
  });

});
