$(document).ready(function(){
	
	$("a[href*=#][class!=more_information]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$("html,body")
				.animate({scrollTop: targetOffset}, 1000);
			return false;
			}
		}
	});
	
	if (document.location.href == 'http://www.intaeco.co.uk/products/') {
		$("#sub_nav_holder").hide();
		$("#sub_nav_holder").slideDown(1000);
	};
	
	$(".more_information").click(function() {
		$(".product_information:visible").slideUp("slow");
		setTimeout("1000");
		$(this).parents().nextAll(".product_information").slideDown("slow");
		return false;
	});
	
	$(".product_information").append('<a class="hide_link"><img src="/images/12-em-cross.png" /></a>');
	
	$(".product_information").each( function() {
		var link = $(this).prev().children("a").attr("href");
		$(this).append("<p /><a href=\"" + link + "\" class=\"read_more\">Read More</a>");
	});
	
	$(".hide_link").click(function() {
		$(this).parents(".product_information").slideUp("slow");
	});
	
	$("#supplementary_column div:gt(0)").hide();
	$("#supplementary_column h2 a").click(function() {
		$("#supplementary_column div:visible").slideUp("slow");
		$(this).parent().next().slideDown("slow");
		return false
	});
	
	regex = new RegExp("^http://www.intaeco.co.uk/products/");
	address = document.location.href;
	
	if (regex.test(address)) {
		return false;
	} else {
		var myPix = new Array("/images/solar.jpg", "/images/water_drop.jpg", "/images/underfloor.jpg", "/images/geothermal.jpg", "/images/control.jpg");
		imgCt = myPix.length;
		randomNum = Math.floor ((Math.random() * imgCt));
		link = myPix[randomNum]
		$('#main_pic').attr({ src: link });
	};
	
	return;
})