﻿var intNetscape = -1;
var blnClick = true; 		// Must page be loaded

function determineBrowser() {
	if (navigator.appName.toLowerCase() == "netscape")
		intNetscape = 1;
	else
		intNetscape = 0;
}

function GetAttribute(objObject, strName) {
	if (objObject.getAttribute("data-" + strName) != null)
		return objObject.getAttribute("data-" + strName);
	else
		return objObject.getAttribute(strName);
}

function popup(intX, intY, intWidth, intHeight, blnCenter, blnToolbar, blnResizable, blnScrollbars, strUrl) {
	var intWinX, intWinY;
	var strOptions = "";

	if (intNetscape == -1) determineBrowser();

	intWinX = (intNetscape == 0) ? window.top.screenLeft : window.top.screenX;
	intWinY = (intNetscape == 0) ? window.top.screenTop : window.top.screenY;

	if (blnCenter) {
		intWinX += ((window.top.document.body.clientWidth / 2) - (intWidth / 2));
		intWinY += ((window.top.document.body.clientHeight / 2) - (intHeight / 2));
	}
	else {
		intWinX += intX;
		intWinY += intY;
	}

	strOptions = "left=" + intWinX + ",top=" + intWinY + ",width=" + intWidth + ",height=" + intHeight;
	if (blnToolbar)
		strOptions += ",fullscreen=0,location=1,menubar=1,status=1,toolbar=1,titlebar=1";
	else
		strOptions += ",fullscreen=0,location=0,menubar=0,status=0,toolbar=0,titlebar=0";
	strOptions += ",resizable=" + ((blnResizable) ? "1" : "0");
	strOptions += ",scrollbars=" + ((blnScrollbars) ? "1" : "0");

	window.open(unescape(strUrl), "", strOptions);
}

function clickLink(objLink) {
	if (intNetscape == -1) determineBrowser();

	if (objLink.href.indexOf("javascript:") == -1) {
		if (intNetscape == 0) {
			objLink.click();
		}
		else {
			if (objLink.target != "")
				window.open(objLink.href, objLink.target);
			else
				window.location.href = objLink.href;
		}
	}
	else {
		eval(objLink.href.substring(11));
	}
}

/*
* Login 
*/
function LoginCheckKey(objEvent, intPageID) {
	if (objEvent.keyCode == 13) {
		LoginSubmit(intPageID);
		objEvent.returnValue = false;
	}
	else {
		objEvent.returnValue = true;
	}
}

function LoginSubmit(intPageID) {
	var objForm;

	objForm = document.getElementById("formlogin" + intPageID);
	if (objForm != null) objForm.submit();

	return false;
}

function PollSubmit(intPageID) {
	var objForm;

	objForm = document.getElementById("formpoll" + intPageID);
	if (objForm != null) objForm.submit();

	return false;
}


/*
* Section
*/
var intCurrentSectionNr = -1;
var intStartSectionNr = -1;
var blnUseSectionSelectedStyle = false;

function SetSection() {
	var objLink;
	var i, objItem;

	// Workaround for bug in IE (sometimes the cell is to wide when fetched from cache)
	for (i = 1; ; i++) {
		objItem = document.getElementById("G" + i);
		if (objItem != null) {
			objItem.className = 'section_idle';
			document.getElementById("GT" + i).className = 'section_text_idle';
		}
		else
			break;
	}

	blnClick = false;
	objLink = document.getElementById("G" + intStartSectionNr);
	if (objLink != null) SectionClick(intStartSectionNr);
	blnClick = true;
}

function SectionOver(intSectionNr) {
	if (intCurrentSectionNr != intSectionNr) {
		document.getElementById("G" + intSectionNr).className = 'section_active';
		document.getElementById("GT" + intSectionNr).className = "section_text_active";
	}
}

function SectionOut(intSectionNr) {
	if (intCurrentSectionNr != intSectionNr) {
		document.getElementById("G" + intSectionNr).className = 'section_idle';
		document.getElementById("GT" + intSectionNr).className = 'section_text_idle';
	}
}

function SectionSelected(intSectionNr) {
	document.getElementById("G" + intSectionNr).className = 'section_selected';
	document.getElementById("GT" + intSectionNr).className = "section_text_selected";
}

function SectionCombinedOver(objSender, objItem) {
	var objTD;
	// Change the class of the text when displaying a lock image in menu item
	objTD = document.getElementById("GT" + objItem.get_item().get_value())
	if (objTD != null) objTD.className = (blnUseSectionSelectedStyle) ? "section_text_selected" : "section_text_active";
}

