$(document).ready(function() {
		
	/**** Idea input - remove text on click
	/************************************************/
	$('#idea-input').click (function () {
		$(this).val('');
	});
	
	/**** Idea submit
	/************************************************/
	$('#ideas-add-form .submit').click (function () {
		
		// Set button HTML to nothing
		$(this).css('display', 'none');
		
		$('#ideas-add-form .loader').css('display', 'block');
		
		$idea = $('#idea-input').val();
		$cat_id = $('#cat-id').val();
		
		$.post("/ajax.php?q=submit_idea", { idea: $idea , cat_id: $cat_id },
			   
		function(data, textStatus) 
		{
			$('#ideas-add-form .loader').css('display', 'none');
			
			if (data == 1)
			{
				$('.msg').html('<span class="success">Many thanks for your suggestion. If approved it will appear here shortly.</span>');
				
				$('.msg').slideDown('slow');
				$('#idea-input').val('');
				$('#ideas-add-form .submit').html('Add another proposal idea');
			}
			else
			{
				$('.msg').html('<span class="error">' + data + '</span>');
				$('.msg').slideDown('slow');
			}
			
			$('#ideas-add-form .submit').slideDown(200);
			
		}, "json");
		
	});

	
	/**** Menu animation
	/************************************************/
	$("#menu li")
	
	.mouseover(function(){
						
		if ( $(this).attr('class') != 'active' )
		{			
			$(this).stop().animate(
				{backgroundPosition:"(0 0)"}, 
				{duration:200})	
		}
	})
	
	.mouseout(function(){
					   
		if ( $(this).attr('class') != 'active' )
		{	
			$(this).stop().animate(
				{backgroundPosition:"(0 58px)"}, 
				{duration:100})
		}
	})
	/************************************************/
	
	
	/**** Menu animation
	/************************************************/
	
	$('.box-categories div').click( function (){
											  
		switch ( $(this).attr('class') )
		{
			case 'romantic':
				$slug = 'romantic-proposal-ideas';
			break;
			
			case 'impressive':
				$slug = 'impressive-proposal-ideas';
			break;
			
			case 'unconventional':
				$slug = 'unconventional-proposal-ideas';
			break;
			
			case 'discreet':
				$slug = 'discreet-proposal-ideas';
			break;
			
			case 'white-gold':
				$slug = 'white-gold-engagement-rings';
			break;
			
			case 'gold':
				$slug = 'gold-engagement-rings';
			break;
			
			case 'two-colour':
				$slug = 'two-colour-engagement-rings';
			break;
			
			case 'platinum':
				$slug = 'platinum-engagement-rings';
			break;
			
			case 'engagement-jewellery':
				$slug = 'engagement-jewellery';
			break;
			
			case 'cherishable':
				$slug = 'cherishable-engagement-gifts';
			break;
			
			case 'romantic-experiences':
				$slug = 'romantic-experiences';
			break;
			
			case 'other':
				$slug = 'other-engagement-gift-ideas';
			break;
		}
		
		$url =  $slug + '/';
		
		$(window.location).attr('href', $url);
		
		return;
	});

	/************************************************/
	
	/**** Ring Results item click
	/************************************************/
	$('#results .result').click (function () {
		$ring_id = $(this).attr('id').substring(4);
		$url = 'http://www.yourproposal.co.uk/view-ring/' + $ring_id + '.html'
		window.open($url, "_blank");
	});
	
	/**** Latest rings click
	/************************************************/
	$('#latest-engagement-rings li').click (function () {
		$ring_id = $(this).attr('id').substring(4);
		$url = 'http://www.yourproposal.co.uk/view-ring/' + $ring_id + '.html'
		window.open($url, "_blank");
	});
	
	/**** Gift Results item click
	/************************************************/
	$('#gifts-list .item').click (function () {
		$gift_id = $(this).attr('id').substring(4);
		$url = 'http://www.yourproposal.co.uk/view-gift/' + $gift_id + '.html'
		window.open($url, "_blank");
	});
	
	/**** Latest gifts click
	/************************************************/
	$('#latest-gifts li').click (function () {
		$gift_id = $(this).attr('id').substring(4);
		$url = 'http://www.yourproposal.co.uk/view-gift/' + $gift_id + '.html'
		window.open($url, "_blank");
	});
	
});


function showLoader($id)
{
	document.getElementById($id).innerHTML = '<img src="/images/ajax-loader-2.gif" alt="Loading" class="loading" />';
	return true;
}

