
			function mdebug(msg){
				if(dbug){
					old = $("#debug").html();
					$("#debug").html(old+'--'+msg);
				}
			}
			
			function slide_it(too, high){
				mdebug("slide_it("+too+") called");
				if(dbug){
				//hide_board(too);	
				}else{
				//$("#screen2").stop();
				//$("#screen2").animate({
				//	left: too,
				//	top: high
				//});
			}
		}
			
			function slide_it2(too, high){
				//
				mdebug("slide_it("+too+") called");
				if(dbug){
				//hide_board(too);	
				}else{
					//alert("helloed");
				$("#front_bottom").stop();
				$("#front_bottom").animate({
					left: too,
					top: high
				});
			}
			//clearTimeout(t);
			mdebug("slide_it2("+too+") ended");
			}
			
			var b_shown = true;
			var sb_called = false;
			var dbug = false;
			var t = 0;
			var pot_run = 0;
			
			function color_others(two, three){
				if(two){
					$("#showcase_but").css("border-top-color", "#FCC324");
				}
				if(three){
					$("#opinion_but").css("border-top-color", "#FCC324");
				}
				$("#treer").css("border-right-color", "#FCC324");
				$("#claim_but").css("border-bottom-color", "#FCC324");
				$("#claim_but").css("border-left-color", "#FCC324");
			}
			
			function just_color_3(){
				$("#claim_but").css("border-bottom-color", "#FCC324");
				$("#claim_but").css("border-left-color", "#FCC324");
			}
			function unjust_color_3(){
				$("#claim_but").css("border-bottom-color", "#CCCCCC");
				$("#claim_but").css("border-left-color", "#CCCCCC");
			}
			
			
			function uncolor_others(two, three){
				if(two){
					$("#showcase_but").css("border-top-color", "#CCCCCC");
				}
				if(three){
					$("#opinion_but").css("border-top-color", "#CCCCCC");
				}
				$("#treer").css("border-right-color", "#CCCCCC");
				$("#claim_but").css("border-bottom-color", "#CCCCCC");
				$("#claim_but").css("border-left-color", "#CCCCCC");
			}
			
			$(function(){ //onload functions
				$("#front_search").keydown(function(event){
					if(event.keyCode==13){
						subsearch();
					};
				});
				
				$("#tradelink").click(function(){
					window.location = "/trade.htm";
				});
				setTimeout('potato(1)', 3000); 
				$("#goldcard_but").mouseenter(function(){
					//$("#front_search").Watermark("Enter your postcode to find a craftsman...");
					slide_it(0,-356);
					slide_it2(0,0);
					graceful_fade(0);
					move_treer(-320);
					start_new_swix(1);
				});
				$("#overlay").mouseenter(function(){
					slide_it(-960,0);
					graceful_fade(0);
					move_treer(-320);
				});
				$("#choose_but").mouseenter(function(){
					//$("#front_search").Watermark("Enter the company name to check credentials...");
					mdebug("mouseover fired!");
					slide_it(-960,-356);
					slide_it2(-480,0);
					graceful_fade(-960);
					move_treer(0);
					start_new_swix(2);
					if(pot_run == 0){
						//alert("Running quotes");
					setTimeout('potato(1)', 3000);
				}
				});
				$("#claim_but").mouseenter(function(){
					slide_it(-1920,-356);
					slide_it2(-960,0);
					just_color_3();
					graceful_fade(-1920);
					move_treer(320);
					start_new_swix(3);
				});
				//$("#highstreet_but").mouseenter(function(){
				//	slide_it(-1920,0);
				//	color_others(true,true);
				//});
				//$("#showcase_but").mouseenter(function(){
				//	slide_it(-1920,0);
				//	color_others(true,true);
				//});
				//$("#opinion_but").mouseenter(function(){
				//	slide_it(-1920,-359);
				//	color_others(false,true);
				//	
				//});
				$("#hid_qc").click(function(){
					window.location = "prices.htm";
				});
				
				$("#searchlink").click(function(){
					slink = $("#searchlink").attr("rel");
					window.location = slink;
				});
				
				$("#hid_rm").click(function(){
					hide_if("activeform");
					hide_if("verifyform");
					hide_if("loginform");
					hide_if("aboutus");
					hide_if("recommendoform");
					hide_if("oclaimform");
					$("#recomlink").trigger('click');
					if($("#recomform").css('top')!='33px'){
					$("#recomform").animate({
						top: 33
					});
				}else{
					$("#recomform").animate({
						top: -610
					});
				}
				});
				
				$("#claim_but").mouseleave(function(){
					unjust_color_3();
				});
				$("#highstreet_but").mouseleave(function(){
					uncolor_others(true,true);
				});
				$("#showcase_but").mouseleave(function(){
					uncolor_others(true,true);
				});
				$("#opinion_but").mouseleave(function(){
					uncolor_others(false,true);
				});


				$("#login").click(function(){
					if($.cookie('uid')){
						window.location = 'ma.php';
					}
					hide_if("recommendoform");
					hide_if("recomform");
					hide_if("activeform");
					hide_if("oclaimform");
					hide_if("verifyform");
					hide_if("aboutus");
				if($("#loginform").css('top')!='33px'){
					$("#loginform").animate({
						top: 33
					});
				}else{
					$("#loginform").animate({
						top: -350
					});
				}	
				});
				
				$(".hottip").mouseenter(function(){
					//$("#hottip_text").html($(this).attr("COORDS"));
				});
				
				
				setTimeout("hottip_load()", 1500);
				
				//do mapover thing
				$(".mapover").mouseenter(function(){
					relf = $(this).attr("rel");
					$('#hottipA_'+relf).effect("pulsate", {}, 500);
				});
				$(".mapover2").mouseenter(function(){
					relf = $(this).attr("rel");
					$('#hottipb_'+relf).effect("pulsate", {}, 500);
				});
				
				$(".mapover").mouseleave(function(){
					relf = $(this).attr("rel");
					$('#hottipA_'+relf).stop(true, true);
					$('#hottipA_'+relf).css("opacity", 0);
				});
				$(".mapover2").mouseleave(function(){
					relf = $(this).attr("rel");
					$('#hottipb_'+relf).stop(true, true);
					$('#hottipb_'+relf).css("opacity", 0);
				});
				
				$("#activate").click(function(){
					hide_if("recomform");
					hide_if("recommendoform");
					hide_if("loginform");
					hide_if("verifyform");
					hide_if("oclaimform");
					hide_if("aboutus");
				if($("#activeform").css('top')!='33px'){
					$("#activeform").animate({
						top: 33
					});
				}else{
					$("#activeform").animate({
						top: -450
					});
				}
				});
				
				$("#ver_but").click(function(){
				//validate and then distroy!
				validate_verify();
				});
				
				
				$("#verify_link").click(function(){
					hide_if("recomform");
					hide_if("recommendoform");
					hide_if("activeform");
					hide_if("loginform");
					hide_if("aboutus");
					hide_if("oclaimform");
				if($("#verifyform").css('top')!='33px'){
					$("#verifyform").animate({
						top: 33
					});
				}else{
					$("#verifyform").animate({
						top: -600
					});
				}
				});
				
				$("#recommendo_link").click(function(){
					hide_if("recomform");
					hide_if("activeform");
					hide_if("loginform");
					hide_if("aboutus");
					hide_if("verifyform");
					hide_if("oclaimform");
				if($("#recommendoform").css('top')!='33px'){
					$("#recommendoform").animate({
						top: 33
					});
				}else{
					$("#recommendoform").animate({
						top: -600
					});
				}
				});
				
				$("#oclaim_link").click(function(){
					hide_if("recomform");
					hide_if("activeform");
					hide_if("loginform");
					hide_if("aboutus");
					hide_if("verifyform");
					hide_if("recommendoform");
				if($("#oclaimform").css('top')!='33px'){
					$("#oclaimform").animate({
						top: 33
					});
				}else{
					$("#oclaimform").animate({
						top: -600
					});
				}
				});
				
				$("#recommend").click(function(){
					hide_if("activeform");
					hide_if("loginform");
					hide_if("recommendoform");
					hide_if("aboutus");
					hide_if("oclaimform");
					 $("#recomlink").trigger('click');

					if($("#recomform").css('top')!='33px'){
					$("#recomform").animate({
						top: 33
					});
				}else{
					$("#recomform").animate({
						top: -610
					});
				}
				});
				
				$("#homelink").click(function(){
					window.location = '/index.htm';
				});
				$("#trade_but").click(function(){
					window.location = '/priceengine.htm';
				});
				
				$("#about").click(function(){
					window.location = '/about.htm';
				});
				$("#about_close").click(function(){
					$("#aboutus").animate({
							top:-375
						}, 500);
				});
				
				$("#trade").click(function(){
					window.location = '/trade.htm';
				});
				
					setTimeout("fade_it('cover1');", 1000);
					setTimeout("fade_it('cover2');", 2000);
					setTimeout("fade_it('cover3');", 3000);
				
				$(window).load(function(){
					
					setTimeout("fade_it('coverbot');", 4000);
					setTimeout("fade_it('loading');", 4000);
			});
			
			//submit product thing.
			$("#product_submit").click(function(){
				if(validate_product()){
				$("#prod_form_cont").fadeOut("slow", function(){
					$.post("/nnac/pro_product.php", $("#producto").serialize(), function(data){
						$("#prod_form_cont").html(data);
						$("#prod_form_cont").fadeIn("slow");
						loadup_pro_extra();
					});
				});
			}
			});
			
			//activate form stuff:
			
			$("#pur_but").click(function(){
				validate_active();
			});
			
			$("#rrec_but").click(function(){
			 validate_recommend();	
			});
			
			
			if($.cookie('halfway')){
				loadup_pro_extra();
			}
			
			$("#dooLogin").click(function(){
				choose_a_craftsman();
				
				
			});
			
			$("#finbut").click(function(){
				//validate better quote
				error = '';
				if($("#bq_yes").attr("checked") == "checked"){
				if($("#bq_suppname").val()==""){
					error = error+'- You must enter the supplier name.\n';
				}
				if($("#bq_price").val()==""){
					error = error+'- You must enter the price.\n';
				}
				}
				if($("#start_date").val()==""){
					error = error+'- You must enter when you\'d like work to begin.\n';
				}
				if(error==''){
				
				$("#prod_form_cont").fadeOut("slow", function(){
					$.post("/bq_pro.inc.php", $("#afp_form").serialize(), function(data){
						$("#prod_form_cont").html(data);
						$("#prod_form_cont").fadeIn("slow");
						$("#cf_but").click(function(){
							//validate the confirm
							cerror = '';
							if($("#cf_name").val()==""){
								cerror = cerror+'- You must enter your name.\n';
							}
							if(!isValidEmailAddress($("#cf_email").val())){
								cerror = cerror+'- You must enter your valid email address.\n';
							}
							if($("#cf_phone").val()==""){
								cerror = cerror+'- You must enter your phone number.\n';
							}
							if($("#cf_address").val()==""){
								cerror = cerror+'- You must enter your address.\n';
							}
							if($("#cf_pc").val()==""){
								cerror = cerror+'- You must enter your postcode.\n';
							}
							if(cerror==''){
							$("#prod_form_cont").fadeOut("slow", function(){
								$.post("/bq_final.php", $("#cf_form").serialize(), function(data){
									$("#prod_form_cont").html(data);
									$("#bq_text").fadeOut("fast");
									$("#bq_screen").fadeIn("slow");
									$("#prod_form_cont").fadeIn("slow");
								});
							});
						}else{
							alert(cerror);
						}
						});
					});
				});
			}else{
				alert(error);
			}
			});
			
			//setTimeout("nextext(1)", 5000);
			
			$("a#inline").fancybox({
					'width'				: '75%',
					'height'			: '75%',
        	'autoScale'     	: false,
      	  'transitionIn'		: 'fade',
					'transitionOut'		: 'fade',
					'type'				: 'inline'
				});
				$("#start_date" ).datepicker({ minDate: +21, maxDate: "+12M +1D" });
				
				$("#career_but").click(function(){
					//verfiy data.
					error = '';
					if($("#car_name").val()==""){
						error = '- You must enter your name.\n';
					}
					if($("#car_email").val()==""){
						error = error+'- You must enter your email.\n';
					}
					if($("#car_tel").val()==""){
						error = error+'- You must enter your phone number.\n';
					}
					if($("#car_address").val()==""){
						error = error+'- You must enter your address.\n';
					}
					if($("#car_postcode").val()==""){
						error = error+'- You must enter your postcode.\n';
					}
					
					if(error==''){
						$("#career_app").submit();
					}else{
						alert(error);
					}
					
					
					
				});
				
				$("#bd_sub").click(function(){
					//validate!
					error = "";
					if($("#bd_name").val()==""){
						error = error+'You must enter the name of the account\n';
					}
					if($("#bd_bankname").val()==""){
						error = error+'You must enter the name of the bank\n';
					}
					if($("#bd_sortcode").val()==""){
						error = error+'You must enter the sort code\n';
					}
					if($("#bd_accnum").val()==""){
						error = error+'You must enter the account number\n';
					}
					if(error==""){
						$.post("/bd_pro.php", $("#bd_form").serialize(), function(data){
							window.location = "thanks.htm";
						});
					}else{
						alert(error);
					}
					
					
					
					
				});
				
				//feedback form
				$("#fb_but").click(function(){
					$.post("/feedback_search.php", $("#feedback_form").serialize(), function(data){
						$("#recomform_cont").html(data);
					});
				});
				
				$("#please_qc_but").click(function(){
				error = ''
				if($("#company_name").val()==""){
					error = error+'You must enter the company name.\n';
				}
				if($("#company_tel").val()==""){
					error = error+'You must enter the company phone number.\n';
				}
				
				if(error==''){
					second_prod_step();
				}else{
					alert(error);
				}
				
				});
				
				$("#please_rm_but").click(function(){
					error = '';
					if($("#requirements").val()==""){
						error = error+'You must enter your requirements.\n';
					}
					
					if(error==''){
					second_prod_step();
				}else{
					alert(error);
				}
					
					
				});
				
				$("#rv_but").click(function(){
					review_search();
				});
				$("#hid_fc").click(function(){
					$("#find_company_link").trigger('click');
				});
				
				pe_submiter();
				lightboxes();
				rv_search();
				$("#search_sub").click(function(){
					subsearch();
				});
				$("#write_review_sub").click(function(){
					validate_review();
				});
				//navigation tooltips
				$(".tipped").mouseenter(function(){
					$("#tipper").stop();
					//moveto offset
					this_off = $(this).offset();
					$("#tipper").html($(this).attr("rel"));
					$("#tipper").animate({top: this_off.top+40, left: this_off.left-85}, 200);
					
					$("#tipper").fadeIn(200, function(){
						$("#tipper").css("opacity", "1");
					});
					
				});
				
				$(".tipped").mouseleave(function(){
					$("#tipper").stop();
					$("#tipper").fadeOut("Fast");
				});
				
				//$("#wr_review_text").Watermark("Describe the work you've had done\nHow good is the workmanship?\nWere they punctual and courteous?\nDid they keep their promises?");
				
				$("#rv_name").Watermark("Search for a company...");
				$("#front_search").Watermark("Enter a company name or your postcode...");
				$(".tiptitle").tooltip({ position: "bottom center", opacity: 0.9});
				$("#write_but").click(function(){
					 //$("#write_review_link").trigger('click');
				});
				$(".report_review_but").click(function(){
					$("#report_id").val($(this).attr("rel"));
					 $("#report_review_link").trigger('click');
				});
				$("#review_posneg").change(function(){
					//alert($("#review_posneg option:selected").val());
					if($("#review_posneg option:selected").val()=="Yes"){
						$("#posneg_sent").html("I recommend this company.");
					}else{
						$("#posneg_sent").html("I don't recommend this company.");
					}
					
				});
				$("#actual_report_but").click(function(){
					$("#actual_report_review_cont").fadeOut("slow", function(){
					$.post("/report_review.php", $("#report_review_form").serialize(), function(data){
						$("#actual_report_review_cont").html(data);
						$("#actual_report_review_cont").fadeIn("slow");
					});
					
				});
					
				});
				
				$(".nrec_linkbox").click(function(){
		loc = $(this).attr("rel");
		window.location = loc;
	});
	
	$("#notsure_but").click(function(){
		//validate
			
			error = "";
			if($("#qn_name").val()==""){
				error = error+'You must enter your name.\n';
			}
			if(!isValidEmailAddress($("#qn_email").val())){
				error = error+'You must enter your email address.\n';
			}
			
			if($("#qn_phone").val()==""){
				error = error+'You must enter your phone number.\n';
			}
			if($("#qn_address").val()==""){
				error = error+'You must enter your address.\n';
			}
			if($("#qn_reqs").val()==""){
				error = error+'You must enter your requirements.\n';
			}
			
			if(error!=""){
			alert(error);	
			}else{
		$("#recommendoform_cont").fadeOut("slow", function(){
			
			
			$.post("/notsure_pro.php", $("#notsure_form").serialize(), function(data){
				$("#recommendoform_cont").html(data);
				$("#recommendoform_cont").fadeIn("slow");
				
			});
		});
	}
	});
	
	$("#oclaim_but").click(function(){
		//validate
			
			error = "";
			if($("#oc_name").val()==""){
				error = error+'You must enter your name.\n';
			}
			if(!isValidEmailAddress($("#oc_email").val())){
				error = error+'You must enter your email address.\n';
			}
			
			if($("#oc_phone").val()==""){
				error = error+'You must enter your phone number.\n';
			}
			if($("#oc_address").val()==""){
				error = error+'You must enter your address.\n';
			}
			if($("#oc_reqs").val()==""){
				error = error+'You must enter your requirements.\n';
			}
			if($("#oc_comp_name").val()==""){
				error = error+'You must enter the name of the company that quoted you.\n';
			}
			if($("#oc_quoted").val()==""){
				error = error+'You must enter the amount you were quoted.\n';
			}
			
			if(error!=""){
			alert(error);	
			}else{
		$("#oclaimform_cont").fadeOut("slow", function(){
			
			
			$.post("/oclaim_pro.php", $("#oclaim_form").serialize(), function(data){
				$("#oclaimform_cont").html(data);
				$("#oclaimform_cont").fadeIn("slow");
				$("#oclaim2_but").click(function(){
					$("#oclaimform_cont").fadeOut("slow", function(){
					$.post("/oclaim2_pro.php", $("#oclaim2_form").serialize(), function(data){
						$("#oclaimform_cont").html(data);
						$("#oclaimform_cont").fadeIn("slow");
						
						
					});
				});
			});
				
			});
		});
	}
	});
	
	$(".nrec_linkbox").mouseenter(function(){
		cid = $(this).attr("cid");
		$('#rec_details_'+cid).hide();
		$('#products_'+cid).show();
		
	});
	
	$(".nrec_linkbox").mouseleave(function(){
		cid = $(this).attr("cid");
		$('#rec_details_'+cid).show();
		$('#products_'+cid).hide();
		
	});
	
	$("#request_check_but").click(function(){
		$("#actual_check_a_company").fadeOut("slow", function(){
			$.post("/request_check.php", $("#request_check_form").serialize(), function(data){
				$("#actual_check_a_company").html(data);
				$("#actual_check_a_company").fadeIn("slow");
			});
		});
	});
	
	
	$("#list_but").click(function(){
		$("#actual_list_a_company").fadeOut("slow", function(){
			$.post("/list_company.php", $("#list_form").serialize(), function(data){
				$("#actual_list_a_company").html(data);
				$("#actual_list_a_company").fadeIn("slow");
			});
		});
	});
	var which_way = 1;
	var org_height = 0;
	$("#more_rect").click(function(){
		if(which_way==1){
			org_height = $("#detail_box").height();
			$("#detail_box").animate({height:$("#review_rest_cont").height()}, 1000, function(){
				which_way = 0;
				$("#more_rect").html('Less &uarr;');
				
			});
		}else{
			$("#detail_box").animate({height: org_height}, 1000, function(){
				which_way = 1;
				$("#more_rect").html('More &darr;');
			});
			}
	});
	
	//sort less than on more_rect
	if($("#review_rest_cont").height() < $("#detail_box").height()){
		$("#detail_box").height($("#review_rest_cont").height()+60);
		$("#more_rect").hide();
		
	}
	
	$(".show_reg").click(function(){
		$("#thank_type").val($(this).attr("rel"));
		$("#reg_head").html('<h2>'+$(this).attr("cel")+'</h2>');
		$("#nregister_account_link").trigger('click');
	});
	
	
	$("#nregister_but").click(function(){
		error = "";
		if($("#rainitial").val()==""){
					error = error+'- You must enter your initial.\n';
		}
		if($("#raname").val()==""){
					error = error+'- You must enter your name.\n';
		}
		if(!isValidEmailAddress($("#ra_email").val())){
					error = error+'- You must enter your email address.\n';
		}
		if($("#ra_phone").val()==""){
					error = error+'- You must enter your phone number.\n';
		}
		if($("#ra_houseno").val()==""){
					error = error+'- You must enter your house number.\n';
		}
		if($("#ra_postcode").val()==""){
					error = error+'- You must enter your postcode.\n';
		}
		if(error==""){
			
			$("#actual_nregister").fadeOut("slow", function(){
				$.post("/setup_account.php", $("#nregister_form").serialize(), function(data){
					$("#actual_nregister").html(data);
					$("#actual_nregister").fadeIn("slow");
					
				});
			});
			
		}else{
			alert(error);
		}
		
	});
	
	$("#btrade_link").click(function(){
		window.location = "new_trade.htm";
	});
	
				
			});//end load stuff
			function fade_it(dvname){
				$('#'+dvname).fadeOut("slow");
			}
			
			function validate_recommend(){
				error = "";
				if($("#rinitial").val()==""){
					error = '- You must enter their initial.\n';
				}
				if($("#rsurname").val()==""){
					error = error+'- You must enter their surname.\n';
				}
				if($("#raddress").val()==""){
					error = error+'- You must enter their address.\n';
				}
				if($("#rtel").val()==""){
					error = error+'- You must enter their phone number.\n';
				}
				if(!isValidEmailAddress($("#remail").val())){
					error = error+'- You must enter their valid email address.\n';
				}
				if($("#rreq").val()==""){
					error = error+'- You must enter their requirements.\n';
				}
				if($("#rmname").val()==""){
					error = error+'- You must enter your name.\n';
				}
				if($("#rmtel").val()==""){
					error = error+'- You must enter your phone number.\n';
				}
				if(!isValidEmailAddress($("#rmemail").val())){
					error = error+'- You must enter your valid email address.\n';
				}
				if(error==""){
					$("#recomform_cont").fadeOut("slow", function(){
						$.post("/recomform_pro.php", $("#recomform_form").serialize(), function(data){
							$("#recomform_cont").html(data);
							$("#recomform_cont").fadeIn("slow");
						});
					});
				}else{
					alert(error);
				}
				
			}
			
			
			function validate_active(){
				error = "";
				if($("#ainitial").val()==""){
					error = '- You must enter your initial.\n';
				}
				if($("#asurname").val()==""){
					error = error+'- You must enter your surname.\n';
				}
				if($("#aaddress").val()==""){
					error = error+'- You must enter your address.\n';
				}
				if($("#apostcode").val()==""){
					error = error+'- You must enter your postcode.\n';
				}
				if($("#aphone").val()==""){
					error = error+'- You must enter your phone number.\n';
				}
				if(!isValidEmailAddress($("#aemail").val())){
					error = error+'- You must enter a valid email address.\n';
				}
				
				if($("#asuptel").val()==""){
					error = error+'- You must enter your supplier.\n';
				}
				cn = $("#ainstaller").val();
				udate = new Date().getTime();
				$.post("/num_ck.php", {dforce: udate, xnum: cn}, function(data){
					if(data=="none"){
						error = error+'- You must enter a valid card number.\n';
					}
					if(error==""){
						$("#activeform_cont").fadeOut("slow", function(){
							$.post("/pro_claim.php", $("#pform").serialize(), function(data){
								$("#activeform_cont").html(data);
								$("#activeform_cont").fadeIn("slow");
							});
						});
				}else{
					alert(error);
				}
				});
				
				
				
				
			}
			
			function validate_verify(){
				error = "";
				if($("#vinitial").val()==""){
					error = '- You must enter your initial.\n';
				}
				if($("#vsurname").val()==""){
					error = error+'- You must enter your surname.\n';
				}
				if($("#vaddress").val()==""){
					error = error+'- You must enter your address.\n';
				}
				if($("#vpostcode").val()==""){
					error = error+'- You must enter your postcode.\n';
				}
				if($("#vphone").val()==""){
					error = error+'- You must enter your phone number.\n';
				}
				if(!isValidEmailAddress($("#vemail").val())){
					error = error+'- You must enter a valid email address.\n';
				}
				if($("#vsuptel").val()==""){
					error = error+'- You must enter your preferred supplier.\n';
				}
				if($("#vquote").val()==""){
					error = error+'- You must enter the price quoted.\n';
				}
				if($("#agree").attr("checked") != "checked"){
					error = error+'- You must agree to review this company.';
				}
			if(error==''){
				//submit
			$("#verifyform_cont").fadeOut("slow", function(){
				$.post("/verify_pro.php", $("#verform").serialize(), function(data){
					$("#verifyform_cont").html(data);
					$("#verifyform_cont").fadeIn("slow");
				});
			});
			}else{
				alert(error);
			}
				
				
			}
				
			
			
			
			function is_val_card(num){
				
			}
			
			function isNumber(strString){
				//alert(strString+'hi');
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
      if(strString==""){
      	return false;
      }else{
 			  return blnResult;
 			}
   }
			
			
			
			var supp, pric, uid = 0;
			
			function loadup_pro_extra(){
				
				$("#already").change(function(){
					if($("#already").attr("checked") == "checked"){
					$("#ch1_form").slideDown("fast");
					$("#ch2_form").slideUp("fast");
				}else{
					$("#ch1_form").slideUp("fast");
					$("#ch2_form").slideDown("fast");
				}
				});
				$("#notyet").change(function(){
					if($("#notyet").attr("checked") == "checked"){
					$("#ch2_form").slideDown("fast");
					$("#ch1_form").slideUp("fast");
				}else{
					$("#ch2_form").slideUp("fast");
					$("#ch1_form").slideDown("fast");
				}
				});
			}
			
			
			function loadup_pro_extra_old(){
				$("a#inline").fancybox({
					'width'				: '75%',
					'height'			: '75%',
        	'autoScale'     	: false,
      	  'transitionIn'		: 'fade',
					'transitionOut'		: 'fade',
					'type'				: 'inline'
				});
				$( "#tostart" ).datepicker({ minDate: +21, maxDate: "+12M +1D" });
				//first loadup the submit button with validation.
				$("#step2_but").click(function(){
					//validate
					error = "";
					if($("#hwproduct").val()=="solar"){
						if($("#tostart").val()==""){
							error = '- You must enter preferred start date.\n';
						}
						if($("#hwbedrooms").val()!=""){
						
						}else{
							if($("#hwsupplier").val()==""){
								error = error+'- You must enter the supplier name.\n';
							}
							if($("#hwsuppliertel").val()==""){
								error = error+'- You must enter the suppliers phone number.\n';
							}
							if(!isNumber($("#hwprice").val())){
								error = error+'- You must enter the quote price.\n';
							}
						}
					}else if($("#hwproduct").val()=="homeoffice"){
						if($("#hwtarget").val()!=""){
						
						}else{
							if($("#hwsupplier").val()==""){
								error = error+'- You must enter the supplier name.\n';
							}
							if($("#hwsuppliertel").val()==""){
								error = error+'- You must enter the suppliers phone number.\n';
							}
							if(!isNumber($("#hwprice").val())){
								error = error+'- You must enter the quote price.\n';
							}
						}
						
					}else{
						if($("#tostart").val()==""){
							error = '- You must enter preferred start date.\n';
						}
						if($("#hwsupplier").val()==""){
							error = error+'- You must enter the supplier name.\n';
						}
						if($("#hwsuppliertel").val()==""){
							error = error+'- You must enter the suppliers phone number.\n';
						}
						if(!isNumber($("#hwprice").val())){
							error = error+'- You must enter the quote price.\n';
						}
					}
					
					if(error!=""){
						alert(error);
					}else{
					
					$("#prod_form_cont").fadeOut("slow", function(){
						$.post("/pro_step2.php", $("#step2_form").serialize(), function(data){
							$("#prod_form_cont").html(data);
							$("#prod_form_cont").fadeIn("slow");
						});
					});
				}
				});
			}
			
			
			
			function goto_PE_form(){
				error = "";
				if($("#tostart").val()==""){
					alert('- You must enter preferred start date.');
				}else{
					prod = $("#hwproduct").val();
					hwdate = $("#tostart").val();
					window.location = 'hwpriceengine.htm?p='+prod+'&tsd='+hwdate;
				}
			}
			
			function validate_product(){
				error = "";
				if($("#pinitial").val()==""){
					error = '- You must enter your initial.\n';
				}
				if($("#psurname").val()==""){
					error = error+'- You must enter your surname.\n';
				}
				if($("#daytime").val()==""){
					error = error+'- You must enter your phone number.\n';
				}
				if(!isValidEmailAddress($("#pemail").val())){
					error = error+'- You must enter a valid email address.\n';
				}
				if($("#prequire").val()==""){
					error = error+'- You must enter your requirements.\n';
				}
				if($("#ppostcode").val()==""){
					error = error+'- You must enter your postcode.\n';
				}
				if(error==""){
					return true;
				}else{
					alert(error);
					return false;
				}
			}
		
		function isValidEmailAddress(emailAddress) {
			var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
			return pattern.test(emailAddress);
		}
			
			function hide_login(){
				$("#loginform").animate({
						top: -350
					});
			}
						
			function close_active(){
				$("#activeform").animate({
						top: -450
					});
			}
			
			function close_verify(){
				$("#verifyform").animate({
						top: -650
					});
			}
			
			function close_recommendo(){
				$("#recommendoform").animate({
						top: -650
					});
			}
			
			function close_oclaim(){
				$("#oclaimform").animate({
						top: -650
					});
			}
			function show_oclaim(){
				$("html, body").animate({ scrollTop: 0 }, "slow");
			$("#oclaimform").animate({
						top: 33
					});
			}
			
			var poto = 1;
			var startp = 1;
		
			function potato(spnum){
				if(poto==28){
					poto = 0;
				}
				pot_run = 1;
				$('#conts'+spnum).fadeOut("slow", function(){
					$.post("/testss.inc.php", {ajan: poto}, function(data){
						$('#conts'+spnum).html(data);
						//alert(data);
						$('#conts'+spnum).fadeIn("slow");
						timee = data.length * 50;
						setTimeout('potato(1)', timee);
						poto++;
					});
				});
			}
			
			function product(prod){
				window.location = 'products.htm?p='+prod;
			}
			
			function hide_if(hid){
				if(hid=="aboutus"){
					depth = "152px";
				}else{
					depth = "33px";
				}
				if($('#'+hid).css('top')==depth){
					$('#'+hid).animate({
						top: -610
					});
				}
			}
			var grace_run = false;
			var t;
			function graceful_fade(toid){
				$("#all_extra").stop();
				$("#all_extra").animate({
					left: toid
				});
			}
			
			function move_treer(to){
				$(".subsect").css("color", "#666");
				$(".subsect").css("background", "#FFF");
				$(".subsect").css("border-color", "#CCC");
				
				
				$("#treer").stop();
				$("#treer").animate({
					left: to
				}, function(){
					$(".subsect").css("color", "#000");
					$(".subsect").css("background", "#E6E6E6");
					$(".subsect").css("border-color", "#FCC324");
				});
			}
			
			function nextext(di){
				if(di == 1){
					nextex = "The All Craftsmen Gold Card";
					nxt = 2;
				}else{
					nextex = "A free loyalty card to make buying home improvements more rewarding."
					nxt = 1;
				}
				
				$("#head_text").fadeOut("slow", function(){
					$("#head_text").html(nextex);
					$("#head_text").fadeIn("slow");
				});
				setTimeout('nextext('+nxt+')', 6000);
			}
			
			function forgotpass(){
				$("#login_cont").fadeOut("slow", function(){
					$.post("/forgotpass.php", {a: 1}, function(data){
						$("#login_cont").html(data);
						$("#login_cont").fadeIn("slow");
					});
				});
			}
			
			function send_rem(){

				em = $("#femail").val();
				$("#login_cont").fadeOut("slow", function(){
					
					$.post("/sendpwreminder.php", {fem: em}, function(data){
						$("#login_cont").html(data);
						$("#login_cont").fadeIn("slow");
					});
				});
			}
			
			function correct_email(){
	cem = $("#corremail").val();
	cid = $("#corrid").val();
	$.post("/correct_email.php", {xem: cem, xid: cid}, function(data){
		$("#activeform_cont").fadeOut("slow", function(){
			$("#activeform_cont").html(data);
			$("#activeform_cont").fadeIn("blind");			
		});
	});
}

