var slide =	[0,1,2,3,4,5,6,7,8,10,12,14,16,18,20,23,26,29,32,36,40,44,48,52,56,60,64,68,71,74,77,80,82,84,86,88,90,91,92,93,94,91,96,97,98,99,100];
var swift =	[0,2,4,6,8,12,16,20,26,32,40,48,56,64,71,77,82,86,90,92,94,96,98,100];
var slice = [0,0.125,0.25,0.5,0.75,1,1.33,1.67,2,2.5,3,4,6,9,12,16,20,25,30,35,40,50,60,80,100];
var slip = [0,10,20,40,100]

var NONE		= 0;
var ROTATE 		= 1;
var SCALE		= 2;
var TRANSLATE	= 4;
var TRANSFORM	= ROTATE|SCALE|TRANSLATE;
var LOCK		= 8;
var NORTH		= 16;
var SOUTH		= 32;
var EAST		= 64;
var WEST		= 128;

var vpw = 800;
var vph = 600;
var vpcx = 400;
var vpcy = 300;

var ua = "xx";

var waiter = null;
var tick = 0;

var panes = [null];

var xhrhalt = false;
var xhrstack = [[""]];
var xhractive = 0;
var xhrclear = null;
var vistrans = null;
var vispd = 10;
var anim_on = true;

var pHelp;
var pFast;
var pTagline;
var pFSB;
var pLogo;
var pBullets;
var pHelpCap;
var pAfford;
var pCap2;
var pSocial;
var pCompete;
var pCap3;
var pContact;
var pReader;
var pGo1;

