//   #########################################################################################
//  #                                                                                         #
//  #                                                                                         #
//  #                                                                                         #
//  #                                                                                         #
//  #                           cleverspin javascript dom functions                           #
//  #                                                                                         #
//  #                                                                                         #
//  #                                                                                         #
//  #                                                                                         #
//   #########################################################################################

//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    information collection                                           #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  get browser type
//  ######################################

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//  ######################################
//  #  get page width
//  ######################################

function getPageWidth()
{
	var body = document.getElementsByTagName("body")[0];
	var bodyOffsetWidth = 0;
	var bodyScrollWidth = 0;
	var thisWidth = 0;
	if ((domCheck(document.documentElement)) && (domCheck(document.documentElement.scrollWidth)))
	{
		thisWidth = document.documentElement.scrollWidth;
	}
	bodyOffsetWidth = body.offsetWidth;
	bodyScrollWidth = body.scrollWidth;
	if (bodyOffsetWidth > thisWidth) thisWidth = bodyOffsetWidth;
	if (bodyScrollWidth > thisWidth) thisWidth = bodyScrollWidth;
	return thisWidth;
}

//  ######################################
//  #  get page height
//  ######################################

function getPageHeight()
{
	var body = document.getElementsByTagName("body")[0];
	var bodyOffsetHeight = 0;
	var bodyScrollHeight = 0;
	var thisHeight;
	if ((domCheck(document.documentElement)) && (domCheck(document.documentElement.scrollWidth)))
	{
		thisHeight = document.documentElement.scrollHeight;
	}
	bodyOffsetHeight = body.offsetHeight;
	bodyScrollHeight = body.scrollHeight;
	if (bodyOffsetHeight > thisHeight) thisHeight = bodyOffsetHeight;
	if (bodyScrollHeight > thisHeight) thisHeight = bodyScrollHeight;
	return thisHeight;
}

//  ######################################
//  #  get port width
//  ######################################

function getPortWidth()
{
	var thisWidth = 0;
	if (domCheck(window.innerWidth))
	{
		thisWidth = window.innerWidth;
	} else if ((domCheck(document.documentElement)) && (domCheck(document.documentElement.clientWidth)) && (document.documentElement.clientWidth!=0)) {
		thisWidth = document.documentElement.clientWidth;
	} else {
		thisWidth = document.getElementsByTagName('body')[0].clientWidth;
	}
	return thisWidth;
}

//  ######################################
//  #  get port height
//  ######################################

function getPortHeight()
{
	var thisHeight = 0;
	if (domCheck(window.innerHeight))
	{
		thisHeight = window.innerHeight;
	} else if ((domCheck(document.documentElement)) && (domCheck(document.documentElement.clientHeight)) && (document.documentElement.clientHeight!=0)) {
		thisHeight = document.documentElement.clientHeight;
	} else {
		thisHeight = document.getElementsByTagName('body')[0].clientHeight;
	}
	return thisHeight;
}

//  ######################################
//  #  get element width
//  ######################################

function getElementWidth()
{
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisWidth = 0;
	if (theID !== false) 
	{
		thisWidth = document.getElementById(theID).offsetWidth;
	}
	return thisWidth;
}

//  ######################################
//  #  get element height
//  ######################################

function getElementHeight()
{
	
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisHeight = 0;
	if (theID !== false) 
	{
		thisHeight = document.getElementById(theID).offsetHeight;
	} 
	//alert(thisHeight);		
	
	return thisHeight;
}

//  ######################################
//  #  get element left position
//  ######################################

function getElementLeft()
{
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisX = 0;
	if (theID !== false) 
	{
		thisElement = document.getElementById(theID);
		while (thisElement != null)
		{
			thisX += thisElement.offsetLeft;
			thisElement = thisElement.offsetParent;
		}
	}
	return thisX;
}

//  ######################################
//  #  get element right position
//  ######################################

function getElementRight()
{
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisX = 0;
	if (theID !== false) 
	{
		thisElement = document.getElementById(theID);
		while (thisElement != null)
		{
			thisX += thisElement.offsetLeft;
			thisElement = thisElement.offsetParent;
		}
		thisX = getPageWidth() - thisX;
	}
	return thisX;
}

