window.onerror=errorsuppressor
var GLOBALSession 			= "";
var GLOBALThePageData 		= "";
var GLOBALTextBorderColor 	= "";
var GLOBALTextBorderVisible = "";
var GLOBALTextTopMargin		= "";
var GLOBALTextBoxHeight		= "";
var GLOBALSearchVisible 	= "";
var GLOBALImagePath 		= "";
var GLOBALContentWidth 		= "";
var GLOBALContentLeft 		= "";
var GLOBALColor 			= "";
var GLOBALLayer2			= "";
var GLOBALTelNos 			= "";
var GLOBALEMail 			= "";
var GLOBALText 				= "";
var GLOBALLatLong			= "";
var GLOBALCheckThese 		= new Array();
var GLOBALEmailRecipient 	= "";		
var GLOBALCustomDesign 		= "";
var GLOBALURLforEGIZMO		= "";
var GLOBALMap				= "N";
var GLOBALCDLogo			= "cdlogo.png";
//flag to make sure 
var GLOBALDone				= false;

//we need to know if they want to use the layout capapbilities and stylesheets within EGZ
//if they do we include the name of their design here
var GLOBALDesigns			= "default, rounded blue,";

//var PNGNOT					= "background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=REPLACETHIS, sizingMethod=noscale)";

var TURNON 					= true;
var Direction				= -1;
var SlidesclockID			= null;
var s						= null;
var ID 						= null;
var Sl						= "Slides1";
var S2						= "Slides2";
var Slides1					= null;
var Slides2					= null;

function errorsuppressor(){
	return true;
}

function callEGZToGenerateGUID(){
	if(GLOBALSession==""){
		GLOBALSession 	= Math.floor(Math.random()*(1234354353454645));
		//check for referrer
		getReferrer();
	}
}

