// This file contains some of the common functions used for this site.
// To use these functions you must make reference to this page in the
// HTML pages. 

// Unless otherwise stated all the following code is copyright of netXdesign

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// General Stuff
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function initTBS() { // Page load initialisation
MM_preloadImages('../images/toilet.jpg','../images/acc.jpg','../images/brush.jpg','../images/razor.jpg','../images/mens.jpg','../images/travel.jpg','../images/gift.jpg','../images/hairdress.jpg');

}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Flash content placer
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function getFlash(id, file, w, h, wmode){
	
	//alert ("getFlash");

var idC = document.getElementById(id);
var cont;

cont = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase="+
"'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' "+
"width='"+w+"' height='"+h+"' title='"+file+"' id='"+file+"SWF'>\n"+
"<param name='movie' value='Flash/"+ file +".swf' />\n"+
"<param name='allowScriptAccess' value='sameDomain' />\n"+
"<param name='quality' value='high' />\n"+ 
"<param name='wmode' value='"+wmode+"' />\n"+
"<embed src='Flash/"+ file +".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'"+
"type='application/x-shockwave-flash' width='"+w+"' height='"+h+"' allowScriptAccess='sameDomain' name='headerSWF' swLiveConnect='true' wmode='"+wmode+"' />\n"+
"</object>\n";
//alert (cont);
idC.innerHTML = cont;
	
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dynamic Menu Positioning 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function menuObj(){
	this.mainMenuID 	= null;
	this.subMenuID 		= null;
	this.subMenuVis 	= 'hidden';
	this.posTop 		= null;
	
	this.posLeft 		= null;
	this.currentPos 	= null;
	this.finalPos 		= null;
	this.hiddenPos 		= null;
	this.direction 		= true; //in/down
	this.timeOutID 		= null;
	this.moveTimeoutID 	= null;
}
var menu0 				= new menuObj;
var menu1 				= new menuObj;

menuObjs 				= new Array (menu0,menu1);

var tOutG 				= 200;		// mS
var headingSpace 		= 60;		// mS
var tMove 				= 20;		// mS
var tMoveOut			= 15;		// mS

var menuMovIncrement 	= 15;		// pixels
var startPos			= 0;		// pixels

function initMenus(){
for (i=0; i<menuObjs.length - 1;i++){
	//menuObjs[i].mainMenuID = getElementById(menus[i]);
	//menuObjs[i].subMenuID = parent.main.document.getElementById(menus[i]);
	//menuObjs[i].posTop = parent.main.document.body.scrollTop - (menuNo[i] * 20);
	//menuObjs[i].posLeft = 
	}
}



function posMenu(menu, i) {
	clearTimeout(menuObjs[i].timeOutID);
	menuObjs[i].subMenuID = document.getElementById(menu);//document.getElementById(menus[i]);
	// if we are already there don't restart the process
	if (menuObjs[i].subMenuID.style.visibility == 'visible')
		return;		//document.body.scrollTop
	//menuObjs[i].currentPos = menuObjs[i].posTop = startPos  - (menuNo[i] * 20);

	menuObjs[i].currentPos = menuObjs[i].posTop = startPos - menuObjs[i].subMenuID.offsetHeight;
	
	//menuObjs[i].subMenuID.style.top = menuObjs[i].currentPos;
	//shiftTo("footerOpen",getObjectLeft("content"),getObjectTop("content") + getObjectHeight("content"));
	
	shiftTo(menuObjs[i].subMenuID,getObjectLeft(menuObjs[i].subMenuID),menuObjs[i].currentPos);
	
	menuObjs[i].direction = true; 
	menuObjs[i].subMenuID.style.visibility = 'visible';
	if (menuObjs[i].moveTimeoutID != null)
		clearInterval(menuObjs[i].moveTimeoutID);
	 menuObjs[i].moveTimeoutID = setInterval(moveMenuIDs[i], tMove);
	
	
}



function moveMenu(i){
if (menuObjs[i].direction == true) // Menu In
	{//
		if (menuObjs[i].currentPos >= startPos){
		
			clearInterval(menuObjs[i].moveTimeoutID);
			menuObjs[i].subMenuID.style.top = startPos + 2;
			//menuPosG[pos] = document.body.scrollTop;
			return;
			}
	
		menuObjs[i].currentPos += menuMovIncrement;
		//menuObjs[i].subMenuID.style.top = menuObjs[i].currentPos;
		shiftTo(menuObjs[i].subMenuID,getObjectLeft(menuObjs[i].subMenuID),menuObjs[i].currentPos);
		
	}
	else // Menu Out
	{
	
	if (menuObjs[i].currentPos <=  menuObjs[i].posTop){
			clearInterval(menuObjs[i].moveTimeoutID);
			menuObjs[i].subMenuID.style.top = startPos;
			menuObjs[i].subMenuID.style.visibility = 'hidden';
			//menuPosG[pos] = parent.main.document.body.scrollTop;
			return;
			}
	
		menuObjs[i].currentPos -= menuMovIncrement;
		//menuObjs[i].subMenuID.style.top = menuObjs[i].currentPos;
		shiftTo(menuObjs[i].subMenuID,getObjectLeft(menuObjs[i].subMenuID),menuObjs[i].currentPos);
	}	


}
function clearMenuTimeout(i){

	clearTimeout(menuObjs[i].timeOutID);

	//if (menuObjs[i].moveTimeoutID != null){
	//	clearInterval(menuObjs[i].moveTimeoutID);
	//	}

	
	}



//menus = new Array ('subMenu','subMenu2');
menuNo = new Array (4,4);
function t0(){
if (menuObjs[0].moveTimeoutID != null){
clearInterval(menuObjs[0].moveTimeoutID);}
menuObjs[0].direction = false; // Sub menu out
menuObjs[0].moveTimeoutID = setInterval(moveMenuIDs[0], tMoveOut);
}
function t1(){
if (menuObjs[1].moveTimeoutID != null){
clearInterval(menuObjs[1].moveTimeoutID);}
menuObjs[1].direction = false; // Sub menu out
menuObjs[1].moveTimeoutID = setInterval(moveMenuIDs[1], tMoveOut);
}

function moveMenu0(){
moveMenu(0);
}
function moveMenu1(){
moveMenu(1);
}

moveMenuIDs = new Array ('moveMenu0()','moveMenu1()',0);



/////////////////////////////////////////////////////////////////////////////////
// Open new simulated window using a DIV
/////////////////////////////////////////////////////////////////////////////////
// Global variables
var newWindow;
var newImg;
var newHead;



function showLarge(img){

	
	// First change path to new (larger with same name) image
	newImg = "";
	imgParts = img.src.split("/");
	for (var i=0;i<imgParts.length-1;++i){
		newImg += imgParts[i];
		newImg += "/";
		}
	newImg += "large/";
	newImg += imgParts[imgParts.length - 1];
	newHead = img.alt; // Used for Title in the new window
	// Compute height for large image based on width of 400
	var ht;
	ht = Math.round((400/img.width)*img.height) + 120;
	newContent = "<p  onclick='closePopup();' class='close2'>Close</p>";
	newContent += "<p class='largeImgTxt'>"+newHead+"</p><img src='" +newImg+"' border='2' /><br />\n";
	newContent += "<p class='largeImgTxt'>&copy; 2006 -  TBS- All rights reserved.\n";
	newContent += "<p  onclick='closePopup();' class='close'>Close</p><br />";
	//newContent += "<form onsubmit='this.visibility=\"hidden\";'><label><input type='submit' name='Close' value='Close' /></label></form>\n</p>";
	
	var popUp = document.getElementById("popUp");
	popUp.style.visibility = 'visible';
	popUp.innerHTML = newContent;
	
	centerOnWindow("popUp",false); //true for centre, false for top left
	

}

function closePopup(){
		var popUp = document.getElementById("popUp");
	popUp.style.visibility = 'hidden';
	
}

/////////////////////////////////////////////////////////////////////////////////
// Center a positionable element whose name is passed as 
// a parameter in the current window/frame, and show it
/////////////////////////////////////////////////////////////////////////////////

function centerOnWindow(elemID, center) {
    // 'obj' is the positionable object
	// center = true to cettre obj, false for top left
	
    var obj = getRawObject(elemID);
    // window scroll factors
    var scrollX = 0, scrollY = 0;
    if (document.body && typeof document.body.scrollTop != "undefined") {
        scrollX += document.body.scrollLeft;
        scrollY += document.body.scrollTop;
        if (document.body.parentNode && 
            typeof document.body.parentNode.scrollTop != "undefined") {
            scrollX += document.body.parentNode.scrollLeft;
            scrollY += document.body.parentNode.scrollTop;
        }
    } else if (typeof window.pageXOffset != "undefined") {
        scrollX += window.pageXOffset;
        scrollY += window.pageYOffset;
    }
    if (!center){ // top left
		
		shiftTo(obj, scrollX, scrollY);
		return;
	}
	else {
    	var x = Math.round((getInsideWindowWidth()/2) - 
        	(getObjectWidth(obj)/2)) + scrollX;
    	var y = Math.round((getInsideWindowHeight()/2) - 
        	(getObjectHeight(obj)/2)) + scrollY;
    	shiftTo(obj, x, y);
    	show(obj);
		}
}


// Return the available content height space in browser window
function getInsideWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}