function do_please_contact(){
	error = "";
			if($("#pc_company").val()==""){
				error = '- You must enter your company name.\n';
			}
			if($("#pc_postcode").val()==""){
				error = error+'- You must enter your postcode.\n';
			}
			if($("#pc_contact").val()==""){
				error = error+'- You must enter your name.\n';
			}
			if($("#pc_position").val()==""){
				error = error+'- You must enter your position.\n';
			}
			if(!isValidEmailAddress($("#pc_email").val())){
				error = error+'- You must enter a valid email address.\n';
			}
			if($("#pc_website").val()==""){
				error = error+'- You must enter your website.\n';
			}
			if($("#pc_phone").val()==""){
				error = error+'- You must enter your phone number.\n';
			}
			if(error==""){
				$("#pcm_cont").fadeOut("slow", function(){
					$.post("/pcm_pro.php", $("#pcmform").serialize(), function(data){
						//$("#pcm_cont").html(data);
						window.location = 'new_trade.htm';
						//$("#pcm_cont").fadeIn("slow");
					});
				});
				
				
			}else{
				alert(error);
			}
}

function sign_up(){
	$("#prod_form_cont").fadeOut("slow",function(){
		$.post("/sign_up.php", $("#pe_form").serialize(), function(data){
			$("#prod_form_cont").html(data);
			$("#prod_form_cont").fadeIn("slow");
			$("#s2_but").click(function(){
				new_final_step();
			});
		});
	});
}


