/* Author: Intelligent Integration */
/* Creation date: 30/07/2003 */
/* Last modofied: 17/03/2006 */
	
	function breakOutOfFrames()
	{
		if (self.parent.frames.length != 0)
			window.top.location.replace(self.location.href);
	}
	
	function greyLinks()
	{
   	// First get the pagename.
      var pageName = '';
      var metatags = document.getElementsByTagName('meta');
      for (var i = 0; i < metatags.length; i++) {
      	if (metatags[i].getAttribute('name') == 'pagename') {
         	pageName = metatags[i].getAttribute('content');
         } 
      }
   	// Then get the link candidates.
      var navdiv = document.getElementById('navigation');
      var links = navdiv.getElementsByTagName('a');
      for (var i = 0; i < links.length; i++) {
      	// Check for link matching page name.
         if (links[i].getAttribute('id') == ('tm' + pageName)) {
      		// Change this item from an active <a> link to a <span> element with its
      		// text greyed under control of the css.
      		var parentItem = links[i].parentNode;
      		var node = links[i].firstChild;
            var text = '';
            do {
            	if (node.nodeType == 3){
               	text = text + node.nodeValue;
               }
               else {
               	text = text + (node.firstChild).nodeValue;
               }
               node = node.nextSibling;
            }
            while (node != null)
     			var newNode = document.createElement('span');
            var textNode = document.createTextNode(text);
      		newNode.appendChild(textNode);
      		parentItem.replaceChild(newNode, links[i]);
			}
		}       
	}
		
	function validate()
	{
		if ((document.getElementById('name').value == "") || 
      		(document.getElementById('name').value == "name")) {
			alert("Please complete the field; name:");
			document.getElementById('name').focus();
         return false;
		}
		if ((document.getElementById('tel').value == "") ||
      		(document.getElementById('tel').value == "telephone")) {
			alert("Please complete the field; telephone:");
			document.getElementById('tel').focus();
         return false;
		}
		if (!(document.getElementById('email').value == "email address")) {
         var email_pattern = /^((".+")|(\w+([\.-]?\w+)*))@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
         var emailaddr = document.getElementById('email').value;
         if (!(email_pattern.test(emailaddr))) {
         	alert('Email address is not a valid format. Please correct.');
            document.getElementById('email').focus();
            return false;
         }
      }
      
      // If we've got here, all the validation has passed.
		return true;
	}

   function validateMail()
   {
      var email_pattern = /^((".+")|(\w+([\.-]?\w+)*))@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
      var emailaddr = document.getElementById('sender').value;
      if (!(email_pattern.test(emailaddr))) {
      	alert('Email address is not a valid format. Please correct.');
         document.getElementById('sender').focus();
         return false;
      }
		if (document.getElementById('subject').value == "") {
			alert("Please complete the field; subject:");
			document.getElementById('subject').focus();
         return false;
		}
		if ((document.getElementById('mailmsg').value == "") || 
      		(document.getElementById('mailmsg').value == "enter your message here")) {
			alert("Please enter a message.");
			document.getElementById('mailmsg').focus();
         return false;
		}            
   }
   
	function setFocus()
	{
		document.getElementById('name').focus();
	}
		
   function fieldBlur(thisField, str)
   {
   	if (thisField.value == '')
      	thisField.value = str;
   }
   
	window.onLoad = breakOutOfFrames();