//----------

// Special handling for CSS-P redraw bug in Navigator 4
function handleResize() {
    if (isNN4) {
        // causes extra redraw, but must do it to get banner object color drawn
        location.reload();
    } else {
        centerOnWindow("banner");
    }
}
// Keep centered during scroll
function handleScroll() {
    centerOnWindow("banner");
}

window.onresize = handleResize;
window.onscroll = handleScroll;


//////////////////////////////////////////////////////////////////////////////////////////////////
// Get Mouse position
//////////////////////////////////////////////////////////////////////////////////////////////////


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0} 
  
  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  //return true
}



/////////////////////////////////////////////////////////////////////////////////
// Open new window
/////////////////////////////////////////////////////////////////////////////////



function showLarge2(img){
	// First change path to new (larger with same name) image
	newImg = "";
	imgParts = img.src.split("/");
	for (var i=0;i<imgParts.length-1;++i){
		newImg += imgParts[i];
		newImg += "/";
		}
	newImg += "large/";
	newImg += imgParts[imgParts.length - 1];
	newHead = img.alt; // Used for Title in the new window
	// Compute height for large image based on width of 400
	var ht;
	ht = Math.round((400/img.width)*img.height) + 120;


/* onclick="window.open('http://www.pixmania.co.uk/dev/gui_web/common_dsp/zoom.php?itag=5899&ArticleId=95369','remotewindow','toolbar=0,location=0,directories=0,status=no,menubar=no,scrollbars=0,resizable=0,width=620,height=622,left=0,top=0','mainwindow');">
*/
	if (newWindow)  {
        // window is already open - close and start afresh
        newWindow.close();
    }
	 if (!newWindow || newWindow.closed) {
		newWindow = window.open("limage.htm","largeProd","width=470,height="+ht+"toolbar=0,location=0,directories=0,status=no,menubar=no,scrollbars=0,resizable=0,left=0,top=0",false);
		
		//newWindow = window.open("limage.htm","","width=470,height="+ht+"status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes");
        // delay writing until window exists in IE/Windows
        //setTimeout("writeToWindow()", 100);
    } 
	
}

