﻿var CWS_nMaxX = 0;
var CWS_nMaxY = 0;

var nWinPosX = -1;
var nWinPosY = -1;
var bCentered = true;

var oCWS_Popup = null;

function CWS_onLoad() {	eval(CWS_sOnLoad); CWS_onResize(); }

// Track cursor position
var CWS_curPosX, CWS_curPosY;
if(document.Event) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = CWS_MouseMove;
function CWS_MouseMove(evt)
{
//	if(document.Event)
	{
		if(evt && evt.pageX)
		{
			CWS_curPosX = evt.pageX;
			CWS_curPosY = evt.pageY;
		}
		else if(evt && evt.clientX)
		{
			CWS_curPosX = evt.clientX + document.body.scrollLeft;
			CWS_curPosY = evt.clientY + document.body.scrollTop;
		}
		else if(event && event.pageX)
		{
			CWS_curPosX = event.pageX + document.body.scrollLeft;
			CWS_curPosY = event.pageY + document.body.scrollTop;
		}
		else if(event && event.clientX)
		{
			CWS_curPosX = event.clientX + document.body.scrollLeft;
			CWS_curPosY = event.clientY + document.body.scrollTop;
		}
	}
//	else if(document.body)
//	{
//		CWS_curPosX = event.clientX + document.body.scrollLeft;
//		CWS_curPosY = event.clientY + document.body.scrollTop;
//	}
	
	//window.status = CWS_curPosX + ',' + CWS_curPosY;
}
// End - Track cursor position


/* Helpers */

function CWS_OnMouseLeave(obj, evt)
{
	oParent = window.event ? evt.toElement : evt.relatedTarget;
	while(oParent != null)
	{
		if(oParent == obj) return false;
		oParent = oParent.parentNode;
	}
	
	return true;
}

function CWS_GetParent(oNode, sNodeName, nLevel) {
	while (oNode) {
		if (oNode.nodeName == sNodeName) {
			nLevel--;

			if (nLevel <= 0) return oNode;
		}

		oNode = oNode.parentNode;
	}
}

function CWS_GetChild(oNode, sNodeName, nLevel) {
	var i;

	if (oNode) {
		for (i = 0; i < oNode.childNodes.length; i++) {
			if (oNode.childNodes[i].nodeName == sNodeName) {
				nLevel--;
				if (nLevel <= 0) return oNode.childNodes[i];
				else return CWS_GetChild(oNode.childNodes[i], sNodeName, nLevel - 1)
			}
		}
	}

	return null;
}

function CWS_GetNextNode(oNode) {
	var sNodeName = oNode.nodeName;

	while (oNode) {
		oNode = oNode.nextSibling;
		if (oNode != null && oNode.nodeName == sNodeName) return oNode;
	}

	return null;
}

function CWS_GetFirstChild(oNode) {
	for (i = 0; i < oNode.childNodes.length; i++) {
		if (oNode.childNodes[i].nodeName != '#text') return oNode.childNodes[i];
	}
}

function CWS_GetLastChild(oNode) {
	for (i = oNode.childNodes.length - 1; i >= 0; i--) {
		if (oNode.childNodes[i].nodeName != '#text') return oNode.childNodes[i];
	}
}

function CWS_OpenWindow(ur)
{
	return CWS_OpenWindow(ur, 20, 20);
}

function CWS_OpenWindow(ur, nX, nY)
{
	return window.open(ur,'','width=' + nX + ',height=' + nY + ',scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes,systembar=no');
}

function CWS_OpenViewWindow(ur)
{
	return CWS_OpenWindow(ur, 800, 600);
}

function CWS_OpenFixedWindow(ur)
{
	return CWS_OpenFixedWindow(ur, 100, 100);
}
function CWS_OpenFixedWindow(ur, nX, nY)
{
	return window.open(ur,'','width=' + nX + ',height=' + nY + ',scrollbars=no,toolbar=no,menubar=no,location=no,resizable=no,systembar=no');
}

function CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2) {
	CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2, false, '');
}

function CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2, bSetCookie, sDisplay) {
	b = 0;
	if (sDisplay == null || sDisplay.length == 0) sDisplay = 'inline';

	if (document.getElementById(sDivName).style.display == 'none') {
		document.getElementById(sDivName).style.display = sDisplay;
		if (sImgName != null) document.getElementById(sImgName).src = sSrc1;
		b = 1;
	}
	else {
		document.getElementById(sDivName).style.display = 'none';
		if (sImgName != null) document.getElementById(sImgName).src = sSrc2;
	}

	if (bSetCookie) document.cookie = sDivName + "=" + b + ";expires=Thu, 31 Dec 2099 23:59:59 GMT";

	CWS_AutoResize();
}

function CWS_ShowPopmenu(sDivName) {
	oDiv = document.getElementById(sDivName);

	if (oDiv) {
		nPosLeft = oEvent.clientX - 12;
		nPosTop = oEvent.clientY - 12 + document.body.scrollTop;

		oParent = oDiv.offsetParent;
		while (oParent) {
			nPosLeft -= oParent.offsetLeft;
			nPosTop -= oParent.offsetTop;
			oParent = oParent.offsetParent;
		}

		oDiv.style.display = 'inline';
		oDiv.style.left = nPosLeft;
		oDiv.style.top = nPosTop;
		oDiv.scrollIntoView;

		oDiv.style.zIndex = 1000;
	}
}

function CWS_ShowObj(sObjId) {
	oObj = document.getElementById(sObjId);
	if (oObj != null) {
		oObj.style.display = 'inline';

		oDivs = oObj.getElementsByTagName('DIV');
		for (i = 0; i < oDivs.length; i++) {
			if (oDivs.item(i).getAttribute('id') != null) {
				if (oDivs.item(i).getAttribute('id').substr(0, 8) == 'cmsAjax_') eval(oDivs.item(i).getAttribute('id') + '_Load()');
			}
		}
	}
}

function CWS_HideObj(sObjId) {
	oObj = document.getElementById(sObjId);
	if (oObj != null) {
		oObj.style.display = 'none';
	}
}

function CWS_HTMLEncode(str) {
	var div = document.createElement('div');
	var text = document.createTextNode(str);
	div.appendChild(text);
	return div.innerHTML;
}

function CWS_HTMLDecode(str) {
	var div = document.createElement('div');
	div.innerHTML = str;
	if (div.firstChild) return div.firstChild.nodeValue;
	else return '';
}

function CWS_Alert(sAlert) {

	if (sAlert.indexOf('[') == 0) sAlert = sAlert.substr(sAlert.indexOf(']') + 1);
	if (sAlert.indexOf('-DIV-') == 0) {
		oPopup = CWS_ShowPopup('Alert', false, true);
		oPopup.InnerHTML = sAlert.substr(5);
		return;
	}

	if (sAlert.indexOf('-WIN-') == 0) {
		CWS_OpenWindow(sAlert.substr(5), 700, 700);
		return;
	}

	while (sAlert.indexOf('&eacute;') != -1) sAlert = sAlert.replace('&eacute;', 'é');
	while (sAlert.indexOf('&egrave;') != -1) sAlert = sAlert.replace('&egrave;', 'è');
	while (sAlert.indexOf('&agrave;') != -1) sAlert = sAlert.replace('&agrave;', 'à');
	while (sAlert.indexOf('&ccedil;') != -1) sAlert = sAlert.replace('&ccedil;', 'ç');
	while (sAlert.indexOf('&acirc;') != -1) sAlert = sAlert.replace('&acirc;', 'â');
	while (sAlert.indexOf('&ecirc;') != -1) sAlert = sAlert.replace('&ecirc;', 'ê');
	while (sAlert.indexOf('&ucirc;') != -1) sAlert = sAlert.replace('&ucirc;', 'û');
	while (sAlert.indexOf('&icirc;') != -1) sAlert = sAlert.replace('&icirc;', 'î');
	while (sAlert.indexOf('&ocirc;') != -1) sAlert = sAlert.replace('&ocirc;', 'ô');
	while (sAlert.indexOf('&ugrave;') != -1) sAlert = sAlert.replace('&ugrave;', 'ù');
	while (sAlert.indexOf('&auml;') != -1) sAlert = sAlert.replace('&auml;', 'ä');
	while (sAlert.indexOf('&euml;') != -1) sAlert = sAlert.replace('&euml;', 'ë');
	while (sAlert.indexOf('&iuml;') != -1) sAlert = sAlert.replace('&iuml;', 'ï');
	while (sAlert.indexOf('&ouml;') != -1) sAlert = sAlert.replace('&iuml;', 'ö');
	while (sAlert.indexOf('\\r\\n') != -1) sAlert = sAlert.replace('\\r\\n', '\r\n');


	alert(sAlert);
}

function CWS_GotoAnchor(sID) {
	sURL = window.location.href;
	if (sURL.indexOf('#') != -1) sURL = sURL.substring(0, sURL.indexOf('#'));

	window.location = sURL + '#' + sID;
}

function CWS_SetCookie(sName, sValue) {
	document.cookie = sName + "=" + sValue + ";path=/;expires=Thu, 31 Dec 2099 23:59:59 GMT";
	//	alert(document.cookie);
}

function CWS_SetCookieVolatile(sName, sValue) {
	document.cookie = sName + "=" + sValue + ";path=/";
	//	alert(document.cookie);
}

function CWS_GetCookie(sName) {
	//	alert(document.cookie);
	sCookies = '' + document.cookie + ';';
	s = 0;
	while (-1 != (e = sCookies.indexOf(';', s))) {
		sCookie = sCookies.substr(s, e - s);
		if (sCookie.indexOf('=') != -1) {
			sCookieName = sCookie.substr(0, sCookie.indexOf('=')).replace(' ', '');
			//	alert(sCookieName + ' ' + sName);
			if (sCookieName == sName) return sCookie.substr(sCookie.indexOf('=') + 1);
		}

		s = e + 1;
	}

	return '';
}

function CWS_Print(sParams) {
	CWS_Print(sParams, 520, 600);
}

function CWS_Print(sParams, nWidth, nHeight) {
	try {
		sLocation = '' + window.location;
		if (sLocation.indexOf('?') == -1) sLocation += '?bPrint=1';
		else sLocation += '&bPrint=1';
		if (sParams && sParams.length > 0) sLocation += '&' + sParams;

		CWS_OpenWindow(sLocation, nWidth, nHeight); //.replace('action=','xxx=');
	}
	catch (e) { }
}

function CWS_HidePopup(sName) {
	if (sName == null) oPopup = oCWS_Popup;
	else oPopup = document.getElementById(sName);

	if (oPopup) oPopup.style.display = 'none';
}