//  ######################################
//  #  get element top position
//  ######################################

function getElementTop()
{
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisY = 0;
	if (theID !== false) 
	{
		thisElement = document.getElementById(theID);
		while (thisElement != null)
		{
			thisY += thisElement.offsetTop;
			thisElement = thisElement.offsetParent;
		}
	}
	return thisY;
}

//  ######################################
//  #  get element bottom position
//  ######################################

function getElementBottom()
{
	var theID = (arguments[0] != null) ? arguments[0] : false;
	var thisY = 0;
	if (theID !== false) 
	{
		thisElement = document.getElementById(theID);
		while (thisElement != null)
		{
			thisY += thisElement.offsetTop;
			thisElement = thisElement.offsetParent;
		}
		thisY = getPageWidth() - thisY;
	}
	return thisY;
}

//  ######################################
//  #  get horizontal scroll position
//  ######################################

function getScrollX()
{
	var thisX = 0;
	if (domCheck(window.pageXOffset))
	{
		thisX = window.pageXOffset;
	} else if ((domCheck(document.documentElement.scrollLeft)) && (document.documentElement.scrollLeft > 0)) {
		thisX = document.documentElement.scrollLeft;
	} else if (domCheck(document.body.scrollLeft)) {
		thisX = document.body.scrollLeft;
	}
	return thisX;
}

//  ######################################
//  #  get vertical scroll position
//  ######################################

function getScrollY()
{
	var thisY = 0;
	if (domCheck(window.pageYOffset))
	{
		thisY = window.pageYOffset;
	} else if ((domCheck(document.documentElement.scrollTop)) && (document.documentElement.scrollTop > 0)) {
		thisY = document.documentElement.scrollTop;
	} else if (domCheck(document.body.scrollTop)) {
		thisY = document.body.scrollTop;
	}
	return thisY;
}

//  ######################################
//  #  get a style property
//  ######################################

function getStyleProperty()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var theProperty = (arguments[1] != null) ? arguments[1] : "position";
	var theStyle = null;
	if (domCheck(theID.currentStyle))
	{
		theStyle = theID.currentStyle;
	} else {
		theStyle = document.defaultView.getComputedStyle(document.getElementById(theID),null);
	}
	propertyValue = theStyle[theProperty];
	return propertyValue;
}

//  ######################################
//  #  get a style pixel position
//  ######################################

function getStylePosition()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var theProperty = (arguments[1] != null) ? arguments[1] : "left";
	fullProperty = getStyleProperty(theID,theProperty);
	if (fullProperty.slice(-2) == "px")
	{
		return parseInt(fullProperty.substr(0,fullProperty.indexOf("px")));
	} else {
		return parseInt(fullProperty);
	}
}




















































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    alert utilities                                                  #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  create alert shader
//  ######################################
//
//  createAlertShader(theID);
//

function createAlertShader()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertShader";
	var body = document.getElementsByTagName("body")[0];
	var pageHeight = getPageHeight();
	var portHeight = getPortHeight();
	//var pageWidth = getPageWidth();
	//var portWidth = getPortWidth();
	if (portHeight > pageHeight) pageHeight = portHeight;
	//if (portWidth > pageWidth) pageWidth = portWidth;
	var alertShader = document.createElement("div");
	var alertShaderInner = document.createElement("div");
	alertShader.setAttribute("id",theID);
	alertShaderInner.setAttribute("id",theID+"Inner");
	//alertShader.style.width = pageWidth+"px";
	alertShader.style.height = pageHeight+"px";
	alertShader.appendChild(alertShaderInner);
	body.appendChild(alertShader);
}

//  ######################################
//  #  destroy alert shader
//  ######################################
//
//  destroyAlertShader(theID);
//

function destroyAlertShader()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertShader";
	var alertShader = document.getElementById(theID);
	alertShader.parentNode.removeChild(alertShader);
}

//  ######################################
//  #  create alert 
//  ######################################
//
//  createAlert(theHTML,theID,theClassName);
//