function writeToWindow() {
    // assemble content for new window
    var newContent = "<html>\n<head>\n<title>"+newHead+"</title>\n";
	newContent += "<link rel='stylesheet' type='text/css' media='screen' href='style/style.css' />\n";
	/* newContent += "<script type='text/javascript' src='js/function.js'></script>\n"; */
    newContent += "</head>\n<body>\n";
	newContent += "<p class='largeImgTxt'>"+newHead+"</p><img src='" +newImg+"' border='2' /><br />\n";
	newContent += "<p class='largeImgTxt'>&copy; 2006 -  TBS- All rights reserved.\n";
	newContent += "<form onsubmit='parent.close();'><label><input type='submit' name='Close' value='Close' /></label></form>\n</p>";

    newContent += "</body>\n</html>";
	
    // write HTML to new window document
    newWindow.document.write(newContent);
    newWindow.document.close(); // close layout stream
	
}




/////////////////////////////////////////////////////////////////////////////////
// Change background on focus 
/////////////////////////////////////////////////////////////////////////////////

function changeBg(form,field, requiredFields, fieldNames)
{
var	c,i,z,r;
r=0;
	
	setBGColor(field, 'eeeeee');
	//field.style.borderColor = '6699ff';
	
	// Find form field pos.
	//alert (form.length);
	for (i=0;i<form.length;i++)
	{
		
	if (field.name == form[i].name)
		{
			break;
		}
	}
	msg = "";
	
	c = 0;
	for (t=0;t<i;t++)
	{
		
		if ((form[t].value == "") || (form[t].value == null))
			{
				
			for (z=0;z<requiredFields.length;z++)
				{
					//alert (form.elements.length);
					if (form[t].name == requiredFields[z])
					{
						
						msg += "'" + fieldNames[z] + ":'\n";
						c++;
						if (r==0)
							r = t;
					}
				}
			
			}
		
	}
	if (c == 1){
		alert ("Please complete the required field:\n\n" + msg);
		restoreBg(field);
		form.elements[r].focus();
	}
	else if (c > 1){
		alert ("Please complete the required fields:\n\n" + msg);
		restoreBg(field);
		form.elements[r].focus();
	}
}