function new_final_step(){
	//validate middle form
	switcher = $('input[@name="s2_choice"]:checked').val();
	error = "";
	//alert('-'+switcher+'-');
			if(switcher=="Recommend me a craftsman"){
				if($("#requirements").val()==""){
					error = error+'You must enter your requirements.\n';
				}
			}else if(switcher=="I already know you I want to use"){
				if($("#company_name").val()==""){
					error = error+'You must enter the company name.\n';
				}
				if($("#price_quoted").val()==""){
					error = error+'You must enter the price you have been quoted.\n';
				}
			}else{
				error = "You must select an option.";
			}
		if(error!=""){
			alert(error);
		}else{
	
	$("#prod_form_cont").fadeOut("slow",function(){
		$.post("/new_final_step.php", $("#s2_choice").serialize(), function(data){
			$("#prod_form_cont").html(data);
			$("#prod_form_cont").fadeIn("slow");
		});
	});
}
}

function choose_a_craftsman(){
	//validate middle form
	switcher = $('input[@name="s2_choice"]:checked').val();
	error = "";
	//alert('-'+switcher+'-');
			if(switcher=="Recommend me a craftsman"){
				if($("#requirements").val()==""){
					error = error+'You must enter your requirements.\n';
				}
			}else if(switcher=="Please Quality-Check this company for me"){
				if($("#company_name").val()==""){
					error = error+'You must enter the company name.\n';
				}
				if($("#company_tel").val()==""){
					error = error+'You must enter the companies phone number.\n';
				}
			}else{
				error = "You must select an option.";
			}
		if(error!=""){
			alert(error);
		}else{
	
	$("#prod_form_cont").fadeOut("slow",function(){
		$.post("/new_step_2.php", $("#pe_form").serialize(), function(data){
			$("#prod_form_cont").html(data);
			$("#prod_form_cont").fadeIn("slow");
		});
	});
}
}

