(function($){
  
    $.fn.toggleFav = function(){
        $(this).each(function(){
			var jthis = $(this);
			action = false
            var $productNo = jthis.attr('rel');
           	jthis.click(function(event){
			if(jthis.hasClass('on')){
				if(confirm('Are you sure you want to remove this item from your favourites?')){
					action = true;
				}
			} else {
				action = true;
			}
	      
		  	if(action == true){
				$.get('xhttp.php', { request : 'favourite', item : $productNo});
              $(this).toggleClass('on').toggleClass('off');
              
			}

            
              event.preventDefault();
            })
        });
    }
 })(jQuery);