function getInternetExplorerVersion(){
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
  var rv = -1; // Return value assumes failure
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function getxmlvalue(datastring, tagstring){
    var idx1 = null;
    var idx2 = null;
	var data = "";
    idx1=datastring.indexOf("<"+tagstring+">");
    if (idx1 > -1) {
        idx2=datastring.indexOf("</"+tagstring+">", idx1);
        if  (idx2 > -1){
            data = datastring.substring(idx1+tagstring.length+2, idx2);
        }
    }
    return data;
}

function MultiMover() {  //reloads the window if Nav4 resized
	if(document.getElementById("Slides1")==null){
		clearInterval(MulticlockID);
	}
	else
	{
		if(s==true){
			for(x in Slides1){
				if(document.getElementById(Slides1[x])!=null){
					Pos=document.getElementById(Slides1[x]).style.backgroundPosition;
					T=Pos.split(" ");
					xPos=parseInt(T[0]);
					yPos=parseInt(T[1]);
					xPos=(xPos-0);
					yPos=(yPos-1);
					document.getElementById(Slides1[x]).style.backgroundPosition=xPos+"px "+yPos+"px";
				}
			}
			
			for(y in Slides2){
				if(document.getElementById(Slides2[x])!=null){
					Pos=document.getElementById(Slides2[y]).style.backgroundPosition;
					T=Pos.split(" ");
					xPos=parseInt(T[0]);
					yPos=parseInt(T[1]);
					xPos=(xPos-0);
					yPos=(yPos+1);
					document.getElementById(Slides2[y]).style.backgroundPosition=xPos+"px "+yPos+"px";
				}
			}
		}
	}
}

var MulticlockID=null;
function Multistart() {
	clearInterval(MulticlockID);
	Slides1=Sl.split(",");
	Slides2=S2.split(",");
	MulticlockID=setInterval("MultiMover()",20);
}

function MultiKill() {
    clearInterval(MulticlockID);
}

var map = null;     
function GetMap(){
	//stop slideshow and hide controller button
	clearInterval(SlidesclockID);
	
	if(document.getElementById("Starter")!=null)document.getElementById("Starter").style.visibility="hidden";
	document.getElementById("Layer2").innerHTML="<div id=\"ContactDetails\" style=\"position:absolute; left:0%; top:0%; width:100%; height:20%; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 75%; cursor: default; overflow-Y:auto;overflow-X:hidden; z-index:10; background-color:#ffffff;\" ><div style=\"position:absolute; left:2%; top:5px; width:46%;\">" 
	+ GLOBALText + "<BR><hr size=\"1\" width=\"100%\" ><BR><BR></div><div style=\"position:absolute; left:52%; top:5px; width:46%; padding:2px;\"><strong>Contact Details</strong><hr size=\"1\" width=\"100%\" ><a href=\"mailto:" 
	+ GLOBALEMail + "\">&bull;&raquo; " 
	+ GLOBALEMail + "</a><BR><BR>&nbsp;&nbsp;&nbsp;T : " 
	+ GLOBALTelNos + "<BR><hr size=\"1\" width=\"100%\" ></div></div><div id=\"theMap\" style=\"position:absolute; top:20%; width:100%; height:80%; left:0px;\"></div>";

	var LatLong = GLOBALLatLong.split(",");
	LAT = parseFloat(LatLong[0]);
	LNG = parseFloat(LatLong[1]);

	map = new VEMap('theMap');
	map.LoadMap();
	map.SetZoomLevel(8);
	PanMap(null,null,new VELatLong(LAT,LNG));
	AddPin();
	layer = new VEShapeLayer();
	map.AddShapeLayer(layer);
	//GetCircle();
} 
 
function PanMap(x,y,latlong)         {
	if (x!=null & y!=null){map.Pan(x,y);}  
				     else if (latlong!=null)  
					 {map.PanToLatLong(latlong);}
 }  
 
var pinID = 1;
function AddPin(){   
	var pin = new VEPushpin(
		pinID, 
		map.GetCenter(), 
		null, 
		'Company Dynamics&trade;', 
		'Business Works'//+pinID
	);
	map.AddPushpin(pin);
	pinID++;
} 

function GetCircle(){
   var LatLong = GLOBALLatLong.split(",");
   LAT = parseFloat(LatLong[0]);
   LNG = parseFloat(LatLong[1]);
    // earth's mean radius in km
    var R = 6371;
	//rad
    var lat = (LAT * Math.PI) / 180; 
    var lon = (LNG * Math.PI) / 180; 
	// d = angular distance covered on earth's surface
    var d = 10 / R;  
    myCirclePoints = new Array();
    for (x = 0; x <= 360; x++)
    {
        var p2 			= new VELatLong(0,0)
        brng 			= x * Math.PI / 180; //rad
        p2.Latitude 	= Math.asin(Math.sin(lat)*Math.cos(d) + Math.cos(lat)*Math.sin(d)*Math.cos(brng));
        p2.Longitude 	= ((lon + Math.atan2(Math.sin(brng)*Math.sin(d)*Math.cos(lat), Math.cos(d)-Math.sin(lat)*Math.sin(p2.Latitude))) * 180) / Math.PI;
        p2.Latitude 	= (p2.Latitude * 180) / Math.PI;
        myCirclePoints.push(p2);
    }
    //return myCirclePoints;
    var shape = new VEShape(VEShapeType.Polygon, myCirclePoints);
    shape.HideIcon();
    layer.AddShape(shape);
    var shape2 = new VEShape(VEShapeType.Polyline, myCirclePoints);
    shape2.HideIcon();
    layer.AddShape(shape2);
}

function Switch(a){
	if (a.value=="Hide Service Area"){
		a.value="Show Service Area";
		layer.Hide();
		}
		else
		{
		a.value="Hide Service Area";
		layer.Show();
		}
}

function ClickChange(a,b){
	a.style.backgroundColor="";
	if(ID!=null)document.getElementById(ID).className="Links";
	if(a.className!="clickclass" || a.className!="Links"){
		a.className=b;
		ID=a.id;
		}

}

function Change(a,b){
	if(a.className!="clickclass"){
	 	a.className=b;
		a.style.backgroundColor="";
	 }
}

function onRes() {
	ResizeContentLayer();
	if(document.getElementById("Content")!=null){
		var H=document.getElementById("Content").offsetHeight;
		if((H-220)>10)document.getElementById("TheWords").style.height=(H-220)+"px";
	}
}

function ResizeContentLayer(){
	var ver = getInternetExplorerVersion();
	//if it is IE but less than version 7
	if(ver<7 && ver > -1){
		//now resize the Content layer correctly ONLY if it is the Homepage
		if(document.getElementById("PlaceHolder")!=null){	
		//always reset it before adjusting the width otherwise it is done cumulatively
		document.getElementById("Content").style.width = GLOBALLayer2;
		var PlaceHolderWidth = document.getElementById("PlaceHolder").width;
		PlaceHolderWidth = PlaceHolderWidth - 210;
		document.getElementById("Content").style.width = PlaceHolderWidth + "px";
		}
		//reset the layer to its original width every time VERY IMPORTANT
		document.getElementById("CENTREMARKER").style.width = "50%";
		//make sure IE6 and less don't let the window go off screen to the left
		var CentrePlaceHolderWidth = document.getElementById("CentrePlaceHolder").width;
		var newGLOBALHOLDERwidth = document.getElementById("HOLDERPlaceHolder").width/2;
		var Amount = "50%"
		if(CentrePlaceHolderWidth<newGLOBALHOLDERwidth)Amount = newGLOBALHOLDERwidth+"px";
		document.getElementById("CENTREMARKER").style.width = Amount;			
	}
}



function SearchData(){
 var ID = null;
 SearchPhrase=document.getElementById("search").value;
 var SearchableContactDetails = GLOBALTelNos+" "+ GLOBALEMail + " " + GLOBALText;
 if(SearchPhrase.length<3){
 	document.getElementById("search").value="Three letters or more please..."
	}
	else

	{
	 //reset contact us color and class
	 if(document.getElementById("Map")!=null){
		 document.getElementById("Map").className="Links";
		 document.getElementById("Map").style.backgroundColor="";
	 }
	 
	 FinalData=GLOBALThePageData.split("@@");
	 for(x=0;x<FinalData.length-1;x++){
		if(document.getElementById(x)!=null)
		//reset all buttons color and class
		document.getElementById(x).className="Links";
		document.getElementById(x).style.backgroundColor="";
		FinalDataTest=FinalData[x].replace(/(<([^>]+)>)/ig,""); // Strip out HTML tags put in by user
		y=eval("FinalDataTest.search(/"+SearchPhrase+"/i)");
		if(y>-1){
				document.getElementById(x).style.backgroundColor="#ff9900";
				}
		  }
		 //search contact data
		 y1=eval("SearchableContactDetails.search(/"+SearchPhrase+"/i)");
		 if(y1>-1){
				document.getElementById("Map").style.backgroundColor="#ff9900";
				}
		}
		document.getElementById("search").focus();
}

var onSelectToggle = 0;
function on_Select(){
	if(onSelectToggle == 0){
		return false;
		//return true;
	}
	else
	{
		return true;
	}
}

function stopStart(){
	if(s==true){
		s=false;
		if(TURNON == true)if(document.getElementById("Slides")!=null)KillSlides();
		if(document.getElementById("Slides1")!=null)MultiKill();
			Slideshow('Start Slideshow');
		}
		else
		{
		s=true;
		if(TURNON == true)if(document.getElementById("Slides")!=null)startSlides();
		if(document.getElementById("Slides1")!=null)Multistart();
			Slideshow('Stop Slideshow');
		}
}

function startSlides() {
	clearInterval(SlidesclockID);
	SlidesclockID=setInterval("mover()",20);
}

function KillSlides() {
    clearInterval(SlidesclockID);
}

function mover() {  //
if(s==true){
	Pos 	= document.getElementById("Slides").style.backgroundPosition;
	T 		= Pos.split(" ");
	xPos	= parseInt(T[0]);
	yPos	= parseInt(T[1]);
	xPos	= (xPos+Direction);
	yPos	= (yPos+0);
	document.getElementById("Slides").style.backgroundPosition=xPos+"px "+yPos+"px"; 
	}
}

var GLOBALAllValidImages 		= null;
var GLOBALVaryingValidImages 	= "";
var GLOBALCycleImagesLessThanFive = 0;
function RandomiseImage() {
 	if(GLOBALAllValidImages.length>=5){
		//This does not show each image once until they are all shown before refreshing the list
		var whichImage 	= Math.floor(Math.random()*(GLOBALAllValidImages.length));
	}
	else
	{
		//this cycles through the images if there are five or less	
		if(GLOBALCycleImagesLessThanFive>GLOBALAllValidImages.length-1)GLOBALCycleImagesLessThanFive = 0;
		var whichImage = GLOBALCycleImagesLessThanFive++;
	}
	var imageNumber = GLOBALAllValidImages[whichImage];
	document.getElementById("Layer3").innerHTML="<img src=\""+GLOBALImagePath+imageNumber+"\" onerror=\"RandomiseImage()\" onabort=\"RandomiseImage()\">";
	BlendImage('Blend', GLOBALImagePath+imageNumber, 15);
}

var RandomClockID = null;
function RandomImageTimer(Seconds){
	RandomImageKill();
	var Con 		= 1000*Seconds;
	RandomClockID 	= setInterval("RandomiseImage()",Con);
}

function RandomImageKill() {
    clearInterval(RandomClockID);
}

function LoadData(a,TheImages){
	var ver 				= getInternetExplorerVersion();
	var IEFilter 			= "";
	if(ver>-1)IEFilter 		= "filter:alpha(opacity=0);"
	//take out any spaces in the string first
	TheImages 				= TheImages.replace(/\s/g,"");
	var RandomImage 		= TheImages.split(",");
	//make sure there are no empty spaces
	var ValidImage 			= new Array();
	for(d=0;d<RandomImage.length;d++){
		if(RandomImage[d]!="")ValidImage.push(RandomImage[d]);
	}
	var whichImage 			= Math.floor(Math.random()*(ValidImage.length));
	imageNumber 			= ValidImage[whichImage];
	GLOBALAllValidImages 	= ValidImage;
	//initialise in random location
	var randomnumber		= Math.floor(Math.random()*10000);
	//show stop start buttons if not already visible
	if(document.getElementById("Starter")!=null)document.getElementById("Starter").style.visibility="visible";
	//force the load of the image for the chosen page
	document.getElementById("Layer3").innerHTML="<img src=\""+GLOBALImagePath+imageNumber+"\">";

	//clear form array of elements to check
	GLOBALCheckThese.length = 0;
	var ver = getInternetExplorerVersion();
	//if it IE7 or FF
	if(ver==-1 || ver > 6)pp=" background-image: url(" + GLOBALImagePath+GLOBALCDLogo +");";
	//if it is IE but less than version 7
	if(ver<7 && ver > -1)pp=" background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + GLOBALImagePath+GLOBALCDLogo +", sizingMethod=noscale);";
	MultiKill();
	KillSlides();
	//var Titles="";
	Menu=GLOBALThePageData.split("@@");
    Boo=Menu[a].split("++");
	var PoundSignCorrectedText = Boo[1].replace(/£/g,"&pound;"); 
	if(a!=0){
		document.getElementById("Layer2").innerHTML = "<div id=\"Content\" style=\"position:absolute; padding-left:0%; padding-right:0%; padding-bottom:1%; padding-top:0%; left:"
		+ GLOBALContentLeft 
		+ "; top:"
		+ GLOBALTextTopMargin
		+ "; width:" 
		+ GLOBALContentWidth 
		+ "; height:"
		+ GLOBALTextBoxHeight
		+ "%; overflow:hidden; z-index:10; border: "
		+ GLOBALTextBorderVisible 
		+ " solid " 
		+ GLOBALTextBorderColor 
		+ "; \" class=\"text\" >"
		+ "<div id=\"CompanyLogo\" style=\"position:absolute ; left:0px; top:0px; width:100%; height:200px; z-index:10; "
		+ pp 
		+ " background-position: 0px 0px; background-repeat : no-repeat;\"></div>"					
		+ "<div id=\"Slides\" style=\"position:absolute; left:0px; top:0px; width:100%; height:200px; z-index:1; background-image: url("
		+ GLOBALImagePath+imageNumber 
		+ "); background-position: 0px 0px; border: 1px none #000000;\"><img src=\"" + GLOBALImagePath+imageNumber +"\" id=\"Blend\" style=\"-moz-opacity:0;opacity:0;" + IEFilter + "\"></div><div id=\"TheWords\" style=\"position:relative; left:1%; width:97%; top:210px; height:60%; overflow-y:auto; overflow-x:hidden; padding-right:1%; \">"
		+ PoundSignCorrectedText 
		//Build Form if it is present in page
		+ FormBuilder(Boo[6])
		+ "</div></div>";
		//if moving image
		if(Boo[5]=="Y"){
			//random position
			Pos=document.getElementById("Slides").style.backgroundPosition;
			T	 	= Pos.split(" ");
			xPos 	= parseInt(T[0]);
			yPos 	= parseInt(T[1]);
			xPos	= (xPos+Direction);
			yPos	= (yPos+0);
			document.getElementById("Slides").style.backgroundPosition=xPos+"px "+yPos+"px";
			startSlides();
			if(document.getElementById("Starter")!=null)document.getElementById("Starter").style.visibility = "visible";
			//if they have an image on the homepage we need to know whether or not to animate it if they press the StopStart button
			//because they can turn the animation on and off on a per page basis
			TURNON = true;
			}
			else
			{
			document.getElementById("Slides").style.backgroundPosition = "0px 0px";
			document.getElementById("Slides").style.backgroundRepeat = "no-repeat";
			if(document.getElementById("Starter")!=null)document.getElementById("Starter").style.visibility = "hidden";
			TURNON = false;
		}
		//if random image timer
		if(parseInt(Boo[7])>0){
			RandomImageTimer(parseInt(Boo[7]));
			}
			else
			{
			RandomImageKill();
			}
	}
	else
	{
	//check to see whether to animate the top image
	if(Boo[5]=="Y"){
			TURNON = true;
		}
		else
		{
			TURNON = false;
		}
	var Clear = "<div id=\"Slides1\" style=\"position:absolute; right:0px; top:0px; width:200px; height:100%; z-index:1; background-image: url("
	+ GLOBALImagePath+Boo[4]
	+ "); background-position: 0px 0px;\"></div>"
	+ "<div id=\"Content\" style=\"position:absolute; left:10px; right: 210px; top:"
	+ GLOBALTextTopMargin
	+ "; height:"
	+ GLOBALTextBoxHeight
	+ "%; overflow:hidden; z-index:2; padding-left:0%; padding-right:0%; padding-bottom:1%; padding-top:0%; background-color:" 
	+ GLOBALColor 
	+ "; border: "
	+ GLOBALTextBorderVisible 
	+ " solid " 
	+ GLOBALTextBorderColor 
	+ ";\" class=\"text\">"	
	+ "<div id=\"CompanyLogo\" style=\"position:absolute ; left:0px; top:0px; width:100%; height:200px; z-index:10; "
	+ pp 
	+ " background-position: 0px 0px; background-repeat : no-repeat;\"></div>"				
	+ "<div id=\"Slides\" style=\"position:absolute; left:0px; top:0px; width:100%; height:200px; z-index:1; background-image: url("
	+ GLOBALImagePath+imageNumber 
	+ "); background-position: 0px 0px; background-repeat:no-repeat; border: 1px none #000000;\"><img src=\"" + GLOBALImagePath+imageNumber +"\" id=\"Blend\" style=\"-moz-opacity:0;opacity:0;" + IEFilter + "\"></div>"	
	+ "<div id=\"TheWords\" style=\"position:relative; left:0px; top:210px; height:90%; overflow:auto; z-index:2; padding-right:2%; padding-left:0px; padding-top:0px; width:98%; padding-bottom:0px; overflow-x:hidden; overflow-y:auto; background-color:transparent;\" >"
	 + PoundSignCorrectedText 
	 + "</div>"
	//used to adjust size correctly in IE6 which doesn't support right and left positioning
	//set to 98% to accommodate padding in TheWords layer
	+ "<img src=\"\" width=\"98%\" height=\"0\" id=\"PlaceHolder\" style=\"visibility:hidden;\">"
	+ "</div>";
	document.getElementById("Layer2").innerHTML=Clear;
	//if random image timer
	if(parseInt(Boo[7])>0){
		RandomImageTimer(parseInt(Boo[7]));
		}
		else
		{
		RandomImageKill();
		}
		if(ver<7 && ver>-1){
			s=false;
			Slideshow('Start Slideshow');
		}
		else
		{
		Slideshow('Stop Slideshow');
		s=true;
		MultiKill();
			//random position
			for(x in Slides1){
				if(document.getElementById(Slides1[x])!=null){
					Pos=document.getElementById(Slides1[x]).style.backgroundPosition;
					T=Pos.split(" ");
					xPos=parseInt(T[0]);
					yPos=parseInt(T[1]);
					xPos=(xPos-0);
					yPos=(yPos-(1*randomnumber));
					document.getElementById(Slides1[x]).style.backgroundPosition=xPos+"px "+yPos+"px";
				}
			}
			for(y in Slides2){
				if(document.getElementById(Slides2[x])!=null){
					Pos=document.getElementById(Slides2[y]).style.backgroundPosition;
					T=Pos.split(" ");
					xPos=parseInt(T[0]);
					yPos=parseInt(T[1]);
					xPos=(xPos-0);
					yPos=(yPos+(1*randomnumber));
					document.getElementById(Slides2[y]).style.backgroundPosition=xPos+"px "+yPos+"px";
				}
			}
		if(document.getElementById("Starter")!=null)document.getElementById("Starter").style.visibility = "visible";
		Multistart();
		}
	}

	onRes();
	//swap direction of movement on horizontal slide
	if(Direction==1){
		Direction=-1;
		}
		else
		{
		Direction=1;
	}
	//document.getElementById("PageText").style.visibility = "hidden";
	//user stats
	callEGZToGenerateGUID();
	getData(GLOBALURLforEGIZMO+"&Data="+Boo[0].replace(/&/g,"and")+"&SessionID="+GLOBALSession);//.replace(/^[A-Z0-9]*=/g,"")); 
	//document.getElement("TheWords").scrollTop = 100000;
	//document.getElement("TheWords").scrollTop = 0;	

}

