<!--//

// minimize/maximize/close div function(s) added by "D" 08|10|05

function hidediv(hidedivname) {
      if (document.getElementById) { 
        document.getElementById(''+hidedivname+'').style.display = 'none';
            } else {
            if (document.layers) { 
            document.hidedivname.style.display = 'none';
            } else { 
        document.all.hidedivname.style.display = 'none';
      }
   }   
}



function showdiv(showdivname) {
    if (document.getElementById) {
      document.getElementById(''+showdivname+'').style.display = 'block';
        } else {
          if (document.layers) {
          document.showdivname.style.display = 'block';
        } else {
      document.all.showdivname.style.display = 'block';
    }
  }
}


function closediv(closedivname) {
    if (document.getElementById) {
      document.getElementById(''+closedivname+'').style.display = 'none';
        } else {
          if (document.layers) {
          document.closedivname.style.display = 'none';
        } else {
      document.all.closedivname.style.display = 'none';
    }
  }
}


// contactus.php FORM VALIDATION //

	function checkValue(field,displayvalue){
		var temp = eval("document.contactForm."+field+".value;");
		if(temp=="" || temp==" "){
			alert("Please fill in your " + displayvalue + ", and try again.");
			eval("document.contactForm."+field+".focus();");
			return false;
		}else{
			return true;
		}
	}

	function checkForm(){
		if(checkValue("yname","name") && checkValue("postcode","postcode") && checkValue("comments","comments about us, or any questions you may have")){
			if(emailCheck(document.contactForm.email.value)){
				document.contactForm.submit();
			}else{
				alert("Please fill in your email address, and try again.\nIf you have filled in your email address, check the '.' and '@' sign are correct, an email address will look something like this:\n\nyourname@somewhere.com                   or                  yourname@somewhere.co.uk\n");
				document.contactForm.email.focus();
			}
		}
	}

// Check Email Adress Validation :)
function emailCheck(emailStr)
{
	emailStr = emailStr.toLowerCase();
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|biz|edu|int|mil|gov|arpa|aero|name|coop|info|pro|museum|tv|ca|se|fr|de|it|jp|ng|no)$/;
	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)
	{
			return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
			return false;
		}
	}

	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			return false;
		}
	}

	if (user.match(userPat)==null)
	{
        	return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				return false;
			}
		}
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			return false;
		}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
	{
		return false;
	}

	if (len<2)
	{
		return false;
	}
	return true;
}

var parents = new Array();

function addToParents(no,parentid) {
	parents[no] = "sub"+parentid;
}

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

if (browser == "Internet Explorer" && OS == "Mac")
{
     var sfElsH = document.getElementById("horizontal").getElementsByTagName("LI");
      	
      for (var i = 0; i < sfElsH.length; i++)
      {
          sfElsH.style.width = '100px';
      }
}

sfHover = function()
{
    if (document.getElementById("horizontal"))
    {
      	var sfElsH = document.getElementById("horizontal").getElementsByTagName("LI");
      	
        for (var i = 0; i < sfElsH.length; i++)
        {
            if (browser == "Internet Explorer" && OS == "Mac")
          	{
          	     
	          }
        		
            sfElsH[i].onmouseover = function()
            {
        			 this.className += " sfhover";
        		}
        		
        		sfElsH[i].onmouseout = function()
            {
        			 this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        		}
      	}
  	}
  	else
    {
        alert('Can not find H menu');
    }
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

//-->