function SectionCombinedOut(objSender, objItem) {
	var objTD;

	// Change the class of the text when displaying a lock image in menu item
	objTD = document.getElementById("GT" + objItem.get_item().get_value())
	if (objTD != null) objTD.className = "section_text_idle";
}

function SectionClick(intSectionNr) {
	var objHtml;
	var objSectionLink = null;

	if (intCurrentSectionNr != -1) {
		document.getElementById("G" + intCurrentSectionNr).className = 'section_idle';
		document.getElementById("GT" + intCurrentSectionNr).className = 'section_text_idle';
	}

	objHtml = document.getElementById('GI' + intCurrentSectionNr);
	if (objHtml != null) objHtml.src = objHtml.src.replace(/Open/gi, 'Closed');
	objHtml = document.getElementById('GI' + intSectionNr);
	if (objHtml != null) objHtml.src = objHtml.src.replace(/Closed/gi, 'Open');

	(blnUseSectionSelectedStyle) ? SectionSelected(intSectionNr) : SectionOver(intSectionNr);
	intCurrentSectionNr = intSectionNr;

	objSectionLink = document.getElementById("SectionLink");
	objSectionLink.href = document.getElementById("G" + intCurrentSectionNr).getAttribute("href");
	if (blnClick) clickLink(objSectionLink);
}

/*
* Menu
*/
var blnKeepParent = true; 	// No open/close submenu
var blnHideShowSub = true; 	// Hide/Show submenu
var objCurrentParentNode = null;
var intWantedPageID = -1;
var blnUseMenuSelectedStyle = false;

function SetMenu() {
	// Flash workaround for 'click to activate'
	if (window.ActiveXObject) {
		var allObjects = document.body.getElementsByTagName("Object");
		for (i = 0; i < allObjects.length; i++) {
			if ((allObjects[i].classid == "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000") || (allObjects[i].classid == "clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6")) allObjects[i].outerHTML = allObjects[i].outerHTML;
		}
		allObjects = document.body.getElementsByTagName("embed");
		for (i = 0; i < allObjects.length; i++) {
			allObjects[i].outerHTML = allObjects[i].outerHTML;
		}
	}
	CheckFormTextArea();

	if (document.getElementById("ctl00_Menu_FlexonyMenuTree_div") != null) {
		if ((intWantedPageID > 0) && (ctl00_Menu_FlexonyMenuTree.FindNodeById(intWantedPageID) != null)) {
			MenuClickTree(ctl00_Menu_FlexonyMenuTree.FindNodeById(intWantedPageID));
		}
	}
}

function MenuBeforeClickTree(sender, arguments) {
	if (objCurrentParentNode == null) objCurrentParentNode = sender.get_selectedNode();
}

function MenuClickTree(objCurrentNode) {
	var objParentNode;
	var objNode;
	var objTree;
	var intLevel;
	var strName;

	objTree = objCurrentNode.get_parentTreeView();
	objTree.beginUpdate();
	strName = objTree.get_cssClass();
	strName = strName.substr(0, strName.indexOf("_"));

	objParentNode = objCurrentNode.get_parentNode();

	if ((objCurrentParentNode != null) && (objCurrentParentNode.get_parentNode() != null)) {
		if (blnKeepParent || blnHideShowSub) {
			intLevel = 0
			objNode = objCurrentParentNode.get_parentNode();
			while (objNode.get_parentNode() != null) {
				intLevel += 1;
				objNode = objNode.get_parentNode();
			}

			objNode = objCurrentParentNode.get_parentNode();
			while (objNode != null) {
				switch (intLevel) {
					case 0:
						if (blnKeepParent) objNode.set_rowCssClass(strName + "_idle");
						if (blnHideShowSub) objNode.set_expanded(false);
						break;
					case 1:
						if (blnKeepParent) objNode.set_rowCssClass("sub" + strName + "_idle");
						if (blnHideShowSub) objNode.set_expanded(false);
						break;
					default:
						if (blnKeepParent) objNode.set_rowCssClass("sublevel" + strName + "_idle");
						if (blnHideShowSub) objNode.set_expanded(false);
						break;
				}

				intLevel -= 1
				objNode = objNode.get_parentNode();
			}
		}
	}
	if (objParentNode == null) {
		objCurrentParentNode = objCurrentNode;
	}
	else {
		if (blnKeepParent || blnHideShowSub) {
			intLevel = 0
			objNode = objParentNode;
			while (objNode.get_parentNode() != null) {
				intLevel += 1;
				objNode = objNode.get_parentNode();
			}

			objNode = objParentNode;
			while (objNode != null) {
				switch (intLevel) {
					case 0:
						if (blnKeepParent) objNode.set_rowCssClass((blnUseMenuSelectedStyle) ? strName + "_selected" : strName + "_active");
						if (blnHideShowSub) objNode.set_expanded(true);
						break;
					case 1:
						if (blnKeepParent) objNode.set_rowCssClass((blnUseMenuSelectedStyle) ? "sub" + strName + "_selected" : "sub" + strName + "_active");
						if (blnHideShowSub) objNode.set_expanded(true);
						break;
					default:
						if (blnKeepParent) objNode.set_rowCssClass((blnUseMenuSelectedStyle) ? "sublevel" + strName + "_selected" : "sublevel" + strName + "_active");
						if (blnHideShowSub) objNode.set_expanded(true);
						break;
				}

				intLevel -= 1
				objNode = objNode.get_parentNode();
			}
		}
		objCurrentParentNode = objCurrentNode;
	}
	objTree.endUpdate();

	return true;
}