function CWS_ShowPopup(sName, bCloseOnleave, bKeepOldPos) {
	if (sName == null) sName = 'div_CWSPopup';

	oPopup = document.getElementById(sName);

	if (oPopup == null) {
		if (bCloseOnleave) {
			//	oPopup = document.createElement('DIV id="' + sName + '" onmouseleave="CWS_HidePopup(\'' + sName + '\');"');
			oPopup = document.createElement('DIV');
			oPopup.onmouseout = function() { CWS_HidePopup(sName); };
		}
		else oPopup = document.createElement('DIV');

		oPopup.setAttribute('id', sName);

		document.body.insertBefore(oPopup, null);
		oPopup.style.display = 'none';
		oPopup.style.position = 'absolute';
		oPopup.style.border = 'solid 1px #000000';
		oPopup.style.padding = '2px';
		oPopup.style.backgroundColor = '#E8E8E8';
		oPopup.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=\'#808080\', Direction=135, Strength=5)';

		oPopup.style.left = CWS_curPosX - 10;
		oPopup.style.top = CWS_curPosY - 10;
	}

	if (oPopup) {
		oPopup.style.display = 'inline';
		if (!bKeepOldPos) {
			px = CWS_curPosX - 10;
			py = CWS_curPosY - 10;
			oParent = oPopup.offsetParent;
			while (oParent) {
				px -= oParent.offsetLeft;
				py -= oParent.offsetTop;
				oParent = oParent.offsetParent;
			}

			oPopup.style.left = px; //CWS_curPosX - 10;
			oPopup.style.top = py; //CWS_curPosY- 10;
		}
		oPopup.style.zIndex = 20;
		//	oPopup.scrollIntoView();

		Drag.init(oPopup);
	}

	return oPopup;
}

function CWS_HttpRequest(sURL, sPostData) {
	var xml_objet = false;

	while (sURL.indexOf('&amp;') != -1) sURL = sURL.replace('&amp;', '&');

	try { xml_objet = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch (e) {
		try { xml_objet = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (E) { xml_objet = false; }
	}

	if (!xml_objet && typeof XMLHttpRequest != 'undefined') {
		try { xml_objet = new XMLHttpRequest(); }
		catch (e) { xml_objet = false; }
	}

	if (!xml_objet && window.createRequest) {
		try { xml_objet = window.createRequest(); }
		catch (e) { xml_objet = false; }
	}

	if (xml_objet) {
		if (sPostData != null && sPostData.length > 0) {
			xml_objet.open('POST', sURL, false);
			xml_objet.setRequestHeader('Cache-Control', 'no-cache');
			xml_objet.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
			xml_objet.setRequestHeader('Content-length', sPostData.length);
			xml_objet.setRequestHeader('Connection', 'close');
			xml_objet.send(sPostData);
		}
		else {
			xml_objet.open('GET', sURL, false);
			xml_objet.setRequestHeader('Cache-Control', 'no-cache');
			xml_objet.send(null);
		}

		if (xml_objet.readyState == 4) {
			return xml_objet.responseText;
			//	return xml_objet.responseXML;
		}
	}

	return '';
}

function CWS_IsOK(sXml) {
	if (sXml.indexOf('<STATUS>0</STATUS>') != -1) return true;
	else return false;
}

function CWS_Trim(sValue) {
	sValue = '' + sValue;

	while (sValue.length > 0 && sValue.substr(0, 1) == ' ') sValue = sValue.substr(1);
	while (sValue.length > 0 && sValue.substr(sValue.length - 1, 1) == ' ') sValue = sValue.substr(0, sValue.length - 1);

	return sValue;
}

function CWS_GetTagValue(sXml, sTagName, sDefault) {
	s = sXml.indexOf('<' + sTagName + '>');
	e = sXml.indexOf('</' + sTagName + '>');

	if (s != -1 && e > s) {
		s += 2 + sTagName.length;
		return sXml.substr(s, e - s);
	}
	else return sDefault;
}

function CWS_CancelBubble(evt) {
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;
	return false;
}

function CWS_ShowWithTimer(oDiv) {
	if (oDiv == null) return;

	nTimerID = oDiv.getAttribute('TimerID');
	if (nTimerID != null) {
		window.clearTimeout(nTimerID);
		oDiv.removeAttribute('TimerID');
	}

	oDiv.style.display = 'inline';
}

function CWS_HideWithTimer(oDiv, nMilisec) {
	if (oDiv == null) return;

	nTimerID = oDiv.getAttribute('TimerID');
	if (nTimerID != null) {
		window.clearTimeout(nTimerID);
		oDiv.removeAttribute('TimerID');
	}

	sID = oDiv.getAttribute('id');
	nTimerID = window.setTimeout('CWS_Hide(\'' + sID + '\')', nMilisec);
	oDiv.setAttribute('TimerID', nTimerID);
}

function CWS_Hide(sID) {
	oDiv = document.getElementById(sID);
	if (oDiv == null) return;

	oDiv.style.display = 'none';
}

function CWS_URLEncode(sText) {
	return encodeURIComponent(sText);

	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" + 				// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()"; 				// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = sText;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+"; 			// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				alert("Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted.");
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function CWS_URLDecode(sText) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var encoded = sText;
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length - 2)
					&& HEXCHARS.indexOf(encoded.charAt(i + 1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i + 2)) != -1) {
				plaintext += unescape(encoded.substr(i, 3));
				i += 3;
			} else {
				alert('Bad escape combination near ...' + encoded.substr(i));
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	} // while

	return plaintext;
};

function setInnerHTML(pDivObject, pHTML) {
	pDivObject.innerHTML = pHTML;

	var All = pDivObject.getElementsByTagName("*");
	for (var i = 0; i < All.length; i++) {
		All[i].id = All[i].getAttribute("id");
		All[i].name = All[i].getAttribute("name");
		//	All[i].className = All[i].getAttribute("class");
	}
	var AllScripts = pDivObject.getElementsByTagName("script");

	for (var i = AllScripts.length - 1; i >= 0; i--) {
		var s = AllScripts[i];
		var oScript = document.createElement("script");

		oScript.type = 'text/javascript';

		if (s.src && s.src != "") {
			oScript.src = s.src;
		}
		else {
			//	oScript.innerHTML = s.innerHTML;
			eval(s.innerHTML);
		}

		//	document.body.appendChild(oScript);

		//	pDivObject.removeChild(s);
	}
}

function CWS_CopyToClipboard(s)
{
	try
	{
		if( window.clipboardData && clipboardData.setData )
		{
			clipboardData.setData("Text", s);
		}
		else
		{
/*
			// You have to sign the code to enable this or allow the action in about:config by changing
			user_pref("signed.applets.codebase_principal_support", true);
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

			var clip Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;

			// create a transferable
			var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
			if (!trans) return;

			// specify the data we wish to handle. Plaintext in this case.
			trans.addDataFlavor('text/unicode');

			// To get the data from the transferable we need two new objects
			var str = new Object();
			var len = new Object();

			var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

			var copytext=meintext;

			str.data=copytext;

			trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);

			var clipid=Components.interfaces.nsIClipboard;

			if (!clip) return false;

			clip.setData(trans,null,clipid.kGlobalClipboard);
*/	  
		}
	}
	catch(e)
	{
		alert(e);
	}
}

function getFlashMovieObject(movieName)
{  
	if (window.document[movieName])
	{
		return window.document[movieName];  
	}  

	if (navigator.appName.indexOf("Microsoft Internet") == -1)
	{
		if (document.embeds && document.embeds[movieName]) return document.embeds[movieName];  
	}  
	else return document.getElementById(movieName);
}

function CreateXMLStringParser(XMLString)
{
	try
	{
		var xmlParser = new DOMParser();
		var xmlDoc = xmlParser.parseFromString(XMLString, "text/xml");
	}
	catch (Err)
	{
		try
		{
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = "false";
			xmlDoc.loadXML(XMLString);
		}
		catch (Err)
		{
			window.alert("Browser does not support XML parsing.");
			return false;
		}
	}

	return xmlDoc;
}


function XSLTTransform(XSLStyleSheet, XMLData, InsertElementID, Parameters)
{//Function to perform the XSLT based transformation
	if (window.ActiveXObject)
	{//Code for internet explorer
		var XSLTCompiled = new ActiveXObject("MSXML2.XSLTemplate");
		//	var XSLTCompiled = new ActiveXObject("Microsoft.XMLDOM");

		XSLTCompiled.stylesheet = XSLStyleSheet.documentElement;
		// create XSL-processor
		var XSLTProc = XSLTCompiled.createProcessor();
		XSLTProc.input = XMLData;

		if (Parameters != "")
		{//Loop through the parameters and apply each to the XSLT Processor
			for ($Index in Parameters)
			{
				XSLTProc.addParameter(Index, Parameters[Index]);
			}
		}

		XSLTProc.transform();

		document.getElementById(InsertElementID).innerHTML = XSLTProcessor.output;
	}
	else if (document.implementation && document.implementation.createDocument)
	{//Code for mozilla
		XSLTProc = new XSLTProcessor();
		XSLTProc.importStylesheet(XSLStyleSheet);

		if (Parameters != "")
		{//Loop through the parameters and apply each to the XSLT Processor
			for ($Index in Parameters)
			{
				XSLTProc.setParameter("", Index, Parameters[Index]);
			}
		}

		TransformDoc = XSLTProc.transformToFragment(XMLData, document);
		document.getElementById(InsertElementID).appendChild(TransformDoc);
	}
	else
	{
		window.alert("Browser does not support XSLT.");
		return false;
	}
}

function CWS_XslTransform(xmlURL, xslURL, sDestElementName, xslParams)
{
	if (window.ActiveXObject)
	{
		var xml = new ActiveXObject("Microsoft.XMLDOM");
		var xslt = new ActiveXObject("Microsoft.XMLDOM");

		xml.async = false;
		xslt.async = false;

		xml.load(xmlURL);
		xslt.load(xslURL);

		document.getElementById(sDestElementName).innerHTML = xml.transformNode(xslt);
	}
	else if (window.XMLHttpRequest)
	{
		XSLTTransform(CreateXMLStringParser(CWS_HttpRequest(xslURL)), CreateXMLStringParser(CWS_HttpRequest(xmlURL)), sDestElementName, xslParams);
	}
}


/* Forms */
function CWS_CheckDay(fname)
{
	dd = eval('document.all.' + fname + '_DD');
	mm = eval('document.all.' + fname + '_MM');
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	if(parseInt(dd.value) < 1) dd.value = 1;
	if(parseInt(dd.value) > 31) dd.value = 31;
	if(parseInt(dd.value) > 30 && (parseInt(mm.value) == 4 || parseInt(mm.value) == 6 || parseInt(mm.value) == 9 || parseInt(mm.value) == 11)) dd.value = 30;
	if(parseInt(dd.value) > 28 && parseInt(mm.value) == 2)
	{
		if(parseInt(yyyy.value) % 4 != 0 || parseInt(yyyy.value) == 2000) dd.value = 28;
		else dd.value = 29;
	} 
}

function CWS_CheckMonth(fname)
{
	mm = eval('document.all.' + fname + '_MM');
	
	if(parseInt(mm.value) < 1) mm.value = 1;
	if(parseInt(mm.value) > 12) mm.value = 12;
	
	CWS_CheckDay(fname);
}

function CWS_CheckYear(fname)
{
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	if(parseInt(yyyy.value) < 1900) yyyy.value = 1900 + parseInt(yyyy.value);
	if(parseInt(yyyy.value) < 1950) yyyy.value = 100 + parseInt(yyyy.value);
	if(parseInt(yyyy.value) > 2100) yyyy.value = 2100;
	
	CWS_CheckDay(fname);
}

function CWS_CheckHour(fname)
{
	hh = eval('document.all.' + fname + '_HH');
	
	if(parseInt(hh.value) < 0) hh.value = 0;
	if(parseInt(hh.value) > 23) hh.value = 23;
}

function CWS_CheckMinute(fname)
{
	nn = eval('document.all.' + fname + '_NN');
	
	if(parseInt(nn.value) < 0) nn.value = 0;
	if(parseInt(nn.value) > 59) nn.value = 59;
}

