//var xmlhttpdefault;
var xmlhttp;
var globe=new Array();
var butholder=new Array(2);
var galholder=new Array(2);
var hisholder=new Array(2);
var vtimeDelay;
var tempflat= new Array();
var tempflatb= new Array();
var tempflatd= new Array();
function showoptions(obj)
{

//1ST CHECK FOR LINKS AND IFRAMES
if(obj.id=="button10")
{
var gal = document.createElement('input');
gal.style.visibility = 'hidden';
gal.type = 'button';
gal.id = 'button10';
gal.value = 'Gallery';	
//showoptions(gal);	
Gallery(gal);
return
}
//Need to test if gallery menu on start page - dont want to make tooltip disappear also want banner display
if(obj.value!="main" && obj.value!="banner")
{
//alert(obj.value);
UnTip();
}
//alert(obj.id);
//return
//globe variable can be passed to onreadystatechange function
globe[0]=obj.id;
globe[1]=obj.title;
globe[2]=obj.value;
//alert(globe[1]);
//return
var str=obj.value;
//var sta=str.value;
//alert(str);
//return
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }  
//check for refresh button first
//if(globe[1]=="menugal")
//{
	//str="menugal";
//}

switch (str)
{
case ("st"):
alert('in');


return
break;

case ("main"):

//alert(obj.id);
var cid = obj.id;

//should only really handle display buttons to avoid repetitiveness
var url="shotokangetuser.php";
//url+="?q="+cid+"&t=menu&u=gallery";
//url+="&sid="+Math.random();

if(globe[1]=="menugal")
{
//NOTE: loads fewer values
url+="?q="+cid+"&t=title&u=gallery";
url+="&sid="+Math.random();
xmlhttp.onreadystatechange = stategalleryshow;//function() { handleHttpResponse(globe) };
}
else
{
url+="?q="+cid+"&t=menu&u=gallery";
url+="&sid="+Math.random();
xmlhttp.onreadystatechange = stategallerystart;//function() { handleHttpResponse(globe) };
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
break;
case ("loadglobals"):
//alert('case loadglobals');
//alert(obj.id);
//should only really handle display buttons to avoid repetitiveness
var url="shotokangetuser.php";
url+="?q=globals&t=loadglobals&u=buttons";
url+="&sid="+Math.random();
xmlhttp.onreadystatechange = stateloadglobals;//function() { handleHttpResponse(globe) };
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
//document.getElementById('pop').innerHTML='';
break;

case ("Members"):
//should only really handle display buttons to avoid repetitiveness
var url="shotokangetuser.php";
url+="?q=Members&t=client&u=gallery";
url+="&sid="+Math.random();
xmlhttp.onreadystatechange = statemembers;//function() { handleHttpResponse(globe) };
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
break;

default:
//Need to strip the number component from the category ie. 1. Welcome message > Welcome message.
var drop = new Array();
drop=str.split(". ");
var ndrop="";
for(var y=1;y<drop.length;y++)
{
ndrop +=drop[y];
}
//this checks to see if prefixed by number
if(drop[0]==str)
{
ndrop=str;
}
var ostr = "buttons";//document.getElementById('tab').value;
if(obj.id=="histories")
{
	//alert(globe[0]);
	
	ostr=globe[0];
}

//CHECK FOR TOOLTIP - goes to database everytime - more sluggish
//need to change toolip call cards!!!!!
if(globe[1]=="textfunction" || globe[1]=="dentisttip")
{
var url="shotokangetuser.php";
url+="?q="+ndrop+"&t=client&u="+ostr;
url+="&sid="+Math.random();
//next method allows passing of a variable to the onreadystatechange call
//***********************************************************************
xmlhttp.onreadystatechange = function() { handleHttpResponse(globe) };
//xmlhttp.onreadystatechange=stateChangeclient;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
handleHttpResponse(obj.id);
}
//OLD CODE GOES TO DATABASE EVERY CALL
/*
var url="shotokangetuser.php";
url+="?q="+ndrop+"&t=client&u="+ostr;
url+="&sid="+Math.random();
//next method allows passing of a variable to the onreadystatechange call
//***********************************************************************
xmlhttp.onreadystatechange = function() { handleHttpResponse(globe) };
//xmlhttp.onreadystatechange=stateChangeclient;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
*/
//OLD CODE
}
}
function stategallerystart()
{
if (xmlhttp.readyState==4)
{
menu(xmlhttp.responseText);
//alert(xmlhttp.responseText);
}
}
function stategalleryshow()
{
if (xmlhttp.readyState==4)
{
menugalshow(xmlhttp.responseText);
}
}
function statemembers()
{
if (xmlhttp.readyState==4)
{
startPix(xmlhttp.responseText);
//alert('in');
}
//return xmlhttp.responseText;
//NEW CODE - LOAD ALL GALLERY DATA


//END NEW CODE
}
function stateloadglobals()
{
//NEED TO LOAD GLOBAL JAVASCRIPT VARIABLES HERE FOR BUTTONS
//
//RETURN

var ar = new Array();
var response = xmlhttp.responseText;
ar = response.split("/h/");
var count=0;
for(var g=0;g<ar.length;g++)
{
var tit=ar[g];
g++;
var text=ar[g];
//g++;
if(!text || !tit)
{
//alert('in');
}
else
{
//alert('this far');
//MAKE ARRAY
butholder[count]=new Array(2);
butholder[count][0]=tit;//.push(g,text);
butholder[count][1]=text;
count++;

//CHECK FOR DISPLAY BUTTONS
if(tit=="Display buttons")
{

txt="";
//document.getElementById('buttonholder').innerHTML="";
var car = new Array();
car = text.split(",");
var tp=50;

var txt2="<center><input id='home' align='left'  onclick='return startpage()' type ='button' value='Home' style='font-weight:bold;width:150px;left:0;text-decoration:underline;position:relative;top:5px;color:#cc9900;font-size:12px'/>";

var txt="<center>";//<input id='home' align='left'  onclick='return startpage()' type ='button' value='Home' style='border:0;margin:0;text-decoration:underline;position:relative;text-align:center;top:5px;color:#cc9900;width:50px;font-size:12px;background:transparent'/>";
for(var h=0;h<car.length;h++)
{	
	//Need to set button10 for gallery
	if(car[h]=="Gallery")
	{
	txt2 +="<input id='button10' align='left' onmouseover='buttonin(this)' onmouseout='buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+(h+1)+". "+car[h]+"' style='font-weight:bold;width:150px;position:relative;text-align:left;color:red;top:5px;font-size:12px'/>";
	
	txt +="<input id='button10' align='left' onmouseover='buttonin(this)' onmouseout='buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+(h+1)+". "+car[h]+"' style='font-weight:bold;border:0;margin:0;position:relative;text-align:left;color:red;top:5px;font-size:12px;background:transparent'/>";
	}
	else
	{
	txt2 +="<input id='"+car[h]+"' align='left' onmouseover='buttonin(this)' onmouseout='buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+(h+1)+". "+car[h]+"' style='font-weight:bold;width:150px;position:relative;text-align:left;color:red;top:5px;font-size:12px'/>";
 	
	txt +="<input id='"+car[h]+"' align='left' onmouseover='buttonin(this)' onmouseout='buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+(h+1)+". "+car[h]+"' style='font-weight:bold;border:0;margin:0;position:relative;text-align:left;color:red;top:5px;font-size:12px;background:transparent'/>";
 	
	}
	
}
//alert(txt);
txt +="</center>";
//document.getElementById('buttons').innerHTML="";
//document.getElementById('buttons').innerHTML+=txt;
document.getElementById('buttons2').innerHTML="";
document.getElementById('buttons2').innerHTML+=txt2;


/*
var txt="<center><input id='startpage'  onclick='return showoptions(this)' type ='button' value='startpage' style='background-color:transparent;font-size:11px;position:relative;top:5px;font-weight:bold;border-left:0;border-top:0;border-bottom:0;border-right:solid 2px #cc9900;margin:0px;text-decoration:underline;text-align:middle;color:#cc9900'/>";
for(var h=0;h<car.length;h++)
{	
	//Need to set button10 for gallery
	if(car[h]=="Gallery")
	{
	txt +="<input id='button10' onmouseover='buttonin(this)' onmouseout='return buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+car[h]+"' style='background-color:transparent;font-size:11px;position:relative;top:5px;font-weight:bold;border-left:0;border-top:0;border-bottom:0;border-right:solid 2px #cc9900;margin:0;text-align:middle;color:white'/>";
	}
	else
	{	
	if(h<(car.length-1))
	{	
	txt +="<input id='"+car[h]+"' onmouseover='buttonin(this)' onmouseout='return buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+car[h]+"' style='background-color:transparent;font-size:11px;position:relative;top:5px;font-weight:bold;border-left:0;border-top:0;border-bottom:0;border-right:solid 2px #cc9900;margin:0;text-align:middle;color:white'/>";
	
	}
	else
	{
	
	txt +="<input id='"+car[h]+"' onmouseover='buttonin(this)' onmouseout='return buttonout(this)' onclick='return showoptions(this)' type ='button' value='"+car[h]+"' style='background-color:transparent;font-size:11px;position:relative;top:5px;font-weight:bold;border-left:0;border-top:0;border-bottom:0;border-right:0;margin:0;text-align:middle;color:white'/>";
	
	}
	}
	tp +=20;
}
txt+="</center>";
//alert(txt);
document.getElementById('buttonholder').innerHTML+=txt;//"hello";//txt;
*/
//return
txt="";
}
else if(tit=="banner")
{
document.getElementById('holding').value=text;
}
}
}
//NOW LOAD START PAGE
//var sendval="startpage";
handleHttpResponse('startpage');
}
function remborders()
{
//window.clearInterval(Tmer);
//document.getElementById('horborderbottom').style.width = 50+"px";
//document.getElementById('horborderbottom').style.visibility ="hidden";
document.getElementById('horbordertop').style.width = 50+"px";
document.getElementById('horbordertop').style.visibility ="hidden";
document.getElementById('title').style.visibility="hidden";
document.getElementById('lowerleft').style.visibility="hidden";
document.getElementById('lowerright').style.visibility="hidden";
document.getElementById('lowermiddle').style.visibility="hidden";
document.getElementById('loadergif').style.visibility="hidden";

}
function verborder(obj)
{
//var tempflat= new Array();
var y=document.getElementById('verborderflat').style.top;
tempflat=y.split("p");
var newflat=(parseInt(tempflat[0])-5);
//var tempflatb= new Array();
var yb=document.getElementById('verborderflatb').style.bottom;
tempflatb=yb.split("p");
var newflatb=(parseInt(tempflatb[0])-5);
//var tempflatd= new Array();

var yd=document.getElementById('dojobox').style.top;
tempflatd=yd.split("p");
var newflatd=(parseInt(tempflatd[0])-5);

if(newflat<2)//30)
{
window.clearInterval(vTmer);
return
}
document.getElementById('verborderflat').style.top = newflat +"px";
document.getElementById('verborderflatb').style.bottom = newflatb +"px";
document.getElementById('dojobox').style.top = newflatd +"px";
}
function handleHttpResponse(ident)//stateChangeclient()
{
//TESTS FOR INITIALISING PAGE
//NEW CODE 1 PASS DATABASE
//NOTE:butholder not accessible when iframes are loaded - need to use holding element on parent to extract
		if(ident=="banner")
		{
		var t=parent.document.getElementById('holding').value;
		text=t;
		tit="banner";
		}		
			
		else
		{
		for(var g=0;g<butholder.length;g++)
		{
		if(butholder[g][0]==ident)
		{
		text=butholder[g][1];
		tit=butholder[g][0];
		//window.clearInterval(Tmer);
		//alert(text);
		}
		}
		}
//END NEW
//alert(text);
if(globe[1]!="Display buttons" && ident!="startpage" && globe[1]!="textfunction" && ident!="Calendar")
{
//alert('in');
remborders();
//var t="<input id='home' align='left'  onclick='return startpage()' type ='button' value='Home' style='height:30px;left:0;text-decoration:underline;position:absolute;top:0px;color:#cc9900;width:100px;font-size:12px'/>";
//document.getElementById('main').innerHTML +=t;
//THRU TO DETAILS PAGES
document.getElementById('verborderflat').style.top = 140+"px";
document.getElementById('verborderflatb').style.bottom =200+"px";
document.getElementById('dojobox').style.top = 205 +"px";
//document.getElementById('verbordermiddle').style.height = 40+"px";
document.getElementById('verborderflat').style.visibility="visible";
document.getElementById('verborderflatb').style.visibility="visible";
document.getElementById('verbordermiddle').style.visibility="visible";
document.getElementById('verborderright').style.visibility="visible";
document.getElementById('butcat').style.visibility="visible";
document.getElementById('buttons2').style.visibility="visible";
//document.getElementById('pennant').style.visibility="visible";
clearInterval(Tmer);

vtimeDelay=25;
vTmer = setInterval("verborder()", vtimeDelay);
}
if (ident)//xmlhttp.readyState==4)
{
//need to update tooltips
if(ident[1]=="textfunction" || ident[1]=="dentisttip")
{
//alert('only for tooltip');
ar = new Array();
var response = xmlhttp.responseText;
ar = response.split("/h/");
//default buttons
var pid=ar[0];
var pics=ar[1];
var tit=ar[2];
var text=ar[3];
}
//add a space onto text otherwise does not pick up last character
text +=" ";

if(globe[0]=="histories")
{
var name=ar[1];
pics=ar[2];
text=ar[5]+"<br>";
tit=ar[4];
}
var newtext="";
var tooltipwidthmax=0;//allows setting tooltipwidth to first table that is encountered
for(var m=0;m<text.length-1;m++)
{
if (text.charCodeAt(m) == "13")
{
}
else
{
	newtext += text.charAt(m);
}
}
text=newtext;

//alert(text);
	var target=unwantedframes();
	var cl = new Array();	
		cl[0] = ['0','black'];
        cl[1] = ['1','white'];
        cl[2] = ['2','red'];
        cl[3] = ['3','lightgreen'];
        cl[4] = ['4','gray'];
        cl[5] = ['5','#003366'];
        cl[6] = ['6','olivedrab'];
        cl[7] = ['7','plum'];
        cl[8] = ['8','transparent'];
        cl[9] = ['9','#cc9900'];
	var tooltipwidth=0;	
	var dojoholder='';	
	if(tit!="startpage")
	{
	document.getElementById('dojobox').style.visibility = 'visible';	
	}
	if(globe[1]!="textfunction" && tit!="Calendar")
	{
	document.getElementById('dojobox').innerHTML = '';
	document.getElementById('dojobox').scrollTop = 0+"px";
	}
	var count = 0;
				//
				//var tp="Welcome message";
				//keeps title out of main text field - just placed in tooltip heading later
				if(globe[1]!="textfunction" && tit!="startpage" &&tit!="banner")
				{
				//dojoholder += "<span class='ast' id='title' style='color:lightgreen'>" + tit + "</span>";
				}
                dojoholder += "<p>";
                //Clever code to check dates
                var temp = new Array();

                //Gives 2 splits 1 for month and 2 for year - split occurs at ','!
                temp = text.split('#');				
                var str;
                str ="<p>";				
                //for determining which picture
                var vr = 1;
                var newinner = '';					
                for (var k = 0; k < (temp.length - 1); k++)
                {   //check first if char 10 -- new line
                    var newinner = '';					
                   for (var m = 0; m < (temp[k].length - 1); m++)
                   {		
					if (temp[k].charCodeAt(m) == "10")
                    {newinner += "<br/>";
                    }						
					else if (temp[k].charCodeAt(m) == "126")
			            {
						newinner +="<span class='ast' id='colour' style='font-size:18px;color:red'>"; 

						//To add a coloured bit of text
						//Nested condition
						m++;
						
						while (temp[k].charCodeAt(m) != "126")
						{				

						
			                        newinner += temp[k].charAt(m);
			                        m++;
						}

						newinner += "</span>"; 


			            }			
				 
				 
				 		//***********************************************new table section*****************************************************
						//test for table		
						//character code 96 or ` 
						//?? does this code need to be placed above as well???
								
				
						
						else if (temp[k].charCodeAt(m) == "96")
			            {			
						
						//get table row count - should be column
						m++;
						var trowcount = temp[k].charAt(m);
						//get table fore color
						//use cl[0];etc					
						
						//newinner += "<Table><tr>"; 
						m++;
						var headcolors = new Array();
						headcolors[0]=cl[temp[k].charAt(m)][1];//temp[k].charAt(m);					
						
						//count thru and initialize - get heading colors first
						//0 - background
						//1--4 - forecolors
						for (p=0; p < trowcount; p++)
						{
						m++;						
						headcolors[p+1]=cl[temp[k].charAt(m)][1];
						
						}	

						//Get column widths												
						
						m++;
						m++;										
						
						var tcellwidth = new Array();						
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							tcellwidth[tcount]='';
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									tcellwidth[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}
											
							m++;
						
						}			
						
						
						
						//***********NEW GET FONTS FOR HEADINGS and MAIN TEXT*********************
						//Get column widths	
						//WORKING nicely -  need to adjust all tables and MAKE TABLE section to account for font changes


						
						
						//m++;
						//m++;										
						
						var headingfont = new Array();						
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							headingfont[tcount]='';//default is 16
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									headingfont[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}

							//?should check for null value
							
							
							m++;
						
						}			
						
						//MAIN TEXT FONTS
						
						
						//m++;
						//m++;										
						
						var textfont = new Array();						
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							textfont[tcount]='';//default is 16
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									textfont[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}
							
							
							//should check for null value

							
							
							m++;
						
						}			
						
						
						
						//*****************************************************************
											
						
						
						//get heading titles
						newinner += "<TABLE><TR>"; 
						//m++;
						
						var headtitle='';
						
						for (p=0; p < trowcount; p++)
						{						
							headtitle='';
							
							while (temp[k].charCodeAt(m) != "126")
							{	
									headtitle += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);
									m++;
							}


							//**********NEED TO CHANGE TO SPAN TO GET ALIGN WORKING*************
							//<span style='color:white'>English</span>
							//;color:"+headcolors[p+1]+"
							newinner +="<TD style='background-color:"+headcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+headingfont[p]+";color:"+headcolors[p+1]+"'>"+headtitle+"</span></center></TD>";
							m++;
						}
						
						
						
						//get align attributes-center or left
						var aligntext = new Array();
						for (p=0; p < trowcount; p++)
						{
												
							aligntext[p]=temp[k].charAt(m);
							m++;
						}					
											
						newinner +="</TR><TR>";											
						
						//get column colors
						//m already increased!!
						m++;
						var colcolors = new Array();
						colcolors[0]=cl[temp[k].charAt(m)][1];					
						
						//count thru and initialize - get heading colors first
						//0 - background
						//1--4 - forecolors
						for (p=0; p < trowcount; p++)
						{
						m++;						
						colcolors[p+1]=cl[temp[k].charAt(m)][1];
						
						}						

						//now interate thru data
						m++;
						m++;
						m++;							
							
							var coldata ='';
							//use this next variable for data after image
							var coldata2 ='';
							var holdcolor=''; 
							var cellimage ='';
							var celllink ='';
							var buttonfunction='';
							var dats = new Array;
							
							while (temp[k].charCodeAt(m) != "96")
							{									
									
									for (p=0; p < trowcount; p++)
									{			
																	
										coldata ='';
										coldata2 ='';
										holdcolor=colcolors[p+1];
										cellimage='';
										cellimagewidth ='';
										celllink='';
										buttonfunction='';
										dats[0]='';//relates to text before image??
										dats[1]='';//relates to image
										dats[2]='';//relates to text below image
										dats[3]='';//relates to href link
										dats[4]='';//button function
										dats[5]='';//tooltip function
										while (temp[k].charCodeAt(m) != "126")
										{																
											
											//test for ^ to change individual cell color and check for image
											if(temp[k].charCodeAt(m) == "94")
											{											
												m++;
												//alert(temp[k].charCodeAt(m));
												//test for image first use * character
												//this should allow for text above and below image?
												if(temp[k].charCodeAt(m)=="42")
												{
													//alert('in');
													
													//need to get image file name - seperate by another * character
													m++;
													
													//test for wide image first - char +
													if(temp[k].charCodeAt(m) == "43")
													{
															//alert('in');
															cellimagewidth="w";
															
															m++;
													}
													
													
													while (temp[k].charCodeAt(m) != "42")
													{	
															
															cellimage += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}
													
													
												}
												
												//next test for link
												//test for % character
												if(temp[k].charCodeAt(m)=="37")
												{
													//alert('in');
													m++;
													var linkcolor = '';
													linkcolor = temp[k].charAt(m);
													m++;
													
													while (temp[k].charCodeAt(m) != "42")
													{	
															
															celllink += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}	
													dats[3] ="<a href='"+celllink+"' style='color:"+cl[linkcolor][1]+"'>";
													m++;
													while (temp[k].charCodeAt(m) != "37")
													{	
															
															dats[3] += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}	
													
													//m++;
												
												}
												
												
												
												
												
												//*********************************FUNCTION CALLS******************************************
												//next test for function call - can be either image or button
												//test for f(102)character
												//need to test subsequent char for either image = *(42) or button = $(36) or tooltip = @(64)
												if(temp[k].charCodeAt(m)=="102")
												{
													//alert('in');
													m++;							
													
													//*************BUTTON TEST**********************
													//*************************************************
													if(temp[k].charCodeAt(m)=="36")
													{													
														
																								
														m++;
														
														//****FIRST TEST TO SEE IF BACKGROUND URL****
														//****use ^ character*****
														//****for now this sets default for whole <td> cell****	
														//****the default is transparent which is great!!****
														//****NOTE - STRUCTURE SAME FOR TOOLTIP****														
														var burl='';
														var extratext='';
														var dummy=0;
														if(temp[k].charCodeAt(m) == "94")
														{
															
															m++;
															while (temp[k].charCodeAt(m) != "94")
																{
																	burl += temp[k].charAt(m);
																	m++;
																}
														
														m++;
														}											
														
														
														while (temp[k].charCodeAt(m) != "36")
														{					
																
																//*****CHECK FOR EXTRA CHARACTERS AFTER FUNCTION CALL*****
																//*****this gives more versatility in the appearance ********
																//******do this before check for multiple entries- sets up <br> better***
																//******NEED TO INCORPORATE ABOVE**********
																if(temp[k].charAt(m)=="%")
																{										
																			
																	//alert('in');
																	m++;
																	while (temp[k].charAt(m) != "%")
																		{
																			extratext += temp[k].charAt(m);
																			m++;
																		}	
																	//alert(buttonfunction + ":" + extratext);
																
																	dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
													
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';
																	
																	m++;									
																	
																	
																}	
																															
																//****CHECK FOR ANOTHER BUTTON IN SAME CELL
																//****use '|' character******
																//****allows multiple entries*****
																if(temp[k].charAt(m)=="|")
																{						
																	
																	if(buttonfunction!='')
																	{
																	m++;	

																	dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+"' /><br>";
																	}
																	else if(buttonfunction=='')
																	{
																		dats[4] +="<br>";
																		m++;
																	}
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';															
																	
																									
																}						
																
																//need to check if closing value before load
																if (temp[k].charCodeAt(m) != "36")
																{												
																	
																	buttonfunction += temp[k].charAt(m);
																	//newinner += temp[k].charAt(m);
																	m++;
																}
																//m++;
														}
														
														//alert(buttonfunction +":"+buttonfunction.length);
														
														if(buttonfunction!='')
														{
														//alert('in'+":"+buttonfunction);
														dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+"' />";
														
														//m++;
														}
														
													}

													//******************END BUTTON TEST*******************
													
													//alert(dats[4] + "NEWINNER:" +newinner);
													//alert(temp[k].charAt(m));
													//*************TOOLTIP TEST**********************
													//*************************************************
													if(temp[k].charCodeAt(m)=="64")
													{													
																								
														m++;
														
														//****FIRST TEST TO SEE IF BACKGROUND URL****
														//****use ^ character*****
														//****for now this sets default for whole <td> cell****	
														//****the default is transparent which is great!!****
														var burl='';
														var extratext='';
														if(temp[k].charCodeAt(m) == "94")
														{
															
															m++;
															while (temp[k].charCodeAt(m) != "94")
																{
																	burl += temp[k].charAt(m);
																	m++;
																}
														
														m++;
														}											
														
														
														while (temp[k].charCodeAt(m) != "64")
														{																
																//*****CHECK FOR EXTRA CHARACTERS AFTER FUNCTION CALL*****
																//*****this gives more versatility in the appearance ********
																//******do this before check for multiple entries- sets up <br> better***
																//******NEED TO INCORPORATE ABOVE**********
																if(temp[k].charAt(m)=="%")
																{						
																	
																	m++;
																	while (temp[k].charAt(m) != "%")
																		{
																			extratext += temp[k].charAt(m);
																			m++;
																		}
																		
																		
																		//alert(buttonfunction);
																		
																		dats[5] +="<input type='button' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
													
																		//reset for another button
																		buttonfunction = '';												
																		extratext='';																
																
																	m++;
																	//m++;
																			
																}	
																//*************************************
																//*************************************										
																//NEW PART TO ENSURE LINKING TO CORRECT FILE
																//find relative file i.e. histories, buttons etc																															
																var rel='';
																if(temp[k].charAt(m)=="$")
																{																		
																	m++;
																	while (temp[k].charAt(m) != "$")
																		{
																			rel += temp[k].charAt(m);
																			m++;
																		}																		
																		//alert(buttonfunction);																		
																		dats[5] +="<input type='button' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' alt='"+rel+"' onclick='return help(this)' id='textfunction"+buttonfunction+"' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
																		//reset for another button
																		buttonfunction = '';												
																		rel='';																	
																	m++;
																	//m++;
																	//alert('in');//dats[5]);		
																}		
																
																//alert('inn');
																//****CHECK FOR ANOTHER BUTTON IN SAME CELL
																//****use '|' character******
																//****allows multiple entries*****
																if(temp[k].charAt(m)=="|")
																{						
																	
																	if(buttonfunction!='')
																	{
																	m++;	

																	dats[5] +="<input type='button' onmouseover='return unimover(this)' onmouseout='return unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' /><br>";
																	}
																	else if(buttonfunction=='')
																	{
																		dats[5] +="<br>";
																		m++;
																	}
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';
																									
																}											
																
																//need to check if closing value before load
																if (temp[k].charCodeAt(m) != "64")
																{												
																	
																	buttonfunction += temp[k].charAt(m);
																	//newinner += temp[k].charAt(m);
																	m++;
																}
																//m++;
																
																
																
																
																
																
																//buttonfunction += temp[k].charAt(m);
																//newinner += temp[k].charAt(m);
																//m++;
														}
														
														//alert(burl);

														//if(buttonfunction!='')
														//{
														
														if(buttonfunction!='')
														{
														//alert('in'+":"+buttonfunction);
														
														
														
														
														dats[5] +="<input type='button' onmouseover='return unimover(this)' onmouseout='return unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+"' />";
													
															
														//m++;
														}												
														
													}

													//******************END TOOLTIP  TEST*******************
													
													
																					
													//******************IMAGE SECTION*******************
													//*********************************************************
													
													if(temp[k].charCodeAt(m)=="42")
													{	
													
													}
													
													//******************END IMAGE TEST*******************
																						
												
												}
												//************************************************************************************
												
												
												
												
																							
												//set colours for initial text
												else if(temp[k].charCodeAt(m)!="42" && temp[k].charCodeAt(m)!="37" && temp[k].charCodeAt(m)!="102")
												{									
													//alert('in');
													colcolors[p+1]=cl[temp[k].charAt(m)][1];
													m++;
												}											
											
											}										
																				
											//sets text below image
											if(cellimage!='')
											{
												//first set image data
												//check if wide or normal size
												if(cellimagewidth=="w")
												{	
													//alert('in');	
													dats[1]="<br><img id='clientpicsw' onclick='help(this)' name='"+cellimage+"' src='Pictures/"+cellimage+"' width='"+tcellwidth[p]+"px' />";
												}
												else if(cellimagewidth=="")
												{
													//alert('in');
													dats[1]="<br><img id='clientpics' onclick='help(this)' name='"+cellimage+"' src='Pictures/"+cellimage+"' width='"+tcellwidth[p]+"px' />";
									
												}
												
												//set image details for cell												
												m++;
												if(temp[k].charCodeAt(m)!="126")
												{
												coldata2 +=	temp[k].charAt(m);
												}//m++;			
											}	
											
											
											if(cellimage=='')
											{
												coldata += temp[k].charAt(m);
												m++;										
											}			
											
											
										}											
										
										
										
										//alert(temp[k].charAt(m));
										//load all the td values									
										//need this check as loads % character into coldata
										//***************THIS CHECK IS PROVING TO BE DECISIVE FOR FUNCTIONALITY*********************
										//***********************************(may need updataing)*************************************************
										if(coldata!='' && celllink=='' && buttonfunction=='' && temp[k].charCodeAt(m-2)!="36" && temp[k].charCodeAt(m-1)!="36" && temp[k].charCodeAt(m-1)!="64" && temp[k].charCodeAt(m-2)!="64")
										{
											//check for carriage return
											//********use |n**********	
											//need [p+1] in this  part ?? - confusing --WORKS STRANGE FOR A 2 COLUMN TABLE - CAN ONLY SET 1 FONT!! - uses the second position????? - weird
											dats[0] = "<span style='color:"+colcolors[p+1]+"'>";										
																				
											//alert(p);
											
											for(o=0;o < coldata.length; o++)
											{									
												
												if(coldata.charAt(o)=="|")
												{																							
													o++;													
													dats[0] +="</span><br><span style='color:"+colcolors[p+1]+"'>";
																					
												}
												
												dats[0] += coldata.charAt(o);
																							
											}										
											dats[0]+="</span>";										
																			
										}
										
										
										
										
										if(coldata2!='')
										{
											//Should add carriage return here as well
											//****YET TO DO
											dats[2] = "<br><span style='color:"+colcolors[p+1]+"'>"+coldata2+"</span>";
																			
										}	

										
										
										
										//? doesnt really need closing tag
										if(dats[3]!='')
										{
											dats[3]+="</a>";
										}
										
										
										//this condition tests for alignment
										if(aligntext[p]=="c")
										{																	
											//newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"'><center><span style='font-size:16;color:"+colcolors[p+1]+"'>"+coldata+"</span></center></TD>";
											
											if(trowcount==2)
											{
											
											//alert(textfont[0]);
											
											
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></center></TD>";
											}
											else
											{
											//alert(textfont[0]);
											
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></center></TD>";
										
											}
											
											
											
											
											//alert(newinner);								
										}
										else if(aligntext[p]!="c")
										{
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+ dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></TD>";
										}												
										
										m++;	
										//reset column color
										colcolors[p+1]=holdcolor;
										
										
									}						
									
			                        newinner +="</TR><TR>";							 
							 
							}

							newinner +="</TR></TABLE>";																										
							
						}					
				 
						//***********************************************new table section*****************************************************
				 		
					
	
                    else
                    {

                        newinner += temp[k].charAt(m);
                        //dojoholder += temp[k].charAt(m);

                    }


                   }


                    if (temp[(k + 1)].charAt(0) == "l")
                    {

                         //alert('in');		 
						 
						 var newtemp = new Array();

                            newtemp[0] = "";

                            //to drop the 'l'
                            for (var l = 1; l < (temp[(k + 1)].length); l++)
                            {
                                 newtemp[0] += temp[(k + 1)].charAt(l);
                            }


                         temp[(k + 1)] = newtemp[0];

                         //str = newtemp[0];
                         //}
						//the help or tooltip only set up for karate shop at present time
						dojoholder += newinner + "<img src='Pictures/" + tit + " " + vr + ".jpeg' id='"+tit+"' name=' "+vr+"' onclick='help(this)' align='left' width='150' hspace='20' vspace='30'>";
						//alert(dojoholder);
						
                         vr++;

                         //str += temp[k] + "<img src='/Pictures/Latest " +  k + ".jpeg' align='left' hspace='20' vspace='30'>" + "<br/>" + "<br/>";

                    }

					
                    else if (temp[(k + 1)].charAt(0) == "r")
                    //Right sided picture
                    {

                         var newtemp = new Array();

                         newtemp[0] = "";
                         for (var l = 1; l < (temp[(k + 1)].length); l++)
                         {
                            newtemp[0] += temp[(k + 1)].charAt(l);
                         }

                         temp[(k + 1)] = newtemp[0];

                         //str = newtemp[0];
                         //}

						dojoholder += newinner +  "<img src='Pictures/" + tit + " " + vr + ".jpeg' id='"+tit+"' name=' "+vr+"' onclick='help(this)' align='right' width='150' hspace='20' vspace='30'>";

                        vr++;

                        //str += temp[k] + "<img src='/Pictures/Latest 2.jpeg' align='left' hspace='20' vspace='30'>"+ "<br/>" + "<br/>";

                    }					
	
					
					else //(temp[(k + 1)].charAt(0) == "m")
                    //middle picture
                    {

                         var newtemp = new Array();

                         newtemp[0] = "";
                         for (var l = 1; l < (temp[(k + 1)].length); l++)
                         {
                            newtemp[0] += temp[(k + 1)].charAt(l);
                         }

                         temp[(k + 1)] = newtemp[0];

                         //str = newtemp[0];
                         //}

						dojoholder += newinner +  "<img src='Pictures/" + tit + " " + vr + ".jpeg' id='"+tit+"' name=' "+vr+"' onclick='help(this)' style='position:relative;left:30px' width='300px' hspace='20' vspace='10'>";

                        vr++;

                        //str += temp[k] + "<img src='/Pictures/Latest 2.jpeg' align='left' hspace='20' vspace='30'>"+ "<br/>" + "<br/>";

                    }
					
					
					


                 }

				 //****************************************************
                //str +=  temp[(temp.length - 1)] + "</p>";


                //alert(str);

				//dojoholder +=newinner;

                //check for char 10 -- new line

                var newinner = '';

                for (var m = 0; m < temp[(temp.length - 1)].length; m++)
                {

                if (temp[(temp.length - 1)].charCodeAt(m) == "10")
                {

                   newinner += "<br/>";

                }
				
				
				
				else if (temp[(temp.length - 1)].charCodeAt(m) == "126")
	             {
				

				newinner +="<span class='ast' id='colour' style='font-size:15px;color:red'>"; 

				//To add a coloured bit of text
				//Nested condition
				m++;
				
				while (temp[k].charCodeAt(m) != "126")
				{				

				
	                        newinner += temp[k].charAt(m);
	                        m++;
				}

				newinner += "</span>"; 


	             }
				 
				 
				 
				 		//***********************************************new table section*****************************************************
						//test for table		
						//character code 96 or ` 
						//?? does this code need to be placed above as well???
						
						
						else if (temp[k].charCodeAt(m) == "96")
			            {
						
						
						
						
						//get table row count - should be column
						m++;
						var trowcount = temp[k].charAt(m);
						//get table fore color
						//use cl[0];etc					
						
						//newinner += "<Table><tr>"; 
						m++;
						var headcolors = new Array();
						headcolors[0]=cl[temp[k].charAt(m)][1];//temp[k].charAt(m);					
						
						//count thru and initialize - get heading colors first
						//0 - background
						//1--4 - forecolors
						for (p=0; p < trowcount; p++)
						{
						m++;						
						headcolors[p+1]=cl[temp[k].charAt(m)][1];
						
						}	

						//Get column widths												
						
						m++;
						m++;										
						
						var tcellwidth = new Array();							
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							tcellwidth[tcount]='';
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									tcellwidth[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}
							
							//good trick to convert string to number - just multiply by 1 - if not number then returns nan
							
							if(tooltipwidthmax==0)
							{
							tooltipwidth +=(tcellwidth[tcount]*1);
							}							
							m++;						
						}								
						tooltipwidthmax = 1;//allows setting tooltipwidth to first table in text						
						//***********NEW GET FONTS FOR HEADINGS and MAIN TEXT*********************
						//Get column widths	
						//WORKING nicely -  need to adjust all tables and MAKE TABLE section to account for font changes
						//m++;
						//m++;										
						
						var headingfont = new Array();						
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							headingfont[tcount]='';//default is 16
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									headingfont[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}

							//?should check for null value
							
							
							m++;
						
						}			
						
						//MAIN TEXT FONTS
						
						
						//m++;
						//m++;										
						
						var textfont = new Array();						
						
						for (tcount=0; tcount < trowcount; tcount++)
						{							
							textfont[tcount]='';//default is 16
							
							while (temp[k].charCodeAt(m) != "126")
							{				

									textfont[tcount] += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);									

							  m++;
							}
							
							
							//should check for null value
							//if(trowcount==2)
							//{
							//	alert(textfont[tcount]);
							
							//}
							
							
							m++;
						
						}			
						
						
						
						//*****************************************************************
						
						
						
						
						
						
						
						//get heading titles
						newinner += "<TABLE><TR>"; 
						//m++;
						
						var headtitle='';
						
						for (p=0; p < trowcount; p++)
						{						
							headtitle='';
							
							while (temp[k].charCodeAt(m) != "126")
							{	
									headtitle += temp[k].charAt(m);
			                        //newinner += temp[k].charAt(m);
									m++;
							}


							//**********NEED TO CHANGE TO SPAN TO GET ALIGN WORKING*************
							//<span style='color:white'>English</span>
							//;color:"+headcolors[p+1]+"
							newinner +="<TD style='background-color:"+headcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+headingfont[p]+";color:"+headcolors[p+1]+"'>"+headtitle+"</span></center></TD>";
							m++;
						}
						
						
						
						//get align attributes-center or left
						var aligntext = new Array();
						for (p=0; p < trowcount; p++)
						{
												
							aligntext[p]=temp[k].charAt(m);
							m++;
						}					
											
						newinner +="</TR><TR>";											
						
						//get column colors
						//m already increased!!
						m++;
						var colcolors = new Array();
						colcolors[0]=cl[temp[k].charAt(m)][1];					
						
						//count thru and initialize - get heading colors first
						//0 - background
						//1--4 - forecolors
						for (p=0; p < trowcount; p++)
						{
						m++;						
						colcolors[p+1]=cl[temp[k].charAt(m)][1];
						
						}						

						//now interate thru data
						m++;
						m++;
						m++;							
							
							var coldata ='';
							//use this next variable for data after image
							var coldata2 ='';
							var holdcolor=''; 
							var cellimage ='';
							var celllink ='';
							var buttonfunction='';
							var dats = new Array;
							
							while (temp[k].charCodeAt(m) != "96")
							{									
									
									for (p=0; p < trowcount; p++)
									{			
																	
										coldata ='';
										coldata2 ='';
										holdcolor=colcolors[p+1];
										cellimage='';
										cellimagewidth ='';
										celllink='';
										buttonfunction='';
										dats[0]='';//relates to text before image??
										dats[1]='';//relates to image
										dats[2]='';//relates to text below image
										dats[3]='';//relates to href link
										dats[4]='';//button function
										dats[5]='';//tooltip function
										while (temp[k].charCodeAt(m) != "126")
										{																
											
											//test for ^ to change individual cell color and check for image
											if(temp[k].charCodeAt(m) == "94")
											{											
												m++;
												//alert(temp[k].charCodeAt(m));
												//test for image first use * character
												//this should allow for text above and below image?
												if(temp[k].charCodeAt(m)=="42")
												{
													//alert('in');
													
													//need to get image file name - seperate by another * character
													m++;
													
													//test for wide image first - char +
													if(temp[k].charCodeAt(m) == "43")
													{
															//alert('in');
															cellimagewidth="w";
															
															m++;
													}
													
													
													while (temp[k].charCodeAt(m) != "42")
													{	
															
															cellimage += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}
													
													
												}
												
												//next test for link
												//test for % character
												if(temp[k].charCodeAt(m)=="37")
												{
													//alert('in');
													m++;
													var linkcolor = '';
													linkcolor = temp[k].charAt(m);
													m++;
													
													while (temp[k].charCodeAt(m) != "42")
													{	
															
															celllink += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}	
													dats[3] ="<a href='"+celllink+"' style='color:"+cl[linkcolor][1]+"'>";
													m++;
													while (temp[k].charCodeAt(m) != "37")
													{	
															
															dats[3] += temp[k].charAt(m);
															//newinner += temp[k].charAt(m);
															m++;
													}	
													
													//m++;
												
												}
												
												
												
												
												
												//*********************************FUNCTION CALLS******************************************
												//next test for function call - can be either image or button
												//test for f(102)character
												//need to test subsequent char for either image = *(42) or button = $(36) or tooltip = @(64)
												if(temp[k].charCodeAt(m)=="102")
												{
													//alert('in');
													m++;							
													
													//*************BUTTON TEST**********************
													//*************************************************
													if(temp[k].charCodeAt(m)=="36")
													{													
														//alert('in');																								
														m++;
														
														//****FIRST TEST TO SEE IF BACKGROUND URL****
														//****use ^ character*****
														//****for now this sets default for whole <td> cell****	
														//****the default is transparent which is great!!****
														//****NOTE - STRUCTURE SAME FOR TOOLTIP****														
														var burl='';
														var extratext='';
														var dummy=0;
														if(temp[k].charCodeAt(m) == "94")
														{
															
															m++;
															while (temp[k].charCodeAt(m) != "94")
																{
																	burl += temp[k].charAt(m);
																	m++;
																}
														
														m++;
														}											
														
														
														while (temp[k].charCodeAt(m) != "36")
														{					
																
																//*****CHECK FOR EXTRA CHARACTERS AFTER FUNCTION CALL*****
																//*****this gives more versatility in the appearance ********
																//******do this before check for multiple entries- sets up <br> better***
																//******NEED TO INCORPORATE ABOVE**********
																if(temp[k].charAt(m)=="%")
																{										
																			
																	//alert('in');
																	m++;
																	while (temp[k].charAt(m) != "%")
																		{
																			extratext += temp[k].charAt(m);
																			m++;
																		}	
																	//alert(buttonfunction + ":" + extratext);
																
																	dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
													
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';
																	
																	m++;									
																	
																	
																}	
																																																
																//****CHECK FOR ANOTHER BUTTON IN SAME CELL
																//****use '|' character******
																//****allows multiple entries*****
																if(temp[k].charAt(m)=="|")
																{						
																	
																	if(buttonfunction!='')
																	{
																	m++;	

																	dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+"' /><br>";
																	}
																	else if(buttonfunction=='')
																	{
																		dats[4] +="<br>";
																		m++;
																	}
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';															
																	
																									
																}						
																
																//need to check if closing value before load
																if (temp[k].charCodeAt(m) != "36")
																{												
																	
																	buttonfunction += temp[k].charAt(m);
																	//newinner += temp[k].charAt(m);
																	m++;
																}
																//m++;
														}
														
														//alert(buttonfunction +":"+buttonfunction.length);
														
														if(buttonfunction!='')
														{
														//alert('in'+":"+buttonfunction);
														dats[4] +="<input type='button' id='"+buttonfunction+"' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='"+buttonfunction+"(this)' style='border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+"' />";
														
														//m++;
														}														
													}
													//******************END BUTTON TEST*******************
													//alert(dats[4] + "NEWINNER:" +newinner);
													//alert(temp[k].charAt(m));
													//*************TOOLTIP TEST**********************
													//*************************************************
													if(temp[k].charCodeAt(m)=="64")
													{													
										
														m++;
														
														//****FIRST TEST TO SEE IF BACKGROUND URL****
														//****use ^ character*****
														//****for now this sets default for whole <td> cell****	
														//****the default is transparent which is great!!****
														var burl='';
														var extratext='';
														if(temp[k].charCodeAt(m) == "94")
														{
															
															m++;
															while (temp[k].charCodeAt(m) != "94")
																{
																	burl += temp[k].charAt(m);
																	m++;
																}														
															m++;
														}														
														while (temp[k].charCodeAt(m) != "64")
														{																
																//*****CHECK FOR EXTRA CHARACTERS AFTER FUNCTION CALL*****
																//*****this gives more versatility in the appearance ********
																//******do this before check for multiple entries- sets up <br> better***
																//******NEED TO INCORPORATE ABOVE**********
																if(temp[k].charAt(m)=="%")
																{																		
																	m++;
																	while (temp[k].charAt(m) != "%")
																		{
																			extratext += temp[k].charAt(m);
																			m++;
																		}																		
																		//alert(buttonfunction);																		
																		dats[5] +="<input type='button' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction"+buttonfunction+"' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
																		//reset for another button
																		buttonfunction = '';												
																		extratext='';																	
																	m++;
																	//m++;																			
																}	
																//*************************************										
																//NEW PART TO ENSURE LINKING TO CORRECT FILE
																//find relative file i.e. histories, buttons etc																															
																var rel='';
																if(temp[k].charAt(m)=="$")
																{																		
																	m++;
																	while (temp[k].charAt(m) != "$")
																		{
																			rel += temp[k].charAt(m);
																			m++;
																		}																		
																		//alert(buttonfunction);																		
																		dats[5] +="<input type='button' onmouseover='unimover(this)' onmouseout='unimout(this)' title='"+colcolors[p+1]+ "' alt='"+rel+"' onclick='return help(this)' id='textfunction"+buttonfunction+"' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' />";
																		//reset for another button
																		buttonfunction = '';												
																		rel='';																	
																	m++;
																	//m++;
																	//alert('in');//dats[5]);		
																}															
																//*************************************										
																//****CHECK FOR ANOTHER BUTTON IN SAME CELL
																//****use '|' character******
																//****allows multiple entries*****
																if(temp[k].charAt(m)=="|")
																{																		
																	if(buttonfunction!='')
																	{
																	m++;	

																	dats[5] +="<input type='button' onmouseover='return unimover(this)' onmouseout='return unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction"+buttonfunction+"' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+ "' /><br>";
																	}
																	else if(buttonfunction=='')
																	{
																		dats[5] +="<br>";
																		m++;
																	}
																	//reset for another button
																	buttonfunction = '';												
																	extratext='';
																									
																}											
																
																//need to check if closing value before load
																if (temp[k].charCodeAt(m) != "64")
																{												
																	
																	buttonfunction += temp[k].charAt(m);
																	//newinner += temp[k].charAt(m);
																	m++;
																}
																//m++;												
																//buttonfunction += temp[k].charAt(m);
																//newinner += temp[k].charAt(m);
																//m++;
														}
														
														//alert(burl);

														//if(buttonfunction!='')
														//{
														
														if(buttonfunction!='')
														{
														//alert('in'+":"+buttonfunction);													
														dats[5] +="<input type='button' onmouseover='return unimover(this)' onmouseout='return unimout(this)' title='"+colcolors[p+1]+ "' onclick='return help(this)' id='textfunction"+buttonfunction+"' name='"+buttonfunction+"' style='width:"+tcellwidth[p]+"px;border:0;font-size:"+textfont[p]+";color:"+colcolors[p+1]+";background: url("+burl+");background-repeat:repeat' value='"+buttonfunction+extratext+"' />";
																												
														//m++;
														}												
														
													}

													//******************END TOOLTIP  TEST*******************
													
													
																					
													//******************IMAGE SECTION*******************
													//*********************************************************
													
													if(temp[k].charCodeAt(m)=="42")
													{	
													
													}
													
													//******************END IMAGE TEST*******************
																						
												
												}
												//************************************************************************************
												
												
												
												
																							
												//set colours for initial text
												else if(temp[k].charCodeAt(m)!="42" && temp[k].charCodeAt(m)!="37" && temp[k].charCodeAt(m)!="102")
												{									
													//alert('in');
													colcolors[p+1]=cl[temp[k].charAt(m)][1];
													m++;
												}											
											
											}										
																				
											//sets text below image
											if(cellimage!='')
											{
												//first set image data
												//check if wide or normal size
												if(cellimagewidth=="w")
												{														
													
													dats[1]="<br><img id='clientpicsw' onclick='help(this)' name='"+cellimage+"' src='Pictures/"+cellimage+"' width='"+tcellwidth[p]+"px' />";
												}
												else if(cellimagewidth=="")
												{
													//alert(cellimage);
													//Need to strip title link
													var str="";//cellimage;
													var newpos=0;
													var ncount=0;
													
													for(var y=cellimage.length;y>0;y--)
													{
														if(ncount==2)
														{
															//alert(y);
															newpos=y;
															newpos++;
															ncount++;
														}														
														if(cellimage.charAt(y)=="$")
														{
															ncount++;
														}												
													}													
													str=cellimage.substring(0,newpos);
													//alert(str);	
													
													if(str=="")
													{
														str=cellimage;//=str;
													}
													
													//alert(cellimage);
													
													dats[1]="<br><img id='clientpics' onclick='help(this)' name='"+cellimage+"' src='Pictures/"+str+"' width='"+tcellwidth[p]+"px' />";
									
												}
												
												//set image details for cell												
												m++;
												if(temp[k].charCodeAt(m)!="126")
												{
												coldata2 +=	temp[k].charAt(m);
												}//m++;			
											}	
											
											
											if(cellimage=='')
											{
												coldata += temp[k].charAt(m);
												m++;										
											}			
											
											
										}											
										
										
										
										//alert(temp[k].charAt(m));
										//load all the td values									
										//need this check as loads % character into coldata
										//***************THIS CHECK IS PROVING TO BE DECISIVE FOR FUNCTIONALITY*********************
										//***********************************(may need updataing)*************************************************
										if(coldata!='' && celllink=='' && buttonfunction=='' && temp[k].charCodeAt(m-2)!="36" && temp[k].charCodeAt(m-1)!="36" && temp[k].charCodeAt(m-1)!="64" && temp[k].charCodeAt(m-2)!="64")
										{
											//check for carriage return
											//********use |n**********	
											//need [p+1] in this  part ?? - confusing --WORKS STRANGE FOR A 2 COLUMN TABLE - CAN ONLY SET 1 FONT!! - uses the second position????? - weird
											dats[0] = "<span style='color:"+colcolors[p+1]+"'>";										
																				
											//alert(p);
											
											for(o=0;o < coldata.length; o++)
											{									
												
												if(coldata.charAt(o)=="|")
												{																							
													o++;													
													dats[0] +="</span><br><span style='color:"+colcolors[p+1]+"'>";
																					
												}
												
												dats[0] += coldata.charAt(o);
																							
											}										
											dats[0]+="</span>";										
																			
										}								
										
										if(coldata2!='')
										{
											//Should add carriage return here as well
											//****YET TO DO
											dats[2] = "<br><span style='color:"+colcolors[p+1]+"'>"+coldata2+"</span>";
																			
										}										
										
										
										//? doesnt really need closing tag
										if(dats[3]!='')
										{
											dats[3]+="</a>";
										}
										
										
										//this condition tests for alignment
										if(aligntext[p]=="c")
										{																	
											//newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"'><center><span style='font-size:16;color:"+colcolors[p+1]+"'>"+coldata+"</span></center></TD>";
											
											if(trowcount==2)
											{
											
											//alert(textfont[0]);
											
											
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></center></TD>";
											}
											else
											{
											//alert(textfont[0]);
											
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><center><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></center></TD>";
										
											}										
											
											//alert(newinner);								
										}
										else if(aligntext[p]!="c")
										{
											newinner +="<TD style='background-color:"+colcolors[0]+";width:"+tcellwidth[p]+"px'><span style='font-size:"+textfont[p]+"px;color:"+colcolors[p+1]+"'>"+ dats[0]+dats[1]+dats[2]+dats[3]+dats[4]+dats[5]+"</span></TD>";
										}												
										
										m++;	
										//reset column color
										colcolors[p+1]=holdcolor;
										
										
									}						
									
			                        newinner +="</TR><TR>";							 
							 
							}

							newinner +="</TR></TABLE>";																										
							
						}					
				 
						//***********************************************new table section*****************************************************
				 				

                else
                {

                   newinner += temp[(temp.length - 1)].charAt(m);

                }

                }			
								
				if(globe[1]=="textfunction")
				{
					
					
				 if(tooltipwidth>430)
				 {
					//add a little border
					tooltipwidth +=20;//
					//alert(tooltipwidth);
				 }
				 else
				 {
					tooltipwidth=430;
				 }
				 
				 //alert(tooltipwidth);
				 
				 var txt="";
				 txt += dojoholder+newinner+"</p>";
				 //alert(txt);
				 //return				 
				 
				 var backhex="#000000";
				 				 						
				 //Tip(txt,FOLLOWMOUSE, false,HEIGHT,-410,JUMPHORZ, true,FIX, ['title',138,27],FADEIN,700,FONTCOLOR, '#3A5FCD', BGCOLOR, backhex,SHADOW, true, TITLEBGCOLOR, '#808080',TITLEFONTCOLOR,cl[0][0],FONTSIZE,15,PADDING, 9);
				Tip(txt,CLOSEBTN, true,FOLLOWMOUSE, false,WIDTH,tooltipwidth,HEIGHT,540,JUMPHORZ, true,FIX, [50,10],FADEIN,700,FONTCOLOR, '#cc9900', BGCOLOR, backhex,TITLE,tit,TITLEBGCOLOR, '#808080',TITLEFONTCOLOR,'#272222',FONTSIZE,15,PADDING, 9);
		
				
				}
				/*
				else if(tit=="banner" || tit=="contentsbanner")
				{
                
					alert('in');
				//document.getElementById('dojoboxwriteup').innerHTML = str;
				return newinner
				}
				*/
				
				else
				{
				
				//alert(newinner);
				//document.getElementById('dojobox').innerHTML +=  newinner + "</p>" ;
				//document.getElementById('dojobox').innerHTML = dojoholder + newinner + "</p>" ;
				//alert('ok');
					if(ident=="Calendar")
					{
					//document.getElementById('calendar').style.visibility="visible";
					//document.getElementById('calendar').innerHTML += dojoholder + newinner + "</p>";
					tooltipwidth=775;
					var txt="";
					 txt += dojoholder+newinner+"</p>";
					 var backhex="#19212B";
					
					Tip(txt,CLOSEBTN, true,FOLLOWMOUSE, false,WIDTH,tooltipwidth,FIX,[50,50],JUMPHORZ, true,FADEIN,100,FONTCOLOR, '#cc6633', SHADOW, true,BGCOLOR, backhex,TITLE,tit,TITLEBGCOLOR, '#808080',TITLEFONTCOLOR,'#272222',FONTSIZE,15,PADDING, 9);
							
					
					}
					else
					{	
					document.getElementById('butcat').value=globe[0];
					if(tit!="startpage")
					{
					
					document.getElementById('dojobox').innerHTML += dojoholder + newinner + "</p>";
					}
					}		
				
				}	


				//alert(newinner);
				
				//NEED TO CALL THE BANNER SECTION HERE
				if(tit=="startpage")
				{				
					
					//alert('in');
					document.getElementById('lowermiddle').innerHTML="";
					document.getElementById('lowermiddle').innerHTML += dojoholder + newinner + "</p>";
				
					
					//alert('in');
					//LOADED ELSEWHERE
					/*
					var st = document.createElement('input');
					st.style.visibility = 'hidden';
					st.type = 'button';
					st.id = 'banner';
					st.value = 'banner';	
					banner(st);		
					*/
					
				}
				
				
				//}
				//else if(obj.id=="banner" || obj.id=="contentsbanner")
				//{
                //document.getElementById('dojoboxwriteup').innerHTML = str;
				//return newinner
				//}

            //}
//var loaddojo=myClientButton_onclick(xmlhttp.responseText);
//var response = xmlhttp.responseText;

//alert(xmlhttp.responseText);//ar[0]);
//document.getElementById('loadoption').innerHTML=xmlhttp.responseText;
//alert('startup option');
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function unwantedframes(){
//flash is a nuisance
if (document.getElementById('flash')== undefined) {
  
}
else {
  
  var iframe = parent.document.getElementById('flash');
iframe.parentNode.removeChild(iframe);
  
}				
}