function MenuItemSelect(objSender, objItem) {
	return true;
}

/*
* Body
*/
function CheckFormTextArea() {
	var arrText = document.getElementsByTagName("TEXTAREA");
	var i;

	for (i = 0; i < arrText.length; i++) {
		if (GetAttribute(arrText[i], "maxlength")) {
			arrText[i].onkeydown = arrText[i].onkeyup = arrText[i].onchange = new Function("return CheckFormTextAreaMaxLength(event, this);");
		}
	}
}

function CheckFormTextAreaMaxLength(objEvent, objText) {
	var intMaxLength = GetAttribute(objText, 'maxlength');
	var intCode;

	if (!objEvent) objEvent = event;
	intCode = (typeof objEvent.charCode != "undefined") ? objEvent.charCode : objEvent.keyCode;

	if (intCode >= 47) {
		if (objText.value.length >= intMaxLength) {
			if (objText.value.length > intMaxLength) objText.value = objText.value.substr(0, intMaxLength);
			return false;
		}
	}
	else
		if (objText.value.length > intMaxLength) objText.value = objText.value.substr(0, intMaxLength);
	return true;
}

function CheckFormFields(objForm) {
	var i, j;
	var objField, objField2;
	var blnNoError;
	var strError = '';

	while ((objForm != null) && (objForm.tagName.toUpperCase() != "FORM")) objForm = objForm.parentNode;

	if (objForm != null) {
		for (i = 0; i < objForm.elements.length; i++) {
			objField = objForm.elements[i];

			blnNoError = true;
			if ((objField.tagName.toUpperCase() == "INPUT") && ((objField.type == "text") || (objField.type == "password"))) {
				if (GetAttribute(objField, "Required") == "true") {
					if (objField.value.length == 0) {
						strError += GetAttribute(objField, "RequiredMsg") + '\n';
						blnNoError = false;
					}
				}
				if (objField.value.length > 0) {
					if (blnNoError && (GetAttribute(objField, "IsNumber") == "true")) {
						if (!objField.value.match("^[0-9]+$")) {
							strError += GetAttribute(objField, "AcceptMsg") + '\n';
							blnNoError = false;
						}
					}
					if (blnNoError && (GetAttribute(objField, "IsEmail") == "true")) {
						if (!objField.value.match("^[\\w-_\.]*[\\w-_\.]\@[\\w-_\.]+[\.][\\w-_\.]+[\\w-_\.]$")) {
							strError += GetAttribute(objField, "AcceptMsg") + '\n';
							blnNoError = false;
						}
					}
				}
				if (GetAttribute(objField, "SameField") != null) {
					objField2 = null;
					for (j = 0; j < objForm.elements.length; j++) {
						objField2 = objForm.elements[j];
						if ((objField2.tagName.toUpperCase() == "INPUT") && ((objField2.type == "text") || (objField2.type == "password")) && (objField2.name == GetAttribute(objField, "SameField"))) {
							if (objField.value != objField2.value) {
								strError += GetAttribute(objField, "SameMsg") + '\n';
								blnNoError = false;
							}
							break;
						}
					}
				}
			}

			if (blnNoError && (objField.tagName.toUpperCase() == "INPUT") && (objField.type == "file")) {
				if (GetAttribute(objField, "Required") == "true") {
					if (objField.value.length == 0) strError += GetAttribute(objField, "RequiredMsg") + '\n';
				}
			}

			if (blnNoError && (objField.tagName.toUpperCase() == "INPUT") && ((objField.type == "checkbox") || (objField.type == "radio"))) {
				if (GetAttribute(objField, "Required") == "true") {
					if (objField.checked == false) strError += GetAttribute(objField, "RequiredMsg") + '\n';
				}
			}

			if (blnNoError && (objField.tagName.toUpperCase() == "TEXTAREA")) {
				if (GetAttribute(objField, "Required") == "true") {
					if (objField.value.length == 0) strError += GetAttribute(objField, "RequiredMsg") + '\n';
				}
			}
		}
	}

	if (strError == '')
		return true;
	else {
		alert(GetAttribute(objForm, "ErrorTitle") + '\n\n' + strError);
		return false;
	}
}

