function review(form){
var emailRegex=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
var phoneRegex=/^\d+$/;
var postcodeRegex=/[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}/i;
var oops=0;
var required = form.required.value;
var form_values=required.split(',');
$.each(form_values,function(k,v){			
var bit=$('#'+v).val();
var s=v.replace(/_/g,' ');
if(bit==""){inlineMsg(v,'Enter your '+s+'.',2);oops++;return false;}
if(v.indexOf("email")>=0){if(!bit.match(emailRegex)){inlineMsg(''+v+'','Enter a valid '+s+'.',2);oops++;return false;}}
if(v=='postcode'){if(!bit.match(postcodeRegex)){inlineMsg(v,'Enter a valid '+s+'.',2);oops++;return false;}}
if(v=='agree'){if($('#'+v).attr('checked')==false){inlineMsg(v,'Please accept our terms.',2);oops++;return false;}}
if(v=='captcha'){var answer=$('#answer').val();if(bit!=answer){inlineMsg(v,'Incorrect, try again.',2);oops++;return false;}}
});
if(oops > 0){return false;}
else{return true;}
}


function worldPay(form) {
  var name = form.name.value;
  var address = form.address.value;
  var country = form.country.value;
  var postcode = form.postcode.value;
  var tel = form.tel.value;
  var email = form.email.value;
  var terms= form.terms.checked;

  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
 
   if(terms == "") {
    inlineMsg('terms','Please accept our terms.',2);
    return false;
  }
  if(name == "") {
    inlineMsg('name','Enter your name',2);
    return false;
  }
   if(address == "") {
    inlineMsg('address','Enter your address.',2);
    return false;
  }
   if(country == "") {
    inlineMsg('country','Enter your country.',2);
    return false;
  }
  if(postcode == "") {
    inlineMsg('postcode','Enter your postcode.',2);
    return false;
  }
  if(tel == "") {
    inlineMsg('tel','Enter your telephone.',2);
    return false;
  }
  if(email == "") {
    inlineMsg('email','Enter your email.',2);
    return false;
  }
 


return true ;
}

// START OF MESSAGE SCRIPT //