function restoreBg(obj)
{
	obj.style.backgroundColor = 'white';
	//obj.style.borderColor = '999999';
}


////////////////////////////////////////////////////////////////////////////////
// Navigation
////////////////////////////////////////////////////////////////////////////////

// Goback one page
function navBack(){
history.back();
}


////////////////////////////////////////////////////////////////////////////////
// Test for empty/null data
function isEmpty(data){
if ((data == null) ||
(data == "") ||
(data.length < 1))
return (true);
else return (false);
}

////////////////////////////////////////////////////////////////////////////////
// Change cursor to hand
function changeHand (ref){
if (ua.indexOf("MSIE")>=1)
	ref.style.cursor = 'hand';
else
	ref.style.cursor = 'pointer';
return (ref);
}
////////////////////////////////////////////////////////////////////////////////
// Show mouse over effect
function mm_hover (ref){
changeHand(ref);
ref.style.backgroundImage = 'none';
//ref.style.backgroundColor = 'FF9933';
ref.style.color = '000050';
//ref.style.borderColor = '000050';
//ref.title = "netxdesign - " + ref.innerHTML;
}
////////////////////////////////////////////////////////////////////////////////
// Show mouse out effect
function mm_hoverOut (ref){
	//alert(ref.innerHTML);
ref.style.backgroundImage = 'url(../images/headBack.jpg)';
//ref.style.color = 'FFFFFF';
//
//ref.style.borderColor = 'FF9933';

}
////////////////////////////////////////////////////////////////////////////////
// Determine MS IE or Nav
var ua = navigator.userAgent;
function IE(){
if (ua.indexOf("MSIE")>=1)
	return true;
}
////////////////////////////////////////////////////////////////////////////////
// Returns the date in long hand format
function date1 ()
{
  var d, s = "";
  var month = ["January", "February", "March", "April", "May" , "June",
  "July", "August", "September", "October", "November", "December"];
  
  var day = ["Sunday", "Monday", "Tuesday",
  "Wenesday", "Thursday", "Friday", "Saturday"];
  
  d = new Date();
  //s += day[d.getDay()] + " ";
  s += d.getDate() + " ";
  s += month[(d.getMonth())] + " ";
  s += d.getFullYear();
  return (s)
   
}
////////////////////////////////////////////////////////////////////////////////
function year ()
{
  var d, s = "";
  
  d = new Date();
  s += d.getFullYear();
  return (s)
   
}