function CWS_CheckSeconde(fname)
{
	ss = eval('document.all.' + fname + '_SS');
	
	if(parseInt(ss.value) < 0) ss.value = 0;
	if(parseInt(ss.value) > 59) ss.value = 59;
}

function CWS_GetSelectedIDs(oForm)
{
	sIDs = '';
	
	for(i=0;i<oForm.length;i++)
	{
		if(oForm.elements[i].getAttribute('name') == 'IDs' && oForm.elements[i].checked)
		{
			if(sIDs.length > 0) sIDs += ',';
			sIDs += oForm.elements[i].value;
		}
	}
	
	return sIDs;
}

function CWS_GetPostDataFromForm(oForm)
{
	var		sPostData = 'bAjax=1', sFieldValue = '';
	
	if(oForm)
	{
		for(i=0;i<oForm.length;i++)
		{
			oField = oForm.elements[i];
		
			if(oField.getAttribute('type') == 'checkbox')
			{
				if(oField.checked) sFieldValue = '1';
				else sFieldValue = '0';
				
				sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
			}
			else if(oField.getAttribute('type') == 'radio')
			{
				if(oField.length > 1)
				{
					for(j=0;j<oField.length;j++)
					{
						if(oField[j].checked)
						{
							sFieldValue = oField[j].value;
							sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
						}
					}
				}
				else
				{
					if(oField.checked)
					{
						sFieldValue = oField.value;
						sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
					}
				} 
			}
			else if(oField.nodeName == 'SELECT')
			{
				if(oField.selectedIndex >= 0)
				{
					sFieldValue = oField.options[oField.selectedIndex].value;
					sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
				}
			}
			else
			{
				sFieldValue = oField.value;
				sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
			}
		}
	}
	
	return sPostData;
}

function CWS_isValidEMail(string)
{
	var first;
	var second;
	var last;
	
	if((last=string.length-1) < 4) return false;
	
	if(string.indexOf(' ') != -1) return false;
	if(string.indexOf('..') != -1) return false;
	if(string.indexOf('\'') != -1) return false;
	if(string.indexOf('"') != -1) return false;
	if(string.indexOf('&') != -1) return false;
	if(string.indexOf('|') != -1) return false;
	if(string.indexOf(';') != -1) return false;
	if(string.indexOf(',') != -1) return false;
	if(string.indexOf('£') != -1) return false;
	if(string.indexOf('+') != -1) return false;
	if(string.indexOf('%') != -1) return false;
	if(string.indexOf('?') != -1) return false;
	if(string.indexOf('/') != -1) return false;
	if(string.indexOf('=') != -1) return false;
	if(string.indexOf('µ') != -1) return false;
	if(string.indexOf('$') != -1) return false;
	if(string.indexOf('\\') != -1) return false;
	if(string.indexOf(':') != -1) return false;
	if(string.indexOf('<') != -1) return false;
	if(string.indexOf('>') != -1) return false;
	if(string.indexOf('[') != -1) return false;
	if(string.indexOf(']') != -1) return false;
	if(string.indexOf('(') != -1) return false;
	if(string.indexOf(')') != -1) return false;
	if(string.indexOf('§') != -1) return false;
	if(string.indexOf('!') != -1) return false;
	if(string.indexOf('{') != -1) return false;
	if(string.indexOf('}') != -1) return false;
	
	if( (first=string.indexOf("@",1)) !=-1 )
	{
		if(string.indexOf("@", first+1) != -1) return false;
		
		if( ((last-first) >= 3) && (second=string.indexOf(".",first+2)) !=-1 ) return true;
	}

	return false;
}

function CWS_ValidateNumeric(evt, nLength, bInt, bPos)
{
	var e = (window.event)?window.event:evt;
	oField = (window.event)?e.srcElement:e.target;
	nKeyCode = (window.event)?e.keyCode:e.charCode;
	
	if(nLength == null || nLength == 0) nLength = 16;
	
	sValue = '' + oField.value;
	
	if((e.keyCode == 45 && !bPos && sValue.length == 0) || (e.keyCode == 46 && !bInt && sValue.length < (nLength-1)) || e.keyCode == 8 || e.keyCode == 13 || e.keyCode == 9) return true; 
		
	if(sValue.length >= nLength)
	{
		return false;
	}
	
	if(nKeyCode < 48 || nKeyCode > 58) return false;

	return true;
}

function CWS_FormatNumber(valeur,decimal,separateur)
{
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	return val_format;
}

/* Objects */

var nBigItemsPaneIndex = 0;
var nRightItemsPaneIndex = 1;
var nPreviousBigItem = -1;
var PreviousSelected = null;

function SynchroniseBigItem(_Self, fElapsedtime)
{
	this.Animate = function()
	{
		var nCurItem = oScrollingPanes.aScrollingPanes[nBigItemsPaneIndex].nCurPage;
		if (nPreviousBigItem != nCurItem)
		{
			nPreviousBigItem = nCurItem;

			oScrollingPanes.aScrollingPanes[nRightItemsPaneIndex].nCurPage = Math.floor(nCurItem / 3);

			if (PreviousSelected) PreviousSelected.className = "RMItem";
			PreviousSelected = oScrollingPanes.aScrollingPanes[nRightItemsPaneIndex].oContent.getElementsByTagName('DIV')[nCurItem];

			oScrollingPanes.aScrollingPanes[nRightItemsPaneIndex].oContent.getElementsByTagName('DIV')[nCurItem].className = "RMItem Selected";
		}
	}
}

function ShowBigItem(oObj, x)
{
	oScrollingPanes.aScrollingPanes[nBigItemsPaneIndex].GotoPage(x - 1);
	oScrollingPanes.aScrollingPanes[nBigItemsPaneIndex].nSlideShowDelay = 0;

	if (oObj)
	{
		if (PreviousSelected != oObj) PreviousSelected.className = "RMItem";
		PreviousSelected = oObj;
		oObj.className = "RMItem Selected";
	}
}

/* Helpers */

function getStyle(oObj, styleProp)
{
	var sResult = null;

	if (oObj.currentStyle) sResult = oObj.currentStyle[styleProp];
	else if (window.getComputedStyle) sResult = document.defaultView.getComputedStyle(oObj, null).getPropertyValue(styleProp);

	if (sResult == null) sResult = "0";

	return sResult;
}

function getCSSProperty(mixed, sProperty) {

	oNode = (typeof mixed == "object") ? mixed : document.getElementById(mixed);

	if (document.defaultView) {
		return document.defaultView.getComputedStyle(oNode, null).getPropertyValue(sProperty);
	}
	else if (oNode.currentStyle) {
		sProperty = sProperty.replace(/\-(\w)/g, function(m, c) { return c.toUpperCase(); });
		return oNode.currentStyle[sProperty];
	}
	else {
		return null;
	}
}

/**
* Retourne les coordonnées d'un élément pour Internet Explorer.
*/
function ieGetCoords(elt) {
	var coords = elt.getBoundingClientRect();
	var border = getCSSProperty(document.getElementsByTagName('HTML')[0], 'border-width');
	var border = (border == 'medium') ? 2 : parseInt(border);

	coords.left += Math.max(elt.ownerDocument.documentElement.scrollLeft, elt.ownerDocument.body.scrollLeft) - border;
	coords.top += Math.max(elt.ownerDocument.documentElement.scrollTop, elt.ownerDocument.body.scrollTop) - border;

	return coords;
}

/** 
* Retourne les coordonnées d'un élément sur une page en fonction de tous ses éléments parents.
* 
* @param objet element
* @param objet eltRef (optionnel)
* @return json coords = {left:x, top:x}
*/
function getElementCoords(element, eltReferant) {

	var coords = { left: 0, top: 0 };

	// IE pour résoudre le problème des marges (IE comptabilise dans offsetLeft la propriété marginLeft).
	if (false && element.getBoundingClientRect) {

		coords = ieGetCoords(element);

		if (typeof (eltReferant) == 'object') {
			var coords2 = ieGetCoords(eltReferant);

			coords.left -= coords2.left;
			coords.top -= coords2.top;

			coords2 = null;
		}
	}
	// Les autres : récursivité sur offsetParent.
	else {

		while (element) {

			if (/^table$/i.test(element.tagName) && element.getElementsByTagName('CAPTION').length == 1 && getCSSProperty(element, 'position').toLowerCase() == 'relative') {
				coords.top += element.getElementsByTagName('CAPTION')[0].offsetHeight;
			}

			coords.left += element.offsetLeft;
			coords.top += element.offsetTop;
			element = element.offsetParent;

			if (typeof (eltReferant) == 'object' && element === eltReferant) {
				break;
			}
		}
	}

	return coords;
}

function FadeIn(oDiv) {
	if (oFader) oFader.In(oDiv);
	else oDiv.style.display = 'block';
}

function FadeOut(oDiv) {
	if (oFader) oFader.Out(oDiv);
	else oDiv.style.display = 'none';
}

function Fader(oTimersHandler)
{
	this.aIns = new Array();
	this.aOuts = new Array();

	this.In = function(oDiv)
	{
		for (i = 0; i < this.aIns.length; i++)
		{
			if (this.aIns[i] == oDiv) return;
		}

		for (i = 0; i < this.aOuts.length; i++)
		{
			if (this.aOuts[i] == oDiv) return;
		}

		for (i = 0; i < this.aIns.length; i++)
		{
			if (this.aIns[i] == null) {
				this.aIns[i] = oDiv;
				return;
			}
		}

		this.aIns[i] = oDiv;
	}

	this.Out = function(oDiv) {
		for (i = 0; i < this.aOuts.length; i++) {
			if (this.aOuts[i] == oDiv) return;
		}

		for (i = 0; i < this.aIns.length; i++) {
			if (this.aIns[i] == oDiv) return;
		}

		for (i = 0; i < this.aOuts.length; i++) {
			if (this.aOuts[i] == null) {
				this.aOuts[i] = oDiv;
				return;
			}
		}

		this.aOuts[i] = oDiv;
	}

	this.Animate = function(_Self, fElapdseTime) {
		for (i = 0; i < _Self.aOuts.length; i++) {
			if (_Self.aOuts[i] != null) {
				nOpacity = _Self.aOuts[i].style.opacity;
				if (isNaN(nOpacity) || nOpacity == 0) nOpacity = 1.0;
				nOpacity -= fElapdseTime / 100.0;
				if (nOpacity > 0) {
					_Self.aOuts[i].style.opacity = nOpacity;
					_Self.aOuts[i].style.filter = 'alpha(opacity=' + Math.floor(nOpacity * 100) + ')';
				}
				else {
					_Self.aOuts[i].style.opacity = '';
					_Self.aOuts[i].style.filter = '';
					_Self.aOuts[i].style.display = 'none';
					_Self.aOuts[i] = null;
				}
			}
		}

		for (i = 0; i < _Self.aIns.length; i++) {
			if (_Self.aIns[i] != null) {
				nOpacity = _Self.aIns[i].style.opacity;
				if (isNaN(nOpacity) || nOpacity == 1) nOpacity = 0;
				nOpacity += fElapdseTime / 100.0;
				if (nOpacity < 1) {
					_Self.aIns[i].style.opacity = nOpacity;
					_Self.aIns[i].style.filter = 'alpha(opacity=' + Math.floor(nOpacity * 100) + ')';
				}
				else {
					_Self.aIns[i].style.opacity = '';
					_Self.aIns[i].style.filter = '';
					_Self.aIns[i].style.display = 'block';
					_Self.aIns[i] = null;
				}
			}
		}
	}

	oTimersHandler.AddTimer(this);
}