function second_prod_step(){
	$("#prod_form_cont").fadeOut("slow", function(){
		$.post("/new_step_2.php", $("#pe_form").serialize(), function(data){
			$("#prod_form_cont").html(data);
			$("#nss_new_but").click(function(){
				error = "";
				if($("#pe_initial").val()==""){
					error = error+'You must enter your initial.\n';
				}
				if($("#pe_surname").val()==""){
					error = error+'You must enter your surname.\n';
				}
				if($("#pe_phone").val()==""){
					error = error+'You must enter your phone number.\n';
				}
				if($("#pe_email").val()==""){
					error = error+'You must enter your email.\n';
				}
				if($("#pe_address").val()==""){
					error = error+'You must enter your address.\n';
				}
				if($("#pe_postcode").val()==""){
					error = error+'You must enter your postcode.\n';
				}
				if(error==""){
					$("#prod_form_cont").fadeOut("slow", function(){
					$.post("/finish_prod.php", $("#nss_form").serialize(), function(data){
						$("#prod_form_cont").html(data);
						$("#prod_form_cont").fadeIn("slow");
						});
					});
				}else{
					alert(error);
				}
				
				
				});
			$("#prod_form_cont").fadeIn("slow");
		});
	});
	
}

function review_search(){
$("#rv_result").fadeOut("fast", function(){
	$.post("/review_search.php", $("#feedback_form").serialize(), function(data){
		dtest = data.split("?");
		//alert("I'm here!");
		if(dtest[0] == 'review.htm'){
			window.location = data;
		}else{
			$("#rv_result").html(data);
		new_height = 127 + $("#rv_result").height();
		//$.fancybox.resize(new_height);
	//	$("#rv_result").animate({height: new_height}, 500, function(){
			$(".results").click(function(){
				window.location = 'review.htm?c='+$(this).attr("rel");
			});
			$("#rv_result").fadeIn("fast");

		
	}
	});
});
	
}