////////////////////////////////////////////////////////////////////////////////
// Check email validity
/* 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */
// -->

<!-- Begin
function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Email username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Email domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("Email username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Email destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
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) {
alert("Email domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The email address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("The email address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

////////////////////////////////////////////////////////////////////////////////
// Set font attributes
function setFont1(ref, family, style, weight, size, color, pos){
ref.style.fontSize = size;
ref.style.fontFamily = family;
ref.style.fontStyle = style;
ref.style.fontWeight = weight;
ref.style.color = color;
ref.align = pos;
return (ref);
}
////////////////////////////////////////////////////////////////////////////////
// Set border attributes
function setBorder(ref, bg, color, width, style){
ref.style.background = bg;
ref.style.borderColor = color;
ref.style.borderWidth = width;
ref.style.borderStyle = style;
return (ref);
}

////////////////////////////////////////////////////////////////////////////////
// Form Validation
// Arrays for the required fields and discriptions are passed to this function
// from the form. If there is an 'emailaddress' field then this is tested for
// correct syntax.

function formCheck(formobj, fieldRequired, fieldDescription){

	var alertMsg = "Please complete the following field(s):\n";
	
	var l_Msg = alertMsg.length;
	var groupChecked = false;
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "checkbox": // Not likely to be used
			
				if (obj.checked == false){
					
						alertMsg += " - " + fieldDescription[i] + "\n";
				}
				
				
				break;
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
					}
			else	if (fieldRequired[i] == "emailaddress"){
		 			 if (!emailCheck (formobj.emailaddress.value))	
						return false;
					 }
					 
				//}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;

	}
	else{
		alert(alertMsg);
		return false;
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// JavaScript Document - treemenu.js


/*<menu>
	<section name="Tools">
		<sub name="Colour Selector" link="../access.php"/>
		<sub name="Domain Name Search" link="../mwhois/mwhois.php"/>
		<sub name="Domain Name Wizard" link="../mwhois/mwhois.php?do_wizard=1"/>
		<sub name="Global Name Wizard" link="../mwhois/mwhois.php?do_global=1"/>
	</section>
	<section name="Services">
		<sub name="Disability Access" link="../service.php"/>
		<sub name="Statistics" link="../service.php"/>
		<sub name="Domain Name Man." link="../service.php"/>
		<sub name="Host Selection" link="../service.php"/>
		<sub name="Data Base" link="../service.php"/>
	</section>
	<section name="Reference Sites">
		<sub name="print-on-line24" link="http://www.print-on-line24.com"/>
		<sub name="Stephen Forbes" link="http://www.stephenforbes.com"/>
		<sub name="Sport Legends" link="http://www.sportlegends.co.uk"/>
		<sub name="Clacton Models" link="http://www.clactonmodels.co.uk"/>
		<sub name="Primary Care UK" link="http://www.primarycareuk.com"/>
		<sub name="Campwood Press" link="http://www.campwoodpress.co.uk"/>
	</section>
	<section name="Contact Us">
		<sub name="Enquiry" link="../contact.php"/>
		<sub name="Sales email" link="mailto:sales@netxdesign.co.uk"/>
		<sub name="Support email" link="mailto:support@netxdesign.co.uk"/>
	</section>
</menu>*/

/*


//  assign group names - use folder text as in page
//groupNames			= new Array('Free Web Tools','Contact Us','Design Services','Ref Sites');
groupNames			= new Array('Free Web Tools','Contact Us','Design Services');
// assign text labels and hyperlinks for each menu items



labels1				= new Array('Colour Selector','Domain Name Search','Domain Name Wizard','Global Name Wizard','Search Engine Submission');
links1				= new Array('colorsel.htm','mwhois/mwhois.php','mwhois/mwhois.php?do_wizard=1','mwhois/mwhois.php?do_global=1','submitforce/index.php');


labels2				= new Array('Enquiries','Sales email','Support email');
links2				= new Array('contact.htm','mailto:sales@netxdesign.co.uk','mailto:support@netxdesign.co.uk');

labels3				= new Array('Interactive Forms');
links3				= new Array('add/form1.htm');


//labels4				= new Array('Starter Package','print-on-line24','Sport Legends','Clacton Models');
links4				= new Array('designs.htm','http://www.print-on-line24.com','http://www.sportlegends.co.uk','http://www.clactonmodels.co.uk');

// create index of text labels and hyperlinks arrays for each group
masterLabelsIndex	= new Array(labels1,labels2,labels3);
masterLinksIndex	= new Array(links1,links2,links3);

//  assign frame target value for hyperlinks (use frame name or '_blank' '_parent' '_self' '_top')
linkTarget			= '_self';

// calculate total number of groups
totalGroups			= masterLabelsIndex.length;

function openFolder(group) {

	// create layer name value for MM_setTextOfLayer() function
	layerName		= 'group' + group;
	
	// create offset value for array positions
	groupOffset		= group - 1;
	
	// assign relevant group values to local arrays
	labels			= masterLabelsIndex[groupOffset];
	links			= masterLinksIndex[groupOffset];
	
	// calculate offset value to determine array position for last menu item
	endOfRecord		= labels.length - 1;
	
	// create expanded folder graphics with JavaScript call to closeFolder() function
	if (group == totalGroups) {
		treeCode = '<a href="javascript:closeFolder(' + group + ');"><img src="images/minuslst.gif" width="19" height="16" border="0" align="absbottom"></a>';
	} else {
		treeCode = '<a href="javascript:closeFolder(' + group + ');"><img src="images/minus.gif" width="19" height="16" border="0" align="absbottom"></a>';
	}
	treeCode = treeCode + '<img src="images/folderop.gif" width="19" height="16" align="absbottom">' + groupNames[groupOffset] + '<br>';

	// loop through each menu item and create tree graphics, text labels and hyperlinks
	for (i = 0; i < endOfRecord; i++) {
		if (group == totalGroups) {
			treeCode = treeCode + '<img src="images/empty.gif" width="19" height="16" align="absbottom"><img src="images/join.gif" width="19" height="16" align="absbottom">';
		} else {
			treeCode = treeCode + '<img src="images/line.gif" width="19" height="16" align="absbottom"><img src="images/join.gif" width="19" height="16" align="absbottom">';
		}
		if (links[i].substring(0,4) == "http")
			linkTarget = "_blank";
		treeCode = treeCode + '<img src="images/page.gif" width="19" height="16" align="absbottom"><a href="' + links[i] + '" target="' + linkTarget + '">' + labels[i] + '</a><br>';
	}
	
	// create alternative tree graphics, text labels and hyperlinks for last menu item
	if (group == totalGroups) {
		treeCode = treeCode + '<img src="images/empty.gif" width="19" height="16" align="absbottom"><img src="images/joinlast.gif" width="19" height="16" align="absbottom">';
	} else {
		treeCode = treeCode + '<img src="images/line.gif" width="19" height="16" align="absbottom"><img src="images/joinlast.gif" width="19" height="16" align="absbottom">';
	}
	if (links[i].substring(0,4) == "http")
			linkTarget = "_blank";
	treeCode = treeCode + '<img src="images/page.gif" width="19" height="16" align="absbottom"><a href="' + links[endOfRecord] + '" target="' + linkTarget + '">' + labels[endOfRecord] + '</a>';
	
	// update layer with new HTML content
	MM_setTextOfLayer(layerName,'',treeCode)

}

function closeFolder(group) {

	// recreate layer name value for MM_setTextOfLayer() function
	layerName		= 'group' + group;
	
	// create offset value for array positions
	groupOffset		= group - 1;

	// assign relevant group values to local arrays
	labels			= masterLabelsIndex[groupOffset];
	links			= masterLinksIndex[groupOffset];
	
	// create collapsed folder graphics with JavaScript call to openFolder() function
	if (group == totalGroups) {
		treeCode = '<a href="javascript:openFolder(' + group + ');"><img src="images/pluslast.gif" width="19" height="16" border="0" align="absbottom"></a>';
	} else {
		treeCode = '<a href="javascript:openFolder(' + group + ');"><img src="images/plus.gif" width="19" height="16" border="0" align="absbottom"></a>';
	}
	treeCode = treeCode + '<img src="images/folder.gif" width="19" height="16" align="absbottom">' + groupNames[groupOffset];
	
	// update layer with new HTML content
	MM_setTextOfLayer(layerName,'',treeCode)
	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////

// DHTMLapi.js custom API for cross-platform
// object positioning by Danny Goodman (http://www.dannyg.com).
// Release 2.0. Supports NN4, IE, and W3C DOMs.

// Global variables
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
// Initialize upon load to let all browsers establish content objects
function initDHTMLAPI() {
	
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
    }
}
// Set event handler to initialize API
//window.onload = initDHTMLAPI;

// Seek nested NN4 layer from string name
function seekLayer(doc, name) {
    var theObj;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) {
            theObj = doc.layers[i];
            break;
        }
        // dive into nested layers if necessary
        if (doc.layers[i].document.layers.length > 0) {
            theObj = seekLayer(document.layers[i].document, name);
        }
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid element object reference
function getRawObject(obj) {
    var theObj;
    if (typeof obj == "string") {
        if (isW3C) {
            theObj = document.getElementById(obj);
        } else if (isIE4) {
            theObj = document.all(obj);
        } else if (isNN4) {
            theObj = seekLayer(document, obj);
        }
    } else {
        // pass through object reference
        theObj = obj;
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj) {
    var theObj = getRawObject(obj);
    if (theObj && isCSS) {
        theObj = theObj.style;
    }
    return theObj;
}

// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = x + units;
            theObj.top = y + units;
        } else if (isNN4) {
            theObj.moveTo(x,y)
        }
    }
}

// Move an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = getObjectLeft(obj) + deltaX + units;
            theObj.top = getObjectTop(obj) + deltaY + units;
        } else if (isNN4) {
            theObj.moveBy(deltaX, deltaY);
        }
    }
}

// Set the z-order of an object
function setZIndex(obj, zOrder) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.zIndex = zOrder;
    }
}

// Set the background color of an object
function setBGColor(obj, color) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isNN4) {
            theObj.bgColor = color;
        } else if (isCSS) {
            theObj.backgroundColor = color;
        }
    }
}

// Set the visibility of an object to visible
function show(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "visible";
    }
}

// Set the visibility of an object to hidden
function hide(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "hidden";
    }
}

// Retrieve the x coordinate of a positionable object
function getObjectLeft(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.left;
    } else if (elem.style) {
        result = elem.style.left;
    } else if (isNN4) {
        result = elem.left;
    }
    return parseInt(result);
}

// Retrieve the y coordinate of a positionable object
function getObjectTop(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.top;
    } else if (elem.style) {
        result = elem.style.top;
    } else if (isNN4) {
        result = elem.top;
    }
    return parseInt(result);
}

// Retrieve the rendered width of an element
function getObjectWidth(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth) {
        result = elem.offsetWidth;
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}

// Retrieve the rendered height of an element
function getObjectHeight(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}

// Return the available content width space in browser window
function getInsideWindowWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}

// Return the available content height space in browser window
function getInsideWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}