/* Combo box */

function ComboBoxes(oTimersHandler)
{
	this.nNbComboBoxes = 0;
	this.aComboBoxes = new Array();

	this.oDivs = document.getElementsByTagName('INPUT');

	for (var i = 0; i < this.oDivs.length; i++)
	{
		if (this.oDivs[i].className.indexOf('ComboBox ') != -1)
		{
			this.aComboBoxes[this.nNbComboBoxes] = new ComboBox(this.oDivs[i++], oTimersHandler, this.nNbComboBoxes);
			this.nNbComboBoxes++;
		}
	}

	this.Animate = function (_Self, fElapdseTime)
	{
		for (i = 0; i < _Self.aComboBoxes.length; i++)
		{
			_Self.aComboBoxes[i].Animate(_Self.aComboBoxes[i], fElapdseTime);
		}
	}

	oTimersHandler.AddTimer(this);
}

function ComboBox(oDiv, oTimersHandler, nIndex)
{
	this.oObj = oDiv;
	this.nIndex = nIndex;
	this.oObj.setAttribute('index', this.nIndex);
	this.nSelected = -1;
	
	this.sUrl = oDiv.getAttribute('sUrl');
	this.sDefaultText = oDiv.getAttribute('DefaultText');
	this.nWindowSize = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));

	this.oComboBox = document.createElement('DIV');
	this.oComboBox.className = 'Combobox';
	this.oComboBox.style.position = 'relative';

	this.oTextInput = document.createElement('INPUT');
	this.oTextInput.className = 'ComboboxInput';
	this.oTextInput.value = this.oObj.value;
	this.oTextInput.setAttribute('index', this.nIndex);

	if(this.oTextInput.value.length == 0)
	{
		this.oTextInput.value = this.sDefaultText;
		this.oTextInput.className = 'ComboboxInput dimmed';
	}

	this.oList = document.createElement('DIV');
	this.oList.className = 'ComboboxList';
	this.oList.style.display = 'none';
	this.oList.style.position = 'absolute';
	this.oList.style.zIndex = 2;

	this.oComboBox.appendChild(this.oList);
	this.oComboBox.appendChild(this.oTextInput);

	this.oObj.parentNode.insertBefore(this.oComboBox, this.oObj);
	//	this.oObj.type = 'hidden';
	this.oObj.style.position = 'absolute';
	this.oObj.style.top = '-10px';
	this.oObj.style.display = 'block';

	this.Animate = function (_Self, fElapsedtime) {
		_Self.Update();
	}

	this.onclickitem = function (evt)
	{
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'A')) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oComboBox = oComboBoxes.aComboBoxes[oSrc.getAttribute('index')];
	
		oComboBox.oTextInput.value = oSrc.innerHTML;
		oComboBox.oObj.value = oSrc.getAttribute('value');
		oComboBox.oTextInput.className = 'ComboboxInput';

		oComboBox.oList.style.display = 'none';
	}

	this.onblur = function (evt)
	{
		var oSrc = null;

		if (!evt)
		{
			oSrc = window.event.srcElement;
			evt = window.event;
		}
		else
		{
			oSrc = evt.target;
		}

		while (oSrc != null && (oSrc.nodeName != 'INPUT' || oSrc.className.indexOf('ComboboxInput') != 0)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oComboBox = oComboBoxes.aComboBoxes[oSrc.getAttribute('index')];

		oParent = window.event ? evt.toElement : evt.relatedTarget;
		while(oParent != null)
		{
			if(oParent == oComboBox) return false;
			oParent = oParent.parentNode;
		}

		if(oComboBox.oObj.value.length == 0)
		{
			oComboBox.oTextInput.value = oComboBox.sDefaultText;
			oComboBox.oTextInput.className = 'ComboboxInput dimmed';
			oComboBox.oObj.value = '';
		}
		
	//	oComboBox.oList.style.display = 'none';
	}

	this.onKeydown = function (evt)
	{
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'INPUT' || oSrc.className.indexOf('ComboboxInput') != 0)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oComboBox = oComboBoxes.aComboBoxes[oSrc.getAttribute('index')];

		if(evt == null) evt = window.event;

		switch (evt.keyCode)
		{
			case 13:
			case 38:
			case 40:

				return CWS_CancelBubble(evt);
		}
		
	}

	this.onfocus = function(evt)
	{
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'INPUT' || oSrc.className.indexOf('ComboboxInput') != 0)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oComboBox = oComboBoxes.aComboBoxes[oSrc.getAttribute('index')];

		if(oComboBox.oTextInput.value == oComboBox.sDefaultText) oComboBox.oTextInput.value = '';
		oComboBox.oTextInput.className = 'ComboboxInput';
	}

	this.onKeyup = function (evt)
	{
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'INPUT' || oSrc.className.indexOf('ComboboxInput') != 0)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oComboBox = oComboBoxes.aComboBoxes[oSrc.getAttribute('index')];

		if(evt == null) evt = window.event;

		switch (evt.keyCode)
		{
			case 13:

				try
				{
					aLinks = oComboBox.oList.getElementsByTagName('A');

					oComboBox.oTextInput.value = aLinks[oComboBox.nSelected].innerHTML;
					oComboBox.oObj.value = aLinks[oComboBox.nSelected].getAttribute('value');

					oComboBox.oList.style.display = 'none';
				}
				catch (e) { }

				break;

			case 38:

				try
				{
					aLinks = oComboBox.oList.getElementsByTagName('A');

					for (i = 0; i < aLinks.length; i++)
					{
						if (aLinks[i].className == 'selected')
						{
							oComboBox.nSelected = i - 1;
							aLinks[i].className = '';
						}
					}

					if (oComboBox.nSelected < 0) oComboBox.nSelected = 0;
					aLinks[oComboBox.nSelected].className = 'selected';
				}
				catch (e) { }

				break;

			case 40:

				try {
					aLinks = oComboBox.oList.getElementsByTagName('A');

					for (i = 0; i < aLinks.length; i++)
					{
						if (aLinks[i].className == 'selected')
						{
							oComboBox.nSelected = i + 1;
							aLinks[i].className = '';
						}
					}

					if (oComboBox.nSelected >= aLinks.length) oComboBox.nSelected = aLinks.length - 1;
					if (oComboBox.nSelected < 0) oComboBox.nSelected = 0;
					aLinks[oComboBox.nSelected].className = 'selected';
				}
				catch (e) { }

				break;

			default:
				oComboBox.nSelected = -1;
				oComboBox.oObj.value = '';
				sText = oComboBox.oTextInput.value;
				if (sText.length > 1) {
					oComboBox.oList.innerHTML = CWS_HttpRequest(oComboBox.sUrl + '&name=' + CWS_URLEncode(sText));
					oComboBox.oList.style.display = 'block';

					aLinks = oComboBox.oList.getElementsByTagName('A');

					for (i = 0; i < aLinks.length; i++)
					{
						aLinks[i].setAttribute('index', oComboBox.nIndex);
						aLinks[i].onclick = oComboBox.onclickitem;
					}
				}
				else {
					oComboBox.oList.innerHTML = '';
					oComboBox.oList.style.display = 'none';
				}
				break;
		}

		return CWS_CancelBubble(evt);
	}

	this.Update = function ()
	{
		
	}

	this.oTextInput.onkeyup = this.onKeyup;
	this.oTextInput.onkeydown = this.onKeydown;
	this.oTextInput.onblur = this.onblur;
	this.oTextInput.onfocus = this.onfocus;
}

/* /Combo box */

/* Sliders */

function Sliders(oTimersHandler) {
	this.nNbSliders = 0;
	this.aSliders = new Array();

	this.oDivs = document.getElementsByTagName('INPUT');

	for (var i = 0; i < this.oDivs.length; i++) {
		if (this.oDivs[i].className.indexOf('Slider ') != -1) {
			var bVert = false;
			if (this.oDivs[i].className.indexOf('-SLV') != -1) bVert = true;
			this.aSliders[this.nNbSliders] = new Slider(this.oDivs[i], oTimersHandler, this.nNbSliders, bVert);
			this.nNbSliders++;
		}
	}

	this.Animate = function (_Self, fElapdseTime) {
		for (i = 0; i < _Self.aSliders.length; i++) {
			_Self.aSliders[i].Animate(_Self.aSliders[i], fElapdseTime);
		}
	}

	oTimersHandler.AddTimer(this);
}

function Slider(oDiv, oTimersHandler, nIndex, bVert) {
	this.oObj = oDiv;
	this.nIndex = nIndex;
	this.bVert = bVert;
	this.bSliding = false;
	this.nStartMouseX = 0;
	this.nStartMouseY = 0;
	this.nOffset = 0;

	this.nMinValue = '' + oDiv.getAttribute('minValue');
	this.nMaxValue = '' + oDiv.getAttribute('maxValue');
	this.nScaleFactor = '' + oDiv.getAttribute('scaleFactor');
	if (isNaN(this.nMinValue / 1)) this.nMinValue = 0;
	if (isNaN(this.nMaxValue / 1)) this.nMaxValue = 100;
	if (isNaN(this.nScaleFactor / 1)) this.nScaleFactor = 1;
	if (this.nMaxValue < this.nMinValue) {
		this.ntemp = this.nMinValue;
		this.nMinValue = this.nMaxValue;
		this.nMaxValue = this.nTemp;
	}
	this.sUnit = '' + oDiv.getAttribute('unit');
	this.nValue = this.oObj.value / this.nScaleFactor;
	if (isNaN(this.nValue)) this.nValue = nMinValue;

	this.nWindowSize = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));

	this.oObj.style.position = 'relative';

	this.nMaxOffset = this.nWindowSize;

	this.oOutput = document.getElementById('' + oDiv.getAttribute('output'));

	this.oSlider = document.createElement('DIV');
	this.oSlider.className = 'Slider';
	this.oSlider.style.position = 'relative';

	this.oBar = document.createElement('DIV');
	this.oBar.className = 'SliderBar';

	this.oFill = document.createElement('DIV');
	this.oFill.className = 'SliderFill';
	this.oBar.appendChild(this.oFill);

	this.oBut = document.createElement('DIV');
	this.oBut.className = 'SliderButton';

	this.oValue = document.createElement('SPAN');
	this.oValue.className = 'SliderValue';
	this.oBut.appendChild(this.oValue);

	this.oBar.appendChild(this.oBut);

	this.oMin = document.createElement('SPAN');
	this.oMin.className = 'SliderMin';
	this.oBar.appendChild(this.oMin);
	this.oMin.innerHTML = CWS_FormatNumber(this.nMinValue * this.nScaleFactor, 0, '.');

	this.oMax = document.createElement('SPAN');
	this.oMax.className = 'SliderMax';
	this.oBar.appendChild(this.oMax);
	this.oMax.innerHTML = CWS_FormatNumber(this.nMaxValue * this.nScaleFactor, 0, '.');

	this.oSlider.appendChild(this.oBar);
	this.oObj.parentNode.insertBefore(this.oSlider, this.oObj);
