function site_loader()
	{
	if(!document.getElementsByTagName)alert('You will need to update your browser to view this site properly')
	else roll_menu()
	}
	
function flash_intro()
	{
	url = location.href.split(".co.uk",2)[1]
	document.write ('<p class="flash">')
	if		(url=="/contact.asp")	
		document.write ('<img src="/images/ocean.jpg" alt="Ocean">')
	else if	(url=="/commercial.asp")
		document.write ('<img src="/images/beach.jpg" alt="Beach">')
	else if (url=="/")		
		{	
		document.write ('<object type="application/x-shockwave-flash" data="/includes/flash-intro.swf" width="760" height="250">')
		document.write ('<param name="movie" value="/includes/flash-intro.swf">')
		document.write ('<param name="wmode" value="transparent">')
		document.write ('</object>')
		}
	else if (url.split("any",1)=="/comp") 		
		document.write ('<img src="/images/huts.jpg" alt="Huts">')
	else if (url.split("/",2)[1]=="africanthatch") 		
		document.write ('<img src="/africanthatch/images/sunset.jpg" alt="Sunset">')
	else 
		document.write ('<img src="/images/sunset.jpg" alt="Sunset">')
		
	document.write ('</p>') 
	}
	
function cursor_sniff(obj)
	{
	if (document.all){obj.cursor="hand"}
	else{obj.cursor="pointer"}
	}

//Hover Menu
function roll_menu()
	{
	var navRoot 	= document.getElementById("topmenu");
	if (navRoot)
		{
		for (i=0;i<navRoot.childNodes.length;i++) 
			{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") 
				{
				node.onmouseover= function(){this.className="show"}
				node.onmouseout = function(){this.className=""}
				}
			}
		}
		
	img = document.getElementById("middle").getElementsByTagName("IMG")
	for (var d=0;d<img.length;d++)
		{
		if (img[d].className=="tweak"){if (img[d].width<75){padding = (75-img[d].width)/2;img[d].style.paddingLeft=padding+"px";img[d].style.paddingRight=padding+"px"}}
		else if (img[d].className=="tweak2")
			{
			if (img[d].width>55)img[d].width=55	
			else if	(img[d].width<55)
				{
				padding = (55-img[d].width)/2
				img[d].style.paddingLeft=padding+"px"
				img[d].style.paddingRight=padding+"px"
				}
			}
		}
		
	inp = document.getElementById("middle").getElementsByTagName("INPUT")
	for (var d=0;d<inp.length;d++){if(inp[d].className=="btn" || inp[d].className=="big btn")inp[d].onmouseover=function(){cursor_sniff(this.style)}}
	
	f = document.getElementById("focus");if(f)f.focus()
	b = document.getElementById("box1");if(b)drop_downs()
	o = document.getElementById("options");if(o)check_options()
	}
	
function info(stk_code)
	{location.href= eval('document.getElementById("l'+stk_code+'")').href}
	
function image_reload(c)
	{cc=c.options[c.selectedIndex].text;document.getElementById("ccard").src='/images/' + cc + '.gif'}

				
//Form Validation Essentials
function checker(obj,msg)
	{if(obj.value=="" && mt==true)message(obj,msg)}
	
function message(obj,msg)
	{alert(msg);obj.focus();mt=false}
	
function email(obj)
	{
	var emailStr=obj.value;var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)!£$%^&*()+='#~?<>@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s" + specialChars + "\]";var quotedUser="(\"[^\"]*\")";var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+';var word="(" + atom + "|" + quotedUser + ")";var userPat=new RegExp("^" + word + "(\\." + word + ")*$");var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");var matchArray=emailStr.match(emailPat)
	if ((matchArray==null) && mt==true){message(obj,"Email address seems incorrect (check @ and .'s)")}
	if (mt==true){var user=matchArray [1];var domain=matchArray [2];if (user.match(userPat)==null)message(obj,"The username doesn't seem to be valid.")}
	if (mt==true){var IPArray=domain.match(ipDomainPat);if (IPArray!=null){for (var j=1;j<=4;j++){if (IPArray[j]>255)message(obj,"Destination IP address is invalid!")}}}
	if (mt==true){var domainArray=domain.match(domainPat);if (domainArray==null)message(obj,"The domain name doesn't seem to be valid.")}
	if (mt==true){var atomPat=new RegExp(atom,"g");var domArr=domain.match(atomPat);var len=domArr.length;if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4)message(obj,"The address must end in a two,three or four letter domain")}
	if ((len<2) && mt==true)message(obj,"This address is missing a hostname!");
	}
	
function checker_select(obj,msg,stval)
	{if(obj.options[obj.selectedIndex].text==stval && mt==true)message(obj,msg)}
	
