jQuery(document).ready(function() {
	// ---- INI

	loadWishListCore("/shopping/wishlist_ajx.asp");


	 // validate FORM
	jQuery("form#frmEmailWishlist").validate({
    	submitHandler: function(thisform) {
    		// hide the Submit button
    		jQuery("input#submitWishlist").fadeOut('normal');
    		// AJAX sending the Wishlist to a friend
	        jQuery(thisform).ajaxSubmit({
	        	success: function(){
	        		// fade out the form
	        		jQuery("#emailFormBox").fadeOut(1500,function(){
	        			// fade in the confirmation box
	        			jQuery("#emailSentConfirmation").fadeIn(2000);
	        		});
        		}
        	}); 
	        return false; 
	  	}
	});
	

	jQuery("a#emailListLink").click(function(){
		 // toggle the email form
		jQuery("#emailFormBox").toggle();
		 // focus the first form field
		jQuery("#emailFormBox input#sEmailFrom").trigger('focus');
		 // reset the confirmation msg box
		jQuery("#emailSentConfirmation").hide();
		 // show the submit button (it might have been hidden from previous send)
		jQuery("input#submitWishlist").show();
		return false;
	})

});


	function loadWishListCore(url){
		jQuery.get(url, '',function(data){
			var utuilityMenuStart = data.indexOf('<STYLE TYPE="text/css">.coreClass');
			if(utuilityMenuStart > -1){
				data = data.substr(0,utuilityMenuStart)
			}
		    jQuery("#ajx_WishListCore").html(data);
		});
	}
	
