$(function(){
	
	// Load sidebar elements from homepage
	var loadSideGlobalRegion = function(){
		if( $('body').hasClass('home') == false ){
			$("#sidebar_region").load("home.html #sidebar_globalregion", function(){
				//$('.loader_box').fadeOut();
				
			});
		}
	};
	
	//loadSideGlobalRegion();
	
	if ($('.more_link > a').length < 1){
		$('.more_link').remove();
	};
	
	// Set product product enquiry form
	var getValues = function(){
		var product_title = $('#pd_detail_left div#title').text();
		$('input#product_name').val(product_title);
	};
	
	$('a.enquiry_button').click(function(){
		$('#product_enquiry').show();
		getValues();
	});
	
	$('a.close_enquiry').click(function(){
		$('#product_enquiry').hide();
	});
	
	
	// Postcode search & Product search
	$('input#postcode_search').focus(function(){
		if(this.value == "Enter your postcode"){
			this.value = "";
		}
	});
	$('input#postcode_search').blur(function () {
		if(this.value == "") {
			this.value = "Enter your postcode";
		}
	});
	
	$('input#postcode_search').keydown(function(event){
		var k = event.keyCode;
		if(k == 13 && $('input#postcode_search').val().length >= 4) {
			var postcode = $('input#postcode_search').val();
			document.location.href = "/custom/postcodes/" + postcode;
			//return false; 
		}
	});
	
	$('select#searchbox').change(function(){
		var searchTerm = $('select#searchbox option:selected').val();
		if(searchTerm != "null"){
			document.location.href = "http://swordfish.blockshome.com/custom/product_searches/" + searchTerm;
		}
	});
	
	$('.news_toggle a').mouseenter(function(){
		_parent = $(this).parent();
		var slideTo = $('.news_preview .news_content', _parent).height()+"px";
		//$('.news_preview', this).slideDown(800);
		$('.news_preview', _parent).show();
		$('.news_preview', _parent).animate({"height": slideTo}, "slow");
		
	});
	
	$('.news_toggle').mouseleave(function(){
		//$('.news_preview', this).show();
		$('.news_preview', this).animate({"height": "0px"}, "slow");
	});

});