function pe_submiter(){
	$("#pe_submit").click(function(){
		error = "";
				if($("#login-form-initial").val()==""){
					error = error+'You must enter your initial.\n';
				}
				if($("#login-form-name").val()==""){
					error = error+'You must enter your name.\n';
				}
				if($("#login-form-tel").val()==""){
					error = error+'You must enter your telephone number.\n';
				}
				if(!isValidEmailAddress($("#login-form-email").val())){
					error = error+'You must enter your email.\n';
				}
				if($("#login-form-houseno").val()==""){
					error = error+'You must enter your house number.\n';
				}
				if($("#login-form-postcode").val()==""){
					error = error+'You must enter your postcode.\n';
				}
				if(error==""){
					$("#the_pe_form").submit();
				}else{
					alert(error);
				}
	});
}

function lightboxes(){
	
	$("a#recomlink").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	$("a#write_review_link").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	
	$("a#report_review_link").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	
	$("a#find_company_link").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	
	$("a#check_company_link").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	$("a#list_company_link").fancybox({
		height: 500,
		overlayColor: '#000'
	});
	$("a#notsure_link").fancybox({
		height: 530,
		overlayColor: '#000'
	});
	$("a#nregister_account_link").fancybox({
		height: 530,
		overlayColor: '#000'
	});
}

