$(document).ready(function(){

	$('.addtocart').click(function(){
		var value 	= $(this).attr('id')+"";
		var id 		= value.replace("cs_", "");
		var randomnumber = Math.floor(Math.random()*11);
		
		$.ajax({
			cache: false,
			type: "POST",
			url: "/index.php/cart/add_ajax/"+randomnumber,
			data: "product="+id,
			success: function(html){
				$('#cs_'+id).addClass('selected-item-off');
				$('#remove_'+id).removeClass('selected-item-off');
			}
		});
		return false
	});
		
	$('.removecart').click(function(){
		var value 	= $(this).attr('id')+"";
		var id 		= value.replace("remove_", "");
	
		$.ajax({
			cache: false,
			type: "POST",
			url: "/index.php/cart/remove_ajax",
			data: "product="+id,
			success: function(){
				$('#cs_'+id).removeClass('selected-item-off');
				$('#remove_'+id).addClass('selected-item-off');
			}
		});
		return false
	}); 
	
	$('.removebtn').click(function(){
		var value 	= $(this).attr('id')+"";
		var id 		= value.replace("select_", "");
		
		var checker = confirm('Are you sure you want to remove this item from your cart?');
		
		if (checker== true)
		{
		   $("#remove_"+id).submit();
		}

	}); 
	
	$("#tweets").tweet({
          avatar_size: 32,
          count: 5,
          username: ["kenobriensports"],
          loading_text: "Loading Tweets..."
        });
	
	$('.experts-side').mouseover(function(){
		var value 	= $(this).attr('id')+"";
		var id 		= value.replace("expert_", "");
		$('#fp_content_'+id).removeClass('selected-item-off');

	}); 
	
	$('.experts-side').mouseout(function(){
		var value 	= $(this).attr('id')+"";
		var id 		= value.replace("expert_", "");
		$('#fp_content_'+id).addClass('selected-item-off');
	}); 
	
	$('#phone1').keyup(function(){
		var len = $(this).val();
		if(len.length == 3){
			$('#phone2').focus();
		}
	});
	$('#phone2').keyup(function(){
		var len = $(this).val();
		if(len.length == 3){
			$('#phone3').focus();
		}
	}); 
	
	$('.usecode').click(function(){
			
		var value 	= $(this).attr('id')+"";
		var id		= value.replace("applycode_", "");
		
		var code	= $('#codevalue_'+id).val();
		
		$('#promocode').val(code);
		
	});

})