function validate(form){var name=form.name.value;var email=form.email.value;var telephone=form.telephone.value;var enquiry=form.enquiry.value;var nameRegex=/^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;var emailRegex=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;var messageRegex=new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);if(name=="" || name=="Your Name"){inlineMsg('name','Enter your name.',2);return false;}
if(email==""){inlineMsg('email','Enter your email.',2);return false;}
if(!email.match(emailRegex)){inlineMsg('email','Enter a valid email.',2);return false;}
if(telephone=="" || telephone=="Your Telephone"){inlineMsg('telephone','Enter your telephone.',2);return false;}
if(enquiry=="" || enquiry=="Your Enquiry"){inlineMsg('enquiry','Enter your enquiry.',2);return false;}
enquiry=escape(enquiry);send_it(name,email,telephone,enquiry);return false;}
var MSGTIMER=40;var MSGSPEED=10;var MSGOFFSET=3;var MSGHIDE=8;function inlineMsg(target,string,autohide){var msg;var msgcontent;if(!document.getElementById('msg')){msg=document.createElement('div');msg.id='msg';msgcontent=document.createElement('div');msgcontent.id='msgcontent';document.body.appendChild(msg);msg.appendChild(msgcontent);msg.style.filter='alpha(opacity=0)';msg.style.opacity=0;msg.alpha=0;}else{msg=document.getElementById('msg');msgcontent=document.getElementById('msgcontent');}
msgcontent.innerHTML=string;msg.style.display='block';var msgheight=msg.offsetHeight;var targetdiv=document.getElementById(target);targetdiv.focus();var targetheight=targetdiv.offsetHeight;var targetwidth=targetdiv.offsetWidth;var topposition=topPosition(targetdiv)-((msgheight-targetheight)/2);var leftposition=leftPosition(targetdiv)+targetwidth+MSGOFFSET;msg.style.top=topposition+'px';msg.style.left=leftposition+'px';clearInterval(msg.timer);msg.timer=setInterval("fadeMsg(1)",MSGTIMER);if(!autohide){autohide=MSGHIDE;}
window.setTimeout("hideMsg()",(autohide*1000));}
function hideMsg(msg){var msg=document.getElementById('msg');if(!msg.timer){msg.timer=setInterval("fadeMsg(0)",MSGTIMER);}}
function fadeMsg(flag){if(flag==null){flag=1;}
var msg=document.getElementById('msg');var value;if(flag==1){value=msg.alpha+MSGSPEED;}else{value=msg.alpha-MSGSPEED;}
msg.alpha=value;msg.style.opacity=(value/100);msg.style.filter='alpha(opacity='+value+')';if(value>=99){clearInterval(msg.timer);msg.timer=null;}else if(value<=1){msg.style.display="none";clearInterval(msg.timer);}}
function leftPosition(target){var left=0;if(target.offsetParent){while(1){left+=target.offsetLeft;if(!target.offsetParent){break;}
target=target.offsetParent;}}else if(target.x){left+=target.x;}
return left;}
function topPosition(target){var top=0;if(target.offsetParent){while(1){top+=target.offsetTop;if(!target.offsetParent){break;}
target=target.offsetParent;}}else if(target.y){top+=target.y;}
return top;}
if(document.images){arrow=new Image(7,80);arrow.src="/graphics/msg_arrow.gif";}
var xmlHttp;function send_it(name,email,telephone,enquiry)
{xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request");return;}
var url="/send.php";url=url+"?name="+name;url=url+"&email="+email;url=url+"&telephone="+telephone;url=url+"&enquiry="+enquiry;url=url+"&sid="+Math.random();xmlHttp.onreadystatechange=thisChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);function thisChanged()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{document.getElementById("contact").innerHTML=xmlHttp.responseText;}}}
function GetXmlHttpObject()
{var xmlHttp=null;try
{xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}

(function(w){var E=w(window),u,g,F=-1,o,x,D,v,y,L,s,n=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(w.browser.version>=9.3),m=document.documentElement,l={},t=new Image(),J=new Image(),H,a,h,q,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));h=w('<div id="lbImage" />').appendTo(a).append(q=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(f)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+((e?m.clientHeight:E.height())/2);L=u.initialWidth;s=u.initialHeight;w(a).css({top:Math.max(0,y-(s/2)),width:L,height:s,marginLeft:-L/2}).show();v=n||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();k(1);g=O;u.loop=u.loop&&(g.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=e?m.clientWidth:E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function k(M){w("object").add(n?"select":"embed").each(function(O,P){if(M){w.data(P,"slimbox",P.style.visibility)}P.style.visibility=M?"hidden":w.data(P,"slimbox")});var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",p)}function p(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?f():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function f(){return b(D)}function b(M){if(M>=0){F=M;o=g[F][0];x=(F||(u.loop?g.length:0))-1;D=((F+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";l=new Image();l.onload=j;l.src=o}return false}function j(){a.className="";w(h).css({backgroundImage:"url("+o+")",visibility:"hidden",display:""});w(q).width(l.width);w([q,I,d]).height(l.height);w(A).html(g[F][1]||"");w(K).html((((g.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,g.length));if(x>=0){t.src=g[x][0]}if(D>=0){J.src=g[D][0]}L=h.offsetWidth;s=h.offsetHeight;var M=Math.max(0,y-(s/2));if(a.offsetHeight!=s){w(a).animate({height:s,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+s,marginLeft:-L/2,visibility:"hidden",display:""});w(h).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,i)})}function i(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function r(){l.onload=null;l.src=t.src=J.src=o;w([a,h,c]).stop(true);w([I,d,h,G]).hide()}function C(){if(F>=0){r();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,k)}return false}})(jQuery);if(!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)){jQuery(function($){$("a[rel^='lightbox']").slimbox({},null,function(el){return(this==el)||((this.rel.length>8)&&(this.rel==el.rel));});});}



