$(document).ready(function(){

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Rollovers
  $("a.rollover").hover(
    function() {
      curr = $(this).find("img").attr("src");
      overlen = curr.length;
      over = curr.substr(0, overlen-4);
      over = over+'_on.png';
      $(this).find("img").attr({ src: over });
    },
    function() {
      $(this).find("img").attr({ src: curr });
    }
  );
  // Rollovers - Preload images
  $("a.rollover").find("img").each(function(i){
    temp = this.src;
    prelen = temp.length;
    pre = temp.substr(0, prelen-4);
    pre = pre+'_on.png';
    preload_image_object = new Image();
    preload_image_object.src = pre;
  });

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // toolTip on Email Sign-Up

	$('#emailTip').tipsy({gravity: 's'});



	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Homepage Video

	$('a#videoSplash').click(function(){
		$('img.splashScreen').fadeOut('fast');
	});

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Header Cart Toggler
	$("div#superNav a.cart").click(function(){
		$("div#cartWrapper").slideToggle('fast');
		return false;
	});
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Cart Item Remover
	$("span.removeLink").click(function(){
		id_data = this.id;
		var id_data_array = id_data.split("_");
		var cart_item_key = id_data_array[1];	
		$.post(
			'/cart/removeitem/'+cart_item_key, 
			{}, 
			function(data) {
				$("tr#cartItem_"+cart_item_key).fadeOut('fast');
				$("td.cartSubtotalAmt span").html(data);
		  }, 
			"html"
		);
		return false;
	});
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Cart Continue Shopping Link
	$(".continueShopping").click(function(){
		$("div#cartWrapper").slideUp('fast');
		return false;
	});




	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Footer Newsletter Form
	$("input#subscriberName").focus(function(){
		if ($("input#subscriberName").val() == 'Your Name') {
		  $("input#subscriberName").val('');
		}
  });
	$("input#subscriberName").blur(function(){
		if ($("input#subscriberName").val() == '') {
		  $("input#subscriberName").val('Your Name');
		}
	});      
	
	$("input#subscriberEmail").focus(function(){
		if ($("input#subscriberEmail").val() == 'Email Address') {
		$("input#subscriberEmail").val('');
		}
  });
	$("input#subscriberEmail").blur(function(){
		if ($("input#subscriberEmail").val() == '') {
	  $("input#subscriberEmail").val('Email Address');
		}
	});      





	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Video Preview Player
	if ($('#videoPreviewPlayer').length) {
		flowplayer("videoPreviewPlayer", {src:'/js/flowplayer/flowplayer-3.1.4.swf', wmode:'transparent'}, {
			config: { 
				streamingServer: 'lighttpd'
			},
			clip: {
				autoPlay: true,
				// urlResolvers: 'secure',
				baseUrl: '/flowplayerstreamer.php/'
			},
			plugins: { 
				pseudo: { 
					url: '/js/flowplayer/flowplayer.pseudostreaming-3.1.3.swf' 
				},
				secure: {
					url: '/js/flowplayer/flowplayer.securestreaming-3.1.1.swf', 
					timestampUrl: '/products/returntimestamp', 
					token: 'sn983pjcnhupclavsnda' 
				}
			},
			onBeforeFinish: function() { // Loop it
			  return false; 
			}
		});
	}
	
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Image Preview Player
	if ($('#imagePreviewPlayer').length) {
		flowplayer("imagePreviewPlayer", "/js/flowplayer/flowplayer-3.1.4.swf", {
			play:{
				opacity:0
			},
			config: { 
			},
			clip: {
			},
			plugins: { 
				controls: null
			}
		}); 
	}


});