function InsertSmiley(strCode) {
	document.getElementById("ctl00_Body_Message").value += strCode;
}

function GivePageID() {
	var objTags = document.getElementsByTagName('meta');
	var intIndex;

	for (intIndex = 0; intIndex < objTags.length; intIndex++) {
		if (objTags[intIndex].name == '__flexonypageid') {
			return objTags[intIndex].content;
		}
	}

	return 0;
}

function FlexonyFullPrint() {
	if (window.top.print) {
		window.top.print();
	}
}

function FlexonyPrint() {
	objHtml = document.createElement("iframe");
	objHtml.id = "flexonyprintwindow";
	objHtml.name = "flexonyprintwindow";
	objHtml.style.width = "0px";
	objHtml.style.height = "0px";
	objHtml.style.borderWidth = "0px;"
	objHtml.src = "../Site/Print.aspx?PageID=" + GivePageID();
	document.body.appendChild(objHtml);
}

function FlexonyPDF() {
	var objForm;
	var objText;
	var strHTML;
	var intWidth;

	objForm = document.createElement("form");
	objForm.method = "post";
	objForm.style.display = "none";
	if (document.getElementById("ctl00_BodyCell") != null) {
		intWidth = document.getElementById("ctl00_BodyCell").offsetWidth;
		strHTML = document.getElementById("ctl00_BodyCell").innerHTML;
	}
	else if (document.getElementById("ctl00_bodyCell") != null) {
		intWidth = document.getElementById("ctl00_bodyCell").offsetWidth;
		strHTML = document.getElementById("ctl00_bodyCell").innerHTML;
	}
	else if (document.getElementById("ctl00_Bodycell") != null) {
		intWidth = document.getElementById("ctl00_Bodycell").offsetWidth;
		strHTML = document.getElementById("ctl00_Bodycell").innerHTML;
	}
	else if (document.getElementById("ctl00_bodycell") != null) {
		intWidth = document.getElementById("ctl00_bodycell").offsetWidth;
		strHTML = document.getElementById("ctl00_bodycell").innerHTML;
	}
	else {
		intWidth = document.body.offsetWidth;
		strHTML = document.body.innerHTML
	}
	objForm.action = "../Site/PDF.aspx?Full=0&Width=" + intWidth + "&PageID=" + GivePageID();
	objText = document.createElement("textarea");
	objText.name = "pagehtml";
	objText.value = strHTML;
	objForm.appendChild(objText);
	document.body.appendChild(objForm);
	objForm.submit();
}

function FlexonyFullPDF() {
	var objForm;
	var objText;

	objForm = document.createElement("form");
	objForm.method = "post";
	objForm.style.display = "none";
	objForm.action = "../Site/PDF.aspx?Full=1&PageID=" + GivePageID();
	objText = document.createElement("textarea");
	objText.name = "pagehtml";
	objText.value = document.getElementsByTagName("HTML")[0].innerHTML;
	objForm.appendChild(objText);
	document.body.appendChild(objForm);
	objForm.submit();
}

function FlexonyInfo(intInfoID, intPageID) {
	window.location.href = "../Info/Display.aspx?PageID=" + intPageID + "&ID=" + intInfoID;
}

function FlexonyInfoLink(objLink, intInfoID, intPageID) {
	objLink.href = "../Info/Display.aspx?PageID=" + intPageID + "&ID=" + intInfoID;
}

function FlexonyProduct(intMode, intProductID) {
	switch (intMode) {
		case 1:
			window.location.href = "../Products/Product.aspx?PageID=" + GivePageID() + "&PID=" + intProductID;
			break;
		case 2:
			window.location.href = "../Products/OrderAdd.aspx?PID=" + intProductID + "&NoVariants=1";
			break;
		default:
			window.location.href = "../Products/OverView.aspx?PageID=" + GivePageID() + "&PID=" + intProductID;
			break;
	}
}