(function($){$.fn.innerfade=function(options){return this.each(function(){$.innerfade(this,options);});};$.innerfade=function(container,options){var settings={'animationtype':'fade','speed':'normal','type':'sequence','timeout':2000,'containerheight':'auto','runningclass':'innerfade','children':null};
if(options)$.extend(settings,options);
if(settings.children===null)
var elements=$(container).children();else
var elements=$(container).children(settings.children);if(elements.length>1){$(container).css('position','relative').css('height',settings.containerheight).addClass(settings.runningclass);for(var i=0;i<elements.length;i++){$(elements[i]).css('z-index',String(elements.length-i)).css('position','absolute').hide();};if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(elements,settings,1,0);},settings.timeout);$(elements[0]).show();}else if(settings.type=="random"){var last=Math.floor(Math.random()*(elements.length));setTimeout(function(){do{current=Math.floor(Math.random()*(elements.length));}while(last==current);$.innerfade.next(elements,settings,current,last);},settings.timeout);$(elements[last]).show();}else if(settings.type=='random_start'){settings.type='sequence';var current=Math.floor(Math.random()*(elements.length));setTimeout(function(){$.innerfade.next(elements,settings,(current+1)%elements.length,current);},settings.timeout);$(elements[current]).show();}else{alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');}}};$.innerfade.next=function(elements,settings,current,last){if(settings.animationtype=='slide'){$(elements[last]).slideUp(settings.speed);$(elements[current]).slideDown(settings.speed);}else if(settings.animationtype=='fade'){$(elements[last]).fadeOut(settings.speed);$(elements[current]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);});}else
alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');if(settings.type=="sequence"){if((current+1)<elements.length){current=current+1;last=current-1;}else{current=0;last=elements.length-1;}}else if(settings.type=="random"){last=current;while(current==last)
current=Math.floor(Math.random()*elements.length);}else
alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');setTimeout((function(){$.innerfade.next(elements,settings,current,last);}),settings.timeout);};})(jQuery);function removeFilter(element){if(element.style.removeAttribute){element.style.removeAttribute('filter');}}

$(document).ready(function(){$('.customised').innerfade({	animationtype: 'fade',speed: 750,timeout: 3000,containerheight: '205px'});});

$(document).ready(function(){$('.slide').innerfade({	animationtype: 'fade',speed: 1000,timeout: 6000,containerheight: '180px'});});



$(document).ready(function(){$('.drill').hide();
$('.trigger').click(function(){if($(this).next().is(':hidden')){$('.trigger').removeClass('active').next().slideUp();$(this).toggleClass('active').next().slideDown();}
else{$(this).next().slideUp()}
return false;});});

$(document).ready(function(){
$('#wp-toggle').click(function(){$('#worldpay').slideToggle(200);});
});


$(document).ready(function() {
						   
	
	
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
								   
		var tnt =  $("input[name=size]:checked").val();
		var clr =  $("input[name=colour]:checked").val();
				
		var accsarray='';
		var selectedItems = new Array();
		$("input[name='accs[]']:checked").each(function() {selectedItems.push($(this).val());});
		$.each(selectedItems, function(index, value) { 
  accsarray += value +'<br />'; 
});
		if( !$("input[name=size]:checked").val()){tnt = 'No tent chosen';}	
		if( !$("input[name=colour]:checked").val() ){clr = 'No tent chosen';}	
		
		if(accsarray==''){accsarray='No extra accessories selected'}
		
		if( tnt == 'No tent chosen'  && clr == 'No tent chosen' && accsarray=='No extra accessories selected')
		{$("#gazebo-order").html('No products chosen');	}
		else{
		
		
		$("#gazebo-order").html('Please review your order before adding it to your basket<br /><br /><strong>Gazebo :</strong> '+tnt+'<br /><br /><strong>Colour :</strong> '+clr+'<br /><br /><strong>Accessories :</strong><br />'+accsarray+'<br /><br /><input type="submit" name ="submit" value="Add To Basket" />');						   
		}
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		
		return false;
	});
	
	$(".crnr").click(function() {
								   
		var tnt =  $("input[name=size]:checked").val();
		var clr =  $("input[name=colour]:checked").val();
				
		var accsarray='';
		var selectedItems = new Array();
		$("input[name='accs[]']:checked").each(function() {selectedItems.push($(this).val());});
		$.each(selectedItems, function(index, value) { 
  accsarray += value +'<br />'; 
});
		if( !$("input[name=size]:checked").val()){tnt = 'No tent chosen';}	
		if( !$("input[name=colour]:checked").val() ){clr = 'No tent chosen';}	
		
		if(accsarray==''){accsarray='No extra accessories selected'}
		
		if( tnt == 'No tent chosen'  && clr == 'No tent chosen' && accsarray=='No extra accessories selected')
		{$("#gazebo-order").html('No products chosen');	}
		else{
		
		
		$("#gazebo-order").html('Please review your order before adding it to your basket<br /><br /><strong>Gazebo :</strong> '+tnt+'<br /><br /><strong>Colour :</strong> '+clr+'<br /><br /><strong>Accessories :</strong><br />'+accsarray+'<br /><br /><input type="submit" name ="submit" value="Add To Basket" class="submit" />');						   
		}
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		
		return false;
	});
	
	
	

						   $(".crnr, .bttn, .submit, .prnt, .banner-prnt").fadeTo("fast",1.0);
						   $(".crnr, .bttn, .submit, .prnt, .banner-prnt").hover(function(){
$(this).fadeTo("fast",0.6);},function(){$(this).fadeTo("fast",1.0);});



});