//	this.oObj.type = 'hidden';
	this.oObj.style.position = 'absolute';
	this.oObj.style.top = '-1000px';
	this.oObj.style.display = 'block';

	this.oObj.setAttribute('index', this.nIndex);
	this.oBut.setAttribute('index', this.nIndex);

	this.Animate = function (_Self, fElapsedtime) {
		_Self.Update();
	}

	this.onSlideStart = function (evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className != 'SliderButton')) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oSlider = oSliders.aSliders[oSrc.getAttribute('index')];

		oSlider.bSliding = true;
		oSlider.nStartMouseX = CWS_curPosX;

		return CWS_CancelBubble(evt);
	}

	this.onSlideStop = function (evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className != 'SliderButton')) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oSlider = oSliders.aSliders[oSrc.getAttribute('index')];

		oSlider.bSliding = false;

		return CWS_CancelBubble(evt);
	}

	this.Update = function () {
		if (this.bSliding) {
			if (this.bVert) nDelta = CWS_curPosY - this.nStartMouseY;
			else nDelta = CWS_curPosX - this.nStartMouseX;

			this.nStartMouseY = CWS_curPosY;
			this.nStartMouseX = CWS_curPosX;

			this.nOffset += nDelta;

			if (this.nOffset < 0) this.nOffset = 0;
			if (this.nOffset > this.nMaxOffset) this.nOffset = this.nMaxOffset;

			if (this.bVert) {
				this.oBut.style.top = this.nOffset + 'px';
				this.oFill.style.height = this.nOffset + 'px';
			}
			else {
				this.oBut.style.left = this.nOffset + 'px';
				this.oFill.style.width = this.nOffset + 'px';
			}

			try {
				this.nValue = Math.floor((this.nOffset * this.nMaxValue) / this.nMaxOffset);
				if (this.nValue < this.nMinValue) this.nValue = this.nMinValue;
				if (this.nValue > this.nMaxValue) this.nValue = this.nMaxValue;

				if(this.oOutput) this.oOutput.innerHTML = CWS_FormatNumber(this.nValue * this.nScaleFactor, 0, '.');
				else this.oValue.innerHTML = CWS_FormatNumber(this.nValue * this.nScaleFactor, 0, '.') + ' ' + this.sUnit;

				this.oObj.value = this.nValue * this.nScaleFactor;
				if (this.oObj.onchange) this.oObj.onchange();
			}
			catch (e) { }
		}
	}

	this.oBut.onmousedown = this.onSlideStart;
	this.oBut.onmouseup = this.onSlideStop;
	//	this.oBut.onmouseout = this.onSlideStop;

	this.oBar.onselectstart = CWS_CancelBubble;

	try {
	//	this.nValue = Math.floor((this.nOffset * this.nMaxValue) / this.nMaxOffset);
		if (this.nValue < this.nMinValue) this.nValue = this.nMinValue;
		if (this.nValue > this.nMaxValue) this.nValue = this.nMaxValue;

		this.nOffset = Math.floor(this.nMaxOffset * ((this.nValue - this.nMinValue) / (this.nMaxValue - this.nMinValue)));
		if (this.nOffset < 0) this.nOffset = 0;
		if (this.nOffset > this.nMaxOffset) this.nOffset = this.nMaxOffset;

		if (this.bVert)
		{
			this.oBut.style.top = this.nOffset + 'px';
			this.oFill.style.height = this.nOffset + 'px';
		}
		else
		{
			this.oBut.style.left = this.nOffset + 'px';
			this.oFill.style.width = this.nOffset + 'px';
		}

		if(this.oOutput) this.oOutput.innerHTML = CWS_FormatNumber(this.nValue * this.nScaleFactor, 0, '.');
		else this.oValue.innerHTML = CWS_FormatNumber(this.nValue * this.nScaleFactor, 0, '.') + ' ' + this.sUnit;

		this.oObj.value = this.nValue * this.nScaleFactor;

		if (this.oObj.onchange) this.oObj.onchange();
	}
	catch (e) { }
}

/* /Sliders */

/* Scrolling bars */

function ScrollingBars(oTimersHandler) {
	this.nNbScrollingBars = 0;
	this.aScrollingBars = new Array();

	this.oDivs = document.getElementsByTagName('DIV');

	for (var i = 0; i < this.oDivs.length; i++) {
		if (this.oDivs[i].className.indexOf('ScrollBar ') != -1) {
			var bVert = false;
			var nVisibilityParentLevel = 0;
			if (this.oDivs[i].className.indexOf('-SBV') != -1) bVert = true;
			if (this.oDivs[i].className.indexOf('-P') != -1) {
				nVisibilityParentLevel = this.oDivs[i].className.substr(this.oDivs[i].className.indexOf('-P') + 2);
				if (nVisibilityParentLevel.indexOf(' ') != -1) nVisibilityParentLevel = nVisibilityParentLevel.substr(0, nVisibilityParentLevel.indexOf(' '));
				nVisibilityParentLevel = Math.floor(nVisibilityParentLevel);
			}
			this.aScrollingBars[this.nNbScrollingBars] = new ScrollingBar(this.oDivs[i], oTimersHandler, this.nNbScrollingBars, bVert, nVisibilityParentLevel);
			this.nNbScrollingBars++;
		}
	}

	this.Animate = function(_Self, fElapdseTime) {
		for (i = 0; i < _Self.aScrollingBars.length; i++) {
			_Self.aScrollingBars[i].Animate(_Self.aScrollingBars[i], fElapdseTime);
		}
	}

	oTimersHandler.AddTimer(this);

}

function ScrollingBar(oDiv, oTimersHandler, nIndex, bVert, nVisibilityParentLevel)
{
	this.oObj = oDiv;
	this.nIndex = nIndex;
	this.bVert = bVert;
	this.bScrolling = false;
	this.nStartMouseX = 0;
	this.nStartMouseY = 0;
	this.nOffset = 0;
	this.nTargetOffset = 0;
	this.VisibilityParent = this.oObj;
	
	this.nWindowSize = Math.floor(getStyle(this.oObj, 'height').replace('px', ''));

	if(getStyle(this.oObj, 'position') != 'absolute') this.oObj.style.position = 'relative';

	this.oContent = document.createElement('DIV');
	this.oContent.style.position = 'relative';

	tmpDiv = document.createElement('DIV');
	tmpDiv.style.clear = 'both';

	while (nVisibilityParentLevel > 0 && this.VisibilityParent.parentNode)
	{
		nVisibilityParentLevel--;
		this.VisibilityParent = this.VisibilityParent.parentNode;
	}
	sDisplay = this.VisibilityParent.style.display;
	this.VisibilityParent.style.display = 'inline';

	this.oObj.appendChild(tmpDiv);
	this.nContentSize = tmpDiv.offsetTop;
	if (this.nContentSize < 0) this.nContentSize = 0;
	this.VisibilityParent.style.display = sDisplay;
	this.oContent.style.height = this.nContentSize + 'px';
	
	while (this.oObj.childNodes.length > 0) {
		this.oContent.appendChild(this.oObj.childNodes[0]);
	}
	this.oObj.appendChild(this.oContent);

	if (this.nContentSize > 0) this.nButtonSize = Math.floor(this.nWindowSize / this.nContentSize * this.nWindowSize);
	else this.nButtonSize = this.nWindowSize;
	if (this.nButtonSize < 26) this.nButtonSize = 26;
	if (this.nButtonSize > this.nWindowSize) this.nButtonSize = this.nWindowSize;

	this.nMaxOffset = this.nWindowSize - this.nButtonSize;
	this.nScrollFactor = (this.nContentSize - this.nWindowSize) / this.nMaxOffset;

	this.oBar = document.createElement('DIV');
	this.oBar.className = 'ScrollingBar';

	tmpDiv = document.createElement('DIV');
	tmpDiv.className = 'ScrollingBarTop';
	this.oBar.appendChild(tmpDiv);

	tmpDiv = document.createElement('DIV');
	tmpDiv.className = 'ScrollingBarVert';
	tmpDiv.style.height = (this.nWindowSize - 24) + 'px';
	this.oBar.appendChild(tmpDiv);

	tmpDiv = document.createElement('DIV');
	tmpDiv.className = 'ScrollingBarBottom';
	this.oBar.appendChild(tmpDiv);

	this.oBut = document.createElement('DIV');
	this.oBut.className = 'ScrollingButton';
	this.oBar.appendChild(this.oBut);

	tmpDiv = document.createElement('DIV');
	tmpDiv.className = 'ScrollingButtonTop';
	this.oBut.appendChild(tmpDiv);

	this.oButBody = document.createElement('DIV');
	this.oButBody.className = 'ScrollingButtonVert';
	this.oButBody.style.height = (this.nButtonSize - 26) + 'px';
	this.oBut.appendChild(this.oButBody);

	tmpDiv = document.createElement('DIV');
	tmpDiv.className = 'ScrollingButtonBottom';
	this.oBut.appendChild(tmpDiv);

	if (this.nMaxOffset > 0) this.oObj.appendChild(this.oBar);

	this.oObj.setAttribute('index', this.nIndex);
	this.oBut.setAttribute('index', this.nIndex);

	this.Animate = function(_Self, fElapsedtime) {
		_Self.Update();
	}

	this.onContentChanged = function ()
	{
		tmpDiv = document.createElement('DIV');
		tmpDiv.style.clear = 'both';

		while (this.nVisibilityParentLevel > 0 && this.VisibilityParent.parentNode)
		{
			this.nVisibilityParentLevel--;
			this.VisibilityParent = this.VisibilityParent.parentNode;
		}
		sDisplay = this.VisibilityParent.style.display;
		this.VisibilityParent.style.display = 'inline-block';

		this.oContent.appendChild(tmpDiv);
		this.nContentSize = tmpDiv.offsetTop;

		if (this.nContentSize < 0) this.nContentSize = 0;
		this.VisibilityParent.style.display = sDisplay;
		this.oContent.style.height = this.nContentSize + 'px';

		if (this.nContentSize > 0) this.nButtonSize = Math.floor(this.nWindowSize / this.nContentSize * this.nWindowSize);
		else this.nButtonSize = this.nWindowSize;
		if (this.nButtonSize < 26) this.nButtonSize = 26;
		if (this.nButtonSize > this.nWindowSize) this.nButtonSize = this.nWindowSize;
		this.oButBody.style.height = (this.nButtonSize - 26) + 'px';

		this.nMaxOffset = this.nWindowSize - this.nButtonSize;
		this.nScrollFactor = (this.nContentSize - this.nWindowSize) / this.nMaxOffset;

		if (this.nMaxOffset > 0) this.oObj.appendChild(this.oBar);
	}

	this.onScrollStart = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className != 'ScrollingButton')) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingBar = oScrollingBars.aScrollingBars[oSrc.getAttribute('index')];

		oScrollingBar.bScrolling = true;
		oScrollingBar.nStartMouseY = CWS_curPosY;

		return CWS_CancelBubble(evt);
	}

	this.onScrollStop = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className != 'ScrollingButton')) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingBar = oScrollingBars.aScrollingBars[oSrc.getAttribute('index')];

		oScrollingBar.bScrolling = false;

		return CWS_CancelBubble(evt);
	}

	this.onWheel = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className.indexOf('ScrollBar') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingBar = oScrollingBars.aScrollingBars[oSrc.getAttribute('index')];

		var delta;
		if (!evt) delta = window.event.detail ? window.event.detail : window.event.wheelDelta / -120;
		else delta = evt.detail ? evt.detail : evt.wheelDelta / -120;

		oScrollingBar.nTargetOffset += delta * oScrollingBar.nWindowSize / 10;

		if (evt) evt.preventDefault();
		return CWS_CancelBubble(evt);
	}

	this.ApplyDelta = function(nDelta) {
		this.nOffset += nDelta;

		if (this.nOffset < 0) this.nOffset = 0;
		if (this.nOffset > this.nMaxOffset) this.nOffset = this.nMaxOffset;

		if (this.bVert) {
			this.oBut.style.top = this.nOffset + 'px';
			this.oContent.style.marginTop = Math.floor((-this.nOffset * this.nScrollFactor)) + 'px';
		}
		else {
			this.oBut.style.left = this.nOffset + 'px';
			this.oContent.style.marginLeft = Math.floor((-this.nOffset * this.nScrollFactor)) + 'px';
		}
	}

	this.Update = function() {
		if (this.bScrolling) {
			if (this.bVert) nDelta = CWS_curPosY - this.nStartMouseY;
			else nDelta = CWS_curPosX - this.nStartMouseX;

			this.nStartMouseY = CWS_curPosY;
			this.nStartMouseX = CWS_curPosX;

			this.nOffset += nDelta;

			if (this.nOffset < 0) this.nOffset = 0;
			if (this.nOffset > this.nMaxOffset) this.nOffset = this.nMaxOffset;

			if (this.bVert) {
				this.oBut.style.top = this.nOffset + 'px';
				this.oContent.style.marginTop = Math.floor((-this.nOffset * this.nScrollFactor)) + 'px';
			}
			else {
				this.oBut.style.left = this.nOffset + 'px';
				this.oContent.style.marginLeft = Math.floor((-this.nOffset * this.nScrollFactor)) + 'px';
			}

			this.nTargetOffset = this.nOffset;
		}

		if (this.nTargetOffset != this.nOffset) this.ApplyDelta((this.nTargetOffset - this.nOffset) / 4);
		if (this.nTargetOffset < 0) this.nTargetOffset = 0;
		if (this.nTargetOffset > this.nMaxOffset) this.nTargetOffset = this.nMaxOffset;
	}

	this.oBut.onmousedown = this.onScrollStart;
	this.oBut.onmouseup = this.onScrollStop;
	//	this.oBut.onmouseout = this.onScrollStop;

	this.oBar.onselectstart = CWS_CancelBubble;

	if (window.addEventListener) this.oContent.addEventListener('DOMMouseScroll', this.onWheel, false);
	this.oContent.onmousewheel = this.onWheel;
}


