/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if(!$.browser.msie){
Cufon.replace('span.nav_text', {fontWeight: 300, color: '#ffffff', fontFamily: 'GillSans', fontSize: '13pt'});
Cufon.replace('h1.gillsans_main', {fontWeight: 300, color: '#c0151b', fontFamily: 'GillSans', fontSize: '28pt'});
Cufon.replace('h1.gillsans_main sup', {fontWeight: 300, color: '#c0151b', fontFamily: 'GillSans', fontSize: '14pt'});
Cufon.replace('h1.gillsans', {fontWeight: 300, color: '#666666', fontFamily: 'GillSans', fontSize: '28pt'});
Cufon.replace('h1.gillsans sup', {fontWeight: 300, color: '#666666', fontFamily: 'GillSans', fontSize: '14pt'});
Cufon.replace('h2.gillsans', {fontWeight: 300, color: '#c0151b', fontFamily: 'GillSans', fontSize: '28pt'});
Cufon.replace('h2.gillsans sup', {fontWeight: 300, color: '#c0151b', fontFamily: 'GillSans', fontSize: '14pt'});
Cufon.replace('h4.gillsans', {fontWeight: 300, color: '#666666', fontFamily: 'GillSans', fontSize: '18pt'});
Cufon.replace('h4.gillsans_b', {fontWeight: 300, color: '#333333', fontFamily: 'GillSans', fontSize: '18pt'});
Cufon.replace('h4.gillsans_r', {fontWeight: 300, color: '#c0151b', fontFamily: 'GillSans', fontSize: '18pt', margin:'11px 0'});
Cufon.replace('div.sign_up_form h3', {fontWeight: 300, color: '#ffffff', fontFamily: 'GillSans', fontSize: '18pt'});
Cufon.replace('div.staf_form h3', {fontWeight: 300, color: '#ffffff', fontFamily: 'GillSans', fontSize: '18pt'});
Cufon.replace('div.unsubscribe_box h3', {fontWeight: 300, color: '#ffffff', fontFamily: 'GillSans', fontSize: '18pt'});
Cufon.replace('.social_network_link', {fontWeight: 300, color: '#325e9f', fontFamily: 'GillSans', fontSize: '13pt'});
}
url = 'http://www.campbellsoup.co.uk/';

$(document).ready(function(){
    
	 
	 
	$('.nav_ele').mouseenter(function() {
       $('#nav_top_'+this.id).slideToggle('slow');
    });
    $('.nav_ele').mouseleave(function() {
       $('#nav_top_'+this.id).slideToggle('slow');
    });
	
	
	$('#postcode').focus(function(){
		if($(this).val() == 'Enter Postcode'){
			$(this).val('');
		}
								  });
	$('#postcode').blur(function(){
		if($(this).val() == ''){
			$(this).val('Enter Postcode');
		}
								  });
	
	
	$('.store_submit').click(function(){
								  
			var postcode = $('#postcode').val();
			var product = $('#product').val();
			$.ajax({
			type:'post',
			url:'themes/campbells/javascript/ajax/getStores.php',
				data:{postcode:postcode,product:product},
				success:updateStores
			});
									  });
	
	
	$('#tanc').click(function(){
		$('#tanc_wrapper').show();						  
							  });
	
	$('#tanc_close').click(function(){
		$('#tanc_wrapper').hide();						  
							  });
	
	$('.tanc').click(function(){
		$('#tanc_wrapper').show();						  
							  });
	
	
	
		
	$('#recipe_name').focus(function(){
		if($(this).val() == 'Recipe Name'){
			$(this).val('');
		}
								  });
	$('#recipe_name').blur(function(){
		if($(this).val() == ''){
			$(this).val('Recipe Name');
		}
								  });
	
	$('#first_name').focus(function(){
		if($(this).val() == 'First Name'){
			$(this).val('');
		}
								  });
	$('#first_name').blur(function(){
		if($(this).val() == ''){
			$(this).val('First Name');
		}
								  });
	
	$('#last_name').focus(function(){
		if($(this).val() == 'Last Name'){
			$(this).val('');
		}
								  });
	$('#last_name').blur(function(){
		if($(this).val() == ''){
			$(this).val('Last Name');
		}
								  });
	
	$('#email').focus(function(){
		if($(this).val() == 'Email'){
			$(this).val('');
		}
								  });
	$('#email').blur(function(){
		if($(this).val() == ''){
			$(this).val('Email');
		}
								  });
	$('#recipe').focus(function(){
		if($(this).val() == 'Write your recipe here'){
			$(this).val('');
		}
								  });
	$('#recipe').blur(function(){
		if($(this).val() == ''){
			$(this).val('Write your recipe here');
		}
								  });
	
	$('.vote_button').click(function(){
								  
			var id = $(this).attr('value');
						
			$.ajax({
			type:'post',
			url:url+'themes/campbells/javascript/ajax/vote.php',
				data:{id:id},
				success:function(data){
					 data = $.parseJSON(data);
					$('#vote_'+data.id).html(data.html);	
				}
			});
									  });
									  
	$('#rec_product').change(function(){
		var prodid = $('#rec_product option:selected').val();
		if(prodid != 0){
		$.ajax({
			type:'post',
			url:url+'themes/campbells/javascript/ajax/product_changed.php',
				data:{id:prodid},
				success:function(data){
					 data = $.parseJSON(data);
					$('#rec_ingredient').html(data.ingredients);
					$('#rec_cuisine').html(data.cuisine);
					$('#rec_time').html(data.time);	
				}
			});
		}
	});
	
	
	$('#rec_ingredient').change(function(){
		var prodid = $('#rec_product option:selected').val();
		var ingid = $('#rec_ingredient option:selected').val();
		if(ingid != 0){
		$.ajax({
			type:'post',
			url:url+'themes/campbells/javascript/ajax/ingredient_changed.php',
				data:{id:prodid,ing:ingid},
				success:function(data){
					 data = $.parseJSON(data);
					
					$('#rec_cuisine').html(data.cuisine);
					$('#rec_time').html(data.time);	
				}
			});
		}
	});
	
	$('#rec_cuisine').change(function(){
		var prodid = $('#rec_product option:selected').val();
		var ingid = $('#rec_ingredient option:selected').val();
		var cuiid = $('#rec_cuisine option:selected').val();
		if(cuiid != 0){
		$.ajax({
			type:'post',
			url:url+'themes/campbells/javascript/ajax/cuisine_changed.php',
				data:{id:prodid,ing:ingid,cid:cuiid},
				success:function(data){
					 data = $.parseJSON(data);
					
					//$('#rec_cuisine').html(data.cuisine);
					$('#rec_time').html(data.time);	
				}
			});
		}
	});
	
	
});

function updateStores(data){
	
	$('#store_results').html(data);
	if($('#store_results').is(":hidden")){
		$('#store_results').slideDown("slow");
	}
}