function FlexonyProductLink(objLink, intMode, intProductID) {
	switch (intMode) {
		case 1:
			objLink.href = "../Products/Product.aspx?PageID=" + GivePageID() + "&PID=" + intProductID;
			break;
		case 2:
			objLink.href = "../Products/OrderAdd.aspx?PID=" + intProductID + "&NoVariants=1";
			break;
		default:
			objLink.href = "../Products/OverView.aspx?PageID=" + GivePageID() + "&PID=" + intProductID;
			break;
	}
}

function FlexonyLogin() {
	window.location.href = "../Site/Login.aspx?PageID=" + GivePageID();
}

function FlexonyLoginLink(objLink) {
	objLink.href = "../Site/Login.aspx?PageID=" + GivePageID();
}

function FlexonyLogout() {
	window.location.href = "../Site/Logout.aspx";
}
function FlexonyLogoutLink(objLink) {
	objLink.href = "../Site/Logout.aspx";
}

function FlexonyRegister() {
	window.location.href = "../Site/Register.aspx?PageID=" + GivePageID();
}
function FlexonyRegisterLink(objLink) {
	objLink.href = "../Site/Register.aspx?PageID=" + GivePageID();
}

function FlexonyPassword() {
	window.location.href = "../Site/Password.aspx?PageID=" + GivePageID();
}
function FlexonyPasswordLink(objLink) {
	objLink.href = "../Site/Password.aspx?PageID=" + GivePageID();
}

function FlexonyProfile() {
	window.location.href = "../Site/Profile.aspx?PageID=" + GivePageID();
}
function FlexonyProfileLink(objLink) {
	objLink.href = "../Site/Profile.aspx?PageID=" + GivePageID();
}

var strFlexonyPopupPreviousMargin = "";
var strFlexonyPopupPreviousOverflow = "";
function FlexonyMailAFriend() {
	var objDiv, objFrame;

	if (typeof document.body.scroll != "undefined") {
		strFlexonyPopupPreviousMargin = document.body.style.marginRight;
		strFlexonyPopupPreviousOverflow = document.body.style.overflow;
		document.body.scroll = "no";
		document.body.style.overflow = "hidden";
		document.body.style.marginRight = "17px";
	}
	else {
		strFlexonyPopupPreviousOverflow = document.body.style.overflow;
		document.body.style.overflow = "hidden";
	}
	GetWindowDimensions();
	objDiv = document.getElementById("FlexonyPopupWindow");
	if (objDiv == null) {
		objFrame = document.createElement("iframe");
		objFrame.allowTransparency = true;
		objFrame.frameBorder = "0"
		objFrame.src = "../Site/MailAFriend.aspx?PageID=" + GivePageID();
		objFrame.style.width = "100%";
		objFrame.style.height = "100%";

		objDiv = document.createElement("div");
		objDiv.id = "FlexonyPopupWindow";
		objDiv.style.position = "absolute";
		objDiv.style.left = 0;
		objDiv.style.top = 0;
		objDiv.style.width = intTipWindowWidth + "px";
		objDiv.style.height = "100%";
		objDiv.style.display = "none";
		objDiv.style.zIndex = "80000";
		objDiv.appendChild(objFrame);
		document.body.appendChild(objDiv);
	}
	else {
		objDiv.firstChild.src = "../Site/MailAFriend.aspx?PageID=" + GivePageID();
		objDiv.style.display = "";
		objDiv.focus();
	}
}

function FlexonyLoginPopup() {
	var objDiv, objFrame;

	if (typeof document.body.scroll != "undefined") {
		strFlexonyPopupPreviousMargin = document.body.style.marginRight;
		strFlexonyPopupPreviousOverflow = document.body.style.overflow;
		document.body.scroll = "no";
		document.body.style.overflow = "hidden";
		document.body.style.marginRight = "17px";
	}
	else {
		strFlexonyPopupPreviousOverflow = document.body.style.overflow;
		document.body.style.overflow = "hidden";
	}
	GetWindowDimensions();
	objDiv = document.getElementById("FlexonyPopupWindow");
	if (objDiv == null) {
		objFrame = document.createElement("iframe");
		objFrame.allowTransparency = true;
		objFrame.frameBorder = "0"
		objFrame.src = "../Site/LoginPopup.aspx?PageID=" + GivePageID();
		objFrame.style.width = "100%";
		objFrame.style.height = "100%";

		objDiv = document.createElement("div");
		objDiv.id = "FlexonyPopupWindow";
		objDiv.style.position = "absolute";
		objDiv.style.left = 0;
		objDiv.style.top = 0;
		objDiv.style.width = intTipWindowWidth + "px";
		objDiv.style.height = "100%";
		objDiv.style.display = "none";
		objDiv.style.zIndex = "80000";
		objDiv.appendChild(objFrame);
		document.body.appendChild(objDiv);
	}
	else {
		objDiv.firstChild.src = "../Site/LoginPopup.aspx?PageID=" + GivePageID();
		objDiv.style.display = "";
		objDiv.focus();
	}
}

