// JavaScript Document - Random Utilities
	$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});




// Text Field Remove Text

var swap_text_boxes = [];
var QuantityFieldCheckout = [];

function init_swap_text_boxes(){
  //Store the default value for each swap text box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
 // Atom Adding this for Edit Cart Screen Quantity Boxes 
    $('input[type=text][value].QuantityFieldCheckout').each(function() {
    QuantityFieldCheckout[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].QuantityFieldCheckout').bind('focus', function() {
    if($(this).val() == QuantityFieldCheckout[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].QuantityFieldCheckout').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(QuantityFieldCheckout[$(this).attr('id')]);
    }
  }); 
  $('#loginPasswordLabel').bind('focus', function() {
    $(this).hide();
    $('#loginPassword').show().focus();
  });
  $('#loginPassword').bind('blur', function() {
     // hide password input
     // reveal password label
    if($(this).val() == '') {
      $(this).hide();
      $('#loginPasswordLabel').show();
    }
  });
}

$(document).ready(function(){ init_swap_text_boxes(); }); 

$(function() {
  msg = $.trim($('.notice').html());
  if (msg) {
  	 $('.notice').remove();
    facebox_alert(msg);
  }
});

function facebox_alert(msg) {
  jQuery.facebox(msg);
  setTimeout(function(){ $().trigger('close.facebox'); }, 3000);
}

// Show Hide Credit Card Info Checkout Area 
// preset the variable
show = false;
function showhide(CardDetail){
if(show){
document.getElementById(CardDetail).style.display='none '
show = false
}else{
document.getElementById(CardDetail).style.display='block'
show = true
}
}

// Random Ad Rotator for side images

var imagenumber = 5 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
images = new Array
images[1] = "/images/side_promo.021.jpg"
images[2] = "/images/side_promo.022.jpg"
images[3] = "/images/side_promo.023.jpg"
images[4] = "/images/side_promo.024.jpg"
images[5] = "/images/side_promo.025.jpg"
var image = images[rand1]

links = new Array
links[1] = "/products/41900"
links[2] = "/products/41932"
links[3] = "/products/41966"
links[4] = "/families/42048"
links[5] = "/products/42006"
var link = links[rand1]

//Disable Order Complete Button On Submit
$(document).ready(function(){
  $("#new_order").submit(function(){
    $("input[type='submit']").attr("disabled", true).val("Please wait...");
    jQuery.facebox("Processing Order, Please Wait.. <br /> Do Not Click the Order Button Twice!");
  })
});

// Kill Flash Banners from HTML
function hideFlash() {
		document.getElementById("FlashID").style.display = "none";
	}

// Lightbox Init

		$(document).ready(function(){
			$(".lightbox").lightbox();
		});