function randomNumber(){
	var minutes = 1000*60;
	var hours 	= minutes*60;
	var days 	= hours*24;
	var years 	= days*365;
	var d 		= new Date();
	var t 		= d.getTime();
	var y 		= t/years;
	return y;
}

function getData(Query) {
	if( document.createElement && document.childNodes ) {
		//Quantity = 
		markerlocation = Query+"&R="+randomNumber();
		var scriptElem = document.createElement('script');
		scriptElem.setAttribute('src',markerlocation);
		scriptElem.setAttribute('type','text/javascript');
		document.getElementsByTagName('head')[0].appendChild(scriptElem);
	} else {
		alert('Sorry, your browser is not W3C DOM compliant.');
	}
}

function FormBuilder(FormInformation) {  
	var All = FormInformation.split("<EGZ-Item>");
	var AllTags 	= new Array();
	var TagToSearch = "";
	var str 		= "";
	var HTML 		= new Array();
	//get required font colour only once for all occurences
	var RequiredFontColor 		= getxmlvalue(FormInformation,'EGZ-FontColor');
	if(RequiredFontColor == "")RequiredFontColor = "#ff0000";
		
	for(x in All){
		//get all of the tags in the data string so we know what we are looking for
		var Regex = /<EGZ-[A-Z,a-z\s0-9]*\>/gi;
		while((Results = Regex.exec(All[x])) != null)AllTags.push(Results);
		
		var Caption 				= "";
		var Input 					= "";
		var ID 						= "";
		var Type 					= "";
		var Width 					= "0";
		var Height 					= "auto";
		var HeightAndWidth			= "";
		var MaxLength 				= "";
		var RequiredText			= "<span style=\"visibility:hidden;\"> * </span>";
		var Required 				= "<span style=\"visibility:hidden;\"> * </span>";
		var Txtarea 				= "";
		var Options 				= "";
		var Selector 				= "";
		var ClosingTag 				= "";
		var EndofOpeningTag 		= " >";
		var XMLvalue 				= "";
		var PosLeft 				= "";
		var PosTop 					= "";
		var PosCaptionLeft 			= "";
		var PosCaptionTop 			= "";
		var ElementClosingSpanTag	= ""
		var CaptionClosingSpanTag	= "";
		var CaptionStyle 			= "";
		var ElementStyle 			= "";
		var FontColour				= "";
		var FontStyle				= "";

		var RQ = "Off";

		for(y=0;y<AllTags.length;y++){
			str = AllTags[y].toString();
			TagToSearch = str.replace(/[<>]*/gi,"");
			XMLvalue = getxmlvalue(All[x].toString(),TagToSearch);

			switch (str){
				case '<EGZ-Email>'				:	GLOBALEmailRecipient		= XMLvalue								; 														break;
				case '<EGZ-Input>'				:	Input 						= "<input onBlur=\"Validate(this,'Off');onSelectToggle=0;\" onselectstart=\"onSelectToggle=1\""; 													break;
				case '<EGZ-Id>'					:	ID 							= " id=\""+ XMLvalue+"\""				; 														break;
				//this is a placeholder to indicate it is NOT a form element 
				case '<EGZ-RequiredText>'		:	RequiredText 				= "<span style=\"visibility:visible; FONTCOLOR\"> * </span>"; EndofOpeningTag ="";				break;
				case '<EGZ-Left>'				:	PosLeft 					= XMLvalue								; 														break;
				case '<EGZ-Top>'				:	PosTop 						= XMLvalue								; 														break;
				case '<EGZ-CaptionLeft>'		:	PosCaptionLeft				= XMLvalue								; 														break;
				case '<EGZ-CaptionTop>'			:	PosCaptionTop  				= XMLvalue								; 														break;					
				case '<EGZ-Required>'			:	if(XMLvalue=="Y"){Required 	= "<span style=\"visibility:visible; FONTCOLOR\"> * </span>";	RQ = "On"};						break;
				case '<EGZ-CaptionFontColor>'	:	FontColour 					= XMLvalue								; 														break;
				case '<EGZ-CaptionFontStyle>'	:	FontStyle 					= XMLvalue								; 														break;
				case '<EGZ-Caption>'			:	Caption 					= XMLvalue 		+ "&nbsp;"				; 														break;
				case '<EGZ-Width>'				:	Width 						= XMLvalue 		+ "px" 					; 														break;
				case '<EGZ-Height>'				:	Height 						= XMLvalue 		+ "px" 					; 														break;
				case '<EGZ-ImageTimer>'			: 	GLOABALImageTimer			= parseInt(XMLvalue)					; 														break;
				case '<EGZ-MaxLength>'			:	MaxLength 					= " maxlength=" + XMLvalue + "\""		; 														break;
				case '<EGZ-OptionList>'			: 	Options 					= XMLvalue.replace(/EGZ-/g,"")			;														break;
				
				//button values
				case '<EGZ-Value>'				: 	Input						= Input + " value=\"" + XMLvalue + "\""	; 														break;
				case '<EGZ-Memo>'				:	{
													Txtarea = "<textarea onBlur=\"Validate(this,'Off');onSelectToggle=0;\" onselectstart=\"onSelectToggle=1\"";
													EndofOpeningTag = " >";
													ClosingTag = "</textarea>";
													break;
													} 					
				case '<EGZ-Type>'				:	{if(XMLvalue=="Submit"){
													//if it is a submit button we need to put the function on it to check the values they are trying to submit
													Type = " type=\"button\" onclick=\"Revalidate()\" ";
													}
													else
													{
													Type = " type=\"" 	+ XMLvalue + "\"";
													}
													break;
													}
				case '<EGZ-Select>'				:	{
													Selector = "<select ";
													EndofOpeningTag = ">";
													ClosingTag = "</select>";		
													break;
													}			
							}
		}

		if(isNaN(parseInt(PosLeft))==false)	{
			var ElementStyle 		= "<span style=\"position:absolute; top:" + PosTop 			+ "px; left: " + PosLeft 		+ "px;\">";
			ElementClosingSpanTag 	= "</span>";
			} 
		if(isNaN(parseInt(PosCaptionLeft))==false){
			var CaptionStyle 		= "<span style=\"position:absolute; top:" + PosCaptionTop 	+ "px; left: " + PosCaptionLeft + "px; color: " + FontColour + "; font-weight: " + FontStyle +";\">";
			CaptionClosingSpanTag 	= "</span>";
			}
		//if there is a height or width value then put it in and allow text selection if it is a textarea or input box
		if(Width!="0" || Height!="auto")HeightAndWidth = " style=\"-moz-user-select: enabled; width:" + Width + "; height:" + Height + "\"";
		//change font colour of required asterisk if it is visible
		Required 		= eval("Required.replace(/FONTCOLOR/g, \"color:\" + RequiredFontColor + \";\")");
		RequiredText 	= eval("RequiredText.replace(/FONTCOLOR/g, \"color:\" + RequiredFontColor + \";\")");
		
		if(RQ == "On"){
			 Input 		=	eval("Input.replace(/Off/g, \"On\")");
			 Txtarea 	= 	eval("Txtarea.replace(/Off/g, \"On\")");
			 Theid = ID.replace(/\sid="/,"");
			 Theid = Theid.replace(/"/,"");
			 GLOBALCheckThese.push(Theid);
			 }

		var Len =  CaptionStyle + RequiredText + Caption + CaptionClosingSpanTag + ElementStyle + Required + Input + Txtarea + Selector + ID + Type + MaxLength + HeightAndWidth + EndofOpeningTag + Options + ClosingTag + ElementClosingSpanTag;
		//only put it onto the array if there is sufficient information to be worthwhile. That is it is not  ><BR> which occurs occasionally
		if(Len.length > 100)HTML.push(CaptionStyle + RequiredText + Caption + CaptionClosingSpanTag + ElementStyle + Required + Input + Txtarea + Selector + ID + Type + MaxLength + HeightAndWidth + EndofOpeningTag + Options + ClosingTag + ElementClosingSpanTag);
		AllTags.length = 0;
	}
	var FinishedForm = "<form style=\"position:relative\">" + HTML.join("") + "</form>";
	//take out empty form tag because it causes a redraw problem
	if(FinishedForm == "<form style=\"position:relative\"></form>")FinishedForm = "";
	return FinishedForm.replace(/^&nbsp;/,"");
}

function Validate(obj,OnOff){
	if(obj.value =="" && OnOff == "On"){
		//alert("Sorry, this is a required value.\nPlease enter something valid here.\nThank you.");
		obj.style.backgroundColor = "#ff0000";
		}
		else
		{
		obj.style.backgroundColor = "";
		}
}

function Revalidate(){
	var Wrong = new Array();
 	for(x in GLOBALCheckThese){
			nam = GLOBALCheckThese[x];
			if(document.getElementById(nam).value == ""){
					document.getElementById(nam).style.backgroundColor = "#ff0000";
					Wrong.push(x);
				}
				else
				{
					document.getElementById(nam).style.backgroundColor = "";
				}
			}
	 var TheseNeedCorrecting = "The following values, marked in red, need to be corrected please :-\n\n";
	 if(Wrong.length>0){
	 		for(y in Wrong){
				Tot = (parseInt(y)+1);
				TheseNeedCorrecting = TheseNeedCorrecting + Tot + ") " +GLOBALCheckThese[y] + "\n";
			}
				alert(TheseNeedCorrecting + "\n Thank you.");
			}
	//if the form is OK send it to the egz		
	if(Wrong.length==0){
		var OrigValues = new Array();
		var EmailValues = new Array();
		var TempValues = new Array();
		var Orig 		= document.getElementById("TheWords").getElementsByTagName("INPUT");
		
		OrigValues.push("<FormData>");
		EmailValues.push("SendMail.asp?RecipientEmail="+GLOBALEmailRecipient+"&");
		for(k=0;k<Orig.length;k++){
			
				OrigValues.push("<"+ Orig[k].id +">"  + Orig[k].value + "</" + Orig[k].id +">");
				if(Orig[k].id=="Email"){
						EmailValues.push(Orig[k].id + "=" + Orig[k].value +"&");
					}
					else
					{
						TempValues.push(Orig[k].id + "=" + Orig[k].value +" ++ ");
					}
				}
		//get text area values		
		Orig 		= document.getElementById("TheWords").getElementsByTagName("TEXTAREA");		
		for(kk=0;kk<Orig.length;kk++){
					//add in commas for line feeds on addresses principally.
					OrigValues.push("<"+ Orig[kk].id +">"  + Orig[kk].value.replace(/\n/g,", ") + "</" + Orig[kk].id +">");
					TempValues.push(Orig[kk].id + "=" + Orig[kk].value.replace(/\n/g,", ") +" ++ ");
				}	
				
		Orig 		= document.getElementById("TheWords").getElementsByTagName("SELECT");		
		for(kkk=0;kkk<Orig.length;kkk++){
					//add in commas for line feeds on addresses principally.
					OrigValues.push("<"+ Orig[kkk].id +">"  + Orig[kkk].options[Orig[kkk].selectedIndex].text + "</" + Orig[kkk].id +">");
					TempValues.push(Orig[kkk].id + "=" + Orig[kkk].options[Orig[kkk].selectedIndex].text + " ++ ");
				}					
				
				//Add closing tag
				OrigValues.push("</FormData>");
				//Send off to egz
				getData(GLOBALURLforEGIZMO.replace(/page/gi,"FormData")+"&Data="+OrigValues.join("")+"&SessionID="+GLOBALSession); 
				//send off email 
				//The recipient email must be first, and the enquirer's email has to be the next value. Anything after that is not important
				getData(EmailValues.join("")+TempValues.join("")+"&SessionID="+GLOBALSession);
				
		}
}


function FormDataConfirmed(){
	var theForm = document.getElementById("TheWords").innerHTML;
	document.getElementById("TheWords").innerHTML = "<div style=\"line-height:40px; color:#FF0000; text-align:center;\">Your enquiry has been sent successfully, thank you.</div>" + theForm;
}

function BuildPageAndMenu() {  
	var ver = getInternetExplorerVersion();
	var ImageToGet = "";
	var Titles=new Array();
	
	//Search Button
	if(GLOBALSearchVisible!="N")Titles.push("<div class=\"TextBox\" align=\"center\"><input type=\"text\" id=\"search\" style=\"cursor: default; width:95%; height:15px; margin-top:-4px;\" onselectStart=\"onSelectToggle=1;\" onblur=\"onSelectToggle=0;\" onkeyup=\"Sub(event)\"></div><div class=\"SearchBox\" align=\"center\" ><input type=\"submit\" name=\"Submit\" value=\"Search\" class=\"Search\" onclick=\"SearchData()\"></div>");

	var ItsNew="";
	Menu=GLOBALThePageData.split("@@");
	if(ver<7 && ver>-1){
		for(x=0;x<Menu.length-1;x++){
		 Boo=Menu[x].split("++");
		 if(ImageToGet=="")ImageToGet = Boo[3];
		   if(Boo[0]=="")ItsNew="<sup style=\"color:red; position:relative; top:-4px;\"> New!</sup>";
		   var Marg = 0;
		   if(Boo[8]!="")Marg = Boo[8];
			Titles.push("<div id=\""+x+"\" style=\"margin-top:" + Marg + "px;\" onclick=\"LoadData('"+x+"','"+Boo[3]+"');  ClickChange(this,'clickclass');\" class=\"Links\" onMouseOver=\"Change(this,'Links1')\" onMouseOut=\"Change(this,'Links')\" >"+Boo[0]+ItsNew+"</div>");
			ItsNew="";
		}
		s=false;
		Slideshow('Start Slideshow');
	}
	else
	{
		for(x=0;x<Menu.length-1;x++){
		ItsNew="";
		Boo=Menu[x].split("++");
		 	if(ImageToGet=="")ImageToGet = Boo[3];
		    if(Boo[0]=="")ItsNew="<sup style=\"color:red; position:relative; top:-4px;\"> New!</sup>";
		  	var Marg = 0;
		    if(Boo[8]!="")Marg = Boo[8];			
			Titles.push("<div id=\""+x+"\" style=\"margin-top:" + Marg + "px;\" onclick=\"LoadData('"+x+"','"+Boo[3]+"'); ClickChange(this,'clickclass');\" class=\"Links\" onMouseOver=\"Change(this,'Links1')\" onMouseOut=\"Change(this,'Links')\" >"+Boo[0]+ItsNew+"</div>");
			ItsNew="";
		}
		
		Multistart();
		s=true;
		Slideshow('Stop Slideshow');

	}
	//if they want to show the map
	if(GLOBALMap=="N"){	
		//always put map control and contact section in last
		Titles.push("<div id=\"Map\" onclick=\"GetMap();ClickChange(this,'clickclass');\" class=\"Links\" onMouseOver=\"Change(this,'Links1')\" onMouseOut=\"Change(this,'Links')\">Contact Us</div>");
	}
	
	document.getElementById("Layer1").innerHTML="<div id=\"Menu\" style=\"position:absolute; left:10%; top:4%; width:80%; height:auto; z-index:21; border: 1px none #000000;\">"+Titles.join("")+"</div>";
	LoadData('0',ImageToGet);
}

function Slideshow(Words){
	if(document.getElementById("Starter")!=null)document.getElementById("Starter").innerHTML=Words;
}

function getEGZURL(){
	var WebData 		= document.getElementById("Details").value;
	GLOBALURLforEGIZMO	= getxmlvalue(WebData, 	"EGZ-eGizmo");
	var theString 		= location.search;
	theString 			= theString.replace(/\?venue=[0-9]*&url=|\?venue=[0-9]*/gi,"");
	theString 			= theString.replace(/&gclid=[.]*/gi,"");
	theString			= theString.replace(/&CompanyDynamics=[A-Za-z0-9%\&\s':";,\-_\.\(\)<>@#~\+\*%\?=\[\]{}]*/g,"");
	//this is only used for administrators viewing their own sites NOT for web browsers in general
	if(theString!=""){
			GLOBALURLforEGIZMO = GLOBALURLforEGIZMO.replace(/\/\/[0-9\.:]*\//gi,"//"+theString+"/");
		}
}

function initialise(){
	//get the Egizmo URL for site information
	getEGZURL();
	//default values
	var HOLDERwidthUNITS 	= "px";
	var TextWidthUNITS 		= "px";
	var MenuWidthUNITS 		= "px";
	var p = null;

	var WebData = document.getElementById("Details").value;

		var Website 			= getxmlvalue(WebData, 	"EGZ-Website");
		var WebTitle			= getxmlvalue(Website, 	"EGZ-Title");
		var WebHeader			= getxmlvalue(Website, 	"EGZ-Header");	
		var WebFooter			= getxmlvalue(Website, 	"EGZ-Footer");
		var HOLDERwidth 		= getxmlvalue(Website, 	"EGZ-Width");	
			GLOBALImagePath		= getxmlvalue(Website, 	"EGZ-ImagePath");
			//if it is a custom design we need to ignore this which sets up the page dimensions and settings for style sheets
			GLOBALCustomDesign 	= getxmlvalue(WebData, 	"EGZ-CustomDesign");
		var DesignTrue = GLOBALDesigns.search(GLOBALCustomDesign+",");
		
		document.title = "••• " + WebTitle + " •••"
		document.getElementById("Address").innerHTML = WebHeader;
		document.getElementById("Footer").innerHTML = WebFooter;
		//LISTED DESIGNS THAT CAN HAVE THEIR SETTINGS CONTROLLED BY EGZ
		if(DesignTrue > -1){			
			//set holding layer called HOLDER
			p = HOLDERwidth.search("%");
			if(p > -1) {
				HOLDERwidthUNITS = "%";
				HOLDERwidth = parseInt(HOLDERwidth)*2;
				HOLDERwidth = HOLDERwidth + HOLDERwidthUNITS;
				}
				else
				{
				//we only need to set a minimum width if we are using pixel sizes, otherwise the percentages are OK
				document.getElementById("CENTREMARKER").style.minWidth = parseInt(HOLDERwidth)/2+"px";
				} 
			var HOLDERsize = ((parseInt(HOLDERwidth)/2)-parseInt(HOLDERwidth));
			document.getElementById("HOLDER").style.right = HOLDERsize + HOLDERwidthUNITS;
			document.getElementById("HOLDER").style.width = HOLDERwidth;
		
		//background styles
		var Background 				= getxmlvalue(WebData, 		"EGZ-Background");
		var ImageD 					= getxmlvalue(Background, 	"EGZ-Image");	
		var BorderColor 			= getxmlvalue(Background, 	"EGZ-BorderColor");	
		var TextWidth		 		= getxmlvalue(Background, 	"EGZ-TextWidth");	
			GLOBALColor 			= getxmlvalue(Background, 	"EGZ-Color");
			GLOBALTextBorderColor 	= getxmlvalue(Background, 	"EGZ-TextBorderColor");
			GLOBALTextBorderVisible	= getxmlvalue(Background, 	"EGZ-TextBorderVisible");
			
			if(GLOBALTextBorderVisible == "N"){
				GLOBALTextBorderVisible = "0px";
				}
				else
				{
				GLOBALTextBorderVisible = "1px";
				}
			GLOBALTextTopMargin		= getxmlvalue(Background, 	"EGZ-TextTopMargin");
			var TextBottomMargin	= getxmlvalue(Background, 	"EGZ-TextBottomMargin");
			GLOBALTextBoxHeight		= (100-parseInt(GLOBALTextTopMargin))-parseInt(TextBottomMargin);
			//we must take off 1% to allow for padding on the box;
			GLOBALTextBoxHeight 	= GLOBALTextBoxHeight-1;
		
			p = TextWidth.search("%");
			if(p > -1) TextWidthUNITS = "%";
			GLOBALContentWidth = parseInt(TextWidth) + TextWidthUNITS;
			StyleChange('.text'			,'color'			,'#355F75');
			document.getElementById("HOLDER").style.backgroundColor = GLOBALColor;		
			document.getElementById("Layer2").style.backgroundImage = "url(" + GLOBALImagePath + ImageD + ")";
			document.getElementById("HOLDER").style.border = "1px none "+BorderColor;
		
		//search styles
		var Search 					= getxmlvalue(WebData, 		"EGZ-Search");
		var SearchBackColor 		= getxmlvalue(Search, 		"EGZ-BackgroundColor");	
		var FontColor 				= getxmlvalue(Search, 		"EGZ-FontColor");	
			GLOBALSearchVisible		= getxmlvalue(Search, 		"EGZ-Visible");
			StyleChange('.Search'		,'backgroundColor'	,SearchBackColor);
			StyleChange('.Search'		,'color'			,FontColor);
		
		//left menu styles
		var Menu 					= getxmlvalue(WebData, 		"EGZ-Menu");
		var Alignment 				= getxmlvalue(Menu, 		"EGZ-Alignment");
		var FontStyle 				= getxmlvalue(Menu, 		"EGZ-FontStyle");	
		var FontColor 				= getxmlvalue(Menu, 		"EGZ-FontColor");
		var BackgroundColor 		= getxmlvalue(Menu, 		"EGZ-BackgroundColor");	
		var BorderColor 	  		= getxmlvalue(Menu, 		"EGZ-BorderColor");	
		var SelectedFontColor 		= getxmlvalue(Menu,			"EGZ-SelectedFontColor");
		var SelectedFontStyle 		= getxmlvalue(Menu, 		"EGZ-SelectedFontStyle");		
		var RollOverFontColor 		= getxmlvalue(Menu, 		"EGZ-RollOverFontColor");	
		var MenuWidth				= getxmlvalue(Menu,		 	"EGZ-Width");		
			StyleChange('.Links'		,'textAlign'		,Alignment);
			StyleChange('.Links'		,'fontWeight'		,FontStyle);		
			StyleChange('.Links'		,'color'			,FontColor);		
			StyleChange('.Links'		,'backgroundColor'	,BackgroundColor);	
			StyleChange('.Links'		,'borderColor'		,BorderColor);		
			StyleChange('.Links1'		,'textAlign'		,Alignment);
			StyleChange('.Links1'		,'borderColor'		,BorderColor);	
			StyleChange('.Links1'		,'color'			,RollOverFontColor);			
			StyleChange('.clickclass'	,'textAlign'		,Alignment);
			StyleChange('.clickclass'	,'borderColor'		,BorderColor);
			StyleChange('.clickclass'	,'color'			,RollOverFontColor);
			StyleChange('.clickclass'	,'textDecoration'	,'none');
			StyleChange('.clickclass'	,'fontWeight'		,SelectedFontStyle);
			StyleChange('.SearchBox'	,'backgroundColor'	,BackgroundColor);
			StyleChange('.SearchBox'	,'borderColor'		,BorderColor);		
			StyleChange('.TextBox'		,'backgroundColor'	,BackgroundColor);
			StyleChange('.TextBox'		,'borderColor'		,BorderColor);
	
			p = MenuWidth.search("%");
			if(p > -1) MenuWidthUNITS = "%";
			var Menusize = parseInt(MenuWidth);
			document.getElementById("Layer1").style.width = MenuWidth;
			//if it percentage do this to set the content box width
			if(MenuWidthUNITS == "%"){
				var Layer2Width 	= 100-parseInt(Menusize);
				GLOBALContentLeft 	= ((100-parseInt(TextWidth))/2) + TextWidthUNITS;
				//change overflow to hidden if they use percentages
				StyleChange('.Links'		,'overflow'		,'hidden');
				StyleChange('.Links1'		,'overflow'		,'hidden');
				StyleChange('.clickclass'	,'overflow'		,'hidden');
			}
			else
			{
				var Layer2Width 	= parseInt(HOLDERwidth)-parseInt(Menusize);
				GLOBALLayer2 		= Layer2Width + MenuWidthUNITS;
				GLOBALContentLeft 	= parseInt(Layer2Width)-parseInt(GLOBALContentWidth);
				GLOBALContentLeft 	= GLOBALContentLeft/2;
				GLOBALContentLeft	= GLOBALContentLeft + MenuWidthUNITS;
			}
			document.getElementById("Layer2").style.left = MenuWidth;
			document.getElementById("Layer2").style.width = Layer2Width + MenuWidthUNITS;
		//Contact Information
		var Contact				= getxmlvalue(WebData, 		"EGZ-ContactData");
			GLOBALTelNos 		= getxmlvalue(Contact, 		"EGZ-TelNo");
			GLOBALEMail 		= getxmlvalue(Contact, 		"EGZ-EMail");
			GLOBALText 			= getxmlvalue(Contact, 		"EGZ-Address");
			GLOBALLatLong		= getxmlvalue(Contact, 		"EGZ-Coords");
			GLOBALMap			= getxmlvalue(Contact, 		"EGZ-Hide");	
		
		//Page information
		PageData 	  	= getxmlvalue(WebData, "EGZ-PageData");
		var s 			= PageData.split("<EGZ-Page>");
		
		var one,two,three,four,five,six,seven,eight,nine;
		for(x=0; x<s.length; x++){
			if(s[x].length>0){
				one   	= getxmlvalue	(s[x], "EGZ-Title");
				two   	= getxmlvalue	(s[x], "EGZ-Text"); 
				three 	= getxmlvalue	(s[x], "EGZ-Search"); 
				four  	= getxmlvalue	(s[x], "EGZ-TopImage"); 
				five  	= getxmlvalue	(s[x], "EGZ-SideImage"); 
				six   	= getxmlvalue	(s[x], "EGZ-Scrolling");
				seven  	= getxmlvalue	(s[x], "EGZ-WebForm"); 
				eight 	= getxmlvalue	(s[x], "EGZ-ImageTimer");
				nine 	= getxmlvalue	(s[x], "EGZ-Margin"); 
				GLOBALThePageData = GLOBALThePageData + one+"++"+two+"++"+three+"++"+four+"++"+five+"++"+six+"++"+seven+"++"+eight+"++"+nine+"@@";
			}
		}
	}
	else
	{
		//CUSTOM DESIGN ONLY
		var Background 			= getxmlvalue(WebData, 		"EGZ-Background");
		var TextBottomMargin	= getxmlvalue(Background, 	"EGZ-TextBottomMargin");
		var TextWidth		 	= getxmlvalue(Background, 	"EGZ-TextWidth");
		GLOBALTextTopMargin		= getxmlvalue(Background, 	"EGZ-TextTopMargin");	
		GLOBALTextBorderVisible	= getxmlvalue(Background, 	"EGZ-TextBorderVisible");
			if(GLOBALTextBorderVisible == "N"){
				GLOBALTextBorderVisible = "0px";
				}
				else
				{
				GLOBALTextBorderVisible = "1px";
				}		
		GLOBALTextBoxHeight		= (100-parseInt(GLOBALTextTopMargin))-parseInt(TextBottomMargin);
		//we must take off 1% to allow for padding on the box;
		GLOBALTextBoxHeight 	= GLOBALTextBoxHeight-1;		
		GLOBALTextBorderColor 	= getxmlvalue(Background, 	"EGZ-TextBorderColor");
		p = TextWidth.search("%");
		if(p > -1) TextWidthUNITS = "%";
		GLOBALContentWidth = parseInt(TextWidth) + TextWidthUNITS;		
		//left menu styles in this case just control the width of the content box
		var Menu 				= getxmlvalue(WebData, 		"EGZ-Menu");
		var MenuWidth			= getxmlvalue(Menu,		 	"EGZ-Width");		
		p = MenuWidth.search("%");
			if(p > -1) MenuWidthUNITS = "%";
			var Menusize = parseInt(MenuWidth);
			document.getElementById("Layer1").style.width = MenuWidth;
			//if it percentage do this to set the content box width
			if(MenuWidthUNITS == "%"){
				var Layer2Width 	= 100-parseInt(Menusize);
				GLOBALContentLeft 	= ((100-parseInt(TextWidth))/2) + TextWidthUNITS;
			}
			else
			{
				var Layer2Width 		= parseInt(HOLDERwidth)-parseInt(Menusize);
					GLOBALLayer2 		= Layer2Width + MenuWidthUNITS;
					GLOBALContentLeft 	= parseInt(Layer2Width)-parseInt(GLOBALContentWidth);
					GLOBALContentLeft 	= GLOBALContentLeft/2;
					GLOBALContentLeft	= GLOBALContentLeft + MenuWidthUNITS;
			}	
		//we only need to set a minimum width if we are using pixel sizes, otherwise the percentages are OK
		var HOLDERwidth = document.getElementById("HOLDER").style.width;
		document.getElementById("CENTREMARKER").style.minWidth = parseInt(HOLDERwidth)/2+"px";
		//search styles
		var Search 					= getxmlvalue(WebData, 		"EGZ-Search");
			GLOBALSearchVisible		= getxmlvalue(Search, 		"EGZ-Visible");
					
		//Contact Information
		var Contact				= getxmlvalue(WebData, 		"EGZ-ContactData");
			GLOBALTelNos 		= getxmlvalue(Contact, 		"EGZ-TelNo");
			GLOBALEMail 		= getxmlvalue(Contact, 		"EGZ-EMail");
			GLOBALText 			= getxmlvalue(Contact, 		"EGZ-Text");
			GLOBALLatLong		= getxmlvalue(Contact, 		"EGZ-Coords");			
			GLOBALMap			= getxmlvalue(Contact, 		"EGZ-Hide");	
		//Page information
		PageData 	  	= getxmlvalue(WebData, "EGZ-PageData");
		var s 			= PageData.split("<EGZ-Page>");
		
		var one,two,three,four,five,six,seven,eight,nine;
		for(x=0; x<s.length; x++){
			if(s[x].length>0){
				one   	= getxmlvalue	(s[x], "EGZ-Title");
				two   	= getxmlvalue	(s[x], "EGZ-Text"); 
				three 	= getxmlvalue	(s[x], "EGZ-Search"); 
				four  	= getxmlvalue	(s[x], "EGZ-TopImage"); 
				five  	= getxmlvalue	(s[x], "EGZ-SideImage"); 
				six   	= getxmlvalue	(s[x], "EGZ-Scrolling");
				seven  	= getxmlvalue	(s[x], "EGZ-WebForm"); 
				eight 	= getxmlvalue	(s[x], "EGZ-ImageTimer"); 
				nine 	= getxmlvalue	(s[x], "EGZ-Margin"); 
				GLOBALThePageData = GLOBALThePageData + one+"++"+two+"++"+three+"++"+four+"++"+five+"++"+six+"++"+seven+"++"+eight+"++"+nine+"@@";
			}
		}
	}
	BuildPageAndMenu();
	var theString 	= location.search;
	theString 		= theString.replace(/.*CompanyDynamics=/gi,"");
	AnyButtonClick(decodeURI(theString));
	
}

function getReferrer(){
	if (document.referrer&&document.referrer!=""){
		var PaidAd		= "";
		var theString 	= location.search;
		var KerChing	= theString.match(/gclid/);
		if(KerChing!=null) PaidAd = "Google Ad";
		var Query 		= document.referrer.replace(/.*q=/,"");
		Query 			= Query.replace(/&.*/,"");		
		//find out if the referral is a paid for one from Google
		//is the referrer in its entirety
		var Referer		= document.referrer; 
		Referer 		= Referer.replace(/\&/g," and ");
		//we need to replace the stock with referrer
		getData(GLOBALURLforEGIZMO.replace(/page/g,"referrer")+"&Data="+Referer+"&UserAgent="+navigator.userAgent+"&SessionID="+GLOBALSession+"&Query="+Query+"&Paid Advert="+PaidAd);
	}
	else
	{
	   	//we need to replace the stock with referrer but no referrer data because they came directly to the site
		getData(GLOBALURLforEGIZMO.replace(/page/g,"referrer")+"&UserAgent="+navigator.userAgent+"&SessionID="+GLOBALSession);

	}
}

function StyleChange(TheID,Property,Value) {
	var mysheet = document.styleSheets[0];
	var CSSType = mysheet.cssRules? mysheet.cssRules: mysheet.rules;
	//Find how many rules there are
	AllStyles 	= CSSType.length;
	var RuleID 	= null;
	for(x=0; x<AllStyles; x++){
		RuleID = mysheet.cssRules? mysheet.cssRules[x]: mysheet.rules[x];
		if(RuleID.selectorText == TheID){
			eval("RuleID.style."+Property+"=\""+Value+"\"");
			break;
		}
	}
}

function Sub(evt) {
	if (window.event) { // IE
		if (evt.keyCode == 13) {
			SearchData();
			return false;
		}
	}
	else if(evt.which == 13)
	 { // Netscape/Firefox/Opera
		SearchData();
		return false;
	}
}

function BlendImage(imageid, imagefile, millisec) { 
    var speed = millisec; 
    var timer = 0; 
    //set the current image as background 
    document.getElementById("Slides").style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
    //make image transparent 
    ChangeOpac(0, imageid); 
    //make new image 
    document.getElementById(imageid).src = imagefile; 
    //fade in image 
    for(i=0; i<51; i++) { 
        setTimeout("ChangeOpac(" + i + ",'" + imageid + "')",(timer*speed)); 
        timer++; 
		timer++; 
    } 
} 

function ChangeOpac(opacity, id){
	var ver = getInternetExplorerVersion();
	var object 				= document.getElementById(id).style; 
    object.opacity 			= ((opacity*2)/100);
    object.MozOpacity		= ((opacity*2)/100);
    object.KhtmlOpacity 	= ((opacity*2)/100); 
	//if it is IE 
	if(ver > -1)object.filter 	= "alpha(opacity=" + (opacity*2) + ")";
}

function AnyButtonClick(Data){
	var HowMany = document.getElementById("Menu").childNodes.length;
	var Stuff 	= Data.replace(/&/g,"&amp;");
	for(x=0;x<HowMany;x++){
		var Txt = document.getElementById("Menu").childNodes[x].innerHTML;
		if(document.getElementById("Menu").childNodes[x].innerHTML == Stuff){
			document.getElementById("Menu").childNodes[x].onclick();
			break;
			}
	}
	return Data;
}

function ResultOK(Data){
	//do nothing for Opera etc.,
}