function createAlert()
{
	var theHTML = (arguments[0] != null) ? arguments[0] : "There was a problem.<br /><br /><a href='javascript:destroyAlert();'><span>ok</span></a>"
	var theID = (arguments[1] != null) ? arguments[1] : "alertBox";
	var theCLASS = (arguments[2] != null) ? arguments[2] : "alertBox";
	var body = document.getElementsByTagName("body")[0];
	var alertBox = document.createElement("div");

	setOpacity("alertShaderInner",80);
	document.getElementById("alertShaderInner").style.display = "block";
	
	alertBox.setAttribute("id",theID);
	alertBox.className = theCLASS;
	alertBox.style.visibility = "hidden";
	alertBox.style.position = "absolute";
	alertBox.innerHTML = theHTML;
	body.appendChild(alertBox);
	var portHeight = getPortHeight();
	var portWidth = getPortWidth();
	var scrollX = getScrollX();
	var scrollY = getScrollY();
	var alertBoxWidth = alertBox.offsetWidth;
	var alertBoxHeight = alertBox.offsetHeight;
	alertBox.style.top = (scrollY + parseInt(portHeight / 2) - parseInt(alertBoxHeight / 2))+"px";
	alertBox.style.left = (scrollX + parseInt(portWidth / 2) - parseInt(alertBoxWidth / 2))+"px";
	alertBox.style.visibility = "visible";
}

//  ######################################
//  #  destroy alert 
//  ######################################
//
//  destroyAlert(theID);
//

function destroyAlert()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var alertBox = document.getElementById(theID);
	alertBox.parentNode.removeChild(alertBox);
}




























































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    style utilities                                                  #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################
	
//  ######################################
//  #  set class
//  ######################################
//
//  setClass(theID,theClass);
//

function setClass()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var theClass = (arguments[1] != null) ? arguments[1] : "";
	document.getElementById(theID).className = theClass;
}

//  ######################################
//  #  set opacity
//  ######################################
//
//  setOpacity(theID,theOpacity,theChroma);
//
//  theOpacity = 0-100
//  theChroma = Hex Color (used for fixing IE text anti-aliasing issues)
//

function setOpacity()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var theOpacity = (arguments[1] != null) ? parseInt(arguments[1]) : 100;
	var theChroma = (arguments[2] != null) ? arguments[2] : false;
	var theObject = document.getElementById(theID);
	var altOpacity = theOpacity / 100;
	var fixOpacity = (altOpacity == 1) ? 0.99999 : altOpacity;
	if (domCheck(theObject.style.opacity)) {
		theObject.style.opacity = fixOpacity;
	} else if (domCheck(theObject.style.MozOpacity)) {
		theObject.style.MozOpacity = fixOpacity;
	} else if ((domCheck(theObject.filters)) && (theChroma !== false)) {
		theObject.style.filter = 'progid:DXImageTransform.Microsoft.Chroma(color='+theChroma+') alpha(opacity='+theOpacity+')';
	} else if (domCheck(theObject.filters)) {
		theObject.style.filter = 'alpha(opacity='+theOpacity+')';
	} else if (domCheck(theObject.style)) {
		theObject.style.KhtmlOpacity = altOpacity;
	}
}

//  ######################################
//  #  smoothly fade opacity
//  ######################################
//
//  smoothOpacity(thisID,startOpacity,endOpacity,steps,speed,startDelay,theChroma,endCallback)
//
//  theID = the id of the element to fade
//  startOpacity = 0-100
//  endOpacity = 0-100
//  steps = 1-??
//  speed = 1-??, 1 being fastest
//  startDelay = extra time delay between step 1 and 2 used to delay the start
//  theChroma = Hex Color (used for fixing IE text anti-aliasing issues)
//  endCallback = function to call when complete
//

fadeInstance = 0;
faderPos = new Array();
fadeContinue = new Array();