/* /Scrolling bars */

/* tabbed boxes */

function TabbedBoxes(oTimersHandler) {
	this.nNbTabbedBoxes = 0;
	this.aTabbedBoxes = new Array();

	this.oDivs = document.getElementsByTagName('DIV');

	for (var i = 0; i < this.oDivs.length; i++) {
		if (this.oDivs[i].className.indexOf('TabbedBox') != -1) {
			var bCookie = false;
			if (this.oDivs[i].className.indexOf('-C') != -1) bCookie = true;
			this.aTabbedBoxes[this.nNbTabbedBoxes] = new TabbedBox(this.oDivs[i], oTimersHandler, this.nNbTabbedBoxes, bCookie);
			this.nNbTabbedBoxes++;
		}
	}

	this.Animate = function(_Self, fElapdseTime) {
		for (i = 0; i < _Self.aTabbedBoxes.length; i++) {
			_Self.aTabbedBoxes[i].Animate(_Self.aTabbedBoxes[i], fElapdseTime);
		}
	}

	oTimersHandler.AddTimer(this);

}

function TabbedBox(oDiv, oTimersHandler, nIndex, bCookie) {
	this.oObj = oDiv;
	this.nIndex = nIndex;
	this.nCurrentTab = -1;
	this.bCookie = bCookie;
	this.sCookieName = '' + this.oObj.getAttribute('id');

	this.aTabs = new Array();
	this.aContents = new Array();

	this.aTabs = this.oObj.getElementsByTagName('DIV')[0].getElementsByTagName('LI');
	oContent = CWS_GetFirstChild(this.oObj.getElementsByTagName('DIV')[1]);
	while (oContent) {
		if (oContent.nodeName == 'DIV') this.aContents[this.aContents.length] = oContent;
		oContent = oContent.nextSibling;
	}

	this.Animate = function(_Self, fElapsedtime) {
	}

	this.ShowTab = function(nTab) {
		if (nTab == this.nCurrentTab) return;

		if (this.nCurrentTab >= 0) {
			this.aTabs[this.nCurrentTab].className = this.aTabs[this.nCurrentTab].className.replace(' selected', '');
			this.aContents[this.nCurrentTab].style.display = 'none';
		}

		this.nCurrentTab = nTab;
		if (this.bCookie) CWS_SetCookieVolatile(this.sCookieName, this.nCurrentTab);

		this.aTabs[this.nCurrentTab].className = this.aTabs[this.nCurrentTab].className + ' selected';
		this.aContents[this.nCurrentTab].style.display = 'inline-block';

	}

	this.onclickTab = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && oSrc.nodeName != 'LI') {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oTabbedBox = oTabbedBoxes.aTabbedBoxes[oSrc.getAttribute('index')];
		oTabbedBox.ShowTab(oSrc.getAttribute('numb'));
	}

	for (i = 0; i < this.aTabs.length; i++) {
		this.aTabs[i].setAttribute('index', this.nIndex);
		this.aTabs[i].setAttribute('numb', i);
		this.aTabs[i].onclick = this.onclickTab;
	}

	var nTab = 0;

	if (this.bCookie) {
		nTab = parseInt(CWS_GetCookie(this.sCookieName));
		if (isNaN(nTab)) nTab = 0;
	}

	if ((s = document.URL.indexOf('#')) != -1) {
		sTabname = document.URL.substr(s + 1).toLowerCase();

		for (i = 0; i < this.aTabs.length; i++) {
			if (this.aTabs[i].getAttribute('name') == sTabname) nTab = i;
		}
	}

	if (nTab >= this.aTabs.length) nTab = 0;

	this.ShowTab(nTab);
}

/* Scrolling panes */

function ScrollingPanes(oTimersHandler) {
	this.nNbScrollingPanes = 0;
	this.aScrollingPanes = new Array();

	this.oDivs = document.getElementsByTagName('DIV');

	for (var i = 0; i < this.oDivs.length; i++) {
		if (this.oDivs[i].className.indexOf('ScrollingPane ') != -1) {
			var sDirection = 'H';
			if (this.oDivs[i].className.indexOf('-V') != -1) sDirection = 'V';
			if (this.oDivs[i].className.indexOf('-A') != -1) sDirection = 'A';
			if (this.oDivs[i].className.indexOf('-AI') != -1) sDirection = 'AI';
			var bPaging = (this.oDivs[i].className.indexOf('-NP') == -1);
			var bPrevNext = (this.oDivs[i].className.indexOf('-PN') != -1);
			var nSlideShowDelay = ((this.oDivs[i].className.indexOf('-S ') == -1) ? 0 : 10000);
			this.aScrollingPanes[this.nNbScrollingPanes] = new ScrollingPane(this.oDivs[i], oTimersHandler, this.nNbScrollingPanes, sDirection, bPaging, nSlideShowDelay, bPrevNext);
			this.nNbScrollingPanes++;
		}
	}

	this.Animate = function(_Self, fElapdseTime) {
		for (i = 0; i < _Self.aScrollingPanes.length; i++) {
			_Self.aScrollingPanes[i].Animate(_Self.aScrollingPanes[i], fElapdseTime);
		}
	}

	oTimersHandler.AddTimer(this);
}

function ScrollingPane(oDiv, oTimersHandler, nIndex, sDirection, bPaging, nSlideShowDelay, bPrevNext)
{
	this.oObj = oDiv;
	this.bVert = (sDirection == 'V');
	this.sDirection = sDirection;
	this.nIndex = nIndex;
	this.bPaging = bPaging;
	this.bPrevNext = bPrevNext;
	this.nSlideShowDelay = nSlideShowDelay;
	this.aLinkedPanes = new Array();

	this.nSlideShowElapsed = 0;

	this.oContent = this.oObj.getElementsByTagName('DIV')[0];
	this.divPagination = null;
	this.divPrevNext = null;
	this.PrevBut = null;
	this.NextBut = null

	this.nWidth = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));
	this.nHeight = Math.floor(getStyle(this.oObj, 'height').replace('px', ''));

	this.nContentWidth = 0;
	this.nContentHeight = 0;
	this.nItemWidth = 0;
	this.nItemHeight = 0;
	this.nNbItems = 0;
	this.nNbItemsPerLine = 1;
	this.nNbLinesPerPage = 1;
	this.nNbPages = 0;
	this.nCurPage = 0;
	this.nOffsetX = 0;
	this.nOffsetY = 0;
	this.aButPages = new Array();

	this.bTouching = false;
	this.nTouchStartX = 0;
	this.nTouchStartY = 0;
	this.nDeltaX = 0;
	this.nDeltaY = 0;

	this.nPageHeight = 0;
	this.nPageWidth = 0;

	var o = this.oContent.firstChild;
	while (o && o.nodeName != 'DIV') o = o.nextSibling;

	if (o)
	{
		this.nItemWidth += Math.floor(getStyle(o, 'width').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'margin-right').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'margin-left').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'marginRight').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'marginLeft').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'padding-left').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'padding-right').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'paddingLeft').replace('px', ''));
		this.nItemWidth += Math.floor(getStyle(o, 'paddingRight').replace('px', ''));

	//	if (o.currentStyle && o.currentStyle.borderWidth)
	//	{
	//		try
	//		{
	//		//	this.nItemWidth += Math.floor(o.currentStyle.borderWidth.replace('px', ''));
	//		//	this.nItemWidth += Math.floor(o.currentStyle.borderWidth.replace('px', ''));
	//		}
	//		catch(e) {}
	//	}
	//	else
		{
			this.nItemWidth += Math.floor(getStyle(o, 'border-right-width').replace('px', ''));
			this.nItemWidth += Math.floor(getStyle(o, 'border-left-width').replace('px', ''));

			this.nItemWidth += Math.floor(getStyle(o, 'borderRightWidth').replace('px', ''));
			this.nItemWidth += Math.floor(getStyle(o, 'borderLeftWidth').replace('px', ''));
		}

		this.nItemHeight += Math.floor(getStyle(o, 'height').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'margin-top').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'margin-bottom').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'marginTop').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'marginBottom').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'padding-top').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'padding-bottom').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'paddingTop').replace('px', ''));
		this.nItemHeight += Math.floor(getStyle(o, 'paddingBottom').replace('px', ''));
	}

	while (o)
	{
		this.nNbItems++;
		o = o.nextSibling;
		while (o && o.nodeName != 'DIV') o = o.nextSibling;
	}

	this.nContentWidth = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));
	this.nContentHeight = Math.floor(getStyle(this.oObj, 'height').replace('px', ''));

	if (!this.bVert && isNaN(this.nItemWidth))
	{
		this.nItemWidth = Math.floor(this.nWidth / 2);
		this.nItemHeight = this.nHeight;
		this.nNbItems = Math.ceil(Math.floor(getStyle(this.oContent, 'width').replace('px', '')) / this.nItemWidth);
	}
	if (this.bVert && isNaN(this.nItemHeight))
	{
		this.nItemWidth = this.nWidth;
		this.nItemHeight = Math.floor(this.nHeight / 2);
		this.nNbItems = Math.ceil(Math.floor(getStyle(this.oContent, 'height').replace('px', '')) / this.nItemHeight);
	}

	if (this.sDirection == 'A') this.bVert = (window.orientation % 180 == 0);
	if (this.sDirection == 'AI') this.bVert = !(window.orientation % 180 == 0);

	if (this.bVert)
	{
		if (this.nItemWidth > 0) this.nNbItemsPerLine = Math.floor(this.nContentWidth / this.nItemWidth);
		if (this.nItemHeight > 0) this.nNbLinesPerPage = Math.floor(this.nContentHeight / this.nItemHeight);

		if (this.nNbItemsPerLine < 1) this.nNbItemsPerLine = 1;
		if (this.nNbLinesPerPage < 1) this.nNbLinesPerPage = 1;

		this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);

		this.oContent.style.height = this.nContentHeight * this.nNbPages + 'px';

		this.nPageHeight = this.nItemHeight * this.nNbLinesPerPage;
	}
	else
	{
		if (this.nItemHeight > 0) this.nNbItemsPerLine = Math.floor(this.nContentHeight / this.nItemHeight);
		if (this.nItemWidth > 0) this.nNbLinesPerPage = Math.floor(this.nContentWidth / this.nItemWidth);

		if (this.nNbItemsPerLine < 1) this.nNbItemsPerLine = 1;
		if (this.nNbLinesPerPage < 1) this.nNbLinesPerPage = 1;

		this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);