function list_a_company(){
	$("#list_company_link").trigger('click');
}


var rv_to = null;

function rv_search(){
	//first fire on keyup.
	$("#rv_name").keyup(function(){
		//now cancel any query waiting to go.
		clearTimeout(rv_to);
		rv_to = setTimeout("do_rv_search()", 500);
	});
	
}

function do_rv_search(){
	$("#qdebug").html($("#rv_name").val());
	$.post("/review_search2.php", {searchtext: $("#rv_name").val()}, function(data){
		
		$("#rv_result").html(data);
		$(".results").click(function(){
				window.location = 'review2.htm?c='+$(this).attr("rel");
			});
	});
}

function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
          return false;
     else
          return true;
}

function subsearch(){
	bit = $("#front_search").val();
	window.location = '/search.php?s='+bit;
}

function validate_review(){
	error = '';
	if($("#wr_yname").val()==""){
		error = error+'You must enter your name.\n';
	}
	if(!isValidEmailAddress($("#wr_yemail").val())){
		error = error+'You must enter a valid email address.\n';
	}
	if($("#wr_ypc").val()==""){
		error = error+'You must enter your postcode.\n';
	}
	if($("#wr_review_text").val().length==0){
		error = error+'You must write a review.\n';
	}else if($("#wr_review_text").val().length<50){
		error = error+'Your review must be longer than 50 characters.\n';
	}
	if($("#review_connection:checked").val()!="yes"){
		error = error+'You must tick the box to confirm you have no connection to the company, other than as a customer.\n';
	}
	
	if($("#review_correct:checked").val()!="yes"){
		error = error+'You must tick the box to confirm your review is factual.\n';
	}
	
	if(error!=''){
		alert(error);
	}else{
		//submit the review
		$("#real_write_review_cont").fadeOut("slow", function(){
		$.post("/save_review.php", $("#wr_form").serialize(), function(data){
			$("#real_write_review_cont").html(data);
			$("#real_write_review_cont").fadeIn("slow");
		});
	});
	}
}