function update_sel(v)
	{
	s=document.getElementById("sel")
	if (v=='Advertisement')
		s.innerHTML='<select name="specify"><option>...Please Specify</option><option>25 Beautiful Homes</option><option>BBC Gardeners World</option><option>BBC Good Homes</option><option>Country Living</option><option>House Beautiful</option><option>House & Garden</option><option>Homes & Garden</option><option>Ideal Home</option><option>RHS The Garden</option><option>Your Home</option></select>'
	else if (v=='Exhibition\\Show')
		s.innerHTML='<select name="specify"><option>...Please Select</option><option>Badminton Horse Trials</option><option>BBC Gardeners World Live</option><option>Bramham Horse Trials</option><option>Grand Designs Live</option><option>Great Yorkshire Show</option><option>RHS Cardiff Flower Show</option><option>RHS Chelsea Flower Show</option></select>'
	else
		s.innerHTML='<input type="text" name="specify" maxlength="60">'
	}
	
//Validation Routines
function contact(fm)
	{
	mt=true;
	checker(fm.sender_name,"You must enter your Name");
	checker(fm.sender_email,"You must enter your E-mail");
	checker(fm.address,"You must enter your Address");
	checker(fm.city,"You must enter your City/Town");
	checker(fm.postcode,"You must enter your Postcode");
	email(fm.sender_email);
	checker_select(fm.hear,"You must select how you heard about us","...Please Select");
	return mt;
	}
	
function refer(fm)
	{
	mt=true;
	checker(fm.sender_name,"You must enter your Name");
	checker(fm.sender_email,"You must enter your E-mail");
	checker(fm.name1,"You must enter a friends Name");
	checker(fm.email1,"You must enter a friends E-mail");
	email(fm.sender_email)
	email(fm.email1)
	return mt;
	}
	
function checkout(fm)
	{
	mt=true;
	checker(fm.fname,'You must enter your first name')
	checker(fm.surname,'You must enter your Surname')
	checker(fm.billingaddress1,'You must enter the first line of your address')
	checker(fm.billingaddress2,'You must enter the second line of your address')
	checker(fm.billpcode,'You must enter your Post Code')
	email(fm.email)
	checker(fm.tel,'You must enter a telephone number')
	card_checker(fm)	
	return mt;
	}
	
//Card Checker
function card_checker(fm)
	{
	ccard=fm.creditcard;Str=ccard.value;newStr='';card=fm.card.options[fm.card.selectedIndex].text;
	exp_month=fm.expirymonth.options[fm.expirymonth.selectedIndex].text;exp_year=fm.expiryyear.options[fm.expiryyear.selectedIndex].text;
	val_month=fm.startmonth.options[fm.startmonth.selectedIndex].text;val_year=fm.startyear.options[fm.startyear.selectedIndex].text;
	d=new Date();cur_month=d.getMonth()+1;cur_year=d.getFullYear()
	if (card=='Select' && mt==true)message(ccard,"You must select a Card Type")
	//Remove Dashes and Spaces & Numeric Check
	for (var k=0;k<parseInt(Str.length);k++){var a=Str.charAt(k);if((a!=" ")&&(a!="-")){newStr += Str.charAt(k);}};for(var k=0;k<parseInt(newStr.length);k++){var a=newStr.charAt(k);if(((a<"0")||(a>"9"))&&mt==true)message(ccard,"Numbers only Please")}
	if((Str==""||newStr.length<"10")&&mt==true)message(ccard,"Incorrect Number of Digits")
	//Modulus 10 Checker
	tot=0;z=parseInt(newStr.charAt(0));if(newStr.length%2=="0" && mt==true)bigger_than_5();else tot=tot+z;x=1;y=parseInt(newStr.length);while(x<y){z=parseInt(newStr.charAt(x));if(newStr.length%2=="0" && mt==true){if(x%2!= 0)tot=tot+z;else bigger_than_5()}else{if(x%2!=0)bigger_than_5();else tot=tot+z};x++};if(tot%10!=0 && mt==true)message(ccard,"Invalid Card Number")
	//Check Start Date & Expiry
	if (((val_year==cur_year && val_month>cur_month)||(val_year>cur_year)) && mt==true)message(fm.startmonth,"Your start date is incorrect")
	if ((exp_year<cur_year)||(exp_year==cur_year && exp_month<cur_month) && mt==true)message(fm.expirymonth,"Your Card has expired")
	checker(fm.cv2,'You must enter your card signature code on the back of your card')
	}

function bigger_than_5()
	{if(z*2>=10){num=z*2;n=num.toString();n1=parseInt(n.charAt(0));n2=parseInt(n.charAt(1));tot=tot + n1 + n2;}else tot=tot+(z*2)}	

	
//on page load
window.onload=site_loader