try
{
		this.oContent.style.width = this.nContentWidth * this.nNbPages + 'px';
}
catch(e)
{
}
		this.nPageWidth = this.nItemWidth * this.nNbLinesPerPage;
	}

	this.onContentChanged = function ()
	{
		this.nNbItems = 0;

		this.nPageWidth = this.nItemWidth;
		this.nNbItemsPerLine = 1;
		this.nNbLinesPerPage = 1;

		var o = this.oContent.firstChild;
		while (o && o.nodeName != 'DIV') o = o.nextSibling;

		while (o)
		{
			this.nNbItems++;
			o = o.nextSibling;
			while (o && o.nodeName != 'DIV') o = o.nextSibling;
		}

		if (this.bVert)
		{
			this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);
			this.oContent.style.height = this.nContentHeight * this.nNbPages + 'px';
		}
		else
		{
			this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);
			this.oContent.style.width = this.nContentWidth * this.nNbPages + 'px';

			if (this.nCurPage >= this.nNbPages) this.GotoPage(this.nNbPages - 1);
		}
	}

	this.onOrientationChange = function() {
		var o = this.oContent.firstChild;
		while (o && o.nodeName != 'DIV') o = o.nextSibling;

		if (o) {
			this.nItemWidth = Math.floor(getStyle(o, 'width').replace('px', ''));
			this.nItemWidth += Math.floor(getStyle(o, 'margin-left').replace('px', ''));
			this.nItemWidth += Math.floor(getStyle(o, 'margin-right').replace('px', ''));
			if (!document.all) this.nItemWidth += Math.floor(getStyle(o, 'padding-left').replace('px', ''));
			if (!document.all) this.nItemWidth += Math.floor(getStyle(o, 'padding-right').replace('px', ''));

			this.nItemHeight = Math.floor(getStyle(o, 'height').replace('px', ''));
			this.nItemHeight += Math.floor(getStyle(o, 'margin-top').replace('px', ''));
			this.nItemHeight += Math.floor(getStyle(o, 'margin-bottom').replace('px', ''));
			if (!document.all) this.nItemHeight += Math.floor(getStyle(o, 'padding-top').replace('px', ''));
			if (!document.all) this.nItemHeight += Math.floor(getStyle(o, 'padding-bottom').replace('px', ''));
		}

		var nNbPrviousPages = this.nNbPages;
		if (nNbPrviousPages < 1) nNbPrviousPages = 1;

		this.nWidth = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));
		this.nHeight = Math.floor(getStyle(this.oObj, 'height').replace('px', ''));

		this.nContentWidth = Math.floor(getStyle(this.oObj, 'width').replace('px', ''));
		this.nContentHeight = Math.floor(getStyle(this.oObj, 'height').replace('px', ''));

		if (this.sDirection == 'A') this.bVert = (window.orientation % 180 == 0);
		if (this.sDirection == 'AI') this.bVert = !(window.orientation % 180 == 0);

		if (this.bVert) {
			if (this.nItemWidth > 0) this.nNbItemsPerLine = Math.floor(this.nContentWidth / this.nItemWidth);
			if (this.nItemHeight > 0) this.nNbLinesPerPage = Math.floor(this.nContentHeight / this.nItemHeight);

			if (this.nNbItemsPerLine < 1) this.nNbItemsPerLine = 1;
			if (this.nNbLinesPerPage < 1) this.nNbLinesPerPage = 1;

			this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);

			this.oContent.style.height = this.nContentHeight * this.nNbPages + 'px';
			this.oContent.style.width = this.nContentWidth + 'px';

			this.nPageHeight = this.nItemHeight * this.nNbLinesPerPage;
		}
		else {
			if (this.nItemHeight > 0) this.nNbItemsPerLine = Math.floor(this.nContentHeight / this.nItemHeight);
			if (this.nItemWidth > 0) this.nNbLinesPerPage = Math.floor(this.nContentWidth / this.nItemWidth);

			if (this.nNbItemsPerLine < 1) this.nNbItemsPerLine = 1;
			if (this.nNbLinesPerPage < 1) this.nNbLinesPerPage = 1;

			this.nNbPages = Math.ceil(this.nNbItems / this.nNbItemsPerLine / this.nNbLinesPerPage);

			this.oContent.style.width = this.nContentWidth * this.nNbPages + 'px';
			this.oContent.style.height = this.nContentHeight + 'px';

			this.nPageWidth = this.nItemWidth * this.nNbLinesPerPage;
		}

		if (this.nNbPages > 50) {
			//	alert(this.oObj.getAttribute('id') + ' : ' + this.nItemWidth + ' ' + this.nItemHeight + ' ' + this.nNbItemsPerLine + ' ' + this.nNbLinesPerPage + ' ' + this.nContentWidth);

			return;
		}

		var aButPagesLength = this.aButPages.length;
		for (var i = aButPagesLength; i < this.nNbPages; i++) {
			this.aButPages[i] = document.createElement('INPUT');
			this.aButPages[i].type = 'button';
			this.aButPages[i].className = 'SP_PagingBut';
			this.aButPages[i].setAttribute('numb', i);
			this.aButPages[i].setAttribute('index', this.nIndex);
			this.aButPages[i].onclick = this.OnClickPagingBut;
			this.divPagination.appendChild(this.aButPages[i]);
		}
		for (var i = 0; i < this.aButPages.length; i++) {
			this.aButPages[i].style.display = ((i < this.nNbPages) ? 'inline' : 'none');
		}

		this.divPagination.className = 'SP_Paging' + (this.bVert ? "V" : "");
		if (this.bVert) this.divPagination.style.top = ((this.nContentHeight - (this.nNbPages * 16)) / 2) + 'px';
		else this.divPagination.style.top = 'auto';

		if (this.aButPages[this.nCurPage]) this.aButPages[this.nCurPage].className = 'SP_PagingBut';
		this.nCurPage = Math.floor(0.5 + this.nCurPage * this.nNbPages / nNbPrviousPages);
		if (this.aButPages[this.nCurPage]) this.aButPages[this.nCurPage].className = 'SP_PagingButSelected';
	}

	this.AddLinkedPane = function(oPane) {
		this.AddLinkedPane[this.AddLinkedPane.length] = oPane;
	}

	this.OnClickPagingBut = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];
		oScrollingPane.GotoPage(oSrc.getAttribute('numb'));
		if (oScrollingPane.nSlideShowDelay != 0) oScrollingPane.nSlideShowElapsed = -20000;
	}

	this.OnClickPrevBut = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];
		oScrollingPane.PrevPage();
	}

	this.OnClickNextBut = function(evt) {
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];
		oScrollingPane.NextPage();
	}

	this.NextPage = function() {
		this.GotoPage(this.nCurPage + 1);
		if (this.nSlideShowDelay != 0) this.nSlideShowElapsed = -20000;
	}

	this.PrevPage = function() {
		this.GotoPage(this.nCurPage - 1);
		if (this.nSlideShowDelay != 0) this.nSlideShowElapsed = -20000;
	}

	this.GotoPage = function (nPage)
	{
		if((this.nCurPage - nPage) > 10 || (this.nCurPage - nPage < -10)) bImmediate = true;
		else bImmediate = false;

		this.nCurPage = nPage;
	
		//	if (this.nCurPage >= this.nNbPages) this.nCurPage = 0;
		//	if (this.nCurPage < 0) this.nCurPage = this.nNbPages - 1;

		if (this.nCurPage >= this.nNbPages) this.nCurPage = this.nNbPages - 1;
		if (this.nCurPage < 0) this.nCurPage = 0;

		for (var i = 0; i < this.aButPages.length; i++)
		{
			this.aButPages[i].className = "SP_PagingBut" + ((i == this.nCurPage) ? "Selected" : "");
		}

		if(bImmediate)
		{
			if(this.bVert)
			{
				nTargetX = 0;
				nTargetY = this.nCurPage * this.nPageHeight * -1;
			}
			else
			{
				nTargetX = this.nCurPage * this.nPageWidth * -1;
				nTargetY = 0;
			}

			this.nOffsetY = nTargetY;
			this.oContent.style.top = this.nOffsetY + 'px';

			this.nOffsetX = nTargetX;
			this.oContent.style.top = this.nOffsetX + 'px';
		}
	}

	this.Animate = function(_Self, fElapsedtime) {
		if (_Self.bTouching) return;

		if (_Self.bVert) {
			nTargetX = 0;
			nTargetY = _Self.nCurPage * _Self.nPageHeight * -1;
		}
		else {
			nTargetX = _Self.nCurPage * _Self.nPageWidth * -1;
			nTargetY = 0;
		}

		nDeltaY = (nTargetY - _Self.nOffsetY) / 10.0;
		if (nDeltaY > 100) nDeltaY = 100;
		if (nDeltaY < -100) nDeltaY = -100;

		if (nDeltaY < 0.1 && nDeltaY > -0.1) nDeltaY = nTargetY - _Self.nOffsetY;

		_Self.nOffsetY += nDeltaY;
		_Self.oContent.style.top = _Self.nOffsetY + 'px';

		nDeltaX = (nTargetX - _Self.nOffsetX) / 10.0;
		if (nDeltaX > 100) nDeltaX = 100;
		if (nDeltaX < -100) nDeltaX = -100;

		if (nDeltaX < 0.1 && nDeltaX > -0.1) nDeltaX = nTargetX - _Self.nOffsetX;

		_Self.nOffsetX += nDeltaX;
		_Self.oContent.style.left = _Self.nOffsetX + 'px';

		if (_Self.nSlideShowDelay > 0) {
			_Self.nSlideShowElapsed += fElapsedtime;
			if (_Self.nSlideShowElapsed >= _Self.nSlideShowDelay) {
				_Self.nSlideShowElapsed -= _Self.nSlideShowDelay;
				_Self.GotoPage((_Self.nCurPage + 1) % _Self.nNbPages);
			}
		}
	}

	this.OnTouchStart = function(evt) {
		//	evt.preventDefault();
		//	if(evt.touches.length != 1) return;
		var touch = evt.touches[0];

		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.bTouching = true;

		oScrollingPane.nTouchStartX = touch.screenX;
		oScrollingPane.nTouchStartY = touch.screenY;

		CWS_CancelBubble(evt);

		// Propagate
		oSrc = oSrc.parentNode;
		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.bTouching = true;

		oScrollingPane.nTouchStartX = touch.screenX;
		oScrollingPane.nTouchStartY = touch.screenY;
	}

	this.OnTouchMove = function(evt) {
		evt.preventDefault();
		//	if(evt.touches.length != 1) return;
		var touch = evt.touches[0];

		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.nDeltaX = touch.screenX - oScrollingPane.nTouchStartX;
		oScrollingPane.nDeltaY = touch.screenY - oScrollingPane.nTouchStartY;

		oScrollingPane.nTouchStartX = touch.screenX;
		oScrollingPane.nTouchStartY = touch.screenY;

		if (!oScrollingPane.bVert) {
			if (Math.abs(oScrollingPane.nDeltaX) > Math.abs(oScrollingPane.nDeltaY)) {
				oScrollingPane.nOffsetX += oScrollingPane.nDeltaX;
				oScrollingPane.oContent.style.left = oScrollingPane.nOffsetX + 'px';
			}
		}
		else {
			if (Math.abs(oScrollingPane.nDeltaY) > Math.abs(oScrollingPane.nDeltaX)) {
				oScrollingPane.nOffsetY += oScrollingPane.nDeltaY;
				oScrollingPane.oContent.style.top = oScrollingPane.nOffsetY + 'px';
			}
		}

		if (oScrollingPane.nSlideShowDelay != 0) oScrollingPane.nSlideShowElapsed = -20000;

		CWS_CancelBubble(evt);

		// Propagate
		oSrc = oSrc.parentNode;
		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.nDeltaX = touch.screenX - oScrollingPane.nTouchStartX;
		oScrollingPane.nDeltaY = touch.screenY - oScrollingPane.nTouchStartY;

		oScrollingPane.nTouchStartX = touch.screenX;
		oScrollingPane.nTouchStartY = touch.screenY;

		if (!oScrollingPane.bVert) {
			if (Math.abs(oScrollingPane.nDeltaX) > Math.abs(oScrollingPane.nDeltaY)) {
				oScrollingPane.nOffsetX += oScrollingPane.nDeltaX;
				oScrollingPane.oContent.style.left = oScrollingPane.nOffsetX + 'px';
			}
		}
		else {
			if (Math.abs(oScrollingPane.nDeltaY) > Math.abs(oScrollingPane.nDeltaX)) {
				oScrollingPane.nOffsetY += oScrollingPane.nDeltaY;
				oScrollingPane.oContent.style.top = oScrollingPane.nOffsetY + 'px';
			}
		}
	}

	this.OnTouchEnd = function(evt) {
		//	evt.preventDefault();
		//	if(evt.touches.length != 1) return;
		var touch = evt.touches[0];

		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}

		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.bTouching = false;

		var nPage;
		if (!oScrollingPane.bVert) nPage = Math.floor(((-oScrollingPane.nOffsetX - (oScrollingPane.nDeltaX * 10)) / oScrollingPane.nPageWidth) + 0.5);
		else nPage = Math.floor(((-oScrollingPane.nOffsetY - (oScrollingPane.nDeltaY * 10)) / oScrollingPane.nPageHeight) + 0.5)

		if (nPage >= oScrollingPane.nNbPages) nPage = oScrollingPane.nNbPages - 1;
		if (nPage < 0) nPage = 0;

		oScrollingPane.GotoPage(nPage);

		CWS_CancelBubble(evt);

		// Propagate
		oSrc = oSrc.parentNode;
		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane') == -1)) {
			oSrc = oSrc.parentNode;
		}
		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		oScrollingPane.bTouching = false;

		var nPage;
		if (!oScrollingPane.bVert) nPage = Math.floor(((-oScrollingPane.nOffsetX - (oScrollingPane.nDeltaX * 10)) / oScrollingPane.nPageWidth) + 0.5);
		else nPage = Math.floor(((-oScrollingPane.nOffsetY - (oScrollingPane.nDeltaY * 10)) / oScrollingPane.nPageHeight) + 0.5)

		if (nPage >= oScrollingPane.nNbPages) nPage = oScrollingPane.nNbPages - 1;
		if (nPage < 0) nPage = 0;

		oScrollingPane.GotoPage(nPage);
	}

	this.onWheel = function (evt)
	{
		var oSrc = null;

		if (!evt) oSrc = window.event.srcElement;
		else oSrc = evt.target;

		while (oSrc != null && (oSrc.nodeName != 'DIV' || oSrc.className == null || oSrc.className.indexOf('ScrollingPane ') == -1))
		{
			oSrc = oSrc.parentNode;
		}

		if (!oSrc) return;

		oScrollingPane = oScrollingPanes.aScrollingPanes[oSrc.getAttribute('index')];

		var delta;
		if (!evt) delta = window.event.detail ? window.event.detail * (-120) : window.event.wheelDelta;
		else delta = evt.detail ? evt.detail * (-120) : evt.wheelDelta;

		if (delta > 0) oScrollingPane.PrevPage();
		if (delta < 0) oScrollingPane.NextPage();

		if (evt) evt.preventDefault();
		return CWS_CancelBubble(evt);
	}

	this.oObj.setAttribute('index', nIndex);
	this.divPagination = document.createElement('DIV');
	this.divPagination.className = 'SP_Paging' + (this.bVert ? "V" : "");
	if (this.bVert) this.divPagination.style.top = ((this.nContentHeight - (this.nNbPages * 16)) / 2) + 'px';
	for (var i = 0; i < this.nNbPages; i++) {
		this.aButPages[i] = document.createElement('INPUT');
		this.aButPages[i].type = 'button';
		this.aButPages[i].className = 'SP_PagingBut' + ((i == 0) ? 'Selected' : '');
		this.aButPages[i].setAttribute('numb', i);
		this.aButPages[i].setAttribute('index', nIndex);
		this.aButPages[i].onclick = this.OnClickPagingBut;
		this.divPagination.appendChild(this.aButPages[i]);
	}
	if (this.nNbPages > 1 && this.bPaging) this.oObj.appendChild(this.divPagination);

	this.divPrevNext = document.createElement('DIV');
	this.divPrevNext.className = 'SP_PrevNext';
	if (this.nNbPages > 1 && this.bPrevNext) {
		this.PrevBut = document.createElement('INPUT');
		this.PrevBut.type = 'button';
		this.PrevBut.className = 'SP_Prev but';
		this.PrevBut.setAttribute('index', nIndex);
		this.PrevBut.onclick = this.OnClickPrevBut;
		this.divPrevNext.appendChild(this.PrevBut);

		this.NextBut = document.createElement('INPUT');
		this.NextBut.type = 'button';
		this.NextBut.className = 'SP_Next but';
		this.NextBut.setAttribute('index', nIndex);
		this.NextBut.onclick = this.OnClickNextBut;
		this.divPrevNext.appendChild(this.NextBut);

		this.oObj.appendChild(this.divPrevNext);
	}

	this.oObj.ontouchstart = this.OnTouchStart;
	this.oObj.ontouchmove = this.OnTouchMove;
	this.oObj.ontouchend = this.OnTouchEnd;
	if (window.addEventListener) this.oContent.addEventListener('DOMMouseScroll', this.onWheel, false);
	this.oContent.onmousewheel = this.onWheel;
}