function smoothOpacity()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var startOpacity = (arguments[1] != null) ? parseInt(arguments[1]) : 100;
	var endOpacity = (arguments[2] != null) ? parseInt(arguments[2]) : 0;
	var steps = (arguments[3] != null) ? arguments[3] : 10;
	var speed = (arguments[4] != null) ? arguments[4] : 50;
	var startDelay = (arguments[5] != null) ? arguments[5] : 0;
	var theChroma = (arguments[6] != null) ? arguments[6] : false;
	var endCallback = (arguments[7] != null) ? arguments[7] : "false";
	if (arguments[8] != null) {
		var thisInstance = arguments[8];
		faderPos[thisInstance]++;
	} else {
		fadeInstance++;
		var thisInstance = fadeInstance;
		faderPos[thisInstance] = 1;
		if (startDelay != 0) faderPos[thisInstance] = 0;
		fadeContinue[thisInstance] = true;
	}
	var step = faderPos[thisInstance];
	if (step != 0)
	{
		var oMod = endOpacity - startOpacity;
		var oChange = (oMod != 0) ? Math.floor((oMod/steps)*step) : 0;
		var theOpacity = (startOpacity + oChange);
	} else {
		var theOpacity = startOpacity;
	}
	setOpacity(theID,theOpacity,theChroma);
	if (step == steps) fadeContinue[thisInstance] = false;
	thisSpeed = (step == 0) ? (speed+startDelay) : speed;
	if (fadeContinue[thisInstance]) {
		setTimeout("smoothOpacity('"+theID+"',"+startOpacity+","+endOpacity+","+steps+","+speed+","+startDelay+",'"+theChroma+"','"+endCallback+"',"+thisInstance+");",thisSpeed);
	} else {
		if (endCallback != "false") eval(endCallback+"(theID,thisInstance)");
	}
	return fadeInstance;
}

//  #############################################
//  #  stop a fading object by action instance
//  #############################################

function fadeStop()
{
	var theInstance = (arguments[0] != null) ? arguments[0] : 1;
	fadeContinue[theInstance] = false;
}



























































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    events                                                           #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  #########################################
//  #  create a listener for window loading
//  #########################################

function createLoadListener()
{
	var theFunction = (arguments[0] != null) ? arguments[0] : false;
	if (domCheck(window.addEventListener))
	{
		window.addEventListener("load", theFunction, false);
	} else if (domCheck(document.addEventListener)) {
		document.addEventListener("load", theFunction, false);
	} else if (domCheck(window.attachEvent)) {
		window.attachEvent("onload", theFunction);
	} else {
		var oldFunction = window.onload;
		if (typeof window.onload != "function")
		{
			window.onload = theFunction;
		} else {
			window.onload = function()
			{
				oldFunction();
				theFunction();
			}
		}
	}
}

//  ######################################
//  #  create a listener for events
//  ######################################

function createEventListener()
{
	var theID = (arguments[0] != null) ? arguments[0] : document;
	var eventType = (arguments[1] != null) ? arguments[1] : "click";
	var functionCall = (arguments[2] != null) ? arguments[2] : "click";
	var capture = (arguments[3] != null) ? arguments[3] : false;
	if (domCheck(theID.attachEvent))
	{
		theID.attachEvent("on"+eventType,functionCall);
	} else if (domCheck(theID.addEventListener)) {
		theID.addEventListener(eventType,functionCall,capture);
	} else {
		eventType = "on"+eventType;
		if (typeof theID[eventType] == "function") {
			var oldListener = theID[eventType];
			theID[eventType] = function()
			{
				oldListener();
				return functionCall();
			};
		} else {
			theID[eventType] = functionCall;
		}
	}
}

//  ######################################
//  #  get event target
//  ######################################

function getEventTarget(event)
{
	var target = null;
	if (domCheck(event.target))
	{
		target = event.target;
	} else {
		target = event.srcElement;
	}
	while ((target.nodeType == 3) && (target.parentNode != null))
	{
		target = target.parentNode;
	}
	return target;
}























































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    ajax routines                                                    #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  send an ajax request
//  ######################################
//
//  httpRequest(url,query,endCallback,method,async);
//
//  url = location of the script
//  query = post or get parameters
//  endCallback = function to run when data object received (will be passed the data object)
//  method = GET or POST
//  async = true of false for asynchronous transfer
//