function ready() {
	viewportSetup();
	
	waiter = dgebi("waiter");

	setInterval(animate,100);
	if ((ua=="ie7") || (ua=="ie")) {
		setInterval(run3D,1);
	} else if (ua=="op") {
		setInterval(run3D,15);
	} else {
		setInterval(run3D,10);
	}
	
	var contact = "<div id=\"contactzone\"><div><h1>Contact Us</h1>Use the form below to contact us for more information";
		contact+= "<br><br>";
		contact+= "<table width=\"95%\" cellspacing=\"0\" cellpadding=\"0\">";
		contact+= "<tr>";
		contact+= "<th>Your&nbsp;Name</th>";
		contact+= "<td><input id=c_name name=name></td>";
		contact+= "</tr>";
		contact+= "<tr>";
		contact+= "<th>Your&nbsp;Company</th>";
		contact+= "<td><input id=c_company name=company></td>";
		contact+= "</tr>";
		contact+= "<tr>";
		contact+= "<th>Your&nbsp;Email</th>";
		contact+= "<td><input id=c_email name=email></td>";
		contact+= "</tr>";
		contact+= "<tr>";
		contact+= "<th>Your&nbsp;Phone</th>";
		contact+= "<td><input id=c_phone name=phone></td>";
		contact+= "</tr>";
		contact+= "<tr>";
		contact+= "<th>Optional<br>Message</th>";
		contact+= "<td><textarea name=message></textarea></td>";
		contact+= "</tr>";
		contact+= "<tr>";
		contact+= "<th>&nbsp;</th>";
		contact+= "<td><button name=submit onClick=\"sendContact()\">Send</button></td>";
		contact+= "</tr>";
		contact+= "</table>";
		contact+= "</div>";
	
	pFast = new FlatPane("imgs/fast.png",-999,-999,67,0)
	pFast.addTask( new WaitTask(100) );
	pFast.addTask( new YOrientationTask() );
	pFast.addTask( new MoveTask(-100,10,35,10) );
	pFast.addTask( new DelayTask() );

	pTagline = new FlatPane("imgs/tagline.png",-999,-999,67,0)
	pTagline.addTask( new WaitTask(120) );
	pTagline.addTask( new YOrientationTask() );
	pTagline.addTask( new MoveTask(-100,20,35,20) );
	pTagline.addTask( new DelayTask() );

	pFSB = new FlatPane("imgs/fsb.png",50,125,0,10);
	pFSB.addTask( new WaitTask(250) );
	pFSB.addTask( new MoveTask(50,125,50,94) );
	pFSB.addTask( new DelayTask() );
	pFSB.addTask( new WaitTask(250) );
	pFSB.addTask( new FadeTask(1,0) );
	pFSB.addTask( new DelayTask() );
	pFSB.addTask( new JumpTask(-999,-999) );

	pLogo = new FlatPane("imgs/logo.png",90,6,10,0);
	pLogo.addTask( new HideTask() );
	pLogo.addTask( new JumpTask(90,6) );
	pLogo.addTask( new WaitTask(50) );
	pLogo.addTask( new FadeTask(0,1) );

	pBullets = new TextPane("<ul><li>Need better management information?</li><li>Want to impress your customers?</li><li>Need to make better use of your resources?</li><li>Challenging targets to meet?</li><li>Continuing professional development essential?</li></ul>",-999,-999,25,33);
	pBullets.addTask( new HideTask() );
	pBullets.addTask( new JumpTask(16,40) );
	pBullets.addTask( new WaitTask(175) );
	pBullets.addTask( new FadeTask(0,1) );

	pHelpCap = new TextPane("<center><b style='font-size:200%'>Help is at Hand...</b></center>",-999,-999,33,10);
	pHelpCap.addTask( new HideTask() );
	pHelpCap.addTask( new JumpTask(50,80) );
	pHelpCap.addTask( new WaitTask(200) );
	pHelpCap.addTask( new FadeTask(0,1) );
	pHelpCap.addTask( new DelayTask() );
	pHelpCap.addTask( new WaitTask(200) );
	pHelpCap.addTask( new MoveTask(50,80,16,80) );

	pHelp = new FlatPane("imgs/help.png",-999,-999,33,0);
	pHelp.addTask( new JumpTask(50,50) );
	pHelp.addTask( new HideTask() );
	pHelp.addTask( new WaitTask(225) );
	pHelp.addTask( new FadeTask(0,1) );
	pHelp.addTask( new DelayTask() );
	pHelp.addTask( new WaitTask(200) );
	pHelp.addTask( new FadeTask(1,0) );

	pAfford = new TextPane("<b style='font-size:125%'>Affordable Investments</b>",-999,-999,33,10),
	pAfford.addTask( new HideTask() );
	pAfford.addTask( new JumpTask(50,30) );
	pAfford.addTask( new WaitTask(500) );
	pAfford.addTask( new FadeTask(0,1) );

	pCap2 = new TextPane("There is no big capital outlay on new equipment or software. Nor do you have to recruit technical specialists or send your staff away on expensive training courses. We guarantee to provide you with all the training and support if and when you need it.",-999,-999,33,20),
	pCap2.addTask( new HideTask() );
	pCap2.addTask( new JumpTask(50,40) );
	pCap2.addTask( new WaitTask(520) );
	pCap2.addTask( new FadeTask(0,1) );

	pCompete = new TextPane("<b style='font-size:125%'>Get a Competitive Edge</b>",-999,-999,33,10),
	pCompete.addTask( new HideTask() );
	pCompete.addTask( new JumpTask(50,55) );
	pCompete.addTask( new WaitTask(530) );
	pCompete.addTask( new FadeTask(0,1) );
	pCompete.addTask( new DelayTask() );

	pCap3 = new TextPane("Using Gilt-Edged Management Systems gives your organisation a competitive edge. Your customers have direct and instant access to any information relevant to them without having to contact your staff all the time.",-999,-999,33,20),
	pCap3.addTask( new HideTask() );
	pCap3.addTask( new JumpTask(50,65) );
	pCap3.addTask( new WaitTask(540) );
	pCap3.addTask( new FadeTask(0,1) );

	pSocial = new FlatPane("imgs/social.png",-999,-999,20,0);
	pSocial.addTask( new JumpTask(-16,60) );
	pSocial.addTask( new WaitTask(500) );
	pSocial.addTask( new MoveTask(-16,60,16,60) );
	
	pReader = new FlatPane("imgs/reader.png",-999,-999,0,20);
	pReader.addTask( new JumpTask(150,80) );
	pReader.addTask( new WaitTask(310) );
	pReader.addTask( new MoveTask(150,85,85,85) );
	pReader.addTask( new DelayTask() );

	pContact= new TextPane(contact,-999,-999,30,50),
	pContact.setOverflow("visible");
	pContact.addTask( new HideTask() );
	pContact.addTask( new JumpTask(85,40) );
	pContact.addTask( new WaitTask(300) );
	pContact.addTask( new FadeTask(0,1) );

	pGo1 = new Pane("imgs/continue.png",-999,-999,10,0);
	pGo1.onClick( page2 );
	pGo1.addTask( new JumpTask(-20,94) );
	pGo1.addTask( new WaitTask(550) );
	pGo1.addTask( new MoveTask(-20,94,50,94) );

	panes = [pHelp,pFast,pTagline,pFSB,pLogo,pBullets,pHelpCap,pAfford,pCap2,pSocial,pCompete,pCap3,pContact,pReader,pGo1];
	var i = -1;
	while (++i < panes.length) panes[i].runQueue();
}
function page2() {
	pGo1.addTask( new BounceTask( pGo1.z(), 3 ) );
	pGo1.addTask( new DelayTask() );
	pGo1.addTask( new MoveTask(50,94,120,94) );
	pGo1.addTask( new DelayTask() );
	pGo1.addTask( new HideTask() );
	pGo1.addTask( new JumpTask(-999,-999) );
	pGo1.runQueue();
	
	// Center

	pCap3.addTask( new WaitTask( 0 ) );
	pCap3.addTask( new MoveTask( pCap3.x(),pCap3.y(), 50,150 ) );
	pCap3.addTask( new DelayTask() );
	pCap3.addTask( new FadeTask(1,0) );
	pCap3.addTask( new HideTask() );
	pCap3.runQueue();

	pCompete.addTask( new WaitTask( 5 ) );
	pCompete.addTask( new MoveTask( pCompete.x(),pCompete.y(), 50,150 ) );
	pCompete.addTask( new DelayTask() );
	pCompete.addTask( new FadeTask(1,0) );
	pCompete.addTask( new HideTask() );
	pCompete.runQueue();

	pCap2.addTask( new WaitTask( 10 ) );
	pCap2.addTask( new MoveTask( pCap2.x(),pCap2.y(), 50,150) );
	pCap2.addTask( new DelayTask() );
	pCap2.addTask( new FadeTask(1,0) );
	pCap2.addTask( new HideTask() );
	pCap2.runQueue();

	pAfford.addTask( new WaitTask( 15 ) );
	pAfford.addTask( new MoveTask( pAfford.x(),pAfford.y(), 50,150 ) );
	pAfford.addTask( new DelayTask() );
	pAfford.addTask( new FadeTask(1,0) );
	pAfford.addTask( new HideTask() );
	pAfford.runQueue();

	// Left
	
	pHelpCap.addTask( new WaitTask( 20 ) );
	pHelpCap.addTask( new MoveTask( pHelpCap.x(),pHelpCap.y(), -50,pHelpCap.y() ) );
	pHelpCap.addTask( new DelayTask() );
	pHelpCap.addTask( new FadeTask(1,0) );
	pHelpCap.addTask( new HideTask() );
	pHelpCap.runQueue();

	pSocial.addTask( new WaitTask( 25 ) );
	pSocial.addTask( new MoveTask( pSocial.x(),pSocial.y(), -50,pSocial.y() ) );
	pSocial.addTask( new DelayTask() );
	pSocial.addTask( new FadeTask(1,0) );
	pSocial.addTask( new HideTask() );
	pSocial.runQueue();

	pBullets.addTask( new WaitTask( 30 ) );
	pBullets.addTask( new MoveTask( pBullets.x(),pBullets.y(), -50,pBullets.y()) );
	pBullets.addTask( new DelayTask() );
	pBullets.addTask( new FadeTask(1,0) );
	pBullets.addTask( new HideTask() );
	pBullets.runQueue();
	
	// Right
	
	pReader.addTask( new WaitTask( 35 ) );
	pReader.addTask( new MoveTask( pReader.x(),pReader.y(),pReader.x(),125 ) );
	pReader.addTask( new DelayTask() );
	pReader.addTask( new MoveTask( 15,125,15,85 ) );
	pReader.runQueue();
	
	pContact.addTask( new WaitTask( 40 ) );
	pContact.addTask( new MoveTask( pContact.x(),pContact.y(),pContact.x(),75 ) );
	pContact.runQueue();
	
	pHelp.addTask( new WaitTask( 45 ) );
	pHelp.addTask( new HideTask() );
	pHelp.addTask( new JumpTask(85,30) );
	pHelp.addTask( new FadeTask( 0,1 ) );
	pHelp.runQueue();
	
	// New Stuff
	
	pReduced = new TextPane("<b style='font-size:125%'>Reduced Adminstration Costs<br>Improved Customer Satisfaction</b>",-999,-999,25,10),
	pReduced.addTask( new HideTask() );
	pReduced.addTask( new JumpTask(16,30) );
	pReduced.addTask( new WaitTask(50) );
	pReduced.addTask( new FadeTask(0,1) );
	panes[panes.length] = pReduced;
	pReduced.runQueue();

	pCap4 = new TextPane("Clearly documented procedures and processes underpinned by management checks and balances mean that administration becomes much more effective and systemic failures a thing of the past. Gilt-Edged Management Systems simplifies complex decision-making and ensures a consistent approach.",-999,-999,25,20),
	pCap4.setOverflow("visible");
	pCap4.addTask( new HideTask() );
	pCap4.addTask( new JumpTask(16,45) );
	pCap4.addTask( new WaitTask(55) );
	pCap4.addTask( new FadeTask(0,1) );
	panes[panes.length] = pCap4;
	pCap4.runQueue();

	pCap5 = new TextPane("Improved procedures mean fewer mistakes and less cost. They create confidence and consistency and improve staff morale and motivation.",-999,-999,25,10),
	pCap5.setOverflow("visible");
	pCap5.addTask( new HideTask() );
	pCap5.addTask( new JumpTask(16,65) );
	pCap5.addTask( new WaitTask(60) );
	pCap5.addTask( new FadeTask(0,1) );
	panes[panes.length] = pCap5;
	pCap5.runQueue();

	pCap6 = new TextPane("<b style='font-size:125%'>Measurable Benefits</b><br><br>Getting it right first time every time means less possibility of poor customer service and complaints. This enhances your organisation's image and enables your customers to become advocates of your services.",-999,-999,30,10),
	pCap6.setOverflow("visible");
	pCap6.addTask( new HideTask() );
	pCap6.addTask( new JumpTask(50,30) );
	pCap6.addTask( new WaitTask(65) );
	pCap6.addTask( new FadeTask(0,1) );
	panes[panes.length] = pCap6;
	pCap6.runQueue();
	
	pFolder = new FlatPane("imgs/folder.png",-999,-999,10,0);
	pFolder.addTask( new JumpTask(50,125) );
	pFolder.addTask( new WaitTask(70) );
	pFolder.addTask( new MoveTask(50,125,50,60) );
	panes[panes.length] = pFolder;
	pFolder.runQueue();
	
	pHit1 = new Pane("imgs/hit1.png",-999,-999,30,0);
	pHit1.addTask( new HideTask() );
	pHit1.addTask( new JumpTask(50,80) );
	pHit1.addTask( new WaitTask(75) );
	pHit1.addTask( new FadeTask(0,1) );
	pHit1.addTask( new DelayTask() );
	pHit1.addTask( new WaitTask(250) );
	pHit1.addTask( new YOrientationTask() );

	var i = 0;
	while (++i < 20) {
		pHit1.addTask( new YSpinReplaceTask("imgs/hit2.png",1) );
		pHit1.addTask( new WaitTask(250) );

		pHit1.addTask( new YSpinReplaceTask("imgs/hit3.png",1) );
		pHit1.addTask( new WaitTask(250) );

		pHit1.addTask( new YSpinReplaceTask("imgs/hit4.png",1) );
		pHit1.addTask( new WaitTask(250) );

		pHit1.addTask( new YSpinReplaceTask("imgs/hit5.png",1) );
		pHit1.addTask( new WaitTask(250) );

		pHit1.addTask( new YSpinReplaceTask("imgs/hit6.png",1) );
		pHit1.addTask( new WaitTask(250) );

		pHit1.addTask( new YSpinReplaceTask("imgs/hit1.png",1) );
		pHit1.addTask( new WaitTask(250) );
	}

	pCap7 = new TextPane("For a <b>free</b> introductory consultation, contact Alex Blackie<br>on <tt>01823&nbsp;667&nbsp;722</tt> or </tt>07900&nbsp;258&nbsp;797</tt>",-999,-999,60,5),
	pCap7.setOverflow("visible");
	pCap7.addTask( new JumpTask(150,94) );
	pCap7.addTask( new WaitTask(70) );
	pCap7.addTask( new MoveTask(150,94,66,94) );
	panes[panes.length] = pCap7;
	pCap7.runQueue();

	panes[panes.length] = pHit1;
	pHit1.runQueue();
	

}
function viewportSetup() {
	if ((typeof window.innerWidth == 'number') && (!window.opera) && (!window.devicePixelRatio) ) {	
		ua="ff";
		vpw	= window.innerWidth;
		vph	= window.innerHeight;
	} else if (document.all && document.documentElement && (typeof(dgebi("ietest"))!="undefined") && (typeof(dgebi("ietest").style.filter)!="undefined") ) {
		ua="ie";
		vph	= document.documentElement.clientHeight;
		vpw	= document.documentElement.clientWidth;
		if (vpw+vph==0) {
			vph	= document.body.clientHeight;
			vpw	= document.body.clientWidth;
		}
		if (typeof document.body.style.maxHeight != "undefined") ua="ie7";
		
		document.body.scroll = "no";
	} else if (typeof window.innerWidth == 'number') {
		if (window.opera) { ua = "op"; } else { ua="xx"; }
		vpw	= window.innerWidth;
		vph	= window.innerHeight;
	} else {
		ua="xx";
		vph	= document.body.clientHeight;
		vpw	= document.body.clientWidth;
	}
	if ((ua=="ie") || (ua=="ie7")) location.href = "static.php";
	
	var i;
	
	var strut = document.getElementById("strut");
	strut.style.height = ""+vph+"px";
	
	vpcx = Math.floor( vpw / 2 );
	vpcy = Math.floor( vph / 2 );
}
function animate() {
	processXHRStack();
	if (!anim_on) return;
	
	// Visibility Transitions
	if (vistrans!=null) {
		for (i = 0; i < vistrans.length; i++) {
			if ((vistrans[i]) && (vistrans[i][0]!=null) && (vistrans[i][1]!=null) && (vistrans[i][2]!=null)) {
				if (vistrans[i][1]==vistrans[i][2]) {
					setOpacity( vistrans[i][0] , vistrans[i][1] );
					if (vistrans[i][2]==0) vistrans[i][0].style.display = "none";
					if (vistrans[i][3]!=null) eval(vistrans[i][3]);
					vistrans[i] = null;
				} else {
					setOpacity( vistrans[i][0] , vistrans[i][1] );
					if (vistrans[i][1] <= vistrans[i][2]) {
						vistrans[i][1] = Math.min(vistrans[i][2],vistrans[i][1]+vispd);
					} else if (vistrans[i][1] >= vistrans[i][2]) {
						vistrans[i][1] = Math.max(vistrans[i][2],vistrans[i][1]-vispd);
					}
				}
			}
		}
	}
	
	tick+=1;
}
function pushXHR(uri,container) { xhrstack[xhrstack.length] = [uri,container,null]; }
function pushXHR(uri,container,parameters) { xhrstack[xhrstack.length] = [uri,container,parameters]; }
function immediateXHR(uri,container) { immediateXHR(uri,container,null); }
function immediateXHR(uri,container,parameters) {
	if (!navigator.onLine) return siteDialog("Offline Mode","You are running in Offline Mode. Some features of the system are unavailable.");

	xhrhalt = true;
	
	var xhr = null;
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	} else {
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhractive+=1;
	if (parameters==null) {
		uri = uri + (uri.indexOf("?")==-1 ?"?":"&")+"jx=1";
		xhr.open("GET",uri,true);
		xhr.onreadystatechange = function() { xhrHandler(xhr,uri,container); };
		xhr.send(null);
	} else {
		parameters = "jx=1&"+parameters;
		xhr.open("POST",uri,true);
		xhr.onreadystatechange = function() { xhrHandler(xhr,uri,container); };
		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr.setRequestHeader("Content-length", parameters.length);
		xhr.setRequestHeader("Connection", "close");
		xhr.send(parameters);
	}
}
function xhrHandler(xhr,uri,container) {
	if (xhr==null) return;
	if ((xhr.readyState == 4) && (xhr.status == 200)) {
		var i = -1;
		var callback = null;
		var text = xhr.responseText;
		if (text.indexOf("<!--callback:")!=-1) {
			callback = text.substring(text.indexOf("<!--callback:")+14,text.indexOf(" -->"));
			text = text.substring(0,text.indexOf("<!--callback:"));
			if (container!=null) {
				var e = top.dgebi(container);
				if ( (e) && (typeof(e)!="undefined") ) {
					if ((e.nodeName.toLowerCase()=="textarea") | (e.nodeName.toLowerCase()=="input")) {
						e.value = text;
					} else {
						e.innerHTML = text;
					}
				}
			}
			eval(callback);
		} else {
			if (container!=null) {
				var e = top.dgebi(container);
				if ( (e) && (typeof(e)!="undefined") ) {
					if ((e.nodeName.toLowerCase()=="textarea") | (e.nodeName.toLowerCase()=="input")) {
						e.value = text;
					} else {
						e.innerHTML = text;
					}
				}
			}
		}
		xhrhalt = false;
		xhractive-=1;
	}
}
function processXHRStack() {
	if (!xhrhalt) {
		if (xhrstack.length!=0) {
			if (waiter) { waiter.style.display = "block"; waiter.style.top = ""+getPageYOffset()+"px"; }
			uri = xhrstack[0][0];
			container = xhrstack[0][1];
			parameters = xhrstack[0][2];
			if ((uri!=null) && (uri!="")) {
				immediateXHR(uri,container,parameters);
			}

			var s = [];
			var i = -1;
			while (++i < xhrstack.length-1) {
				s[i] = xhrstack[i+1];
			}
			xhrstack = s;
		} else {
			if (waiter) { waiter.style.display = "none"; }
			if (xhrclear!=null) {
				var x = xhrclear;
				xhrclear = null;
				eval(x);
			}
		}
	}
}
function findID(root,name) {
	if (!root) return null;
	if (root.hasChildNodes()) {
		var i = -1;
		while (++i < root.childNodes.length) {
			var find = findID(root.childNodes[i]);
			if (find) {
				return find;
			}
		}
	} else {
		if (root.id == name) {
			return root;
		} else {
			return null;
		}
	}
}
function getPaneByID(uid) {
	if (panes==null) return null;
	var i = -1;
	while (++i < panes.length) {
		if (panes[i]==null) {
			return null;
		} else {
			if (panes[i].getUID()==uid) return panes[i];
		}
	}
	return null;
}
function getPageXOffset() {
	return window.pageXOffset ? window.pageXOffset : document[(document.compatMode == 'CSS1Compat') ? 'documentElement' : 'body'].scrollLeft;
}
function getPageYOffset() {
	return window.pageYOffset ? window.pageYOffset : document[(document.compatMode == 'CSS1Compat') ? 'documentElement' : 'body'].scrollTop;
}