function TimersHandler() {
	this.nPrevMilliseconds = -1.0;
	this.aIntervals = new Array();
	this.fElapdseTime = 0.0;

	this.oWindowInterval = null;

	this.AddTimer = function(oFunction) {
		for (var i = 0; i < this.aIntervals.length; i++) {
			if (this.aIntervals[i] == oFunction) return;
		}

		this.aIntervals[i] = oFunction;
	}

	this.RemoveTimer = function(oFunction) {
		for (var i = 0; i < this.aIntervals.length; i++) {
			if (this.aIntervals[i] == oFunction) this.aIntervals[i] = null;
		}
	}

	this.Start = function() {
		if (this.oWindowInterval == null) this.oWindowInterval = window.setInterval(this.ProcessTimers, 10);
	}

	this.Stop = function() {
		if (this.oWindowInterval != null) window.clearInterval(this.oWindowInterval);
		this.oWindowInterval = null;
	}

	this.ProcessTimers = function() {
		_Self = oTimersHandler;
		oDate = new Date();

		if (_Self.nPrevMilliseconds < 0) fElapdseTime = 0.0;
		else {
			fElapdseTime = oDate.getMilliseconds() - _Self.nPrevMilliseconds;

			if (fElapdseTime < 0.0) fElapdseTime += 1000.0;
		}

		_Self.nPrevMilliseconds = oDate.getMilliseconds();

		for (var i = 0; i < _Self.aIntervals.length; i++) {
			try {
				_Self.aIntervals[i].Animate(_Self.aIntervals[i], fElapdseTime);
			}
			catch (e) { }
		}
	}

	this.PropagateMouseUpEvent = function ()
	{
		if (!_Self.aIntervals) return;

		for (var i = 0; i < _Self.aIntervals.length; i++)
		{
			try
			{
				if(_Self.aIntervals[i].MouseUp) _Self.aIntervals[i].MouseUp(_Self.aIntervals[i]);
			}
			catch (e) { }
		}
	}
}

var oTimersHandler = null;
var oScrollingPanes = null;
var oTabbedBoxes = null;
var oScrollingBars = null;
var oSliders = null;
var oComboBoxes = null;
var oFader = null;

function onOrientationChange() {
	for (var i = 0; i < oScrollingPanes.aScrollingPanes.length; i++) oScrollingPanes.aScrollingPanes[i].onOrientationChange();
}

function SB_onmouseup() {
	for (var i = 0; i < oScrollingBars.aScrollingBars.length; i++) oScrollingBars.aScrollingBars[i].bScrolling = false;
	for (var i = 0; i < oSliders.aSliders.length; i++) oSliders.aSliders[i].bSliding = false;
	oTimersHandler.PropagateMouseUpEvent();
}

function CWS_InitPage() {
	oTimersHandler = new TimersHandler;

	oScrollingPanes = new ScrollingPanes(oTimersHandler);

	if (document.getElementById('BigItems') && document.getElementById('BigItems').className.indexOf('-Sync') != -1) oTimersHandler.AddTimer(new SynchroniseBigItem());
	if (document.getElementById('BigItemsHP') && document.getElementById('BigItemsHP').className.indexOf('-Sync') != -1) oTimersHandler.AddTimer(new SynchroniseBigItem());

	oTabbedBoxes = new TabbedBoxes(oTimersHandler);
	oScrollingBars = new ScrollingBars(oTimersHandler);
	oSliders = new Sliders(oTimersHandler);
	oComboBoxes = new ComboBoxes(oTimersHandler);
	oFader = new Fader(oTimersHandler);

	oTimersHandler.Start();

	document.getElementsByTagName('BODY')[0].onorientationchange = onOrientationChange;
	document.onmouseup = SB_onmouseup;


	//document.getElementById('Loading').style.display = 'none';

	eval(CWS_sOnLoad);

	aImages = document.getElementsByTagName('IMG');
	for (i = 0; i < aImages.length; i++) {
		sSrc = aImages[i].getAttribute('altsrc');
		if (sSrc) aImages[i].src = sSrc;
	}
}

window.setTimeout(CWS_InitPage, 500);

