$(document).ready(function() {

 function hideTabbedContent() {
  $('div#product div#specification').css({ display: "none" });
  $('div#product div#features').css({ display: "none" });
  $('div#product div#gallery').css({ display: "none" });
  $('div#product div#accessories').css({ display: "none" });
  $('ul#tabs li').removeAttr("class");
  //$('ul#tabs li').css("background-image", "url(images/products/tab_left.gif)");
  //$('ul#tabs li a').css("background-image", "url(images/products/tab_right.gif)");
 }//function

 function doTabRollovers() {
  //Only add event handlers if browser is IE6 or lower
  if (document.all && !(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined")) {

   $('ul#tabs > li:not(.selected)').each(function(index) {
     $(this).hover(function() {
      $(this).addClass('hover');
     }, function() {
     $(this).removeClass('hover');
     });
    });

  }//if
 }//function

 $('ul#tabs li a').click( function() {
  hideTabbedContent();
  doTabRollovers();
  var strClass = $(this).attr('class');
  $('div#product div#' + strClass).css({ display: "block" });
  $(this).parent().attr("class", "selected");
  //$(this).parent().css("background-image", "url(images/products/tab_left_selected.gif)");
  //$(this).css("background-image", "url(images/products/tab_right_selected.gif)");
  $(this).blur();
  return false;
 });

 $('ul#tabs li.selected a').trigger('click');

 $('div#product div#galleryimages a').click( function() {
  $('div#product img#galleryimage').attr('src', $(this).attr('href'));
  return false;
 });

 $('form input.taxfree').click( function() {
  $(this).parents('form').submit();
 });

});

//Code to copy delivery address to billing address
var doBillingAddress = function(strCheckboxID) {
 var elementCheckbox = $('input#' + strCheckboxID);
 if (elementCheckbox.attr('checked')) {
  $('input#input-BillingAddress1').val($('input#input-DeliveryAddress1').val());
  $('input#input-BillingAddress2').val($('input#input-DeliveryAddress2').val());
  $('input#input-BillingAddressTown').val($('input#input-DeliveryAddressTown').val());
  $('input#input-BillingAddressState').val($('input#input-DeliveryAddressState').val());
  $('input#input-BillingAddressPostcode').val($('input#input-DeliveryAddressPostcode').val());
  $('select#select-BillingAddressCountryCode').val($('select#select-DeliveryAddressCountryCode').val());
 }//if
}//function