function offX(e) {
	if (typeof(e)=="string") e = dgebi(e);
	var b = document.getElementsByTagName("body")[0];
	var x = 0;
	if (e.style.position=="absolute") {
		x = e.offsetLeft-e.scrollLeft;
	} else {
		while ((e!=null) && (e!=b) && (e.style.position!="absolute")) {
			x = x + e.offsetLeft-e.scrollLeft;
			if ((e.parentNode) && (e.parentNode.scrollLeft)) x = x - e.parentNode.scrollLeft;
			e = e.offsetParent;
		}
	}
	return x;
}
function offY(e) {
	var s = "";
	if (typeof(e)=="string") e = dgebi(e);
	var b = document.getElementsByTagName("body")[0];
	var y = 0;
	if (e.style.position==="absolute") {
		y = e.offsetTop-e.scrollTop;
	} else {
		while ((e!=null) && (e!=b) && (e.style.position!="absolute")) {
			y = y + e.offsetTop-e.scrollTop;
			if ((e.parentNode) && (e.parentNode.scrollTop)) y = y - e.parentNode.scrollTop;
			e = e.offsetParent;
		}
	}
	return y;
}
function showScroll(id) { show_element = dgebi(id); }
function show(id) { addVisibilityTransition(id,0,100,null); }
function showCall(id,callback) { addVisibilityTransition(id,0,100,callback); }
function showLock(id) { addVisibilityTransition(id,0,100,"showScroll('"+id+"')"); }
function showLimit(id,limit) { addVisibilityTransition(id,0,limit,null); }
function showFromPartial(id) { addVisibilityTransition(id,25,100,null); }
function hide(id) { addVisibilityTransition(id,100,0,null); }
function hideCall(id,callback) { addVisibilityTransition(id,100,0,callback); }
function hideFrom(id,limit) { addVisibilityTransition(id,limit,0,null); }
function hideFromCallback(id,limit,callback) { addVisibilityTransition(id,limit,0,callback); }
function hideToPartial(id) { addVisibilityTransition(id,100,25,null); }
function delayHide(id) { addVisibilityTransition(id,1000,0,null); }
function reveal(e) {
	if (typeof(e)=="string") e = dgebi(e);
	if (typeof(e)=="undefined") return;
	setOpacity(e,100);
}
function unreveal(e) {
	if (typeof(e)=="string") e = dgebi(e);
	if (typeof(e)=="undefined") return;
	if (e==null) return;
	setOpacity(e,0);
}
function addVisibilityTransition(id,start,end,callback) {
	var row = null;
	if (typeof(id)=="string") {
		row = [dgebi(id),start,end,callback];
	} else {
		row = [id,start,end,callback];
	}
	if (start==0) {
		setOpacity(row[0],0);
	}	
	if (vistrans==null) {
		vistrans = [row];
	} else {
		vistrans[vistrans.length] = row;
	}
}
function setOpacity(e,o) {
	if (typeof(e)=="string") e=dgebi(e);
	if ((typeof(e)!="undefined") && (e)) {
		if (o==0) {
			e.style.display="none";
		} else {
			e.style.display="block";
		}
		if ( (ua=="ie") | (ua=="ie7") ) {
			if (e.filters.length==0) {	// Filter attributes in IE must be created before they can be adjusted
				e.style.width = "100%";
				e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(enabled=true,opacity="+o+")";
			} else {
				if (e.filters.alpha) {
					e.filters.alpha.opacity=o;
				} else {
					e.filters.item("DXImageTransform.Microsoft.Alpha").opacity=o;
				}
			}
		} else {
			e.style.opacity=(o/101);	// Try it anyway, we're in Firefox or something else that MIGHT support it
		}
	}
}
/*
** Utilities
*/
function sign(v) { if (v==0) return 0; else return (v>0 ? 1 : -1); }
function euc(n){return encodeURIComponent(n);}
function dgebi(n) { return document.getElementById(n); }
function dgebiv(n){return sdgebi(n).value;}
function dce(n){return document.createElement(n);}
function sdgebi(n) {
	var e = dgebi(n);
	if ((!e) || (typeof(e)=="undefined")) e = dgebi("dummy");
	return e;
}
function dgebivset(n,v) {
	var e = sdgebi(n);
	e.value = v;
}
function getTransformProperty(element) {
    var properties = [
        'transform',
        'WebkitTransform',
        'MozTransform',
        'msTransform',
        'OTransform'
    ];
    var p;
    while (p = properties.shift()) {
        if (typeof element.style[p] != 'undefined') {
            return p;
        }
    }
    return false;
}
function findFirstParentOfType(e,type) {
	type = type.toLowerCase();
	while ((e.parentNode.nodeName.toLowerCase()!="body") && (e.parentNode.nodeName.toLowerCase()!=type)) e = e.parentNode;
	if (e.parentNode.nodeName.toLowerCase()=="body") {
		return null;
	} else {
		return e.parentNode;
	}
}
/*
** 3D Core
*/
function run3D() {
	var i = -1;
	var s = 0;
	var t = 0;
	var d = "";
	while (++i < panes.length) {
		if (!panes[i].isStable()) {
			if (panes[i].queue[0]) {
				d += i+":"+panes[i].getClass()+"."+panes[i].queue[0].getType()+" "+Math.floor(panes[i].x())+","+Math.floor(panes[i].y())+" - ("+Math.floor(panes[i].getScreenWidth(1))+","+Math.floor(panes[i].getScreenHeight(1))+")\n";
			} else {
				d += i+":"+panes[i].getClass()+".DONE "+Math.floor(panes[i].x())+","+Math.floor(panes[i].y())+" - ("+Math.floor(panes[i].getScreenWidth(1))+","+Math.floor(panes[i].getScreenHeight(1))+")\n";
			}
			panes[i].run();
			s+=1;
			t+=panes[i].getQueueLength();
		} else if (panes[i]) {
			d += i+":"+panes[i].getClass()+".STABLE "+Math.floor(panes[i].x())+","+Math.floor(panes[i].y())+" - ("+Math.floor(panes[i].getScreenWidth(1))+","+Math.floor(panes[i].getScreenHeight(1))+")\n";
		}
	}
	dgebi("dbg").value = d;
}
/*
** Contact Form
*/
function sendContact() {
	if (!dgebiv("c_name")) { alert("You must complete the NAME field"); return; }
	if (!dgebiv("c_company")) { alert("You must complete the COMPANY field"); return; }
	if (!dgebiv("c_email")) { alert("You must complete the EMAIL field"); return; }
	if (!dgebiv("c_phone")) { alert("You must complete the PHONE field"); return; }
	
	shuntForm("pony.php","contactzone","contactzone");
}
function shuntForm(uri,container,id) {
	var form = dgebi(id);
	var fields = findFormFields(form,null);
	var parms = "";
	var i = -1;
	while (++i < fields.length) {
		parms = parms + "&" + fields[i].getAttribute("name");
		parms = parms + "=" + euc( fields[i].value );
	}
	parms = parms.substring(1);
	nailFormFields(fields);
	pushXHR(uri,container,parms);
}
function shuntFormWith(uri,container,id,additional) {
	var form = dgebi(id);
	var fields = findFormFields(form,null);
	var parms = "";
	var i = -1;
	while (++i < fields.length) {
		parms = parms + "&" + fields[i].getAttribute("name");
		parms = parms + "=" + euc( fields[i].value );
	}
	i = -1;
	while (++i < additional.length) {
		parms = parms + "&" + additional[i][0];
		parms = parms + "=" + euc( additional[i][1] );
	}
	parms = parms.substring(1);
	nailFormFields(fields);
	pushXHR(uri,container,parms);
}
function findFormFields(node,elements) {
	if ( (node.nodeName.toLowerCase()=="input") || (node.nodeName.toLowerCase()=="select") || (node.nodeName.toLowerCase()=="textarea") ) {
		if ( ((node.type!="checkbox") && (node.type!="radio")) || (node.checked) ) {
			if (elements==null) {
				elements = [node];
			} else {
				elements[elements.length]=node;
			}
		}
		return elements;
	} else if (node.childNodes) {
		var i = -1;
		while (++i < node.childNodes.length) {
			elements = findFormFields(node.childNodes[i],elements);
		}
		return elements;
	} else {
		return elements;
	}
}
function nailFormFields(form) {
	var i = form.length;
	while (--i >= 0) {
		var node = form[i];
		if ( (node.nodeName.toLowerCase()=="input") || (node.nodeName.toLowerCase()=="select") || (node.nodeName.toLowerCase()=="textarea") ) {
			nailField(node);
		}
	}
}
function nailField(node) {
	var tag	= node.nodeName.toLowerCase();
	var type= "";
	if (tag=="input") type = node.getAttribute("type");
	
	if (tag=="select") {
		var o = node.options[node.selectedIndex];
		var par = node.parentNode;
		var div = document.createElement("div");
		div.className = node.className+" simfield";
		div.innerHTML = o.text;
		par.insertBefore(div,node);
		div.style.height = ""+node.clientHeight+"px";
		div.style.width  = ""+node.clientWidth+"px";
		div.style.overflow = "hidden";
		div.style.color = "#666";
		div.style.backgroundColor = "#eee";
		div.style.cursor = "not-allowed";
	} else if ((type=="checkbox") || (type=="radio")) {
		var sel = node.checked;
		var par = node.parentNode;
		var div = document.createElement("div");
		div.className = node.className+" simfield";
		div.innerHTML = (sel ? "<img src='/cogimages/icons/tick.gif'>" : "<img src='/cogimages/icons/notick.gif'>");
		par.insertBefore(div,node);
		div.style.height = ""+node.clientHeight+"px";
		div.style.width  = ""+node.clientWidth+"px";
		div.style.overflow = "hidden";
		div.style.color = "#666";
		div.style.backgroundColor = "#eee";
		div.style.cursor = "not-allowed";
	} else if (type=="password") {
		var par = node.parentNode;
		var div = document.createElement("div");
		div.className = node.className+" simfield";
		var s = "";
		while (s.length < node.value.length) s+="*";
		div.innerHTML = s;
		par.insertBefore(div,node);
		div.style.height = ""+node.clientHeight+"px";
		div.style.width  = ""+node.clientWidth+"px";
		div.style.overflow = "hidden";
		div.style.color = "#666";
		div.style.backgroundColor = "#eee";
		div.style.cursor = "not-allowed";
	} else if (type!="hidden") {
		var par = node.parentNode;
		var div = document.createElement("div");
		div.className = node.className+" simfield";
		div.innerHTML = node.value;
		par.insertBefore(div,node);
		div.style.height = ""+node.clientHeight+"px";
		div.style.width  = ""+node.clientWidth+"px";
		div.style.overflow = "hidden";
		div.style.color = "#666";
		div.style.backgroundColor = "#eee";
		div.style.cursor = "not-allowed";
	}
	node.style.display = "none";
}

