/* Author: 
Yin Zheng
*/

$(document).ready(function(){
	$(".images_gallery").cycle({
		fx: 'none',
		before: function(currSlideElement, nextSlideElement, options, forwardFlag){
			$(".image_description").text($(nextSlideElement).find("img").attr("alt"));
		}
	});
	
	$(".subscribe_to_mybookshop").bind("click", function(){
		$("#nav_item_subscribe a").trigger("click");
		return false;
	})
	
	$(".nav_item_subscribe").bind("click", function(){
		$("#subscribe_form").toggleClass("hide");
		$(".nav_subscribe_form").toggleClass("opacity_zero");
		return false;
	});
	
	$(".nav_subscribe_form .close_div").bind("click", function(){
		$("#subscribe_form").addClass("hide");
		$(".nav_subscribe_form").addClass("opacity_zero");
		return false;
	});
	
	$("#nav_subscribe_form").submit(function(){
		var current_form = this;
		
		$.post(
			$(this).attr("action")+"?ajax=1&app=general&action=subscribeForm",
			$(this).serializeArray(),
			function(data){
				$(current_form).find(".returned_message").html(data);
				$(current_form).find("input[type=text]").val("");
				$(current_form).find("textarea").val("");
				$(current_form).find("input[type=email]").val("");
				$(current_form).find("option").attr("selected","");
				$(current_form).find("input[type=checkbox]").attr("checked","");
				return false;
			}
		);
		return false;
	});
	
});
