function FlexonyClosePopupWindow() {
	var objDiv;

	objDiv = document.getElementById("FlexonyPopupWindow");
	if (objDiv != null) {
		while (objDiv.childNodes[0]) {
			objDiv.removeChild(objDiv.childNodes[0]);
		}
		objDiv.parentNode.removeChild(objDiv);
	}
	if (typeof document.body.scroll != "undefined") {
		document.body.style.marginRight = strFlexonyPopupPreviousMargin;
		document.body.style.overflow = strFlexonyPopupPreviousOverflow;
		document.body.scroll = "";
	}
	else {
		document.body.style.overflow = strFlexonyPopupPreviousOverflow;
	}
}

function Get_ClientWidth() {
	return Get_FilterResults(
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function Get_ClientHeight() {
	return Get_FilterResults(
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function Get_ScrollLeft() {
	return Get_FilterResults(
				window.pageXOffset ? window.pageXOffset : 0,
				document.documentElement ? document.documentElement.scrollLeft : 0,
				document.body ? document.body.scrollLeft : 0
			);
}

function Get_ScrollTop() {
	return Get_FilterResults(
				window.pageYOffset ? window.pageYOffset : 0,
				document.documentElement ? document.documentElement.scrollTop : 0,
				document.body ? document.body.scrollTop : 0
			);
}

function Get_FilterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && !n_result)
		n_result = n_docel;
	return n_body && (!n_result) ? n_body : n_result;
}

var objTipObject = null;
var intTipMousePosX = 0;
var intTipMousePosY = 0;
var intTipWindowWidth = 0;
var intTipWindowHeight = 0;
var intTipFadeTimer = 0;
var intTipHideTimer = 0;

function GetMousePosition(objEvent) {
	if (GetAttribute(objTipObject, "tipmode") == "0") {
		if (objEvent.pageX || objEvent.pageY) {
			intTipMousePosX = objEvent.pageX;
			intTipMousePosY = objEvent.pageY;
		}
		else if (objEvent.clientX || objEvent.clientY) {
			intTipMousePosX = objEvent.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			intTipMousePosY = objEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
	}
	else {
		var objElm;

		intTipMousePosX = 0;
		intTipMousePosY = 0;
		objElm = (objEvent.srcElement) ? objEvent.srcElement : objEvent.target;
		if (objElm.tagName.toLowerCase() == "area") {
			// find area position, tricky!!
			var arrCoords;
			var objImgs = document.getElementsByTagName("IMG");
			var objImg = null;
			var strMapName;

			strMapName = '#' + objElm.parentNode.name;
			if (objElm.shape.toLowerCase() == "rect") {
				arrCoords = objElm.coords.split(",")
				if (arrCoords.length >= 2) {
					intTipMousePosX += parseInt(arrCoords[0]);
					intTipMousePosY += parseInt(arrCoords[1]);
				}
			}
			for (i = 0; i < objImgs.length; i++) {
				if (objImgs[i].getAttribute("useMap") == strMapName) {
					objImg = objImgs[i];
					break;
				}
			}
			while (objImg != null) {
				intTipMousePosX += objImg.offsetLeft;
				intTipMousePosY += objImg.offsetTop;
				objImg = objImg.offsetParent;
			}
		}
		else {
			if (objElm.offsetParent) {
				while (objElm != null) {
					intTipMousePosX += objElm.offsetLeft;
					intTipMousePosY += objElm.offsetTop;
					objElm = objElm.offsetParent;
				}
			}
		}
	}
}

function GetWindowDimensions() {
	if (typeof (window.innerWidth) == 'number') {
		intTipWindowWidth = window.innerWidth;
		intTipWindowHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		intTipWindowWidth = document.documentElement.clientWidth;
		intTipWindowHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		intTipWindowWidth = document.body.clientWidth;
		intTipWindowHeight = document.body.clientHeight;
	}
}

function SetTipPosition(objDiv) {
	var intWidth = eval(GetAttribute(objTipObject, "tipwidth"));
	var intHeight = eval(GetAttribute(objTipObject, "tipheight"));
	var intOffsetX = eval(GetAttribute(objTipObject, "tipoffsetx"));
	var intOffsetY = eval(GetAttribute(objTipObject, "tipoffsety"));
	var intTipX = 0;
	var intTipY = 0;

	if (GetAttribute(objTipObject, "tipmode") == "0") {
		if ((intTipMousePosX + intOffsetX - document.body.scrollLeft + intWidth) > intTipWindowWidth) {
			intTipX = (intTipMousePosX - ((intTipMousePosX + intOffsetX - document.body.scrollLeft + intWidth) - intTipWindowWidth))
		}
		else {
			intTipX = (intTipMousePosX + intOffsetX);
		}
		if ((intTipX - document.body.scrollLeft) < 0) intTipX = document.body.scrollLeft;

		if ((intTipMousePosY + intOffsetY - document.body.scrollTop + intHeight) > intTipWindowHeight) {
			intTipY = (intTipMousePosY - intOffsetY - intHeight);
		}
		else {
			intTipY = (intTipMousePosY + intOffsetY);
		}
		if ((intTipY - document.body.scrollTop) < 0) intTipY = document.body.scrollTop;
	}
	else {
		intTipX = (intTipMousePosX + intOffsetX);
		intTipY = (intTipMousePosY + intOffsetY);
	}
	objDiv.style.left = intTipX + 'px';
	objDiv.style.top = intTipY + 'px';
}

function ShowTip(objObject, objEvent) {
	var objDiv;

	if (!objEvent) objEvent = window.event;
	objTipObject = objObject;
	objDiv = document.getElementById("flexonytipwindow");
	if (intTipHideTimer != 0) window.clearTimeout(intTipHideTimer);
	if (objDiv == null) {
		GetWindowDimensions();
		GetMousePosition(objEvent);
		objFrame = document.createElement("iframe");
		objFrame.allowTransparency = true;
		objFrame.frameBorder = "0"
		objFrame.scrolling = "no";
		objFrame.marginHeight = "0";
		objFrame.marginWidth = "0";
		objFrame.src = GetAttribute(objTipObject, "tiphref");
		objFrame.style.width = GetAttribute(objTipObject, "tipwidth") + "px";
		objFrame.style.height = GetAttribute(objTipObject, "tipheight") + "px";

		objDiv = document.createElement("div");
		objDiv.id = "flexonytipwindow";
		objDiv.style.position = "absolute";
		objDiv.style.width = objFrame.style.width;
		objDiv.style.height = objFrame.style.height;
		objDiv.style.border = GetAttribute(objTipObject, "tipborder");
		objDiv.style.opacity = 0;
		objDiv.style.filter = "alpha(opacity=0)";
		objDiv.style.display = "block";
		objDiv.style.zIndex = "80000";
		objDiv.onmouseover = new Function("if (intTipHideTimer != 0) window.clearTimeout(intTipHideTimer);");
		objDiv.onmouseout = new Function("HideTip();");
		objDiv.appendChild(objFrame);
		SetTipPosition(objDiv);

		document.body.appendChild(objDiv);
		intTipFadeTimer = window.setTimeout("FadeInTip(100);", 100);
	}
	else {
		objDiv.childNodes[0].src = GetAttribute(objTipObject, "tiphref");
		objDiv.childNodes[0].style.width = GetAttribute(objTipObject, "tipwidth") + "px";
		objDiv.childNodes[0].style.height = GetAttribute(objTipObject, "tipheight") + "px";
		objDiv.style.width = objDiv.childNodes[0].style.width;
		objDiv.style.height = objDiv.childNodes[0].style.height;
		objDiv.style.border = GetAttribute(objTipObject, "tipborder");
		GetMousePosition(objEvent);
		SetTipPosition(objDiv);
		FadeInTip(100);
	}
}

function FadeInTip(intValue) {
	var objDiv;
	objDiv = document.getElementById("flexonytipwindow");
	window.clearTimeout(intTipFadeTimer);
	if (objDiv != null) {
		if (intValue > 0) {
			objDiv.style.opacity = (100 - intValue) / 100;
			objDiv.style.filter = "alpha(opacity=" + (100 - intValue) + ")";
			intTipFadeTimer = window.setTimeout("FadeInTip(" + (intValue - 40) + ");", 50);
		}
		else {
			objDiv.style.opacity = 1;
			objDiv.style.filter = "alpha(opacity=100)";
			intTipFadeTimer = 0
		}
	}
}

function FadeOutTip(intValue) {
	var objDiv;
	objDiv = document.getElementById("flexonytipwindow");
	window.clearTimeout(intTipFadeTimer);
	if (objDiv != null) {
		if (intValue > 0) {
			objDiv.style.opacity = intValue / 100;
			objDiv.style.filter = "alpha(opacity=" + intValue + ")";
			intTipFadeTimer = window.setTimeout("FadeOutTip(" + (intValue - 40) + ");", 50);
		}
		else {
			objDiv.removeChild(objDiv.childNodes[0]);
			objDiv.parentNode.removeChild(objDiv);
			objDiv = null;
			intTipFadeTimer = 0
		}
	}
}

function MoveTip(objEvent) {
	objDiv = document.getElementById("flexonytipwindow");
	if (objDiv != null) {
		if (GetAttribute(objTipObject, "tipmode") == "0") {
			GetMousePosition(objEvent);
			SetTipPosition(objDiv);
		}
	}
}

function HideTip() {
	var objDiv;

	objDiv = document.getElementById("flexonytipwindow");
	if (objDiv != null) {
		if (intTipHideTimer != 0) window.clearTimeout(intTipHideTimer);
		if (GetAttribute(objTipObject, "tipmode") == "0")
			intTipHideTimer = window.setTimeout("FadeOutTip(100);", 1);
		else
			intTipHideTimer = window.setTimeout("FadeOutTip(100);", 200);
	}
}

function SlideShowInit(intIndex) {
	window.setTimeout("SlideShowNextSlide(" + intIndex + ",1);", eval("SlideShow" + intIndex + "Sleep") * 1000);
}

function SlideShowNextSlide(intIndex, intSlideIndex) {
	if (intSlideIndex >= (eval("SlideShow" + intIndex + "Images").length)) intSlideIndex = 0;
	document.getElementById("SlideShow" + intIndex + "Image2").src = document.getElementById("SlideShow" + intIndex + "Image1").src;
	document.getElementById("SlideShow" + intIndex + "Image2Container").style.display = "";
	window.setTimeout("SlideShowFade(" + intIndex + ",100," + intSlideIndex + ");", 100);
}

function SlideShowFade(intIndex, intValue, intSlideIndex) {
	if (intValue == 100) {
		document.getElementById("SlideShow" + intIndex + "Image1").src = "/FlexImages/Site/" + eval("SlideShow" + intIndex + "Images")[intSlideIndex] + ".jpg";
	}
	if (intValue > 0) {
		document.getElementById("SlideShow" + intIndex + "Image1Container").style.opacity = (100 - intValue) / 100;
		document.getElementById("SlideShow" + intIndex + "Image1Container").style.filter = "alpha(opacity=" + (100 - intValue) + ")";
		document.getElementById("SlideShow" + intIndex + "Image2Container").style.opacity = intValue / 100;
		document.getElementById("SlideShow" + intIndex + "Image2Container").style.filter = "alpha(opacity=" + intValue + ")";
		window.setTimeout("SlideShowFade(" + intIndex + "," + (intValue - 1) + "," + intSlideIndex + ");", eval("SlideShow" + intIndex + "Fade") * 10);
	}
	else {
		document.getElementById("SlideShow" + intIndex + "Image1Container").style.opacity = 1;
		document.getElementById("SlideShow" + intIndex + "Image1Container").style.filter = "alpha(opacity=100)";
		document.getElementById("SlideShow" + intIndex + "Image2Container").style.opacity = 0;
		document.getElementById("SlideShow" + intIndex + "Image2Container").style.filter = "alpha(opacity=0)";
		document.getElementById("SlideShow" + intIndex + "Image2Container").style.display = "none";
		window.setTimeout("SlideShowNextSlide(" + intIndex + "," + (intSlideIndex + 1) + ");", eval("SlideShow" + intIndex + "Sleep") * 1000);
		if (intSlideIndex >= (eval("SlideShow" + intIndex + "Images").length - 1)) intSlideIndex = -1;
		document.getElementById("SlideShow" + intIndex + "Image2").src = "/FlexImages/Site/" + eval("SlideShow" + intIndex + "Images")[intSlideIndex + 1] + ".jpg"; ;
	}
}

