/*
**  GENERATED FILE (TAVEO EXPORT SCRIPT)
**
**  !!! DO NOT MODIFY !!!
**  FILE IS OVERWRITTEN ON EXPORT
*/

String.prototype._taveoCapitalize = function() {
    return this.charAt(0).toUpperCase() + this.substring(1);
};

// Used by _taveoFindPos().
function _taveoFindPosRec(obj, posInfo)
{
	posInfo.top += obj.offsetTop;
	posInfo.left += obj.offsetLeft;
	if (obj.offsetParent != null)
		return _taveoFindPosRec(obj.offsetParent, posInfo);
	else
		return posInfo;
}

// Find HTML object absoulte position in document.
// Returns an object with 4 properties in pixels : top, left, width, height.
function _taveoFindPos(obj)
{
	var posInfo = new Object(
		{
			top: obj.offsetTop, 
			left: obj.offsetLeft, 
			width: obj.offsetWidth, 
			height: obj.offsetHeight
		});
	return _taveoFindPosRec(obj.offsetParent, posInfo);
}

// Force navigator to scroll to hash.
// If no argument, scroll to current uri hash.
// Useful to force some navigators to scroll correctly 
// to current hash after page is fully loaded (like in body OnLoad).
function _taveoScrollToHash()
{
	var hash;
	if (_taveoScrollToHash.arguments.length > 0)
		hash = _taveoScrollToHash.arguments[0];
	else if (document.location.hash.length > 1)
		hash = document.location.hash.substr(1, document.location.hash.length - 1);
	else
		return false;
	var domAnchor = document.getElementsByName(hash)[0];
	if (domAnchor != undefined)
	{
		var anchorPos = _taveoFindPos(domAnchor);
		scrollTo(anchorPos.left, anchorPos.top);
	}
	return true;
}

// Dynamically add listener for document OnLoad event.
function _taveoAddDocumentOnLoadListener(func)
{
	if(typeof window.addEventListener != 'undefined') //.. gecko, safari, konqueror and standard
		window.addEventListener('load', func, false);
	else if(typeof document.addEventListener != 'undefined') //.. opera 7
		document.addEventListener('load', func, false);
	else if(typeof window.attachEvent != 'undefined') //.. win/ie
		window.attachEvent('onload', func);
}

// Reserved to TAVEO exported pages.
// Dynamically find out current export path in _taveoExport/
// relative to current script execution path.
function _taveoGetExportPath(cssFileName, dummyClassName)
{
	for (var i = 0; i < document.styleSheets.length; i++)
	{
		var cssFile = document.styleSheets[i];
		var cssFileRules = [];
		if (typeof(cssFile.rules) != "undefined")
			cssFileRules = cssFile.rules;
		else if (typeof(cssFile.cssRules) != "undefined")
			cssFileRules = cssFile.cssRules;
		for (var j = 0; j < cssFileRules.length; j++)
		{
			if (cssFileRules[j].selectorText == "." + dummyClassName)
			{
				var tmp = cssFile.href.replace(new RegExp("^[^/]+://[^/]+", ""), "");
				tmp = tmp.split(new RegExp("[/]+", "g"));
				return(tmp.splice(0, tmp.length - 1).join("/")+"/");
			}
		}
	}
	alert("TAVEO EXPORTED JAVASCRIPT ERROR:\n\n_taveoGetOutputPath() failed :\n\n- check if \"" + cssFileName + "\" generation succeed.\n- check if \"" + cssFileName + "\" contains \"." + "." + dummyClassName + "\"");
}

// Align horizontally div "divId" over its hierarchical parent div "parentId"
// according to percentage using Math.round() (not needed in firefox).
function _taveoAlignDivH(parentId, divId, percentage)
{
	if (navigator.userAgent.indexOf("MSIE") != -1)
	{
		var mDiv = document.getElementById(divId);
		mDiv.style.marginLeft = "0px";
		mDiv.style.marginRight = "0px";
		if (parentId == null)
			mDiv.style.left = (Math.round(((document.body.scrollWidth - mDiv.scrollWidth) * percentage) / 100)) + "px";
		else
			mDiv.style.left = (Math.round(((document.getElementById(parentId).scrollWidth - mDiv.scrollWidth) * percentage) / 100)) + "px";
	}
}

// Takes dynamic list of objects ids and CSS classes to assign.
// ex: _taveoClassSwap('obj', 'class', 'obj2', 'class2');
function _taveoClassSwap()
{
	var j = 0;
	var x;
	var a = _taveoClassSwap.arguments;

	document._taveoSwappedClasses = [];
	for (var i = 0; i < (a.length - 1) ; i += 2)
	{
		if ((x = document.getElementById(a[i])) != null)
		{
			document._taveoSwappedClasses[j++] = x;
			if (!x._taveoOrigClass)
				x._taveoOrigClass = x.className;
			x.className = a[i + 1];
		}
	}
}

// Restore CSS classes for modified objects in last _taveoClassSwap().
// Takes no arguments (use globals).
function _taveoClassRestore()
{
	var i;
	var x;
	var a = document._taveoSwappedClasses;

	for(i = 0; a && i < a.length && (x = a[i]) && x._taveoOrigClass; i++)
		x.className = x._taveoOrigClass;
}

// Used by _taveoImagesPreloader
function _taveoImagesPreloaderCheck()
{
	var completed = 0;
	var iTemp = 0;

	while (iTemp < document._taveoPreloadImages.length)
	{
		if (document._taveoPreloadImages[iTemp].complete)
		{
			completed++;
			document._taveoPreloadImages.splice(iTemp, 1);
		}
		else
			iTemp++
	}
	if (completed != document._taveoPreloadImages.length)
	{
		if (!document._taveoPreloadImagesChecks)
			document._taveoPreloadImagesChecks = 1;
		else
			document._taveoPreloadImagesChecks++;
		if (document._taveoPreloadImagesChecks < 300)
			setTimeout("_taveoImagesPreloaderCheck()",100);
	}
}

// Preload images from urls in arguments list (dynamic).
function _taveoImagesPreloader()
{
	if (!document._taveoPreloadImages)
		document._taveoPreloadImages = new Array();
	var j = document._taveoPreloadImages.length;
	var a = _taveoImagesPreloader.arguments;
	for(var i = 0; i < a.length; i++)
	{
		if (a[i].indexOf("#") != 0)
		{
			document._taveoPreloadImages[j] = new Image;
			document._taveoPreloadImages[j++].src = a[i];
		}
	}
	_taveoImagesPreloaderCheck();
}

