/* <![CDATA[ */
// when the DOM is ready to be manipulated do some voodoo.
$(document).ready( function(){

//jmedia flash embed
$("#advert").jmedia(
	{version:"8,0"},
	{src:"/media/advert.swf",
	 allowScriptAccess:"sameDomain",
	 quality:"best",
	 wmode:"transparent",
	 width:"392",
	 height:"320"
});

//jmedia flash embed
$("#colour-catcher").jmedia(
	{version:"8,0"},
	{src:"/media/colour-catcher.swf",
	 allowScriptAccess:"sameDomain",
	 quality:"best",
	 wmode:"transparent",
	 width:"540",
	 height:"340"
});


//where to buy pop up
$("#wheretobuy").hide();
$("#buytoggle, #close").click( function(){
	$("#wheretobuy").toggle();
});



//the range details pop up
$("#range-oxi").hide();
$("#range-ultra").hide();

$(".buytoggle").click( function(){
	$(this.href.substring(this.href.indexOf("#"), this.href.length)).toggle();
	$("#range-cc, #range-oxi, #range-ultra").not( $(this.href.substring(this.href.indexOf("#"), this.href.length)) ).hide();
});

$(".wheretobuy-popup").hide();
$(".wheretobuy").click( function(){
	$(this.href.substring(this.href.indexOf("#"), this.href.length)).toggle();
	//$("#wheretobuy-cc, #wheretobuy-oxi, #wheretobuy-ultra").not( $(this.href.substring(this.href.indexOf("#"), this.href.length)) ).hide();
});

$(".close").click( function(){
	$(this).parent().hide();
});


			$('#i_freesample').click(function() {
				if ($("#i_freesample").is(":checked")){
					$('#i_informedproducts').attr("checked","checked");
				}
			});
		
		// when the form is submitted
		$('#f_contact').submit( function(){
		
			var reg_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
		
			var inputcheck = $('#i_fullname');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				alert("Please enter your name.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
			var inputcheck = $('#i_email');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' || !reg_email.test( inputcheck.val() ) ){
				alert("Please enter a valid email address.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			

			var inputcheck = $('#i_address');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				alert("Please enter your address.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}

			var inputcheck = $('#i_towncity');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				alert("Please enter your town/city.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}

			var inputcheck = $('#i_postcode');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				alert("Please enter your postcode.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}

			var inputcheck = $('#i_postcode2');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				alert("Please enter your postcode.");
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}

			
		});
		
});
/* ]]> */