httpResponse = new Array();
httpResponseInstance = 0;

function httpRequest()
{
	var url = (arguments[0] != null) ? arguments[0] : false;
	var query = (arguments[1] != null) ? arguments[1] : false;
	var endCallback = (arguments[2] != null) ? arguments[2] : "false";
	var method = (arguments[3] != null) ? arguments[3] : "POST";
	var async = (arguments[4] != null) ? arguments[4] : true;
	httpResponseInstance++;
	if (domCheck(window.XMLHttpRequest))
	{
		httpResponse[httpResponseInstance] = new XMLHttpRequest();

	} else if (domCheck(window.ActiveXObject)) {
		httpResponse[httpResponseInstance] = new ActiveXObject("Msxml2.XMLHTTP");
		if (!httpResponse[httpResponseInstance]) httpResponse[httpResponseInstance] = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if ((httpResponse[httpResponseInstance]) && (url !== false) && (query !== false))
	{
		httpResponse[httpResponseInstance].onreadystatechange = function()
		{
			if (httpResponse[httpResponseInstance].readyState == 4)
			{
				if (httpResponse[httpResponseInstance].status == 200)
				{
					var thisResponse = httpResponse[httpResponseInstance].responseText;
					var thisFunc = new Function("return "+thisResponse);
					var thisObject = thisFunc();
					if (endCallback != "false") eval(endCallback+"(thisObject)");
				}
			}
		};
		httpResponse[httpResponseInstance].open(method,url,async);
		httpResponse[httpResponseInstance].setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		httpResponse[httpResponseInstance].send(query);
	}
}
































































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    images                                                           #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  preload an image set
//  ######################################
//
//  imagePreload(theDir,img,img,...);
//

DTimgPreloadLoop = 0;
DTimgPreload = new Array();

function imagePreload()
{
	var theDir = (arguments[0] != null) ? arguments[0] : "templates/images/";
	var loopEnd = arguments.length - 1;
	for (loop=1; loop<=loopEnd; loop++)
	{
		DTimgPreload[(loop+DTimgPreloadLoop)] = new Image();
		DTimgPreload[(loop+DTimgPreloadLoop)].src = theDir+arguments[loop];
	}
	DTimgPreloadLoop = DTimgPreloadLoop + loopEnd;
}
	
//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    animation                                                        #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  slide an object
//  ######################################
//
//  slideObject(theID,startX,startY,endX,endY,hAlign,vAlign,smoothIn,smoothOut,steps,speed,startDelay,endCallback);
//
//  hAlign = left or right
//  vAlign = top or bottom
//  smoothIn =  true or false
//  smoothOut = true or false
//  steps = 1 - ??
//  speed = 1 - ?? (1 being fastest)
//  startDelay = extra time delay between step 1 and 2 used to delay the start
//

slideInstance = 0;
slidePos = new Array();
slideContinue = new Array();

function slideObject()
{
	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var startX = (arguments[1] != null) ? arguments[1] : 0;
	var startY = (arguments[2] != null) ? arguments[2] : 0;
	var endX = (arguments[3] != null) ? arguments[3] : 100;
	var endY = (arguments[4] != null) ? arguments[4] : 100;
	var hAlign = (arguments[5] != null) ? arguments[5] : "left";
	var vAlign = (arguments[6] != null) ? arguments[6] : "top";
	var smoothIn = (arguments[7] != null) ? arguments[7] : 1;
	var smoothOut = (arguments[8] != null) ? arguments[8] : 1;
	var steps = (arguments[9] != null) ? arguments[9] : 30;
	var speed = (arguments[10] != null) ? arguments[10] : 3;
	var startDelay = (arguments[11] != null) ? arguments[11] : 0;
	var endCallback = (arguments[12] != null) ? arguments[12] : "false";
	if (arguments[13] != null) {
		var thisInstance = arguments[13];
		slidePos[thisInstance]++;
	} else {
		slideInstance++;
		var thisInstance = slideInstance;
		slidePos[thisInstance] = 1;
		if (startDelay != 0) slidePos[thisInstance] = 0;
		slideContinue[thisInstance] = true;
	}
	var step = slidePos[thisInstance];
	if (step != 0)
	{
		var xMod = endX - startX;
		var yMod = endY - startY;
		if ((smoothIn) && (smoothOut))
		{
			if (step <= (steps/2))
			{
				xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.pow((Math.abs(xMod)/2),(1/(steps/2))*step)) : 0;
				yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.pow((Math.abs(yMod)/2),(1/(steps/2))*step)) : 0;
			} else {
				xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.abs(xMod)-Math.pow((Math.abs(xMod)/2),(1/(steps/2))*((steps-step)))+1) : 0;
				yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.abs(yMod)-Math.pow((Math.abs(yMod)/2),(1/(steps/2))*((steps-step)))+1) : 0;
			}
		} else if ((!smoothIn) && (!smoothOut)) {
			xPos = (xMod != 0) ? Math.floor((xMod/steps)*step) : 0;
			yPos = (yMod != 0) ? Math.floor((yMod/steps)*step) : 0;
		} else {
			if (smoothIn)
			{
				xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.pow(Math.abs(xMod),(1/(steps))*step)) : 0;
				yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.pow(Math.abs(yMod),(1/(steps))*step)) : 0;
			} else {
				xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.abs(xMod)-Math.pow(Math.abs(xMod),(1/(steps))*((steps-step)))+1) : 0;
				yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.abs(yMod)-Math.pow(Math.abs(yMod),(1/(steps))*((steps-step)))+1) : 0;
			}
		}
	} else {
		xPos = 0;
		yPos = 0;
	}
	if (hAlign == "left")
	{
		document.getElementById(theID).style.left = (startX+xPos)+"px";
	} else {
		document.getElementById(theID).style.right = (startX+xPos)+"px";
	}
	if (vAlign == "top")
	{
		document.getElementById(theID).style.top = (startY+yPos)+"px";
	} else {
		document.getElementById(theID).style.bottom = (startY+yPos)+"px";
	}
	if (step == steps) slideContinue[thisInstance] = false;
	thisSpeed = (step == 0) ? (speed+startDelay) : speed;
	if (slideContinue[thisInstance]) {
		setTimeout("slideObject('"+theID+"',"+startX+","+startY+","+endX+","+endY+",'"+hAlign+"','"+vAlign+"',"+smoothIn+","+smoothOut+","+steps+","+speed+","+startDelay+",'"+endCallback+"',"+thisInstance+");",thisSpeed)
	} else {
		if (endCallback != "false") eval(endCallback+"(theID,thisInstance)");
	}
	return slideInstance;
}

