// 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
// www.netxdesign.co.uk which is part of Interlink Communications Limited

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Even up columns
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function evenCol(){
	
	var lh = getObjectHeight("leftMenu");
	var rh = getObjectHeight("main");

	//var nh = Math.max(lh, rh); 
	//document.getElementById("leftMenu").style.height = lh + 20 + "px";
	document.getElementById("main").style.height = lh + 20 + "px";
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// convert XML data into JavaScript array of JavaScript objects
// function is passed an array of XML files 'xFile', the main page element 'tag' and the image path 'imgpath'
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var xDoc;
var xDocTemp;
var xDocs = new Array();
var handler = 'n';

// handler - Which listing function to use
// 'n' = normal -all products listed on right hand column
// 'f' = full - full page of product information

var xmlFileNames = new Array();
var allProds = new Array();
var content = ""
var contentTmp = "";
var containerTag;
var path;
var output = new Array();
var loaded = false;
var index = 0;
var scrollPos;
var div;

function loadXMLMenu(xFile,tag,imgpath,funcHandler){
var i;
//alert (xFile);
	xmlFileNames = xFile;
	path = imgpath;
	containerTag = tag;
	loaded = false;
	if (funcHandler){
		handler = funcHandler;
		

	}
		// Open the  XML files and get objects into xDoc array
		for (i=0;i<xFile.length;i++){
			loaded = false;
			verifySupport(xFile[i]);
			// Wait for last XMLfile to load
			while (loaded == false)
			{}
			xDocs[i] = xDoc;
		}
		// let file loading catch up to execution thread
		// and parse xlm doc to js
		
        setTimeout("XML2JS(xDocs[0], containerTag)", 1000);		


}

function xlmLoaded(){

	loaded = true;
	
}

// verify that browser supports XML features and load external .xml file
function verifySupport(xFile) {
    if (document.implementation && document.implementation.createDocument) {
        // this is the W3C DOM way, supported so far only in NN6+
        xDoc = document.implementation.createDocument("", "theXdoc", null);
    } else if (typeof ActiveXObject != "undefined") {
        // make sure real object is supported (sorry, IE5/Mac)
        if (document.getElementById("msxml").async) {
            xDoc = new ActiveXObject("Msxml.DOMDocument");
			xDoc.async = false;
			//loaded = true;
        }
    }
    if (xDoc && typeof xDoc.load != "undefined") {
        // load external file (from same domain)
        xDoc.load(xFile);
		if (!IE()){ // If not IE wait wait for file to load 
			xDoc.onload = xlmLoaded();
			
		}
		else{
			while (xDoc.readyState!=4)
			{}
			loaded = true;
		}
		
        return true;
    } else {
		
        var reply = confirm("This example requires a browser with XML support, " +
            "such as IE5+/Windows or Netscape 6+.\n \nGo back to previous page?");
        if (reply) {
            history.back();
        }
    }
    return false;
}

// Required for the order form
var requiredOrdFields = Array("OrderNumber","Name", "Company", "emailaddress");
var fieldOrdNames = Array("Order Number","Name", "Company", "email address");

function XML2JS(xmlDoc, containerTag) {
		
var x, i, j, oneRecord, oneObject, img, rawData;	

	switch (handler)
		{
			case 'n': // Normal
			div = document.getElementById("main");
			break;		
			case 'f': // Full product list
			case 't': // Full text only list
			case 'e': // Admin - full list with edit via forms
			//case 'x': // Admin - full list with edit via forms (TEST)
			div = document.getElementById("leftMenu");
			break;	
			
			case 'o': // Client - Order form
			div = document.getElementById("leftMenu");
			content = "<form action='orderprocess.php' method='post' name='orderprocess' id='orderprocess'  onsubmit='return formCheck(this, requiredOrdFields, fieldOrdNames);'>";
			content += "<br />Please use the form below to place your order. Simply enter the quantity required for each of the items. The price will automatically be updated once you click outside the quantity. The Total price for the order is also displayed at the end of the page. <br /><br />Once you have added all the required quanities please complete the form at the base of this page. You will receive a confirmation via the page and email when you click the 'Place Order' button.<br />";
			
			break;
			
			case 'test': // Client - Order form
			div = document.getElementById("leftMenu");
			content = "<form action='orderprocess_t.php' method='post' name='orderprocess' id='orderprocess'  onsubmit='return formCheck(this, requiredOrdFields, fieldOrdNames);'>";
			content += "<br />Please use the form below to place your order. Simply enter the quantity required for each of the items. The price will automatically be updated once you click outside the quantity. The Total price for the order is also displayed at the end of the page. <br /><br />Once you have added all the required quanities please complete the form at the base of this page. You will receive a confirmation via the page and email when you click the 'Place Order' button.<br />";
			
			break;
		}
			


  for (x=0;x<xDocs.length;x++) {
	  
	  allProds = allProds.concat(output);
	 // Clear output array ready for next xml file
	 output =[];
	 xmlDoc = xDocs[x];
	 
 
    rawData = xmlDoc.getElementsByTagName(containerTag)[0];
	
    for (i = 0; i < rawData.childNodes.length; i++) {
        if (rawData.childNodes[i].nodeType == 1) {
            oneRecord = rawData.childNodes[i];
            oneObject = output[output.length] = new Object();
            for (j = 0; j < oneRecord.childNodes.length; j++) {
                if (oneRecord.childNodes[j].nodeType == 1) {
                    oneObject[oneRecord.childNodes[j].tagName] = oneRecord.childNodes[j].firstChild.nodeValue; 
					//alert (oneRecord.childNodes[j].firstChild.nodeValue);
                }
            }
        }
    }


		switch (handler)
			{
			case 'n': // Normal - list of products in the right hand side
			for (i=0;i<output.length;i++,index++){
				img = trimAll(output[i].image.toLowerCase());

				// Use index as the reference for when the fillContent onClick event is called
				content += "<p><img src='images/"+path+"/th/"+ img + "' alt='" + output[i].title + "' title='" + output[i].title + "' onclick='fillContent(\"leftMenu\", \"" +  index + "\")' width='100' class='pointer' />	<br />" + output[i].title + "</p>";
				}
			break;
	
			case 'f': // Full list of all products
			content += "<h3>" + output[0].catagory + "</h3>";
			content += "<table cellspace='2' cellpadding='3'>";
			content += "<td class='listHead'>Image</td><td class='listHead'>Product</td>";
			content += "<td class='listHead'>Code</td><td class='listHead'>Description</td>";
			content += "<td class='listHead'>Packaging</td><td class='listHead'>Brand</td>";
			content += "<td class='listHead'>Price</td><td class='listHead'>SRP</td></tr>";	

			for (i=0;i<output.length;i++,index++){
				img = trimAll(output[i].image.toLowerCase());
				content += "<tr><td class='list'><img src='../images/"+path+"/th/"+ img + "' alt='" + output[i].title + "' title='" + output[i].title + "' onclick='fillContent(\"leftMenu\", \"" +  index + "\")' class='pointer' /></td>";
				content += "<td class='list'>"+output[i].title+"</td><td class='list'>"+output[i].code+"</td><td class='list'>"+output[i].description+"</td>";
				content += "<td class='list'>"+output[i].packaging+"</td><td class='list'>"+output[i].brand+"</td><td class='list'>&pound;"+output[i].price+"</td>";
				content += "<td class='list'>&pound;"+output[i].rrp+"</td>";
			
				content += "</tr>";
				}
			content += "</table>";
			break;

			case 't': // Full text list of all products (no images)
			content += "<h3>" + output[0].catagory + "</h3>";
			content += "<table cellspace='2' cellpadding='3'>";
			content += "<td class='listHead'>Product</td>";
			content += "<td class='listHead'>Code</td><td class='listHead'>Description</td>";
			content += "<td class='listHead'>Packaging</td><td class='listHead'>Brand</td>";
			content += "<td class='listHead'>Price</td><td class='listHead'>SRP</td></tr>";	

			for (i=0;i<output.length;i++,index++){
				//img = trimAll(output[i].image.toLowerCase());
				//content += "<tr><td class='list'><img src='images/"+path+"/th/"+ img + "' alt='" + output[i].title + "' title='" + output[i].title + "' onclick='fillContent(\"leftMenu\", \"" +  index + "\")' class='pointer' /></td>";
				content += "<td class='list'>"+output[i].title+"</td><td class='list'>"+output[i].code+"</td><td class='list'>"+output[i].description+"</td>";
				content += "<td class='list'>"+output[i].packaging+"</td><td class='list'>"+output[i].brand+"</td><td class='list'>&pound;"+output[i].price+"</td>";
				content += "<td class='list'>&pound;"+output[i].rrp+"</td>";
			
				content += "</tr>";
				}
			content += "</table>";
			break;

			


			case 'e': // Full list of all products
			content += "<h3>" + output[0].catagory + "</h3>";


			for (i=0;i<output.length;i++,index++){
				img = trimAll(output[i].image.toLowerCase());
			
			content += "<form action='../admin/xmlphp.php' method='post' name='editProduct' onsubmit='return getScrollPos(this)'>";
			content += "<input name='id' type='hidden' value='"+i+"' />";
			content += "<input name='function' type='hidden' value='update' />";
			content += "<input name='category' type='hidden' value='"+ output[0].catagory + ":" + xmlFileNames[x] +"' />";
			
			content += "<input name='scrollpos' type='hidden' value='"+scrollPos+"' />";
			
			content += "<table cellspace='2' cellpadding='3'>";
			content += "<tr>";
			content += "<td class='list' rowspan='8'><img src='../images/"+path+"/th/"+ img + "' alt='" + output[i].title + "' title='" + output[i].title + "' onclick='fillContent(\"leftMenu\", \"" +  index + "\")' class='pointer' width='100' /><br /><br />";
			content += "<input type='text' name='image'size='18' value='"+output[i].image+"' /></td></tr>";
				
			content += "<tr><td class='list' >Title:</td><td class='list' colspan='7' > <input type='text' name='title'size='100' value='"+output[i].title+"' /></td></tr>";
			content += "<tr><td class='list' >Desc:</td><td class='list' colspan='7'> <textarea name='description' rows='4' cols='100'>"+output[i].description+"</textarea></td></tr>";
			content += "<tr><td class='list' >Pack:</td><td class='list'  colspan='2'> <input type='text' name='packaging'size='30' value='"+output[i].packaging+"' /></td>";
			content += "<td class='list' >Brand:</td><td class='list'  colspan='5' > <input type='text' name='brand'size='50' value='"+output[i].brand+"' /></td></tr>";
			content += "<tr><td class='list' >Price:</td><td class='list' > <input type='text' name='price'size='15' value='"+output[i].price+"' /></td>";
			content += "<td class='list' >Stock:</td><td class='list' > <input type='text' name='stock'size='15' value='"+output[i].stock+"' /></td>";
			content += "<td class='list' >SRP:</td><td class='list' > <input type='text' name='rrp'size='15' value='"+output[i].rrp+"' /></td>";
			content += "<td class='list' >Code:</td><td class='list' > <input type='text' name='code'size='15' value='"+output[i].code+"' /></td></tr>";

			content += "<tr><td   class='list' ><input name='send' type='submit' value='update' /></td>";
			content += "<td colspan='7'  class='list' ><input name='send' type='submit' value='delete' onclick = 'return confirmDelete()' /></td></tr>";
			content += "</table></form>";
			
			}
			break;

			case 'o': // Client Order Form
			case 'test':
			content += "<h3>" + output[0].catagory + "</h3>";
			content += "<table cellspace='2' cellpadding='3'>";
			content += "<td class='listHead'>Image</td><td class='listHead'>Product</td>";
			content += "<td class='listHead'>Description</td><td class='listHead'>Code</td>";
			content += "<td class='listHead'>Brand</td>";
			content += "<td class='listHead'>Stk</td>";
			content += "<td class='listHead'>Price</td>";
			
			content += "<td class='listHead'>Qnty</td>";	
			content += "<td class='listHead'>Total</td></tr>";

			for (i=0;i<output.length;i++,index++){
				img = trimAll(output[i].image.toLowerCase());
				content += "<tr><td class='list'><img src='../images/"+path+"/th/"+ img + "' alt='" + output[i].title + "' title='" + output[i].title + "' onclick='fillContent(\"leftMenu\", \"" +  index + "\")' class='pointer' width='100' /></td>";
				
				content += "<td class='list'>"+output[i].title+"</td><td class='list'>"+output[i].description+"</td><td class='list'>"+output[i].code+"</td>";
				content += "<input type='hidden' value='"+output[i].title+"' name='title"+index+"' >";
				//content += "<input type='hidden' value='"+output[i].description+"' name='description"+index+"' >";
				content += "<input type='hidden' value='"+output[i].code+"' name='code"+index+"' >";
				content += "<td class='list'>"+output[i].brand+"</td>";
				//content += "<input type='hidden' value='"+output[i].brand+"' name='brand"+index+"' >";
				var sk;
				if (output[i].stock == 'n') sk = "No"; else sk = "Yes";
				
				content += "<td class='list'  >"+sk+"</td>";
				
				
				content += "<td class='list'  >&pound;"+output[i].price+"</td>";
				content += "<input type='hidden' value='"+output[i].price+"' name='price"+index+"' >";
				
				
				//content += "<td class='list'  >&pound;"+output[i].price+"</td>";

				if (sk == "Yes")
					content += "<td class='list'><input type='text' name='q"+index+"' size='6' value='' onBlur='calLineprice(this,"+index+","+output[i].price+")' onkeypress='return noenter()' ></td>";
				else
					content += "<td class='list'><input type='text' name='q"+index+"' size='6' value='' disabled='disabled' ></td>";
				
				
				
				content += "<td class='list'><div id='lp"+index+"' >&pound;0.00</div></td>";
				//content += "<td class='list'><input type='text' size='7'  readonly='true' id='lp"+index+"' value='£0.00' name='total' /></td>";
				
				content += "</tr>";
				}
			//content += "<tr><td colspan='8' class='list'><input name='send' type='submit' value='Place Order' /></td></tr>";
			content += "</table>";
			break;

			}
	
	}
	allProds = allProds.concat(output);

		switch (handler)
			{
			case 'o': // Order form
			case 'test':
// Add customer form fields
	
			//  onfocus='changeBg(forms.orderprocess,this, requiredOrdFields, fieldOrdNames)' onblur='restoreBg(this)'
			content += "<table width='98%' class='total'>";
			content += "<td>Order Number:</td>";
			content += "<td><input type='text' name='OrderNumber' size='40' /></td></tr>";

			content += "<tr>";
			content += "<td>Name:</td>";
			content += "<td><input type='text' name='Name' value='"+ucontact+"' size='40' /></td></tr>";

			content += "<tr>";
			content += "<td>Company:</td>";
			content += "<td><input type='text' name='Company' value='"+ucompany+"'  size='40' /></td></tr>";
			
			content += "<tr>";
			content += "<td>Address:</td>";
			content += "<td><input type='text' name='Address' value='"+uaddress+"'  size='90' /></td></tr>";
			
			content += "<tr>";
			content += "<td>Town:</td>";
			content += "<td><input type='text' name='Town' value='"+utown+"'  size='40' /></td></tr>";
			
			
			content += "<tr>";
			content += "<td>County:</td>";
			content += "<td><input type='text' name='County' value='"+ucounty+"'  size='40' /></td></tr>";
			
			
			content += "<tr>";
			content += "<td>Post Code:</td>";
			content += "<td><input type='text' name='PostCode' value='"+upostCode+"'  size='40' /></td></tr>";
			
			
			content += "<tr>";
			content += "<td>Country:</td>";
			content += "<td><input type='text' name='Country' value='"+ucountry+"'  size='40' /></td></tr>";
			
			
					
			content += "<tr>";
			content += "<td>email address:</td>";
			content += "<td><input type='text' name='emailaddress' value='"+uemail+"'  size='40' /></td></tr>";
			content += "<tr>";
			content += "<td>Telephone No:</td>";
			content += "<td><input type='text' name='TelephoneNo' value='"+utel+"'  size='40' /></td></tr>";
			content += "<td>Fax No:</td>";
			content += "<td><input type='text' name='FaxNo' value='"+ufax+"'  size='40' /></td></tr>";			
			content += "<tr>";
			content += "<td>Additional Information:</td>";
			content += "<td><textarea name='Message' rows='6' cols='60' ></textarea></td></tr>";
			
			content += "</table>";
			content += "<input type='hidden' value='"+index+"' name='count' >";
			content += "<table width='98%' class='total'><tr><td><input name='send' type='submit' value='Place Order' /></td><td class='total'>Order Total (less VAT and Carriage) </td><td>&pound;</td><td class='total' id='total'>0.00</td></tr></table><br /><br />";
			
			

			content += "</form>";
			break;
			
			}


div.innerHTML = content;

//document.write(content);



	switch (handler)
	{
		case 'n': // Normal - list of products in the right hand side
		var main = document.getElementById("leftMenu");
		var head = new Array();
		var head = main.getElementsByTagName("h1");
		head[0].innerHTML += " - " + index + " Products";
		break;
	}
	
}



function confirmDelete(){
	
	if (!confirm("Are you sure you want to delete?"))
		return false;
	
}

function getScrollPos(formobj){
	
var expire;
	// Set expiiry to 10 mins
	expire = getExpDate(0,0,10);
	// Save current scroll pos in cookie, if pos?
	scrollPos = div.scrollTop;
	setCookie("scrollPos", scrollPos,expire);
 	formobj.scrollpos.value = div.scrollTop;
 return (scrollPos);

}

function calLineprice(qnty,idx,price){
	var p;
	var lp = document.getElementById("lp"+idx);
	if (isNaN(qnty.value)){
		alert ("Please enter numbers only");
		lp.innerHTML = "&pound;0.00";
		qnty.value = 0;
		qnty.focus();
		return;
		}
	if (parseInt(qnty.value) != qnty.value){
		//alert ("Please enter whole numbers only");
		lp.innerHTML = "&pound;0.00";
		qnty.value = 0;
		qnty.focus();		
		//return;
	}
	
	if (qnty.value < 0 ){
		alert ("Please enter positive numbers only");
		lp.innerHTML = "&pound;0.00";
		qnty.value = 0;
		qnty.focus();			
		return;
		
	}

	p = qnty.value * price;
	p = p.toFixed(2);
	lp.innerHTML = '&pound;'+ p;
	
	//lp.value = '&pound;'+ p;
	
	
	
	var t, v=0;
	for (i=0;i<index;i++){
		t = document.getElementById("lp"+i).innerHTML;
		//Remove '£' char
		t = t.substring(1,t.length);
		t = parseFloat(t);
		v += t;
	}
	v = v.toFixed(2);
	document.getElementById("total").innerHTML = v;

	
	
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Prevent Return Key from submitting form 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function noenter() {
  return !(window.event && window.event.keyCode == 13); 
  }


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fill content from XML data
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function fillContent(id, code){	
var  i, img;
	div = document.getElementById(id);
	i = code; // Use the code as a direct index into the the product array
	img = trimAll(allProds[i].image.toLowerCase());
	
	switch (handler)
		{
		case 'n': // Normal - list of products in the right hand side
		content = "<h1>" + allProds[i].catagory + " - " + allProds[i].title + "</h1>";
		content += "<table cellpadding='2' width= '100%'><tr>";
		content += "<td class='title'>Brand: " + allProds[i].brand + "</td>";
		content += "<td class='title'>Code: "+ allProds[i].code + "</td>";	
		content += "<td class='title'>Packaging: " + allProds[i].packaging + "</td>";
		content += "</tr></table>";
		content += "<table cellpadding='2' ><tr>";
		content += "<tr><td valign='top'><img onload='evenCol()' src='images/"+path+"/"+ img + "' alt='" + allProds[i].title + "' title='" + allProds[i].title + "' /> </td>";
		content += "<td valign='top'>" + allProds[i].description + "</td></tr>";
		content += "</tr></table>";
		
		break;
		
		case 'f': // Full list
		case 'e':
		case 'o':
		contentTmp = content; // Save current content for later retrieval
		scrollPos = div.scrollTop;
		content = "<h1>" + allProds[i].catagory + " - " + allProds[i].title + "</h1>";
		content += "<table cellpadding='2' width= '100%'><tr>";
		content += "<td class='title'>" + allProds[i].brand + "</td>";
		content += "<td class='title'>Code: "+ allProds[i].code + "</td>";	
		content += "<td class='title'>Packaging: " + allProds[i].packaging + "</td>";
		content += "<td class='title'>Price: £" + allProds[i].price + "</td>";
		content += "<td class='title'>SRP: £" + allProds[i].rrp + "</td>";
		content += "</tr></table>";
		content += "<table cellpadding='2' ><tr>";
		content += "<tr><td valign='top' class='pointer' onclick='reinstate()'><img src='../images/"+path+"/"+ img + "' alt='" + allProds[i].title + "' title='" + allProds[i].title + "' /><br /><i>Click to return to list</i> </td>";
		content += "<td valign='top'>" + allProds[i].description + "</td></tr>";
		content += "</tr></table>";
		break;
		}
		
	content += "<div id='subMenu' class='subMenu' style='visibility:hidden' onmouseover='showMenu();' onmouseout='subMenuT=setTimeout(\"hideMenu()\", 200)'>";
	content += "<a class='subButton' href='shaveAcc.htm' >Shaving Accessories</a>";
	content += "<a class='subButton' href='shaveBrushes.htm'>Shaving Brushes</a>";
	content += "<a class='subButton' href='shaveRazors.htm'>Shaving Razors</a>";  
	content += "<a class='subButton' href='shaveSets.htm'>Shaving Sets</a> ";
	content += "<a class='subButton' href='bodyCare.htm'>Body Care</a> ";
	content += "<a class='subButton' href='hairdressing.htm'>Hairdressing</a> ";
	content += "<a class='subButton' href='shavingStands.htm'>Shaving Stands</a> ";
	content += "<a class='subButton' href='toiletries.htm'>Toiletries</a> ";
	content += "<a class='subButton' href='manicuresets.php'>Manicure Sets</a> ";
	content += "<a class='subButton' href='allProducts.htm'>All Products</a>  </div>";
  
 	content += "<div id='quickMButt' onmouseover='showMenu();' 	onmouseout='subMenuT=setTimeout(\"hideMenu()\", 300)';>Quick Menu</div>";		
	div.innerHTML = content;
		
}

function reinstate(){
	content = contentTmp;
	div = document.getElementById("leftMenu");

	div.innerHTML = contentTmp;
	// Allow time for content to load
	setTimeout("setScrollPos()", 100);		
	
}

function setScrollPos(){
	div =document.getElementById("leftMenu");
	//alert (scrollPos);
	div.scrollTop = scrollPos;
	
}


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


function getFlash(id, file, w, h, wmode){

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=9,0,115,0' "+
"width='"+w+"' height='"+h+"' title='"+file+"'>"+
"<param name='movie' value='"+ file +".swf' />"+
"<param name='allowScriptAccess' value='sameDomain' />"+
"<param name='quality' value='high' />"+ 
"<param name='wmode' value='"+wmode+"' />"+
"<embed src='"+ 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+"' />"+
"</object>";
//alert (cont);
idC.innerHTML = cont;
	
}

function getFlash_2(id, file,title, w, h, wmode){

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=9,0,115,0' "+
"width='"+w+"' height='"+h+"' title='"+title+"' id='"+file+"SWF'>"+
"<param name='movie' value='"+ file +"' />"+
"<param name='allowScriptAccess' value='sameDomain' />"+
"<param name='quality' value='high' />"+ 
"<param name='wmode' value='"+wmode+"' />"+


"<embed src='"+ file +"' 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+"' />"+
"</object>";

idC.innerHTML = cont;
	
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Flash 8 Communicator 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var flash;
function callExternalInterface() {
	var h1Lbl;
	// get Flash movie object
	 if(navigator.appName.indexOf("Microsoft") != -1) {
    	flash = window["headerSWF"];
  	}else {
    	flash = document["headerSWF"];
  	}
	// get <h1> contents	
	h1Lbl = document.getElementById("h1").innerHTML;
	
	//flash.h1(h1Lbl);
	//alert (flash);
	thisMovie("headerSWF").h1(h1Lbl);
    
 
	
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return window.document[movieName]
    }
}

/////////////////////////////////////////////////////////////////////////////////
// Submenu Display
/////////////////////////////////////////////////////////////////////////////////
var subMenuT;
function showMenu(){

	clearTimeout(subMenuT);
	document.getElementById('subMenu').style.visibility = 'visible';

}

function hideMenu(){
	
	document.getElementById('subMenu').style.visibility = 'hidden';
}

/////////////////////////////////////////////////////////////////////////////////
// Display Progress Bar
/////////////////////////////////////////////////////////////////////////////////

function displayProgress(id){
	var d= document.getElementById(id);
	d.innerHTML = "<img src='../images/progress.gif' /> Uploading Image File(s)";
	setTimeout("submitUpload()",200);
	return false;
}

function submitUpload(){
		document.imageUpload.submit();
	
}




/////////////////////////////////////////////////////////////////////////////////
// Generate Random pw
/////////////////////////////////////////////////////////////////////////////////

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
latterNumber, latterLower, latterUpper, latterOther) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
}
return rc;
}

