/* CUSTOM :: Share my favorites */

jQuery(document).ready(function(){


	/* ---------------------------------------------------------------------- */
	
	
	jQuery('.clear_favorites').click(function () {
		
		jQuery("#favorite_photos .share_my_favorites").addClass("hidden");
		
		jQuery("#favorite_photos .share_my_favorites").attr({"href" : ""});
		
		return false;
		
	});	
	
	/* ---------------------------------------------------------------------- */
	

	jQuery('div#smf-form-captcha-ok').hide();


	var optionsSendMyFav = { 
	
		target:     	'.smf-form-captcha-ok',
		
		replaceTarget:	'true',
		
		url:			'http://rubberducky.us/wp-content/themes/photoshot/custom/my-favorites-captcha.php',

		dataType:		'json',
		
		resetForm:		'true',
		
		clearForm:		'true',
		
		beforeSubmit: 	function() {
			
			return jQuery("#smf-form-captcha").validate().form();
			
		},
	
		success:    processSendMyFavJson
		
	}; 

	jQuery('form#smf-form-captcha').ajaxForm(optionsSendMyFav);

	function processSendMyFavJson(data) {
		
    	if (data.response.status) {
			
			jQuery('form#smf-form-captcha').hide().delay(5000).fadeIn();
			
			jQuery('div#smf-form-captcha-ok').show().delay(4000).fadeOut();

		} 
	
	}
	
	
	jQuery(".zoom").parent().hover(function(e) {
	
		var thisParentLink = jQuery(this);
		
		var thisParentLinkHref = jQuery(this).attr("href");
		
		var thisParentLinkPid = $j(this).attr("rel");
		
		//alert(thisParentLinkPid);
				
		jQuery(this).css({"position" : "relative"});
		
		if (jQuery(this).find('.zoom_ico').length == 0) {
		
			jQuery(this).append('<div class="zoom_ico"></div>');
		
			var zx = jQuery(this).find(".zoom").outerWidth()/2 - jQuery(this).find(".zoom_ico").outerWidth()/2;
		
			if (jQuery(this).hasClass("ss_thumb")) {
				var zy = jQuery(this).find(".zoom").outerHeight()/2 - jQuery(this).find(".zoom_ico").outerHeight()/2;
			} else {
				var zy = jQuery(this).find(".zoom").outerHeight()/2;
			}
		
			jQuery(this).find(".zoom_ico").css({
				"opacity" : 0,
				"top"  : zy,
				"left" : zx
			});
		
		}
		
		jQuery(this).find(".zoom_ico").stop().animate({opacity: 1}, 400);
		
		
		if (jQuery(this).find('.delete_ico').length == 0) {
		
			jQuery(this).append('<div class="delete_ico"><a href="JavaScript:void(0);" title="Remove">x</a></div>');
			
			jQuery(this).find(".delete_ico").hover(function(e) {
				
				jQuery(thisParentLink).removeAttr('href');
				
			},
			function(e) {
			
				jQuery(thisParentLink).attr('href', thisParentLinkHref);
				
			});

			jQuery(this).find(".delete_ico, .delete_ico a").focusin(function(e) {
			
				jQuery(thisParentLink).removeAttr('href');
			
			});
							
			jQuery(this).find(".delete_ico, .delete_ico a").click(function(e) {
			
				//UNSETCOOKIE
				var str = "action=unset&favcookie="+thisParentLinkPid;
				$j.ajax({
					 type: "POST",
					 url: templatepath+"setcookie.php",
					 data: str,
					 success: function(response)
					 {
						 $j(thisParentLink).parent().remove();
					 }
				});
			
			
			});
		
		}
		
		jQuery(this).find(".delete_ico").show();

		
	},
    
	// Roll Out
    function(e) {
		
		jQuery(this).find(".zoom_ico").stop().animate({opacity: 0}, 400);
		
		jQuery(this).find(".delete_ico").hide();
		
	});
	
	
			
});
