// <!--------------------------------------
//       File: sa_main.js
//   Language: javascript
//   Contents: Data and functions to drive functionality on body
//             pages on Sarand website (www.sarand.com).
//     Author: www.sarand.com (c) 2002-2006
// ----------------------------------------
var doc=window.document
var dToday=new Date
var sPlatform=navigator.platform
var sAppName=navigator.appName
var fAppVersion=parseFloat(navigator.appVersion)
var bIE=(sAppName.indexOf('Internet Explorer')>-1)
var bIE4=(bIE&&fAppVersion>=4);
var bNS=(sAppName.indexOf('Netscape')>-1)
var bNS4=(bNS&&fAppVersion>=4&&fAppVersion<5.0)
var bNS6=(bNS&&fAppVersion>=5)
var bWin=(sPlatform.indexOf("Win")==0)
var bMac=(sPlatform.indexOf("Mac")==0)
var bHdrPresent=false
var aMnu,oMnu,oOpt,oSct,sDirRel='',bDebug=0
var bLayers=document.layers
if (bNS)
{
	window.captureEvents(Event.RESIZE)
	window.onresize=function(){window.location.reload()}
}
//	#	#	#	#	#	#	#	#	#	#
function InitMenu()
{
	if(aMnu)return;
	aMnu=
	[
		{id:'site',display:'Home',href:'index.html',status:'Sarand home',hdrimg:'sarand.gif',opt:[
		]},
		{id:'bus',display:'Profile',href:'profile.html',hdrimg:'sarand.gif',opt:[
			{id:'whatdowedo',display:'What do we do?',href:'whatdowedo.html',status:'What do we do?',caption:'What do we do?',target:'_self',hdrimg:'background.gif'},
			{id:'whychoose',display:'Why choose us?',href:'whychoose.html',status:'Why choose us?',caption:'Why choose us?',target:'_self',hdrimg:'background.gif'},
			//{id:'case',display:'Case studies',href:'case_studies.html',status:'',target:'_self',hdrimg:'casestudies.gif'},
			{id:'philosophy',display:'Our Philosophy',href:'philosophy.html',status:'',target:'_self',hdrimg:'background.gif'},
			{id:'clients',display:'Clients',href:'clients.html',status:'',target:'_self',hdrimg:'background.gif'},
			{id:'partners',display:'Partners',href:'partners.html',status:'',target:'_self',hdrimg:'partners.gif'},
		]},
		{id:'prd',display:'Products',href:'products.html',hdrimg:'products.gif',opt:[
			{id:'busmgr',display:'Business Manager',href:'prd/businessmgr/businessmgr.html',status:'',target:'_self',hdrimg:'sapphire.gif'},
//			{id:'busmgr',display:'<span class="ManagerSuite"><span class="ManagerCaption">Business</span> Manager</span>',href:'prd/businessmgr/businessmgr.html',status:'',target:'_self',hdrimg:'sapphire.gif'},
			{id:'patmgr',display:'Patient Manager',href:'prd/patientmgr/patientmgr.html',status:'',target:'_self',hdrimg:'wardmanager.gif'},
			{id:'logmgr',display:'Logistics Manager',href:'prd/logisticsmgr/logisticsmgr.html',status:'',target:'_self',hdrimg:'quaysidemanager.gif'},
			//{id:'onion',display:'Onion TSC',href:'prd/onion/onion.html',status:'',target:'_self',hdrimg:'oniontsc.gif'},
		]},
		{id:'srv',display:'Services',href:'services.html',hdrimg:'services.gif',opt:[
			{id:'tech',display:'Technical consultancy',href:'srv_techcons.html',status:'Technical consultancy',target:'_self',hdrimg:'technicalconsultancy.gif'},
			{id:'bus',display:'Business consultancy',href:'srv_buscons.html',status:'Business consultancy',target:'_self',hdrimg:'businessconsultancy.gif'},
			{id:'dev',display:'Development',href:'srv_develop.html',status:'System development',target:'_self',hdrimg:'development.gif'},
			{id:'nhs',display:'<span class=\"NHS\">NHS</Span>&nbsp;Services',href:'srv_nhs.html',status:'NHS Services',target:'_self',hdrimg:'nhsservices.gif'},
			{id:'sage',display:'<span class=\"Sage\">Sage</Span>&nbsp;Extensions',href:'srv_sage.html',status:'Sage extensions',target:'_self',hdrimg:'sageextensions.gif'},
			{id:'winsingad',display:'WinSingad',href:'prd/winsingad/winsingad.html',status:'',target:'_self',hdrimg:'winsingad.gif'},
		]},
		{id:'contact',display:'Contact',href:'contact.html',status:'Contact Sarand',caption:'Contact Sarand',hdrimg:'contact.gif',opt:[
		]},
	];
}
function InitInfo()
{
	if(aInfo)return;
	aInfo=[	// Fields: <ValidFrom>,<ValidTo>,<Caption>,<Text>,<Link>,<Target>
		[new Date('2005 Jan 1'),,"Welcome","If you are looking to save time, improve process, impress your customers or get ahead with technology then Sarand have a solution for you.",""],
		[new Date('2005 Jan 1'),,"<span class=\"NHS\">NHS</Span>&nbsp;Services","Our theatre scheduling application has proven its worth at Addenbrooke's in Cambridge with a further implementation in the Day Surgery department.","prd/wardmgr/wardmgr.html"],
		[new Date('2005 Jan 1'),,"Automotive","Our successful upgrade to the HPI Consumer website has lead to Sarand now planning for a full scale rewrite into 2005.","srv_techcons.html"],
		[new Date('2005 Jan 1'),,"Academia","Our WinSingad audio analysis software has been featured in the 2004 Faraday lectures and academic papers.","prd/winsingad/winsingad.html"],
		[new Date('2005 Jan 1'),,"Quayside Management","Customers love the ease of use and time that is saved in gathering data and supplying it in real time to their custmers via websites.","prd/quayside/quayside.html"],
		[new Date('2005 Jan 1'),,"Eastern Region <span class=\"NHS\">NHS</Span>&nbsp;Innovations","Sarand have been invited to showcase their NHS products at '<i>Accessing Information on the Move in Real Time</i>'.","prd/wardmgr/wardmgr.html"],
	];
	iNextInfoMsg=rnd(aInfo.length)
}
//	#	#	#	#	#	#	#	#	#	#
function sa_body_load()
{
}
var aImgHdr;
function saBodyStart(mnu,opt,sub)
{
	Init(mnu,opt,sub)
	var imgHits=new Image;imgHits.src=sDirRel+'cgi-bin/SaHits.pl?count&loc='+document.location+'&res='+window.screen.width+'x'+window.screen.height+'&ref='+document.referrer;
	// Start page frame:
	dw("<link rel='icon' href='"+sDirRel+"img/ico/sarand.jpg' type='image/x-icon'>");
	dw("<link rel='shortcut icon' href='"+sDirRel+"img/ico/sarand.jpg' type='image/x-icon'>");
	dw("<div class='sarFrame'>")
	dw("<table cellpadding='0' cellspacing='0' border='0' width='100%'>")
	//if(bDebug)dw("<tr><td colspan='2'><div id='debug' class='debug'>Debug:</div></td></tr>");
	dw(tr(td(div("<img src='"+sDirRel+"img/logo/sarand.gif' border=0 alt='Sarand Business Software'/>","class='sarLogo'")+div(InfoPanel(),"class='sarInfo'"),"rowspan='2'")))
	dw("<tr><td width='100%'>")
	dw(table(tr(td(HdrContent(),"")),"width='100%' border='0' cellspacing='0' cellpadding='0'"))
	dw("<div class='sarBody'>")
}
function HdrCaption(obj,iLvl)
{
	if(obj&&obj.hdrimg)return"<img src='"+sDirRel+"img/hdr/"+obj.hdrimg+"' border='' alt='"+obj.display+"'/><br/>";
	var sLvl=parseInt(iLvl+'',10)
	return(obj?"<h"+sLvl+">"+(obj.caption?obj.caption:obj.display)+"</h"+sLvl+">":"")
}
function HdrContent()
{
	// Page caption:
	var divAttr=" style='text-align:right;height:120px;background-image:url("+sDirRel+"img/hdr/"+aImgHdr[rnd(aImgHdr.length)]+");background-repeat:no-repeat;background-position:bottom left;'"
	var s=div(HdrCaption(oMnu,1)+HdrCaption(oOpt,2),divAttr);
	// Navigation menu and date:
	s+="<div><table cellpadding='0' cellspacing='0' border='0' width='100%'>"
	s+=tr(td(NavMenu())+td(div(dToday.format('day<br/>DD-mon-YY'),"class='pageDate'"),"align='right'"),"class='navHdr'");
	s+="</table></div>"
	return s;
}
function saBodyEnd()
{
	// Complete page frame:
	dw("</div></td></tr>"+tr(td(saPageFooter(),"colspan='2'"))+"</table></div>")
	dw(tag("script","setTimeout('info_StartScroll()',20)", "type='text/javascript'"))
}
function saPageFooter()
{
	var sAtagEmail="<a href='mailto:contact@sarand.com?subject=website enquiry' Style='vertical-align:middle;' onMouseOver='Javascript:status=\"Email us with your enquiry\";return 1;' onmouseout='Javascript:status=\"\";return 1;'>"
	var s="<div class='SarFooter'><table cellspacing=0 cellpadding=0 border=0 width='100%'><tr>"
	s+=td(sAtagEmail+"contact@sarand.com</a><br/>&copy; 2000-"+dToday.format('YYYY')+" Sarand Ltd","class='FtrCopy'")
	s+=td("<img src='"+sDirRel+"img/hdr/ftranimation.gif' border='0' alt='Sarand Business Software'>","class='FtrCenter'")
	s+=td(sAtagEmail+"Email enquiries</a>","class='FtrRight'")
	s+="</tr></table></div>"
	return s
}
function Init(idMnu,idOpt,idSub)
{
	if(!dToday)dToday=new Date;
	InitMenu()
	IdRelDir()
	aImgHdr = ['sarand01.jpg','manufacture01.jpg','quayside01.jpg','quayside02.jpg','quayside03.jpg','quayside04.jpg','quayside05.jpg','quayside06.jpg','quayside07.jpg'];
	// Identify the menu, option, sub-option combination:
	for(var iMnu=0;aMnu&&iMnu<aMnu.length;iMnu++)
	{
		var mnu=aMnu[iMnu];if(!mnu||mnu.id!=idMnu)continue;oMnu=mnu;
		var aOpt=mnu.opt;for(var iOpt=0;aOpt&&iOpt<aOpt.length;iOpt++)
		{
			var opt=aOpt[iOpt];if(!opt||opt.id!=idOpt)continue;oOpt=opt;
			var aSub=opt.sub;for(var iSub=0;aSub&&iSub<aSub.length;iSub++)
			{var sub=aSub[iSub];if(!sub||sub.id!=idSub)continue;oSub=sub;break;}break;
		}break;
	}
}
function getMnuByPos(i){if(i>=0&&aMnu&&aMnu.length>i)return aMnu[i];}
//	#	#	#	#	#	#	#	#	#	#
// Navigation menu dropdowns:
var idDivNavMnuPre='mnu',idDivNavMnuAPre='mnuA',idDivNavOptPre='opt'
function NavMenu()
{
	function MOver(mnu){return" onmouseover='javascript:window.status=\""+(mnu.status?mnu.status:mnu.display)+"\";return NavMenuMOver(this,event);'";}
	function MOut(mnu){return" onmouseout='javascript:window.status=\"\";return NavMenuMOut(this,event);'";}
	function MenuHdr(mnu,iMnu){return div(NavLink(mnu,"NavMnu",iMnu),"<div id='"+idDivNavMnuPre+printf("%02d",iMnu)+"' class='navMnu'"+MOver(mnu)+MOut(mnu))}
	InitMenu()
	var s="<table cellpadding='0' cellspacing='0' border='0'><tr class='navMnu'>"+td("&nbsp;")
	for(var iMnu=0;iMnu<aMnu.length;iMnu++)
	{
		var mnu=aMnu[iMnu]
		if(!mnu||!mnu.display)continue;
		s+=td(MenuHdr(mnu,iMnu),"valign='bottom'")
	}
	s+="</tr></table>"+div("","id='mnuDrop' class='mnuDrop' onmouseout='javascript:return NavMenuMOut(this,event);'")+div("","id='mnuDropBG' class='mnuDropBG'");
	return s;
}
function NavLink(item,cn,iMnu)
{
	return (item.href?"<a id='"+idDivNavMnuAPre+iMnu+"' href='"+sDirRel+item.href+"'"+(cn?" class='"+cn+"'":"")+(item.target?" target='"+item.target+"'":"")+" onMouseOver='return omOver(\""+(item.status?item.status:item.display)+"\")' onMouseOut='return omOut()'>":"")+item.display+(item.href?"</a>":"");
}
var divMnuHdr,divOptDrop,divOptDropBG;
function NavMenuMOver(div,evt)
{
	if(!div)return;if(!evt)evt=window.event;NavHideDrop(evt,1)
	var iMnu=div?parseInt(div.id.substr(3,2),10):-1
	var mnu=getMnuByPos(iMnu);if(!mnu.opt||!mnu.opt.length)return;
	aMnuHdr=getElement(idDivNavMnuAPre+iMnu);divOptDrop=getElement('mnuDrop');divOptDropBG=getElement('mnuDropBG');var posMnu=getPos(div);
	if (divOptDrop&&divOptDropBG&&posMnu&&mnu&&mnu.opt)
	{
		divMnuHdr=div;var s='',aOpt=mnu.opt;
		divMnuHdr.className='navMnuHover';
		if(aMnuHdr)aMnuHdr.className='navMnuSel';
		for(var i=0;aOpt&&i<aOpt.length;i++)
		{
			var opt=aOpt[i];
			if(!opt||!opt.display)continue;
			s+=NavLink(opt,"NavSct")+'<br/>';
		}
		divOptDrop.innerHTML=s;
		divOptDrop.style.left=(posMnu.x)+'px';divOptDrop.style.top=(posMnu.y+posMnu.height)+'px';
		divOptDrop.style.visibility='visible';
		posDrop=getPos(divOptDrop);
		if (getPos)
		{
			var offset=5
			divOptDropBG.style.left=(posDrop.x+offset)+'px';divOptDropBG.style.top=(posDrop.y+offset)+'px';
			divOptDropBG.style.width=(posDrop.width)+'px';divOptDropBG.style.height=(posDrop.height)+'px';
			divOptDropBG.style.visibility='visible';
		}
	}
	return true;
}
function NavMenuMOut(div,evt){NavHideDrop(evt);return true;}
function NavHideDrop(evt,bForce)
{
	if(!evt)evt=window.event;if(!divMnuHdr||!divOptDrop||!divOptDropBG)return;
	// Is the mouse still within the menu or its dropdown:
	if(!bForce&&evt)
	{
		var iMouseX=(evt.x?evt.x:evt.pageX),iMouseY=(evt.y?evt.y:evt.pageY);
		var posHdr=getPos(divMnuHdr),posDrop=getPos(divOptDrop)
		if(iMouseX>=posHdr.x+2&&iMouseX<=posHdr.x+posHdr.width&&iMouseY>=posHdr.y+2&&iMouseY<=posHdr.y+posHdr.height+1)return;
		if(iMouseX>=posDrop.x+2&&iMouseX<=posDrop.x+posDrop.width-1&&iMouseY>=posDrop.y+2&&iMouseY<=posDrop.y+posDrop.height-1)return;
	}
	divMnuHdr.className='navMnu';
	if(aMnuHdr)aMnuHdr.className='navMnu';
	divOptDrop.style.visibility='hidden'
	divOptDropBG.style.visibility='hidden'
	divMnuHdr=null,divOptDrop=null;
}
//	#	#	#	#	#	#	#	#	#	#
// Information panel:
function NavOpt(item,cn){return tr(td(NavLink(item,cn),(cn?" class='"+cn+"'":"")+" nowrap"));}
function InfoPanel()
{
	var s='';
	// Hot topics:
	s+=div("Current Topics","class='sarInfoCaption'")
	s+=div(InfoScroller(),"class='sarInfoContent'")
	// Navigation menu:
	InitMenu()
	if(oMnu)
	{
		s+=div("This Section","class='sarInfoCaption'")
		s+="<div class='sarInfoContent'><table border='0' cellspacing='0' cellpadding='1'>"
		s+=NavOpt(oMnu,"navMnu")
		for(var iOpt=0;oMnu.opt&&oMnu.opt.length&&iOpt<oMnu.opt.length;iOpt++)
		{
			var opt=oMnu.opt[iOpt]
			if(opt)s+=NavOpt(opt,"navSct");
		}
		s+="</table></div>"
	}
	s+=div("<a href='http://cb9haverhill.co.uk/' target='_blank'><img src='"+sDirRel+"img/logo/havcb9.gif' alt='Haverhill CB9 - Impetus, buoyancy and optimism' border='0'></a>","style='width:100%;text-align:center;'")
	s+=div("<img src='"+sDirRel+"img/logo/sagedev.jpg' alt='Sage Developer' border='0'>","style='width:100%;padding-top:8px;text-align:center;'")
	s+=div("<img src='"+sDirRel+"img/logo/msregpartner.gif' alt='Microsoft Registered Partner' border='0'>","style='width:100%;padding-top:8px;text-align:center;'")
	return s
}
//	#	#	#	#	#	#	#	#	#	#
// Pausing message scroller.
// From an original by www.dynamicdrive.com.
// Configure the below five variables to change the style of the scroller:
var iInfoWidth=140
var iInfoHeight=155
var divInfo,divInfoTop,divInfoBtm
var iDelayDisplay=4000,iDelayScroll=20,iScrollRate=2
// Configure the array below to change the contents of the scroller:
var aInfo,iNextInfoMsg
function InfoScroller()
{
	InitInfo()
	var s=""
	s+="<div class='sarScroller'>";
	s+="<div id='divScrollBox' class='sarScrollBox'>";
	s+=div(NextInfoMsg(),"id='divScroll1' class='sarScrollMsg'");
	s+=div(NextInfoMsg(),"id='divScroll2' class='sarScrollMsg'");
	s+="</div>"+div("","class='sarScrollBody'")+"</div>"
	return s;
}
function NextInfoMsg()
{
	// Validate next message position:
	if (iNextInfoMsg<0)iNextInfoMsg=0
	if (iNextInfoMsg>=aInfo.length)iNextInfoMsg=0
	if(!aInfo[iNextInfoMsg]){iNextInfoMsg++;return NextInfoMsg()}
	// If this message is not valid for the current date, move to next:
	if(aInfo[iNextInfoMsg][0]&&aInfo[iNextInfoMsg][0]>dToday){iNextInfoMsg++;return NextInfoMsg()}
	if(aInfo[iNextInfoMsg][1]&&aInfo[iNextInfoMsg][1]<dToday){iNextInfoMsg++;return NextInfoMsg()}
	// Retrieve the bits of the message:
	var sMsgHead=aInfo[iNextInfoMsg][2]
	var sMsgBody=aInfo[iNextInfoMsg][3]
	var sMsgLink=aInfo[iNextInfoMsg][4]
	var sMsgTarget=(aInfo[iNextInfoMsg][5]?" target='"+aInfo[iNextInfoMsg][5]+"'":"")
	// Build the next message:
	var sBody=''
	if(sMsgHead.length)sBody+="<Span class='SarInfoHead'>"+sMsgHead+"</Span><br>"
	sBody+=sMsgBody
	if(sMsgLink.length)sBody+="<div class='viewDetails'><a href='"+sDirRel+sMsgLink+"' "+sMsgTarget+">view details >></a></div>"
	iNextInfoMsg++;  // Increment message position for next iteration.
	return sBody;
}
function info_StartScroll()
{
	divInfo=getElement('divScrollBox')
	divInfoTop=getElement('divScroll1')
	divInfoBtm=getElement('divScroll2')
	if(divInfo&&divInfoTop&&divInfoBtm)
	{
		var posBox=getPos(divInfo)
		divInfoTop.style.top='0px';
		divInfoBtm.style.top=(posBox.height+10)+'px';
		divInfoTop.style.visibility='visible'
		divInfoBtm.style.visibility='visible'
		setTimeout("infoScrollDivs()",iDelayDisplay);
	}
}
// Moving the information blocks around:
function infoScrollDivs()
{
	if(!divInfo||!divInfoTop||!divInfoBtm)return;
	var posBox=getPos(divInfo);var posTop=getPos(divInfoTop);var posBtm=getPos(divInfoBtm)
	if(posBtm.y-posBox.y>iScrollRate)
	{
		divInfoTop.style.top=(parseInt(divInfoTop.style.top,10)-iScrollRate)+'px';
		divInfoBtm.style.top=(parseInt(divInfoBtm.style.top,10)-iScrollRate)+'px';
		setTimeout("infoScrollDivs()",iDelayScroll)
		return;
	}
	// Swap panes:
	var divInfoTemp=divInfoTop;
	divInfoTop=divInfoBtm;
	divInfoBtm=divInfoTemp;
	// Top pane goes to top, bottom to below visible area:
	divInfoTop.style.top='0px';
	divInfoBtm.style.top=(posBox.height+10)+'px';
	// Bottom pane gets next message:
	divInfoBtm.innerHTML=NextInfoMsg()
	setTimeout("infoScrollDivs()",iDelayDisplay)
}
//	#	#	#	#	#	#	#	#	#	#
// Basic, raw functionality:
function di(){if(!doc)doc=window.document;}
function dw(s){di();doc.write(s);}
function getElement(id)
{
	if(doc.getElementById)return doc.getElementById(id);
	if(doc.all)return doc.all[id];
	if(doc.layers)return doc.layers[id];
	return doc[id]
}
function rnd(iTop){return Math.round(Math.random()*(iTop-1));}
function undef(o){return typeof o=='undefined'}
// Event handling:
// Swap image and display caption on status bar - called on mouseOver/Out:
function omOver(sCaption,imgTgt,imgSrc){if(imgTgt&&imgSrc)imgTgt.src=imgSrc.src;status=sCaption;return true;}
function omOut(imgTgt,imgSrc){if(imgTgt&&imgSrc)imgTgt.src=imgSrc.src;status='';return true;}
// Convert control value to upper case - called on input.onChange:
function upperCtrl(ctrl){if(ctrl&&ctrl.value&&ctrl.value.length)ctrl.value=ctrl.value.toUpperCase();return true;}
// Return x:y coordinates of the object, relative to the page.
function getPosById(id){return getPos(getElement(id))}
function getPos(obj)
{
	var x=0,y=0,h=0,w=0;
	if(!obj)return;
	// Find object position:
	if(doc.getElementById||doc.all)
	{
		x=getPageOffsetLeft(obj)
		y=getPageOffsetTop(obj)
	}
	else if(doc.layers)
	{
		x=obj.x;
		y=obj.y;
	}
	h=(obj.offsetHeight?obj.offsetHeight:obj.clientHeight)
	w=(obj.offsetWidth?obj.offsetWidth:obj.clientwidth)
	return {x:parseInt(x,10),y:parseInt(y,10),height:parseInt(h,10),width:parseInt(w,10)};
}
// Return x:y coordinates of the object, relative to the screen.
function getPosScreenById(id){return getPosScreen(getElement(id))}
function getPosScreen(obj)
{
	var pos=getPos(obj);
	if (isNaN(window.screenX))
	{
		pos.x=pos.x-document.body.scrollLeft+window.screenLeft;
		pos.y=pos.y-document.body.scrollTop+window.screenTop;
	}
	else
	{
		pos.x=pos.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		pos.y=pos.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
	}
	return pos;
}
// IE functions to get object's position.
function getPageOffsetLeft(o){if(!o||undef(o.offsetLeft))return 0;var ol=0;do{ol+=o.offsetLeft;o=o.offsetParent;}while(o!=null);return ol;}
function getWindowOffsetLeft(o){return getPageOffsetLeft(o)-doc.body.scrollLeft;}
function getPageOffsetTop(o){var ot=o.offsetTop;while((o=o.offsetParent)!=null){ot+=o.offsetTop;}return ot;}
function getWindowOffsetTop(o){return getPageOffsetTop(o)-doc.body.scrollTop;}
// Trap Javascript exceptions:
onerror=function(sErr,sUrl,iLine)
{
	var msg = "A script error has been identified on this page.\n\n"
	msg += "Click OK to continue.\n\nError: "+sErr+"\n"
	msg += "URL: "+sUrl+"\nLine: "+iLine
	alert(msg)
	return true
}
function IdRelDir()
{
	// The 'relative directory' identifies how to locate files in the
	// root on the web server relative to the current page's location.
	// 1. Retrieve document location:
	sDirRel='';var sLoc=new String(doc.location)
	// 2. Convert back-slashes to forward-slashes:
	sLoc=sLoc.replace(new RegExp('\\\\','g'),'/')
	// 3. Check for local file paths:
	var sFolderLocal='/Live/htdocs/'
	var iPosFolderLocal=sLoc.indexOf(sFolderLocal)
	if (iPosFolderLocal>-1){sLoc=sLoc.substring(iPosFolderLocal+sFolderLocal.length);bDebug=1}
	// 4. Strip from first slash after double slashes (//domain/path etc):
	var iPosDoubleSlash=sLoc.indexOf('//')
	if(iPosDoubleSlash>-1)
	{
		var iPosFirstSlash=sLoc.indexOf('/',iPosDoubleSlash+2);
		if(iPosFirstSlash>-1)sLoc=sLoc.substring(iPosFirstSlash+1);
	}
	// 5. Strip to last forward slash:
	var iPosLastSlash=sLoc.lastIndexOf('/')
	if(iPosLastSlash>-1)
	{
		sLoc=sLoc.substring(0,iPosLastSlash);sDirRel+='../';
		// 6. Relative directory has a 'parent' folder for each remaining slash:
		for(i=0;i<sLoc.length;i++){if(sLoc.charAt(i)=='/')sDirRel+='../';}
	}
}
/* Generate standard tags */
function tag(t,s,a){return"<"+t+(a?" "+a:"")+">"+s+"</"+t+">"}
function div(s,a){return tag("div",s,a)}
function table(s,a){return tag("table",s,a)}
function tr(s,a){return tag("tr",s,a)}
function td(s,a){return tag("td",s,a)}
function debug(s){if(!bDebug)return;var div=getElement('debug');if(div)div.innerHTML=s;}
//	#	#	#	#	#	#	#	#	#	#
// Additional string methods:
String.prototype.trim=function()
{
	// Trim leading, trailing and multiple internal spaces:
	return this.replace(/^\s*/,"").replace(/\s*$/,"").replace(/ +/g," ");
}
String.prototype.strip=function(sStrip)
{
	if(undef(sStrip)||!sStrip.length)return this;
	var re=new RegExp (sStrip,'g') ;
	return this.replace(re,"");
}
//	#	#	#	#	#	#	#	#	#	#
// Function printf(format_string,arguments...)
// Javascript emulation of the printf function (modifiers and argument types
// "p" and "n" are not supported due to language restrictions)
// Copyright 2003 K&L Productions. All rights reserved http://www.klproductions.com
// Terms of use: This function can be used free of charge IF this header is not
//               modified and remains with the function code.
var aConv;
function printf(fs)
{
	var pad=function(s,c,l){var ps='';for(var i=0;i<Math.abs(l);i++)ps+=c;return l>0?s+ps:ps+s;}
	var processFlags = function(flags,width,rs,arg)
	{
		var pn=function(flags,arg,rs){if(arg>=0){if(flags.indexOf(' ')>=0)rs=' '+rs;else if(flags.indexOf('+')>=0)rs='+'+rs;}else rs='-'+rs;return rs;}
		var iWidth=parseInt(width,10);
		if(width.charAt(0)=='0'){var ec=0;if(flags.indexOf(' ')>=0||flags.indexOf('+')>=0)ec++;if(rs.length<(iWidth-ec))rs=pad(rs,'0',rs.length-(iWidth-ec));return pn(flags,arg,rs);}
		rs=pn(flags,arg,rs);
		if(rs.length<iWidth){if(flags.indexOf('-')<0)rs=pad(rs,' ',rs.length-iWidth);else rs=pad(rs,' ',iWidth-rs.length);}
		return rs;
	}
	if(undef(aConv))
	{
		aConv=new Array;
		aConv['c']=function(flags,width,prec,arg){if(typeof(arg)=='number')return String.fromCharCode(arg);if(typeof(arg)=='string')return arg.charAt(0);return '';}
		aConv['d']=function(flags,width,prec,arg){return aConv['i'](flags,width,prec,arg);}
		aConv['u']=function(flags,width,prec,arg){return aConv['i'](flags,width,prec,Math.abs(arg));}
		aConv['i']=function(flags,width,prec,arg){var iPrec=parseInt(prec);var rs=((Math.abs(arg)).toString().split('.'))[0];if(rs.length<iPrec)rs=pad(rs,' ',iPrec-rs.length);return processFlags(flags,width,rs,arg);}
		aConv['E']=function(flags,width,prec,arg){return(aConv['e'](flags,width,prec,arg)).toUpperCase();}
		aConv['e']=function(flags,width,prec,arg){iPrec=parseInt(prec);if(isNaN(iPrec))iPrec=6;rs=(Math.abs(arg)).toExponential(iPrec);if(rs.indexOf('.')<0&&flags.indexOf('#')>=0)rs=rs.replace(/^(.*)(e.*)$/,'$1.$2');return processFlags(flags,width,rs,arg);}
		aConv['f']=function(flags,width,prec,arg){iPrec=parseInt(prec);if(isNaN(iPrec))iPrec=6;rs=(Math.abs(arg)).toFixed(iPrec);if(rs.indexOf('.')<0&&flags.indexOf('#')>=0)rs=rs+'.';return processFlags(flags,width,rs,arg);}
		aConv['G']=function(flags,width,prec,arg){return(aConv['g'](flags,width,prec,arg)).toUpperCase();}
		aConv['g']=function(flags,width,prec,arg)
			{iPrec=parseInt(prec);absArg=Math.abs(arg);rse=absArg.toExponential();rsf=absArg.toFixed(6);if(!isNaN(iPrec)){rsep=absArg.toExponential(iPrec);rse=rsep.length<rse.length?rsep:rse;rsfp=absArg.toFixed(iPrec);rsf=rsfp.length<rsf.length?rsfp:rsf;}
			if(rse.indexOf('.')<0&&flags.indexOf('#')>=0)rse=rse.replace(/^(.*)(e.*)$/,'$1.$2');if(rsf.indexOf('.')<0&&flags.indexOf('#')>=0)rsf=rsf+'.';rs=rse.length<rsf.length?rse:rsf;return processFlags(flags,width,rs,arg);}
		aConv['o']=function(flags,width,prec,arg){var iPrec=parseInt(prec);var rs=Math.round(Math.abs(arg)).toString(8);if(rs.length<iPrec)rs=pad(rs,' ',iPrec-rs.length);if(flags.indexOf('#')>=0)rs='0'+rs;return processFlags(flags,width,rs,arg);}
		aConv['X']=function(flags,width,prec,arg){return(aConv['x'](flags,width,prec,arg)).toUpperCase();}
		aConv['x']=function(flags,width,prec,arg){var iPrec=parseInt(prec);arg=Math.abs(arg);var rs=Math.round(arg).toString(16);if(rs.length<iPrec)rs=pad(rs,' ',iPrec-rs.length);if(flags.indexOf('#')>=0)rs='0x'+rs;return processFlags(flags,width,rs,arg);}
		aConv['s']=function(flags,width,prec,arg){var iPrec=parseInt(prec);var rs=arg;if(rs.length>iPrec)rs=rs.substring(0,iPrec);return processFlags(flags,width,rs,0);}
	}
	var farr=fs.split('%');
	var s=farr[0];
	var fpRE=/^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;
	for(var i=1;i<farr.length;i++){fps=fpRE.exec(farr[i]);if(!fps)continue;arg=arguments[i];if(arg!=null)s+=aConv[fps[4]](fps[1],fps[2],fps[3],arg);s+=fps[5];}
	return s;
}
//	#	#	#	#	#	#	#	#	#	#
// Additional date methods:
//    Format - accepts any variation of the following list:
//      YYYY     4-digit year eg. 2002
//      YY       2-digit year eg. 02
//      month    full month eg. September
//      mon      first three letters of the month eg. Sep
//      MM       number of the month (always 2-digit) eg. 09
//      hh       hours eg. 3
//      mm       minutes (always 2-digit) eg. 05
//      ss       seconds (always 2-digit) eg. 08
//      ddd      first three letters of the day eg. Wed
//      DD       numerical day of the month - i.e, 25
//      day      full day of the week eg. Wednesday
//      timezone the timezone in hours from GMT eg. GMT+5
//      time24   based on a 24 hour clock eg. 18:24
//      time     based on am/pm eg. 6:24PM
//  example:
//      myDate = newDate()
//      myDate.format("day, month dd, yyyy hh:mm:ss timezone")
//      returns "Wednesday, September 25, 2002 12:14:11 GMT-5"
Date.prototype.Months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
Date.prototype.Days   = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
Date.prototype.format = function(sFmt)
{
	var sDate=new String(sFmt)
	sDate=sDate.replace(new RegExp("YYYY","g"),this.getFullYear());// 4 digit year.
	sDate=sDate.replace(new RegExp("YY","g"),new String(this.getFullYear()).substring(2,4));// 2 digit year.
	sDate=sDate.replace(new RegExp("month","gi"),this.Months[this.getMonth()]);// Full month name.
	sDate=sDate.replace(new RegExp("mon","gi"),new String(this.Months[this.getMonth()]).substring(0,3));// 3 char month abbreviation.
	var sMM=new String((this.getMonth()<9?'0':'')+this.getMonth()+1)
	sDate=sDate.replace(new RegExp("MM","g"),(sMM));// 2 digit month.
	sDate=sDate.replace(new RegExp("day","gi"),this.Days[this.getDay()]);// Full day name.
	sDate=sDate.replace(new RegExp("ddd","gi"),new String(this.Days[this.getDay()]).substring(0,3));// 3 letter day abbreviation.
	var sDD=new String((this.getDate()<10?'0':'')+this.getDate())
	sDate=sDate.replace(new RegExp("DD","g"),sDD);// 2 digit day of month.
	// hh    is hours eg. 3
	sDate=sDate.replace(new RegExp("hh","gi"),this.getHours());
	// mm    is minutes (always 2-digit) eg. 05:
	var mm=new String(this.getMinutes());
	if(mm.length==1)mm="0"+mm; // Pad if single digit.
	sDate = sDate.replace(new RegExp("mm", "g"), mm);
	// ss    is seconds (always 2-digit) eg. 08
	var ss=new String(this.getSeconds());
	if(ss.length==1)ss="0"+ss; // Pad if single digit.
	sDate=sDate.replace(new RegExp("ss","gi"),ss);
	// Timezone is the the timezone in hours from GMT eg. GMT+5
	var tz=this.getTimezoneOffset();
	timezone="";
	if(tz<0)       timezone="GMT-"+tz/60;
	else if(tz==0) timezone="GMT";
	else           timezone="GMT+"+tz/60;
	sDate=sDate.replace(new RegExp("timezone","gi"),timezone);
	// Time24   is the time based on a 24 hour clock eg. 18:24:
	var mins=new String(this.getMinutes());
	if(mins.length==1)mins="0"+mins; // Pad if single digit.
	var time24=new String(this.getHours()+":"+mins);
	sDate=sDate.replace(new RegExp("time24","gi"),time24);
	// Time is the time based on am/pm eg. 6:24PM:
	var time;
	var ampm;
	var hour=this.getHours();
	if(hour<12){if(hour==0)hour=12;ampm="AM";}
	else{if(hour!=12)hour-=12;ampm="PM";}
	time=new String(hour+":"+mins+ampm);
	sDate=sDate.replace(new RegExp("time","gi"),time );
	return sDate;
}
Date.prototype.setWeekStart=function()
{
	// Change to most recent Monday:
	while(this.getDay()!=1)this.decrDate();
}
Date.prototype.clearTime=function()
{
	// Clear the time values (leaving a pure date):
	//this.setTime (parseInt((this.getTime()/86400000)+'',10)*86400000);
	return this;
}
Date.prototype.incrDate=function(iDays)
{
	// Increment the date (by one day):
	if(undef(iDays)||iDays*1<1)iDays=1;
	this.clearTime();
	this.setTime(this.getTime()+(86400000*iDays));
	return this;
}
Date.prototype.decrDate=function(iDays)
{
	// Increment the date (by one day):
	if(undef(iDays)||iDays*1<1)iDays=1;
	this.clearTime();
	this.setTime(this.getTime()-(86400000*iDays));
	return this;
}
//	#	#	#	#	#	#	#	#	#	# -->