//  #############################################
//  #  stop a sliding object by action instance
//  #############################################

function slideStop()
{
	var theInstance = (arguments[0] != null) ? arguments[0] : 1;
	slideContinue[theInstance] = false;
}

//  ######################################
//  #  grow an object
//  ######################################
//
//  growObject(theID,startX,startY,endX,endY,smoothIn,smoothOut,steps,speed,startDelay,endCallback);
//
//  smoothIn =  true or false
//  smoothOut = true or false
//  steps = 1 - ??
//  startDelay = extra time delay between step 1 and 2 used to delay the start
//  speed = 1 - ?? (1 being fastest)
//

growInstance = 0;
growPos = new Array();
growContinue = new Array();

function growObject()
{

	var theID = (arguments[0] != null) ? arguments[0] : "alertBox";
	var startX = (arguments[1] != null) ? arguments[1] : 0;
	var startY = (arguments[2] != null) ? arguments[2] : 0;
	var endX = (arguments[3] != null) ? arguments[3] : 100;
	var endY = (arguments[4] != null) ? arguments[4] : 100;
	var smoothIn = (arguments[5] != null) ? arguments[5] : 1;
	var smoothOut = (arguments[6] != null) ? arguments[6] : 1;
	var steps = (arguments[7] != null) ? arguments[7] : 30;
	var speed = (arguments[8] != null) ? arguments[8] : 3;
	var startDelay = (arguments[9] != null) ? arguments[9] : 0;
	var endCallback = (arguments[10] != null) ? arguments[10] : "false";
	if (arguments[11] != null) {
		var thisInstance = arguments[11];
		growPos[thisInstance]++;
	} else {
		growInstance++;
		var thisInstance = growInstance;
		growPos[thisInstance] = 1;
		if (startDelay != 0) growPos[thisInstance] = 0;
		growContinue[thisInstance] = true;
	}
	var step = growPos[thisInstance];
	if (step != 0)
	{
		if ((startX !== false) && (endX !== false)) var xMod = endX - startX;
		if ((startY !== false) && (endY !== false)) var yMod = endY - startY;
		if ((smoothIn) && (smoothOut))
		{
			if (step <= (steps/2))
			{
				if ((startX !== false) && (endX !== false)) xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.pow((Math.abs(xMod)/2),(1/(steps/2))*step)) : 0;
				if ((startY !== false) && (endY !== false)) yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.pow((Math.abs(yMod)/2),(1/(steps/2))*step)) : 0;
			} else {
				if ((startX !== false) && (endX !== false)) xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.abs(xMod)-Math.pow((Math.abs(xMod)/2),(1/(steps/2))*((steps-step)))+1) : 0;
				if ((startY !== false) && (endY !== false)) yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.abs(yMod)-Math.pow((Math.abs(yMod)/2),(1/(steps/2))*((steps-step)))+1) : 0;
			}
		} else if ((!smoothIn) && (!smoothOut)) {
			if ((startX !== false) && (endX !== false)) xPos = (xMod != 0) ? Math.floor((xMod/steps)*step) : 0;
			if ((startY !== false) && (endY !== false)) yPos = (yMod != 0) ? Math.floor((yMod/steps)*step) : 0;
		} else {
			if (smoothIn)
			{
				if ((startX !== false) && (endX !== false)) xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.pow(Math.abs(xMod),(1/(steps))*step)) : 0;
				if ((startY !== false) && (endY !== false)) yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.pow(Math.abs(yMod),(1/(steps))*step)) : 0;
			} else {
				if ((startX !== false) && (endX !== false)) xPos = (xMod != 0) ? (xMod/Math.abs(xMod))*Math.floor(Math.abs(xMod)-Math.pow(Math.abs(xMod),(1/(steps))*((steps-step)))+1) : 0;
				if ((startY !== false) && (endY !== false)) yPos = (yMod != 0) ? (yMod/Math.abs(yMod))*Math.floor(Math.abs(yMod)-Math.pow(Math.abs(yMod),(1/(steps))*((steps-step)))+1) : 0;
			}
		}
	} else {
		xPos = 0;
		yPos = 0;
	}
	if ((startX !== false) && (endX !== false)) document.getElementById(theID).style.width = (startX+xPos)+"px";
	if ((startY !== false) && (endY !== false)) document.getElementById(theID).style.height = (startY+yPos)+"px";
	if (step == steps) growContinue[thisInstance] = false;
	thisSpeed = (step == 0) ? (speed+startDelay) : speed;
	if (growContinue[thisInstance]) {
		setTimeout("growObject('"+theID+"',"+startX+","+startY+","+endX+","+endY+","+smoothIn+","+smoothOut+","+steps+","+speed+","+startDelay+",'"+endCallback+"',"+thisInstance+");",thisSpeed)
	} else {
		if (endCallback != "false") eval(endCallback+"(theID,thisInstance)");
	}
	return growInstance;
}

//  #############################################
//  #  stop a sliding object by action instance
//  #############################################

function growStop()
{
	var theInstance = (arguments[0] != null) ? arguments[0] : 1;
	growContinue[theInstance] = false;
}





















































//   #####################################################################
//  #                                                                     #
//  #                                                                     #
//  #    support utilities                                                #
//  #                                                                     #
//  #                                                                     #
//   #####################################################################

//  ######################################
//  #  domCheck
//  ######################################

function domCheck(theObject)
{
	var theResult = (typeof theObject != "undefined") ? true : false;
	return theResult;
}