$(document).ready(function(){

	//Remove text from input box
	if( $("#q").val() == "" ) {
		$("#q").addClass('midgrey');
		$("#q").val('Search Design Supremo...');
	}

	$("#q").focus( function() {
		if ( $(this).val() == 'Search Design Supremo...' ) {
			$(this).val('');
			$(this).removeClass('midgrey');
		}
	});

	$('##nav li').hover(  
		function () {  
			//show its submenu  
			$('ul', this).slideDown(100);  
		},   
		function () {  
			//hide its submenu  
			$('ul', this).slideUp(100);           
		}  
	);  


	$(".hover").hover(
		function(){
			if($(this).attr("src").indexOf("-hover") == -1) {
				var newSrc = $(this).attr("src").replace(".png","-hover.png##hover");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-hover.png##hover") != -1) {
				var oldSrc = $(this).attr("src").replace("-hover.png##hover",".png");
				$(this).attr("src",oldSrc);
			}
		}
	);

	//Remove text from input box
	$("#newsletter-email").focus( function() {
		if ( $(this).val() == 'Enter email address' ) {
			$(this).val('');
			$(this).removeClass('midgrey');
		}
		return false;
	});

	$("#newsletter-form").submit( function() {
		newsletterSubscribe();
		return false;
	});
});

function newsletterSubscribe() {
	$.getJSON(
		'_gateway/newsletter.cfc',
		{ method: 'subscribe', email: $('#newsletter-email').val() },
		function(data) {
			//Set new value
			alert( data.MSG );
			
			if ( data.SUCCESS == 1 ) {
				$('#newsletter-email').val('');
			}
		}
	);
}