function stringFilter (input) {
s = input;
filteredValues = " '&£$!%;:,.()-_=+";     // Characters stripped out
var i;
var returnString = "";
for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
var c = s.charAt(i);
if (filteredValues.indexOf(c) == -1) returnString += c;
}
return(returnString);
}


function generateUser(){
var pw;	
var name;
var bits = new Array();

	name = document.forms.addClient.elements["Name"].value;
	// Trim leading and trailing spaces from name  & update
	name = trimAll(name);
	// Delete spaces between words
	document.forms.addClient.elements["Name"].value = name;
	//bits = name.split(' ');
	//name = "";
	//for (var i=0;i<bits.length;i++){
	//	name += bits[i];
	//}
	
	name = stringFilter(name);
	name = name.toLowerCase();
	name = name.substr(0,8);
	document.forms.addClient.elements["UserName"].value = name;
	// Get random pw
	pw = getPassword(6, "", false, true, false, false,false, true, false, false);
	document.forms.addClient.elements["pw"].value = pw;
	//alert (pw);
	
	
}

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



function showLarge(img){
	
	newContent = "<img src='../images/products/" +img+"' border='1' onclick='closePopup();' class='pointer' /><br />\n";
	newContent += "<div style='position:absolute;padding-left: 10px; padding-right: 10px;left:20px; top:10px; background-color:#FFFFFF;border: 1px solid;'>"+img+" - Click image to close</div>";
	
	var popUp = document.getElementById("popUp");
	popUp.style.visibility = 'visible';
	popUp.innerHTML = newContent;

}

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



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

function changeBg(form,field, requiredFields, fieldNames)
{
var	c,i,z,r;
r=0;
	
	setBGColor(field, 'ece9d8');
	//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;
}


////////////////////////////////////////////////////////////////////////////////
// Trim string (left and right)

function trimAll(sString) 
	{
	while (sString.substring(0,1) == ' ')
		{
		sString = sString.substring(1, sString.length);
		}
	while (sString.substring(sString.length-1, sString.length) == ' ')
		{
		sString = sString.substring(0,sString.length-1);
		}
return sString;

}

// utility function to retrieve a future expiration date in proper format;
// pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire; all three
// parameters required, so use zeros where appropriate
function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}

// utility function called by getCookie()
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


