function colorbox_close() {
  $.fn.colorbox.close();
}

function cancellink() { window.parent.colorbox_close(); }

$().ready(function() {
  //Examples of Global Changes 
  $.fn.colorbox.settings.bgOpacity = "0.0"; 
  $.fn.colorbox.settings.transition = "fade"; 
  
  //Examples of how to assign the ColorBox event to elements.
  $("a[rel='popup']").colorbox({iframe: "true", height:522, width:450});
  $("a[rel='orderPopup']").colorbox({iframe: "true", height:750, width:615});
  
});

$().ready(function() {
  $('.shopnow-div').show();
  $('.shopnow-div').tabSlideOut({
    tabHandle: '.handle',                     //class of the element that will become your tab
    pathToTabImage: 'images/shop_now_tab.png', //path to the image for the tab //Optionally can be set using css
    imageHeight: '486px',                     //height of tab image           //Optionally can be set using css
    imageWidth: '72px',                       //width of tab image            //Optionally can be set using css
    tabLocation: 'left',                      //side of screen where tab lives, top, right, bottom, or left
    speed: 300,                               //speed of animation
    action: 'click',                          //options: 'click' or 'hover', action to trigger animation
    topPos: '0px',                          //position from the top/ use if tabLocation is left or right
    leftPos: '0px',                          //position from left/ use if tabLocation is bottom or top
    fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
  });
  
  $.validator.messages.required = "";
  $.validator.messages.email = ""; 
  $.validator.messages.number = "";
  
  $(".frmValidate").validate();
  
  $(".changeState").change(function() {    
    var country = $(this).val();
    var thisField = $(this).attr("id");
    var stateField = $(this).attr("rel");
    var state = $("#"+stateField).val();
  
    if (country=="US"||country=="CA"||country=="IE") {      
      $.getJSON("options.php",
        {f: (country=="US"?"us_states":(country=="CA"?"ca_provinces":(country=="IE"?"irish_states":""))) },
        function(j){        
          var options = "";
          for (var i = 0; i < j.length; i++) {
            options += "<option value=\"" + j[i].optionValue + "\"" + (j[i].optionValue==state?" selected=\"selected\"":"")+">" + j[i].optionDisplay + "</option>";
          }                  
          $("#"+stateField).html(options);
      });    
      $("#"+stateField).addClass("required");
      $("#div_"+stateField).show();
      $("#div_"+stateField+"_other").hide();      
    } else {
      $("#"+stateField).removeClass("required");
      $("#div_"+stateField).hide();
      $("#div_"+stateField+"_other").show();
    }
    $("#span_"+stateField).html((country=="US"||country=="IE"?"State *":(country=="CA"?"Province *":"State")));
  });    
});