function More_rect(){
	//alert();
	$("#detail_box").animate({height:$("#review_rest_cont").height()}, 1000, function(){
		//alert("How's that?");
	});
}

function hottip_face(){
	howmany = 4;
	appart = 500;
	time = 0;
	i = 0;
	while(i<10){
		time = i * appart;
		nn = 10 - i;
		//setTimeout('fadehottip('+i+');',time);
		i++;
	}
}

function fadehottip(num){
	$('#hottipA_'+num).fadeIn("slow");
	//$('#hottipA_'+num).html(num);
}

function open_recommendo(){
					hide_if("recomform");
					hide_if("activeform");
					hide_if("loginform");
					hide_if("aboutus");
					hide_if("verifyform");
				if($("#recommendoform").css('top')!='33px'){
					$("#recommendoform").animate({
						top: 33
					});
				}else{
					$("#recommendoform").animate({
						top: -600
					});
				}	
}

function hottip_load(){
	var ht_divcount = 0;
				$(".hottip").each(function(){
					coord = $(this).attr("COORDS");
					relf = $(this).attr("rel");
					carr = coord.split(",");
					//offsets
					if ($.browser.webkit) {
						offset_left = 2;
						offset_top = -40;
					}
					if ( $.browser.msie ) {
						offset_left = 2;
						offset_top = -40;
					}
					if ( $.browser.mozilla ) {
						offset_left = 2;
						offset_top = -40;
					}
					offset_top = offset_top + 30;
					
					$("#hottip_areas").prepend('<div id="hottipA_'+relf+'" class="ht_area"></div>');
					//$('#hottipA_'+ht_divcount).css("p", "relative");
					//calc postions from hottip_areas
					var pos = $("#notrecshot").offset();
					//$('#hottipA_'+ht_divcount).append('<BR>Left: '+pos.left);
					//$('#hottipA_'+ht_divcount).append('<BR>Top: '+pos.top);
					$('#hottipA_'+relf).css("position", "absolute");
					//$('#hottipA_'+ht_divcount).css("display", "none");
					//$('#hottipA_'+ht_divcount).css("left", "50%");
					$('#hottipA_'+relf).css("margin-left", parseFloat(carr[0])+offset_left);
					
					//alert(100+carr[1]);
					$('#hottipA_'+relf).css("top", pos.top+parseFloat(carr[1])+offset_top);
					$('#hottipA_'+relf).css("width", carr[2]-carr[0]);
					$('#hottipA_'+relf).css("height", carr[3]-carr[1]);
					$('#hottipA_'+relf).css("opacity", 0);
					
					ht_divcount = ht_divcount + 1;
				});
				
				$(".hottip2").each(function(){
					coord = $(this).attr("COORDS");
					relf = $(this).attr("rel");
					carr = coord.split(",");
					
					//offsets
					if ($.browser.webkit) {
						offset_left = 2;
						offset_top = -65;
					}
					if ( $.browser.msie ) {
						offset_left = 2;
						offset_top = -65;
					}
					if ( $.browser.mozilla ) {
						offset_left = 2;
						offset_top = -70;
					}
					
					$("#hottip2_areas").prepend('<div id="hottipb_'+relf+'" class="ht_area"></div>');
					//$('#hottipA_'+ht_divcount).css("p", "relative");
					//calc postions from hottip_areas
					var pos = $("#recshot").offset();
					//$('#hottipA_'+ht_divcount).append('<BR>Left: '+pos.left);
					//$('#hottipb_'+relf).append('<BR>Rel: '+relf);
					$('#hottipb_'+relf).css("position", "absolute");
					//$('#hottipA_'+ht_divcount).css("display", "none");
					//$('#hottipA_'+ht_divcount).css("left", "50%");
					$('#hottipb_'+relf).css("margin-left", parseFloat(carr[0])+offset_left);
					
					//alert(100+carr[1]);
					$('#hottipb_'+relf).css("top", pos.top+parseFloat(carr[1])+offset_top);
					$('#hottipb_'+relf).css("width", carr[2]-carr[0]);
					$('#hottipb_'+relf).css("height", carr[3]-carr[1]);
					$('#hottipb_'+relf).css("opacity", 0);
					
					ht_divcount = ht_divcount + 1;
				});
	
	
}
