$(document).ready(function(){

	// Products tabs
	// New releases tabs
	$("#tab1").click(function(){
		if($("#product_wrap1").hasClass("active_tab_content")){
			
		}else{
			$(".products_wrap").removeClass("active_tab_content");
			$("#product_wrap1").addClass("active_tab_content");
		}
		$("#products_tabs li").removeClass("active_tab");
		$("#products_tabs li a").removeClass("active_tab");
		$(this).parents("li").addClass("active_tab");
		$(this).addClass("active_tab");
	})
	
	// Featured authors tab
	$("#tab2").click(function(){
		if($("#product_wrap2").hasClass("active_tab_content")){
			
		}else{
			$(".products_wrap").removeClass("active_tab_content");
			$("#product_wrap2").addClass("active_tab_content");
		}
		$("#products_tabs li").removeClass("active_tab");
		$("#products_tabs li a").removeClass("active_tab");
		$(this).parents("li").addClass("active_tab");
		$(this).addClass("active_tab");
	})
	
	//Upcoming releases tab
	$("#tab3").click(function(){
		if($("#product_wrap3").hasClass("active_tab_content")){
			
		}else{
			$(".products_wrap").removeClass("active_tab_content");
			$("#product_wrap3").addClass("active_tab_content");
		}
		$("#products_tabs li").removeClass("active_tab");
		$(this).parents("li").addClass("active_tab");
		$("#products_tabs li a").removeClass("active_tab");
		$(this).addClass("active_tab");
	})
	
	// Top animate
	$("#top_link_wrap a").click(function(){
		$('html,body').animate({scrollTop: 0}, 2500);
	})
		
	// Product page list
	$('#product_list li.first').addClass('active_product');
	
	// Change the image when the user click on it by changing folder name (imagechache)
	$('#product_list li').click(function(){
		img = $(this).find('img');
		var image_link = img.attr('src');
		var new_link = image_link.replace('book_options','product_inner');
		var final_image = "<img src='"+new_link+"' />";
		$('#product_main_image').html(final_image);
		
	// Add arrow to the active image
	$('#product_list li').removeClass('active_product');
	$(this).addClass('active_product');
	})
	
	
	// Newsletter form labels
	// Name
	var name = 'your name';
	// Give the textbox initial value
	$("#newsletter_wrap #edit-username").val(''+name+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#newsletter_wrap #edit-username").click(function(){
		if($(this).val() == 'your name'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#newsletter_wrap #edit-username").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+name+'')
		}else{
			
		}
	});
	
	// E-mail
	var email = 'e - mail';
	// Give the textbox initial value
	$("#newsletter_wrap #edit-mail").val(''+email+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#newsletter_wrap #edit-mail").click(function(){
		if($(this).val() == 'e - mail'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#newsletter_wrap #edit-mail").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+email+'')
		}else{
			
		}
	});
	
	// Slider controls
	$('.externalControl a').click(function(){
		$('.externalControl a').removeClass('active_slider');
		$(this).addClass('active_slider');
	})
	
	
	
	// Contact Us Labels
	// name
	var name = 'name *';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-name").val(''+name+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-name").click(function(){
		if($(this).val() == 'name *'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-name").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+name+'')
		}else{
			
		}
	});
	
	
	// email
	var email = 'e-mail *';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-e-mail-address").val(''+email+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-e-mail-address").click(function(){
		if($(this).val() == 'e-mail *'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-e-mail-address").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+email+'')
		}else{
			
		}
	});
	
	
	// website
	var website = 'website';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-website").val(''+website+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-website").click(function(){
		if($(this).val() == 'website'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-website").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+website+'')
		}else{
			
		}
	});
	
	
	// workphone
	var workphone = 'workphone';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-work-phone").val(''+workphone+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-work-phone").click(function(){
		if($(this).val() == 'workphone'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-work-phone").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+workphone+'')
		}else{
			
		}
	});
	
	
	// mobile
	var mobile = 'mobile';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-mobile-phone").val(''+mobile+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-mobile-phone").click(function(){
		if($(this).val() == 'mobile'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-mobile-phone").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+mobile+'')
		}else{
			
		}
	});
	
	// comment
	var comment = 'comment';
	// Give the textbox initial value
	$("#webform-client-form-8 #edit-submitted-comment").val(''+comment+'');
	// On click function, we check if the value of the textbox == init make it null
	$("#webform-client-form-8 #edit-submitted-comment").click(function(){
		if($(this).val() == 'comment'){
			$(this).val('');
		}else{
			
		}
	});
	// On blur function, if the value null make it init
	$("#webform-client-form-8 #edit-submitted-comment").blur(function (){ 
		if($(this).val() == ''){
			$(this).val(''+comment+'')
		}else{
			
		}
	});

	// Search box effect
	$('#search a').click(function(){
		$(this).hide();
		$('#search_box_wrap').show();
	})		  // Increase Font Size	$(".increaseFont").click(function(){		// Get init size		var init_size =   $('.node .content').css('font-size');		// Decrease it 2 px		var new_size = parseFloat(init_size) + 2;		// Set the new size		$('.node .content').css('font-size',new_size+'px');	});	  // Decrease Font Size  $(".decreaseFont").click(function(){		// Get init size		var init_size =   $('.node .content').css('font-size');		// Decrease it 2 px		var new_size = parseFloat(init_size) - 2;		// Set the new size		$('.node .content').css('font-size',new_size+'px');  });					
})
