	
	friend1Value 	= "Friend #1 Email Address";
	friend2Value 	= "Friend #2 Email Address";
	nameValue		= "Your Name";
	messageValue	= "Message";
	
	// Called when dom is ready....
	$(function() {
		
		$('#shareAddress1').val(friend1Value);
		$('#shareAddress2').val(friend2Value);
		$('#shareName').val(nameValue);
		

		// Blur/Focus events for "Share the Love" and "Sign Our Guestbook"
		$('#signName').blur(nameText);
		$('#signName').focus(clearText);
		$('#shareName').blur(nameText);
		$('#shareName').focus(clearText);
		$('#shareAddress1').blur(friendText);
		$('#shareAddress1').focus(clearText);
		$('#shareAddress2').blur(friendText);
		$('#shareAddress2').focus(clearText);
		$('#signMessage').blur(messageText);
		$('#signMessage').focus(clearText);
		
	
		// "Share the Love" action
		$('#shareTheLove').click(function(e) {
			
			e.preventDefault();
			
			// Make sure the name and at least one friend email address is filled out
			if ( $('#shareName').val() != '' && $('#shareName').val() != nameValue &&
			 		( $("#shareAddress1").val() != '' && $("#shareAddress1").val() != friend1Value) ||
					( $("#shareAddress2").val() != '' && $("#shareAddress2").val() != friend2Value) ) {
			
				$.post("share_the_love.php", { name: $("#shareName").val(), friend1: $("#shareAddress1").val(), friend2: $("#shareAddress2").val() }, function(data, textStatus) {
			
					if ( textStatus == 'success' && data.indexOf('true') >= 0 ) {	// No problems
									
					/*
						// Reset the input fields
						$("#shareName").val("").blur();
						$("#shareAddress1").val("").blur();
						$("#shareAddress2").val("").blur();
					*/
					
						$('#share-the-love-wrapper').fadeOut("slow", function() {
							$(this).html('<div style="padding-top:60px;">Thank you for sharing the love!</div>').fadeIn("slow");
						});
	
				
					} else {			// There was an error
						
						$('#share-the-love-wrapper').fadeOut("slow", function() {
							$(this).html('<div style="padding-top:60px;background:#f1ce69;height:150px;color:#ffffff;"><strong>Sorry, we were unable to send your message.</strong></div>').fadeIn("slow");
						});
						
					}

				}, "html");
				
			}
		
		});
		
		
		// If opera, set a special rel attribute
		if(window.opera) {  
	         if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set  
	             $("a.jqbookmark").attr("rel","sidebar");  
	         }  
	     }
	
		// Set the click even for the bookmark this site link...
		 $("a.jqbookmark").click(function(e){  
			
	         e.preventDefault();  
	         var url = this.href;  
	         var title = this.title;  

	         if (window.sidebar) { 			// Mozilla Firefox Bookmark  
	             window.sidebar.addPanel(title, url,"");  
	         } else if( window.external ) { // IE Favorite  
	             window.external.AddFavorite(url, title);  
	         } else if(window.opera) { 		// Opera 7+  
	             return false; // do nothing - the rel="sidebar" should do the trick  
	         } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)  
	              alert('Unfortunately, this browser does not support the requested action,'  
	              + ' please bookmark this page manually.');  
	         }  

	     });
	
	
		// Show a prompt when a user is going to remove a card from their cart
		$('a.remove-product').click(function(e) {
			
			e.preventDefault();
			var link = $(this).attr('href');
			
			jConfirm("Are you sure you want to remove this item from your shopping cart?", "Remove from Shopping Cart?", function(r) {
				if ( r ) window.location.replace(link);
			});

		});
				
	});


	
	function friendText(e) {
		if ( $(e.target).val() == "" ) {
			var text = $(e.target).attr('id') == 'shareAddress1' ? friend1Value : friend2Value;
			$(e.target).val(text);
		}
	}
	
	function nameText(e) {
		if ( $(e.target).val() == "" ) $(e.target).val(nameValue);
	}
	
	function messageText(e) {
		if ( $(e.target).val() == "" ) $(e.target).val(messageValue);
	}
	
	function clearText(e) {
		var value = $(e.target).val();
		if ( value == friend1Value || value == friend2Value || value == nameValue || value == messageValue ) {
			$(e.target).val("");
		}
	}
	
	
	// Limiting textareass	
	function textLimit(field, maxlen) {
		if (field.value.length > maxlen + 1) alert('Your message cannot be more than '+maxlen+' characters.');
		if (field.value.length > maxlen) field.value = field.value.substring(0, maxlen);
	}