﻿function f_ButtonSingleClick(button)
{
	var bRv = true;
	if (button.className.indexOf('half-transparent') >= 0)
	{
		bRv = false;
	} else
	{
		PioWeb.setClassName(null, button, null, "half-transparent", true, false);
	}
	return bRv;
}
function f_ButtonSingleClick_Reset(button)
{
	PioWeb.setClassName(null, button, null, "half-transparent", false, false);
}

function f_ThumbnailWithGallery_1(varName, dir)
{
	var ar_sImg = window[varName + "__galljsvar"];
	var iIndex = window[varName + "__galljsvar__index"];

	iIndex += dir;
	if (iIndex < 0)
	{
		iIndex = ar_sImg.length - 1;
	} else if (iIndex >= ar_sImg.length)
	{
		iIndex = 0;
	}
	window[varName + "__galljsvar__index"] = iIndex;

	document.getElementById(varName + "__gallcont").innerHTML = ar_sImg[iIndex];
}

function f_VacationMonthView(e, ctl, preffix)
{
	var ctlCurr = PioWeb.getEventTargetElement(e);
	if (ctlCurr.tagName == "TD")
	{
		if (ctlCurr.className.indexOf("disabled") < 0)
		{
			var sDayNumber = PioWeb.trim(ctlCurr.innerHTML);
			var sTmp = sDayNumber.replace(/^[\d]+$/, "");
			if (sTmp == "")
			{
				var sCommand = preffix + "_day_" + sDayNumber;
				sCommand = ctl.getAttribute("evalcommand").replace("{0}", sCommand);
				eval(sCommand);
			}
		}
	}
}

function f_CompareCheckbox(checkbox, hotel)
{
	var ar_oObjects = new Array();
	var iMax = 4;
	var sMyType = checkbox.getAttribute("a_CompareCheckbox");
	var colChecks = document.getElementsByTagName("INPUT");
	for (var i = 0; i < colChecks.length; i++)
	{
		var ctlInput = colChecks[i];
		if (ctlInput.type != "checkbox") continue;
		var sType = ctlInput.getAttribute("a_CompareCheckbox");
		if (sType == null) continue;
		if (sType != sMyType) continue;
		if (!ctlInput.checked) continue;
		if (ctlInput != checkbox)
		{
			ar_oObjects.push(ctlInput);
		} else
		{
			iMax--;
		}
	}
	while (ar_oObjects.length > iMax)
	{
		var ctlInput = ar_oObjects.pop();
		ctlInput.checked = false;
	}
	if (checkbox.tagName == "INPUT" && checkbox.checked)
	{
		ar_oObjects.push(checkbox);
	}

	var sConf = "";
	for (var i = 0; i < ar_oObjects.length; i++)
	{
		sConf += ar_oObjects[i].value + ";";
	}
	if (sConf != "")
		sConf = sConf.substr(0, sConf.length - 1);
	else if (hotel != null)
	{
		var i = 0;
		var iCtl = 0;
		while (i < colChecks.length && iCtl < 4)
		{
			var ctlInput = colChecks[i++];
			if (ctlInput.type != "checkbox") continue;
			var sType = ctlInput.getAttribute("a_CompareCheckbox");
			if (sType == null) continue;
			if (sType != sMyType) continue;
			sConf += ctlInput.value + ";";
			iCtl++;
		}
	}
	if (checkbox.tagName == "A")
	{
		checkbox.href = checkbox.href + "?SVOWSCMPREX=" + sConf;
	}
} //@@@ f_CompareCheckbox()

function f_CompareLink(link, hotel)
{
	f_CompareCheckbox(link, hotel);
}

var _of_Tooltip = null;
function f_Tooltip_PageLoad(e)
{
	if (window.opera && document.readyState != "complete") return;
	PioWeb.detachEvent(window, "load", f_Tooltip_PageLoad);

	var ctlFly = document.body.appendChild(document.createElement("DIV"));
	ctlFly.style.position = "absolute";
	ctlFly.style.top = "0px";
	ctlFly.style.left = "0px";
	ctlFly.className = "f-tooltip";
	ctlFly.style.visibility = "hidden";
	ctlFly.style.zIndex = 1000000;

	ctlFly.innerHTML = "<table style=\"width:100%;height:100%\"><tr><td>&nbsp;<td></tr></table>";

	_of_Tooltip = new PioWebAbsoluteElementEx("_of_Tooltip", null, ctlFly, "align", "align", "bottom", "top", 0, 0);
	_of_Tooltip.freeStateObject = ctlFly.childNodes[0].rows[0].cells[0];

	PioWeb.attachEvent(document, "mouseover", f_Tooltip_MouseOver);
	PioWeb.attachEvent(document, "mouseout", f_Tooltip_MouseOut);
}
function f_Tooltip_MouseOver(e)
{
	var ctlSrc = PioWeb.getEventTargetElement(e);
	if (ctlSrc == null) return;

	var sToolTip = ctlSrc.getAttribute("f_tooltip");

	var bMakeToolTip = false;
	if (sToolTip == null || sToolTip == "")
	{
		var bToolTip = ctlSrc.getAttribute("f_btooltip");
		if (bToolTip != null && bToolTip != "") bMakeToolTip = true;
	} else
	{
		bMakeToolTip = true;
	}
	if (!bMakeToolTip) return;

	if (ctlSrc.title && ctlSrc.title != "" && ctlSrc.title != sToolTip)
	{
		sToolTip = ctlSrc.title;
		ctlSrc.setAttribute("f_tooltip", sToolTip);
		ctlSrc.title = "";
	} else if (ctlSrc.alt && ctlSrc.alt != "" && ctlSrc.alt != sToolTip)
	{
		sToolTip = ctlSrc.alt;
		ctlSrc.setAttribute("f_tooltip", sToolTip);
		ctlSrc.alt = "";
	}

	if (sToolTip == "") return;

	var ctlFly = _of_Tooltip.freeStateObject; //_of_Tooltip.flyObj.childObj;
	ctlFly.innerHTML = sToolTip;
	PioWeb.setClassName(null, _of_Tooltip.flyObj.childObj, null, "f-tooltip-wide", (sToolTip.length > 50), false);
	_of_Tooltip.setPosition(ctlSrc);
	_of_Tooltip.show();
}
function f_Tooltip_MouseOut(e)
{
	var ctlSrc = PioWeb.getEventTargetElement(e);
	if (ctlSrc != null)
	{
		var sTitle = ctlSrc.getAttribute("f_tooltip");
		if (sTitle != null && sTitle != "")
		{
			_of_Tooltip.hide();
		}
	}
}
PioWeb.attachEvent(window, "load", f_Tooltip_PageLoad);


function f_ModalBehaivor_Open()
{
	var oHider = PioEffects.getContetsFader();
	oHider.open();
}
function f_ModalBehaivor_Close()
{
	var oHider = PioEffects.getContetsFader();
	oHider.close();
}

var f_flyShowServerSiteAlert_PageLoaded_Arr = new Array();
function f_flyShowServerSiteAlert_PageLoaded(sender, args)
{
	var f_flyShowServerSiteAlert_PageLoaded_HideModal = document.getElementById("f_flyShowServerSiteAlert_PageLoaded_HideModal");
	if (f_flyShowServerSiteAlert_PageLoaded_HideModal != null)
	{
		f_ModalBehaivor_Close();
	}

	if (f_flyShowServerSiteAlert_PageLoaded_Arr != null)
	{
		for (var i = 0; i < f_flyShowServerSiteAlert_PageLoaded_Arr.length; i++)
		{
			f_flyShowServerSiteAlert(f_flyShowServerSiteAlert_PageLoaded_Arr[i]);
		}
	}
}
function f_flyShowServerSiteAlert(id)
{
	var oFlyWindow = document.getElementById(id);
	if (oFlyWindow == null)
	{
		return false;
	}

	f_ModalBehaivor_Open();

	oFlyWindow.style.display = "";
	var iX = (document.body.clientWidth - oFlyWindow.offsetWidth) / 2;
	var iY = (document.body.clientHeight - oFlyWindow.offsetHeight) / 2;
	if (PioWeb.BrName == "IE" && PioWeb.getDocTypeInfo().importance != "STRICT")
	{
		oFlyWindow.style.left = iX + "px";
		oFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+" + iY + "+'px'");
	} else
	{
		if (PioWeb.getDocTypeInfo().importance == "STRICT")
			{
			iY = (document.documentElement.clientHeight - oFlyWindow.offsetHeight) / 2; //@@@ fix for viewport
			if (PioWeb.BrName == "IE")
				iY=iY+document.documentElement.scrollTop;
			}
		oFlyWindow.style.left = iX + "px";
		oFlyWindow.style.top = iY + "px";
	}
	oFlyWindow.style.visibility = "visible";
}
function f_flyHideServerSiteAlert(id)
{
	var oFlyWindow = document.getElementById(id);
	if (oFlyWindow == null)
	{
		return false;
	}

	oFlyWindow.style.visibility = "hidden";
	oFlyWindow.style.display = "none";

	f_ModalBehaivor_Close();
}

function f_Changecss(theClass, element, value)
{
	//Last Updated on May 21, 2008
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	var cssRules;
	if (document.all)
	{
		cssRules = 'rules';
	}
	else if (document.getElementById)
	{
		cssRules = 'cssRules';
	}

	var added = false;
	for (var S = 0; S < document.styleSheets.length; S++)
	{
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
		{
			if (document.styleSheets[S][cssRules][R].selectorText == theClass)
			{
				if (document.styleSheets[S][cssRules][R].style[element])
				{
					document.styleSheets[S][cssRules][R].style[element] = value;
					added = true;
					break;
				}
			}
		}

		if (!added)
		{
			if (document.styleSheets[S].insertRule)
			{
				document.styleSheets[S].insertRule(theClass + ' { ' + element + ': ' + value + '; }', document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule)
			{
				document.styleSheets[S].addRule(theClass, element + ': ' + value + ';');
			}
		}
	}
}

function gal_Item_Class(previewHtml, thumbnanilHtml, fullsizeHtml, descr)
{
	this.previewHtml = previewHtml;
	this.thumbnanilHtml = thumbnanilHtml;
	this.fullsizeHtml = fullsizeHtml;
	this.descr = descr;
}

function gal_hdlResizeForFlyWindow(e, force)
{
	var pnlFlyWindow = document.getElementById("flyGalWindow");
	if (pnlFlyWindow != null)
		f_hdlResizeForFlyWindow(pnlFlyWindow, force);
}

function careers_hdlResizeForFlyWindow(e, force) {
    var pnlFlyWindow = document.getElementById("flySendToFriend");
    if (pnlFlyWindow != null)
        f_hdlResizeForFlyWindow(pnlFlyWindow,true);
}

function f_hdlResizeForFlyWindow(pnlFlyWindow, force)
{
	if (force || pnlFlyWindow.style.visibility != "hidden")
	{
	    var iX = (document.body.clientWidth - pnlFlyWindow.offsetWidth) / 2;
		var iY = (document.body.clientHeight - pnlFlyWindow.offsetHeight) / 2;
		pnlFlyWindow.style.left = iX + "px";
		if (PioWeb.BrName == "IE" && PioWeb.getDocTypeInfo().importance != "STRICT")
		{
			pnlFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+" + iY + "+'px'");
		} else
		{
			if (PioWeb.getDocTypeInfo().importance == "STRICT")
				{
				iY = (document.documentElement.clientHeight - pnlFlyWindow.offsetHeight) / 2;
				if (PioWeb.BrName == "IE")
					iY=iY+document.documentElement.scrollTop;
				}
			pnlFlyWindow.style.top = iY + "px";
		}
	}
}

PioWeb.attachEvent(window, "resize", gal_hdlResizeForFlyWindow);
PioWeb.attachEvent(window, "resize", forum_hdlResizeForFlyWindow);
PioWeb.attachEvent(window, "resize", careers_hdlResizeForFlyWindow);
window.onunload = function()
{
	window["__flash__removeCallback"] = function(instance, name)
	{
		return;
	};
}

function gal_CloseFlyGalery(button)
{
	gal_lstCurrent = null;
	gal_iIndexCurrent = -1;
	gal_itemFullDetailsLink = null;

	var pnlFlyWindow = document.getElementById("flyGalWindow");
	f_ModalBehaivor_Close();
	pnlFlyWindow.style.visibility = "hidden";
	pnlFlyWindow.style.display = "none";
}

function gal_OpenFlyGallery(button, list, itemFullDetailsLink)
{
	if (list == null || list.length == 0) gal_CloseFlyGalery(button);

	gal_lstCurrent = list;
	gal_iIndexCurrent = -1;
	itemFullDetailsLink = PioWeb.trim(itemFullDetailsLink || "");
	if (itemFullDetailsLink.length == 0)
		itemFullDetailsLink = null;
	gal_itemFullDetailsLink = itemFullDetailsLink;

	var pnlFlyWindow = document.getElementById("flyGalWindow");

	f_ModalBehaivor_Open();
	pnlFlyWindow.style.display = "";
	gal_NextPrevFlyGalery(button, 1);
	//gal_hdlResizeForFlyWindow(null, true);
	pnlFlyWindow.style.visibility = "visible";
}
function gal_OpenFlyGallery_MediaTabs(button)
{
	var sFullSizeHtml = button.nextSibling.innerHTML;
	var sDescr = button.alt;
	var oItem = new gal_Item_Class(null, null, sFullSizeHtml, sDescr);
	var ar_oItems = new Array();
	ar_oItems[0] = oItem;
	gal_OpenFlyGallery(button, ar_oItems);
}
function gal_OpenFlyGallery_MediaTabs1(button)
{
	var oButton = button.parentNode.parentNode.rows[0].cells[0].childNodes[0];
	gal_OpenFlyGallery_MediaTabs(oButton);
}

function gal_NextPrevFlyGalery(button, dir)
{
	if (gal_lstCurrent == null) return;

	var iNewIndex = gal_iIndexCurrent + dir;
	if (iNewIndex >= 0 && iNewIndex < gal_lstCurrent.length)
	{
		gal_iIndexCurrent = iNewIndex;

		var oGalleryItem = gal_lstCurrent[gal_iIndexCurrent];

		var sHtml = oGalleryItem.fullsizeHtml;
		if (sHtml == null || sHtml == "")
		{
			sHtml = oGalleryItem.previewHtml;
			if (sHtml == null || sHtml == "")
			{
				sHtml = oGalleryItem.thumbnanilHtml;
			}
		}
		if (gal_itemFullDetailsLink != null && sHtml != null && sHtml != "")
		{
			sHtml = "<a href=\"" + gal_itemFullDetailsLink + "\">" + sHtml + "</a>";
		}

		//document.getElementById("flyGalPrevNext").style.display = (gal_lstCurrent.length > 1) ? "" : "none";
		document.getElementById("flyGalPrev").style.display = (gal_lstCurrent.length > 1) ? "" : "none";
		document.getElementById("flyGalNext").style.display = (gal_lstCurrent.length > 1) ? "" : "none";

		document.getElementById("flyGalPreview").innerHTML = sHtml;
		document.getElementById("flyGalTitle").innerHTML = oGalleryItem.descr;

		document.getElementById("flyGalPrev").className = (gal_iIndexCurrent == 0) ? "half-transparent" : "pointer";
		document.getElementById("flyGalNext").className = (gal_iIndexCurrent == gal_lstCurrent.length - 1) ? "half-transparent" : "pointer";

		gal_hdlResizeForFlyWindow(null, true);
	}
}

var gal_lstCurrent = null;
var gal_iIndexCurrent = -1;

function f_OrderPrint()
{
	window.print();
}
function f_doSaveAs()
{
	if (document.execCommand && document.all)
	{
		document.execCommand('SaveAs');
	}
	else
	{
		alert("Save-feature available only from Internet Exlorer 5.x.")
	}
}

var imOb = new Array();
imOb[0] = new Image(); imOb[0].src = "files/miscs/diagrams/null.gif";
imOb[1] = new Image(); imOb[1].src = "files/miscs/diagrams/bt1.gif";
imOb[2] = new Image(); imOb[2].src = "files/miscs/diagrams/bt2.gif";
imOb[3] = new Image(); imOb[3].src = "files/miscs/diagrams/bt3.gif";
imOb[4] = new Image(); imOb[4].src = "files/miscs/diagrams/bt4.gif";
imOb[5] = new Image(); imOb[5].src = "files/miscs/diagrams/bt5.gif";
imOb[6] = new Image(); imOb[6].src = "files/miscs/diagrams/bt6.gif";
imOb[7] = new Image(); imOb[7].src = "files/miscs/diagrams/bt7.gif";
imOb[8] = new Image(); imOb[8].src = "files/miscs/diagrams/bt8.gif";
imOb[9] = new Image(); imOb[9].src = "files/miscs/diagrams/bt9.gif";

function f_changeDiagram(n)
{
	eval("document.bt.src=imOb[n].src;");
}

function forum_hdlResizeForFlyWindow(e, force)
{
	var pnlFlyWindow = document.getElementById("flyPostWindow");
	if (pnlFlyWindow != null)
		f_hdlResizeForFlyWindow(pnlFlyWindow, force);
}

function f_CloseFly(button, flyWindowId)
{

	var pnlFlyWindow = document.getElementById(flyWindowId);
	f_ModalBehaivor_Close();
	pnlFlyWindow.style.visibility = "hidden";
	pnlFlyWindow.style.display = "none";
}

function f_OpenFly(modal, flyWindowId)
{
	var pnlFlyWindow = document.getElementById(flyWindowId);
	if (pnlFlyWindow != null)
	{
		if (modal) f_ModalBehaivor_Open();
		pnlFlyWindow.style.display = "";
		pnlFlyWindow.style.visibility = "visible";
		f_hdlResizeForFlyWindow(pnlFlyWindow, true);
	}
}

var f_flyPostWindow_PageLoaded_Arr = new Array();
function f_flyPostWindow_PageLoaded(sender, args)
{
	if (f_flyPostWindow_PageLoaded_Arr != null)
	{
		for (var i = 0; i < f_flyPostWindow_PageLoaded_Arr.length; i++)
		{
			f_flyPostWindow(f_flyPostWindow_PageLoaded_Arr[i]);
		}
	}
}
function f_flyPostWindow(id)
{
	f_SetRank(document.getElementById(id).value);
}

function f_OpenLoginFly(pnlLogin)
{
	var pnlFlyWindow = document.getElementById(pnlLogin);
	if (pnlFlyWindow != null)
	{
		var iX = (document.body.clientWidth - pnlFlyWindow.offsetWidth) / 2;
		pnlFlyWindow.style.left = iX + "px";

		if (PioWeb.BrName == "IE" && PioWeb.getDocTypeInfo().importance != "STRICT")
		{
			pnlFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+10+'px'");
		}

		f_ModalBehaivor_Open();

		var hdl = function() { pnlFlyWindow.style.visibility = "visible"; };
		window.setTimeout(hdl, 10);
		//@@@ forces a redraw (needed for ie7)
		if (PioWeb.BrName == "IE" && PioWeb.getDocTypeInfo().importance != "STRICT")
		{
			pnlFlyWindow.className = pnlFlyWindow.className;
		}
	}
}
function f_CloseLoginFly(pnlLogin)
{
	var pnlFlyWindow = document.getElementById(pnlLogin);
	if (pnlFlyWindow != null)
	{
		f_ModalBehaivor_Close();
		pnlFlyWindow.style.visibility = "hidden";
	}
}
function f_isNumberKey(evt)
{
	if (!evt)
		return false;
	var charCode = (typeof(evt.which)!= "undefined") ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	return true;
}
/*   Campaign function and links */
function f_ParseQueryStringParameter(querystring, param)
{
	var iParamBegin;
	var iParamEnd;
	var sParamValue = "";
	if ((iParamBegin = querystring.indexOf(param + "=")) != -1)
	{
		if ((iParamEnd = querystring.indexOf("&", iParamBegin)) != -1)
			sParamValue = querystring.substring(iParamBegin + param.length + 1, iParamEnd);
		else
			sParamValue = querystring.substring(iParamBegin + param.length + 1);
	}
	return sParamValue;
}
function f_CampaignSrc(querystring)
{
	var iLink = 0;
	if ((iLink = f_ParseQueryStringParameter(querystring, "t")) != "")
		return arrLinks[iLink];
	else
		return "";
}
var arrLinks = new Array();
arrLinks[1] = "http://www.next-in.com/minisites/isrotel/frames/1.html";
arrLinks[2] = "http://www.next-in.com/minisites/isrotel/frames/2.html";
arrLinks[3] = "http://www.next-in.com/minisites/isrotel/frames/3.html";
arrLinks[4] = "http://www.next-in.com/minisites/isrotel/frames/4.html";
arrLinks[5] = "http://www.next-in.com/minisites/isrotel/frames/5.html";
arrLinks[6] = "http://www.next-in.com/minisites/isrotel/frames/6.html";
arrLinks[7] = "http://www.next-in.com/minisites/isrotel/frames/7.html";

/*************************************************************************/

//==============================
//	accordion scripts
//==============================
function accordionItemClick(accordionItemParamsContainer, itemId, ignoreIfAlreadyOpened)
{
	//~~~ get accordion item params
	var oAccordionItemParamsField = PioWeb.getSingleDescendantById(accordionItemParamsContainer, "hdnAccordionItemParams_" + itemId);
	if (oAccordionItemParamsField == null)
		return;
	var oAccordionItemParams = oAccordionItemParamsField.value.split(";");
	if (oAccordionItemParams.length < 3)
		return;

	var sAccordionClientId = oAccordionItemParams[0];
	var sAccordionItemClientId = oAccordionItemParams[1];
	var bAllowOpenMultipleItems = oAccordionItemParams[2] == "true";

	//~~~ single opened item behavior
	if (!bAllowOpenMultipleItems)
	{
		//~~~ get current opened item and compare it to clicked item
		var oAccordionCurrentItemField = document.getElementById(sAccordionClientId + "_hdnCurrentAccordionItemId");
		if (oAccordionCurrentItemField == null)
			return;
		var sCurrentAccordionItemClientId = oAccordionCurrentItemField.value;

		if (sAccordionItemClientId != sCurrentAccordionItemClientId)
		{
			//~~~ close current opened item
			if (sCurrentAccordionItemClientId != "")
				accordionItemClose(sCurrentAccordionItemClientId, false);
			//~~~ set current opened item field's value
			oAccordionCurrentItemField.value = sAccordionItemClientId;
		}
		else
		{
			//~~~ reset current opened item field's value
			oAccordionCurrentItemField.value = "";
		}
	}

	//~~~ toggle clicked item
	if (!isAccordionItemOpened(sAccordionItemClientId))
	{
		//~~~ open clicked item
		accordionItemOpen(sAccordionItemClientId);
	}
	//~~~ close clicked item when already opened
	else if (!ignoreIfAlreadyOpened)
	{
		//~~~ close clicked item
		accordionItemClose(sAccordionItemClientId, true);
	}
}

function accordionItemClose(accordionItemClientId, animate)
{
	var oAccordionItemRow = document.getElementById("tr_" + accordionItemClientId);
	var oAccordionItemDiv = document.getElementById("div_" + accordionItemClientId);
	if (oAccordionItemRow == null || oAccordionItemDiv == null)
		return;

	//~~~ change image
	var oAccordionItemImg = document.getElementById("img_" + accordionItemClientId);
	if (oAccordionItemImg != null)
		oAccordionItemImg.src = oAccordionItemImg.src.replace("minus", "plus");

	//~~~ close item
	accordionUp(accordionItemClientId, animate);
	oAccordionItemRow.setAttribute("opened", "false");
}

function accordionItemOpen(accordionItemClientId)
{
	var oAccordionItemRow = document.getElementById("tr_" + accordionItemClientId);
	var oAccordionItemDiv = document.getElementById("div_" + accordionItemClientId);
	if (oAccordionItemRow == null || oAccordionItemDiv == null)
		return;

	//~~~ change image
	var oAccordionItemImg = document.getElementById("img_" + accordionItemClientId);
	if (oAccordionItemImg != null)
		oAccordionItemImg.src = oAccordionItemImg.src.replace("plus", "minus");

	//~~~ open item
	oAccordionItemRow.style.display = "";
	oAccordionItemDiv.style.display = "";
	oAccordionItemDiv.style.height = "0px";
	accordionDown(accordionItemClientId, 0);
	oAccordionItemRow.setAttribute("opened", "true");
}

function isAccordionItemOpened(accordionItemClientId)
{
	var oAccordionItemRow = document.getElementById("tr_" + accordionItemClientId);
	if (oAccordionItemRow == null)
		return false;
	return oAccordionItemRow.getAttribute("opened") == "true";
}

function accordionUp(clId, animate)
{
	var divHeight = 0;
	var offset = 20;
	var tr = document.getElementById("tr_" + clId);
	var div = document.getElementById("div_" + clId);
	//var span = document.getElementById("span_" + clId);
	if (/^\d/.test(div.style.height))
		divHeight = parseInt(div.style.height);
	else
		divHeight = div.offsetHeight;
	//if (span != null && divHeight == 0)
	//	divHeight = span.offsetTop;
	if (!animate) offset = 1000;

	if (divHeight > 0)
	{
		divHeight -= offset;
		if (divHeight > 0)
		{
			div.style.display = "";
			div.style.height = divHeight + "px";
		}
		else
		{
			div.style.display = "none";
			div.style.height = "0px";
		}
		var timeId = window.setTimeout("accordionUp('" + clId + "','" + animate + "')", 20);
	}
	else
	{
		tr.style.display = "none";
	}
}

function accordionDown(clId, divHeight)
{
	var div = document.getElementById("div_" + clId);
	var span = document.getElementById("span_" + clId);
	div.style.display = "";
	var maxHeight = span.offsetTop;
	if (divHeight < maxHeight)
	{
		divHeight += 20;
		div.style.height = divHeight < maxHeight ? divHeight + "px" : maxHeight + "px"
		var timeId = window.setTimeout("accordionDown('" + clId + "'," + divHeight + ")", 20);
	}
}

function onAccordionItemLinkClick(itemLink)
{
	var sItemId = itemLink.href.substring(itemLink.href.indexOf("#") + 1);
	sItemId = sItemId.replace(/^{|}$/g, "");

	accordionItemClick(document.body, sItemId, true);
	if (PioWeb.BrName == "IE")
	{
		//itemLink.click();
		//location.href = itemLink.href;
	}
	return true;
}

//==============================
//	package details fly window
//==============================

function openPackageDetailsFlyWindow(popUpId)
{
	var oPackagePopUp = document.getElementById(popUpId);
	if (oPackagePopUp == null)
		return;

	f_ModalBehaivor_Open();
	oPackagePopUp.style.visibility = "visible";
	oPackagePopUp.style.display = "";
	openPackageDetailsFlyWindow.CurrentOpenedPopUp = oPackagePopUp;
}
openPackageDetailsFlyWindow.CurrentOpenedPopUp = null;

function closePackageDetailsFlyWindow()
{
	if (openPackageDetailsFlyWindow.CurrentOpenedPopUp == null)
		return;

	var oPackagePopUp = openPackageDetailsFlyWindow.CurrentOpenedPopUp
	f_ModalBehaivor_Close();
	oPackagePopUp.style.visibility = "hidden";
	oPackagePopUp.style.display = "none";
}


//=================================
//  sites navigation
//=================================

function f_renderCurrentSitePanel()
{
	var oOWSConf = OWSCtl_getConfData();
	var sHtml = "";

	sHtml += '<table border="0" cellpadding="0" cellspacing="0" dir="ltr" style=\"cursor:pointer;\" onclick="languagesNavig_f_open(this);"><tr>';
	sHtml += '<td class="langs-bar-current-site-icon"><img src="coreTemplate/' + SITEUTILS_IMG + '/' + SITEUTILS_R + '.png" width="24" height="20"/></td>';
	sHtml += '<td><div class="langs-bar-container"><table border="0" cellpadding="0" cellspacing="0" class="langs-bar"><tr>';
	if (SITEUTILS_TR.indexOf("ingdom") < 0)
	{
		sHtml += '<td style="font-weight:bold;">' + SITEUTILS_TR + '</td>';
	} else
	{
		sHtml += '<td style="font-weight:bold;"><span f_btooltip="1" title="' + SITEUTILS_TR + '">UK</span></td>';
	}
	sHtml += '<td>:</td><td>' + SITEUTILS_TL + '</td><td>:</td><td><nobr><span f_btooltip="1" title="' + SITEUTILS_TCL + '">' + SITEUTILS_TC + '</span></nobr></td>';
	sHtml += '</tr></table></div></td>';
	if (oOWSConf.CURRENCY_WARNING != "")
	{ //(SITEUTILS_C == SITEUTILS_CB) {
		sHtml += '<td><img src="coreTemplate/img/g0.gif" width="4" height="1"/></td>';
		//sHtml += '<td><img src="coreTemplate/' + SITEUTILS_IMG + '/REGION____warning.gif" width="18" height="17" f_btooltip="1" title="' + PioWeb.htmlEncode(PioWeb.stringFormat(oOWSConf.CURRENCY_WARNING, SITEUTILS_CB, SITEUTILS_C)) + '"/></td>';
		sHtml += '<td><img src="coreTemplate/' + SITEUTILS_IMG + '/REGION____warning.gif" width="18" height="17" f_btooltip="1" title="' + PioWeb.htmlEncode(oOWSConf.CURRENCY_WARNING) + '"/></td>';
	}
	sHtml += '<td><img src="coreTemplate/img/g0.gif" width="4" height="1"/></td>';
	sHtml += '<td><img src="coreTemplate/' + SITEUTILS_IMG + '/REGION____arrow.gif" width="18" height="17"/></td>';
	sHtml += '<td><img src="coreTemplate/img/g0.gif" width="5" height="1"/></td>';
	sHtml += '</tr></table>';

	document.write(sHtml);
}

function languagesNavig_f_submit(button)
{
	var sUrl = languagesNavig_f_generateSelectedUrl();
	if (sUrl != null)
	{
	    //alert(sUrl); f_ButtonSingleClick_Reset(button);
	    if (sUrl.indexOf("http://") == 0 || sUrl.indexOf("https://") == 0)
	    {
			if (typeof(go2TrackingUrl) == "function")
	    		go2TrackingUrl(sUrl);
	        location.href = sUrl;
	    }
		else
	    {
	        alert("This site is not configured"); f_ButtonSingleClick_Reset(button);
	    }
	} 
	else
	{
		//alert("It's current site"); f_ButtonSingleClick_Reset(button);
		languagesNavig_f_close();
	}
}

var __oLanguagesNavig = null;

function languagesNavig_f_close()
{
	if (__oLanguagesNavig != null)
	{
		__oLanguagesNavig.hide();
		f_ModalBehaivor_Close();
	}
}

function languagesNavig_f_open(currentSitePanel)
{
	if (__oLanguagesNavig == null)
	{
		var oCtl = document.createElement("DIV");
		oCtl.className = "langs-navig-container";
		oCtl.style.position = "absolute";
		oCtl.style.zIndex = PioEffectsContentsFaider_Config.zIndex + 100;
		oCtl.style.visibility = "hidden";
		document.body.appendChild(oCtl);

		oCtl.innerHTML = languagesNavig_f_genreateHtml();
		var oFly = new PioWebAbsoluteElementEx("__oLanguagesNavig", currentSitePanel, oCtl, "opposite-align", "opposite-align", "bottom", "top", 0, 2);
		oFly.closeOnResize = false;

		__oLanguagesNavig = oFly;
	} else
	{
		__oLanguagesNavig.flyObj.childObj.innerHTML = languagesNavig_f_genreateHtml();
	}

	__oLanguagesNavig.setPosition();
	f_ModalBehaivor_Open();
	__oLanguagesNavig.show();
}

function languagesNavig_f_genreateHtml()
{
	var oData = $get("langsBarRRR");
	var oOWSConf = OWSCtl_getConfData();

	var sHtml = "";
	var iCnt = 0;

	frame_write_disable_document_write = true;
	sHtml += frame19(1);
	frame_write_disable_document_write = false;

	sHtml += '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
	sHtml += '<td style="width:100%;"><div class="title">' + oOWSConf.HCONF_CHOOSE_REGION_LANGUAGE_CURRENCY + '</div></td>';
	sHtml += '<td style="white-space:nowrap;"><div class="pointer window-x" onclick="languagesNavig_f_close();">' + oOWSConf.HCONF_CLOSE + '</div></td>';
	sHtml += '</tr></table>';

	frame_write_disable_document_write = true;
	sHtml += frame19(2);
	frame_write_disable_document_write = false;	

	sHtml += '<table dir="ltr" class="langs-navig" border="0" cellpadding="0" cellspacing="0">';
	sHtml += '<thead><tr>';
	sHtml += '<th colspan="2">Region</th>';
	//~~~ separator th
	sHtml += '<th class="separator-ver"><div><img src="coreTemplate/img/g0.gif" width="1" height="10"/></div></th>';
	sHtml += "<th>Language</th>";
	//~~~ separator th
	sHtml += '<th class="separator-ver"><div><img src="coreTemplate/img/g0.gif" width="1" height="10"/></div></th>';
	sHtml += '<th>Currency</th>';
	sHtml += "</tr></thead><tbody>";

	var colRegions = oData.childNodes;
	for (var i = 0; i < colRegions.length; i++)
	{
		var oRegion = colRegions[i]; //~~~<LI><SPAN></SPAN><UL>
		var bRegionIsCurrent = (oRegion.getAttribute("mls_key") == SITEUTILS_R);

		//~~~ separator tr
		sHtml += '<tr class="separator-hor"><td colspan="6"><div><img src="coreTemplate/img/g0.gif" width="5" height="1"/></div></td></tr>';

		sHtml += '<tr ' + ((bRegionIsCurrent) ? ' class="selected"' : "") + 'style="height:30px;" onclick="languagesNavig_f_selectRow(this,event)">';

		//~~~ region title
		sHtml += '<td class="first"><img class="region-icon" src="coreTemplate/' + SITEUTILS_IMG + '/' + oRegion.getAttribute("mls_key") + ((bRegionIsCurrent) ? '' : '_o') + '.png" width="24" height="20"/></td>';
		sHtml += '<td' + ((bRegionIsCurrent) ? ' class=current' : "") + ' style="cursor:default;">' + oRegion.childNodes[0].innerHTML + '</td>';

		//~~~ separator td
		sHtml += '<td class="separator-ver"><div style="height:100%;"><img src="coreTemplate/img/g0.gif" width="1" height="10"/></div></td>';

		//~~~ languages
		sHtml += '<td>'
		var colLanguages = oRegion.childNodes[1].childNodes;
		for (var j = 0; j < colLanguages.length; j++)
		{
			var oLanguage = colLanguages[j];  //<LI><A></A><UL>
			var bLanguageIsCurrent = (bRegionIsCurrent && oLanguage.getAttribute("mls_key") == SITEUTILS_LANG);

			if (j != 0) sHtml += "<br/>";

			var sRadioId = "__oLanguagesNavig_radio_" + (++iCnt);
			sHtml += '<input type="radio" name="reg_' + 'all' + '_lang" id="' + sRadioId + '"' + ((bLanguageIsCurrent) ? " checked" : "") + ' onclick="if(this.checked)languagesNavig_f_selectCurrency(this)" value="' + oLanguage.getAttribute("mls_key") + '" mls_key_reg="' + oRegion.getAttribute("mls_key") + '" mls_key_url="' + oLanguage.childNodes[0].href + '">';
			sHtml += '<label for="' + sRadioId + '"' + ((bLanguageIsCurrent) ? ' class="current"' : '') + '>' + oLanguage.childNodes[0].innerHTML + '</label>';
		}
		sHtml += '</td>';

		//~~~ separator td
		sHtml += '<td class="separator-ver"><div style="height:100%;"><img src="coreTemplate/img/g0.gif" width="1" height="10"/></div></td>';

		//~~~ currencies
		sHtml += '<td class="last" width="40%">';
		var colLanguages = oRegion.childNodes[1].childNodes;
		for (var j = 0; j < colLanguages.length; j++)
		{
			var oLanguage = colLanguages[j];  //<LI><A></A><UL>
			var bLanguageIsCurrent = (bRegionIsCurrent && oLanguage.getAttribute("mls_key") == SITEUTILS_LANG);

			var sLangSelectionContainerId = "__oLanguagesNavig_reg_" + oRegion.getAttribute("mls_key") + "_lang_" + oLanguage.getAttribute("mls_key") + "_curr";
			if (bLanguageIsCurrent) languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId = sLangSelectionContainerId;
			sHtml +=
				'<table id="' + sLangSelectionContainerId + '" style="display:' + (bLanguageIsCurrent ? '' : 'none') + ';"' + (colLanguages.length == 1 ? ' mls_key_issingle="yes"' : '') + ' border="0" cellpadding="0" cellspacing="0">';

			var colCurrencies = oLanguage.childNodes[1].childNodes;
			for (var z = 0; z < colCurrencies.length; z++)
			{
				var oCurrency = colCurrencies[z]; //<LI>
				var bCurrencyIsCurrent = (bLanguageIsCurrent && oCurrency.getAttribute("mls_key") == SITEUTILS_C);
				var bCurrencyIsSelected = (bCurrencyIsCurrent || (!bLanguageIsCurrent && z == 0));

				var sRadioId = "__oLanguagesNavig_radio_" + (++iCnt);
				var sTdStyle;
				if (colCurrencies.length == 1) {
				    if(PioWeb.BrName == "IE")
				        sTdStyle = ' style="padding-top: 4px;"';
				    else
				        sTdStyle = ' style="padding-top: 1px;"';
				} else if (z != 0) {
				    if (PioWeb.BrName == "IE")
				        sTdStyle = '';
				    else
				        sTdStyle = ' style="padding-top: 2px;"';
				} else {
				    sTdStyle = '';
				};
				sHtml +=
					'<tr>' +
						'<td valign="top"' + sTdStyle + '><input type="radio" style="position: relative; top: -2px;" name="reg_' + i + '_lang_' + j + '" id="' + sRadioId + '" value="' + oCurrency.getAttribute("mls_key") + '"' + ((bCurrencyIsSelected) ? " checked" : "") + ((colCurrencies.length == 1) ? ' mls_key_issingle="yes"' : '') + ((z == 0) ? ' mls_key_isdefault="yes"' : '') + '></td>' +
						'<td valign="top"' + sTdStyle + '>&nbsp;<label for="' + sRadioId + '"' + ((bCurrencyIsCurrent) ? " class=\"current\"" : "") + '>' + oCurrency.innerHTML + '</label></td>' +
					'</tr>';
			}

			sHtml +=
				'</table>';
		}
		sHtml += '</td>';

		sHtml += '</tr>';
	}

	sHtml += '</tbody></table>';

	sHtml += '<div class="langs-navig-buttons-container"><table align="center"><tr>';
	sHtml += '<td><span class="langs-navig-buttons-close" onclick="languagesNavig_f_close();">close</span></td>';
	sHtml += '<td>';
	sHtml += '<input type="image" src="sitebutton.axd?text=Go&skin=' + SITEUTILS_BTN_SKIN + '" onclick="if(!f_ButtonSingleClick(this))return false;languagesNavig_f_submit(this);return false;" value="Go"/>';
	sHtml += '</td>';
	sHtml += '</tr></table></div>';

	frame_write_disable_document_write = true;
	sHtml += frame19(3);
	frame_write_disable_document_write = false;

	return sHtml;
}

function languagesNavig_f_selectRow(row, e)
{
	var ctlTbl = row.offsetParent;
	var colRows = ctlTbl.rows;
	var ctlRowToSelect = row;

	var ctlEventTarget = PioWeb.getEventTargetElement(e);
	if (ctlEventTarget != null && ctlEventTarget.tagName == "LABEL") return;

	for (var i = 0; i < colRows.length; i++)
	{
		var ctlRow = colRows[i];
		var bToSelect = (ctlRow == ctlRowToSelect);

		//~~~ class name
		PioWeb.setClassName(null, ctlRow, null, "selected", bToSelect, false);

		//~~~ icon
		var colTmp = ctlRow.getElementsByTagName("IMG");
		for (var j = 0; j < colTmp.length; j++)
		{
			var ctlTmp = colTmp[j];
			if (ctlTmp.className == "region-icon")
			{
				ctlTmp.src = ctlTmp.src.replace(/(_o)?\.png$/, ((bToSelect) ? ".png" : "_o.png"));
				break;
			}
		}

		//~~~ radio buttons        
		if (bToSelect)
		{
			var colTmp = ctlRow.getElementsByTagName("INPUT");
			var colRadioLang = new Array();
			for (var j = 0; j < colTmp.length; j++)
			{
				var ctlTmp = colTmp[j];
				if (ctlTmp.type == "radio" && ctlTmp.name == "reg_all_lang")
				{
					if (ctlTmp.checked)
					{
						colRadioLang = null;
						break;
					} else
					{
						colRadioLang.push(ctlTmp);
					}
				}
			}
			if (colRadioLang != null)
			{
				colRadioLang[0].checked = true;
				languagesNavig_f_selectCurrency(colRadioLang[0]);
			}
		}
	}
}

function languagesNavig_f_selectCurrency(radioButton)
{
	var sLangSelectionContainerId = "__oLanguagesNavig_reg_" + radioButton.getAttribute("mls_key_reg") + "_lang_" + radioButton.value + "_curr";
	var ctlLangSelectionContainer = $get(sLangSelectionContainerId);

	var ctlLangTD = ctlLangSelectionContainer.parentNode;
	var colLangSelectionContainers = ctlLangTD.childNodes;

	for (var i = 0; i < colLangSelectionContainers.length; i++)
	{
		var ctlTmp = colLangSelectionContainers[i];
		if (ctlTmp.tagName == ctlLangSelectionContainer.tagName && ctlTmp.id.replace(/^__oLanguagesNavig_reg_(.|_)+_lang_.+_curr$/, "") != ctlTmp.id)
		{
			if (ctlTmp != ctlLangSelectionContainer)
			{
				ctlTmp.style.display = "none";
			}
			else
			{
				ctlTmp.style.display = "";
			}
		}
	}
	if (languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId != null && languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId != sLangSelectionContainerId)
	{
		var ctlPrevLangSelectionContainer = $get(languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId);

		var ctlPrevLangTD = ctlPrevLangSelectionContainer.parentNode;
		if (ctlPrevLangTD != ctlLangTD)
		{
			var colLangSelectionContainers = ctlPrevLangTD.childNodes;

			for (var i = 0; i < colLangSelectionContainers.length; i++)
			{
				var ctlTmp = colLangSelectionContainers[i];
				if (ctlTmp.tagName == ctlPrevLangSelectionContainer.tagName && ctlTmp.id.replace(/^__oLanguagesNavig_reg_(.|_)+_lang_.+_curr$/, "") != ctlTmp.id)
				{
					ctlTmp.style.display = "none";
				}
			}
		}
	}
	languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId = sLangSelectionContainerId;
}
languagesNavig_f_selectCurrency.currentLanguageSelectionContainerId = null;

function languagesNavig_f_generateSelectedUrl()
{
	var ctlSelectedLanguage = null;
	var colTmp = document.getElementsByName("reg_all_lang");
	for (var j = 0; j < colTmp.length; j++)
	{
		var ctlTmp = colTmp[j];
		if (ctlTmp.type == "radio" && ctlTmp.name == "reg_all_lang")
		{
			if (ctlTmp.checked)
			{
				ctlSelectedLanguage = ctlTmp;
				break;
			}
		}
	}
	if (ctlSelectedLanguage == null) return null;

	var ctlSelectedCurrency = null;
	var sSelectedCurrencyDivId = "__oLanguagesNavig_reg_" + ctlSelectedLanguage.getAttribute("mls_key_reg") + "_lang_" + ctlSelectedLanguage.value + "_curr";
	var ctlSelectedCurrencyDiv = $get(sSelectedCurrencyDivId);
	var colTmp = ctlSelectedCurrencyDiv.getElementsByTagName("INPUT");
	for (var j = 0; j < colTmp.length; j++)
	{
		var ctlTmp = colTmp[j];
		if (ctlTmp.type == "radio" && ctlTmp.checked)
		{
			ctlSelectedCurrency = ctlTmp;
			break;
		}
	}
	if (ctlSelectedCurrency == null) return null;

	var sRegionKey = ctlSelectedLanguage.getAttribute("mls_key_reg");
	var sLanguageKey = ctlSelectedLanguage.value;
	var sCurrencyKey = ctlSelectedCurrency.value;
	if (sRegionKey == SITEUTILS_R && sLanguageKey == SITEUTILS_LANG && SITEUTILS_C == sCurrencyKey)
		return null;

	var sLangUrl = ctlSelectedLanguage.getAttribute("mls_key_url");

	//if (ctlSelectedCurrency.getAttribute("mls_key_isdefault") != "yes") {
	if (ctlSelectedCurrency.getAttribute("mls_key_issingle") != "yes")
	{
		if (sLangUrl.indexOf("?") < 0)
		{
			sLangUrl = sLangUrl + "?currencyCode=" + sCurrencyKey;
		} else
		{
			sLangUrl = sLangUrl + "&currencyCode=" + sCurrencyKey;
		}
	}

	//alert(sLangUrl);
	return sLangUrl;
}

function escapeGoogleAnalyticsCookie()
{
	//~~~ The __utmz cookie's utmctr parameter matches the searched phrase.
	//~~~ In Firefox this value is not escaped and therefore might contain unicode characters, which cause IIS7 crash
	PioWeb.attachEvent(window, "unload", function()
	{
		var sCookie = document.cookie;
		var oReg = /^((?:.+;\s*)?__utmz=.+?)(\butmctr=)([^|;]*)(.*)$/i;
		var aMatches = sCookie.match(oReg);
		if (aMatches != null && aMatches.length > 4)
		{
			var sUtmctrVal = aMatches[3];
			//sCookie = aMatches[1] + aMatches[2] + escape(sUtmctrVal) + aMatches[4];
			sCookie = aMatches[1] + aMatches[2] + encodeURIComponent(sUtmctrVal) + aMatches[4];
			document.cookie = sCookie;
		}
	});
}

//================================================================
//	BEGIN: Horizontal Accordion
//================================================================
HorizAccordion = function(container)
{
	this._sId = 'HorizAccordion_' + HorizAccordion.Count++;
	eval(this._sId + ' = this;');
	HorizAccordion[this._sId] = this;
	if (container == null)
		return;

	this._oContainer = container;
	this._oContainer.HorizAccordionInstanceId = this._sId;

	this._oItems = { Titles: PioWeb.getDescendantsById(this._oContainer, 'HorizAccordionItemTitle'), Contents: PioWeb.getDescendantsById(this._oContainer, 'HorizAccordionItemContent') };
	this._iSelectedItemIndex = 0;
	if (this._oItems.Titles != null)
	{
		for (var i = 0; i < this._oItems.Titles.length; i++)
		{
			this._oItems.Titles[i].ItemIndex = i;
			if (/\bhoriz-accordion-selected-item\b/i.test(this._oItems.Titles[i].className))
				break;
		}
		this._iSelectedItemIndex = i;
		for (; i < this._oItems.Titles.length; i++)
			this._oItems.Titles[i].ItemIndex = i;
	}
	this._iDefaultSelectedIndex = this._iSelectedItemIndex;
};
HorizAccordion.prototype.TitleClick = function(titleObj)
{
	if (this._oContainer == null)
		return;
	if (titleObj.ItemIndex == this._iSelectedItemIndex)
	{
		if (this._iSelectedItemIndex == this._iDefaultSelectedIndex)
			return;
		//~~~ select default selection
		titleObj = this._oItems.Titles[this._iDefaultSelectedIndex];
	}

	//~~~ unselect selected item
	var oSelectedTitle = this._oItems.Titles[this._iSelectedItemIndex];
	var oSelectedContent = this._oItems.Contents[this._iSelectedItemIndex];
	PioWeb.setClassName(null, oSelectedTitle, null, 'horiz-accordion-selected-item', false, false);
	PioWeb.setClassName(null, oSelectedContent, null, 'horiz-accordion-selected-item', false, false);

	//~~~ select clicked item
	var oItemContent = this._oItems.Contents[titleObj.ItemIndex];
	PioWeb.setClassName(null, titleObj, null, 'horiz-accordion-selected-item', true, false);
	PioWeb.setClassName(null, oItemContent, null, 'horiz-accordion-selected-item', true, false);
	this._iSelectedItemIndex = titleObj.ItemIndex;
}
HorizAccordion.prototype.TitleOver = function(titleObj)
{
	if (this._oContainer == null)
		return;

	this.ExpandStart(titleObj.ItemIndex);
}
HorizAccordion.prototype._iAnimStepWidthInc = 10;
HorizAccordion.prototype._iAnimStepInterval = 25;
HorizAccordion.prototype._iAnimIntervalId = -1;
HorizAccordion.prototype._bAnimInitialized = false;
HorizAccordion.prototype.ExpandStart = function(itemIndex)
{
	if (!this._bAnimInitialized)
	{
		this._bAnimInitialized = true;
		if (PioWeb.BrName == "IE" && PioWeb.BrVers <= 7)
		{
			this._iAnimStepWidthInc = 20;
			this._iAnimStepInterval = 50;
		}
		var oSelectedContent = this._oItems.Contents[this._iSelectedItemIndex];
		oSelectedContent.animW = 100;
		oSelectedContent.firstChild.style.width = oSelectedContent.offsetWidth;
		oSelectedContent.style.width = '0%';
		for (var i = 0; i < this._oItems.Contents.length; i++)
		{
			if (i == this._iSelectedItemIndex)
				continue;
			var oContent = this._oItems.Contents[i];
			oContent.animW = 0;
			//~~~ compute items' content offset width and height
			oContent.style.width = '100%';
			oContent.style.display = '';
			oContent.firstChild.style.width = oContent.offsetWidth;
			oContent.firstChild.style.height = oContent.offsetHeight;
			oContent.style.width = '0%';
		}
		oSelectedContent.style.width = '100%';
	}
	//	else
	//	{
	//		for (var i = 0; i < this._oItems.Contents.length; i++)
	//		{
	//			var oContent = this._oItems.Contents[i];
	//			oContent.style.display = '';
	//		}
	//	}

	window.clearInterval(this._iAnimIntervalId);
	this._iAnimIntervalId = window.setInterval(this._sId + '.ExpandStep(' + itemIndex + ')', this._iAnimStepInterval);
}
HorizAccordion.prototype.ExpandStep = function(itemIndex)
{
	var oContent = this._oItems.Contents[itemIndex];

	if (oContent.animW >= 100)
	{
		oContent.style.width = '100%';

		//~~~ select expanded item
		var oTitle = this._oItems.Titles[itemIndex];
		PioWeb.setClassName(null, oTitle, null, 'horiz-accordion-selected-item', true, false);
		PioWeb.setClassName(null, oContent, null, 'horiz-accordion-selected-item', true, false);
		this._iSelectedItemIndex = itemIndex;

		for (var i = 0; i < this._oItems.Contents.length; i++)
		{
			if (i == itemIndex)
				continue;
			this._oItems.Contents[i].animW = 0;
			this._oItems.Contents[i].style.width = '0%';
			//			this._oItems.Contents[i].style.display = 'none';

			//~~~ unselect collapsed items
			PioWeb.setClassName(null, this._oItems.Titles[i], null, 'horiz-accordion-selected-item', false, false);
			PioWeb.setClassName(null, this._oItems.Contents[i], null, 'horiz-accordion-selected-item', false, false);
		}
		window.clearInterval(this._iAnimIntervalId);
		return;
	}

	//~~~ expand selected item's content
	oContent.animW += this._iAnimStepWidthInc;
	if (oContent.animW > 100)
		oContent.animW = 100;
	oContent.style.width = oContent.animW + '%';

	//~~~ calculate item's to collapse
	var aVisibleItems = [];
	for (var i = 0; i < this._oItems.Contents.length; i++)
	{
		if (i == itemIndex)
			continue;
		if (this._oItems.Contents[i].animW > 0)
			aVisibleItems.push(i);
		else if (this._oItems.Contents[i].animW < 0)
			this._oItems.Contents[i].animW = 0;
	}

	//~~~ collapse calculated items' content
	var iItemsDecrementWidth = Math.floor(this._iAnimStepWidthInc / aVisibleItems.length);
	for (var i = 0; i < aVisibleItems.length; i++)
	{
		var oContent = this._oItems.Contents[aVisibleItems[i]];
		oContent.animW -= iItemsDecrementWidth;
		if (oContent.animW < 0)
		{
			if (i < aVisibleItems.length - 1)
				iItemsDecrementWidth -= Math.floor(oContent.animW / (aVisibleItems.length - i));
			oContent.animW = 0;
		}
		//		else if (oContent.animW > 0)
		//		{
		//			var oTitle = this._oItems.Titles[aVisibleItems[i]];
		//			//~~~ display item title as if selected while collapsing
		//			PioWeb.setClassName(null, oTitle, null, 'horiz-accordion-selected-item', true, false);
		//		}
		oContent.style.width = oContent.animW + '%';
	}
	//~~~ fix last item's content width
	var oLastContent = this._oItems.Contents[aVisibleItems[i - 1]];
	oLastContent.style.width = 'auto';
	////	var iLastItemWidth = this._oContainer.offsetWidth;
	////	for (var i = 0; i < this.__oItems.Titles.length; i++)
	////		iLastItemWidth -= this.__oItems.Titles[i].style.width;
	////	for (var i = 0; i < this.__oItems.Contents.length; i++)
	////		if (this.__oItems.Contents[i] != oLastContent)
	////			iLastItemWidth -= this.__oItems.Contents[i].offsetWidth;
	////	oLastContent.style.width = iLastItemWidth + 'px';
	//alert([this._oItems.Contents[0].style.width,this._oItems.Contents[1].style.width,this._oItems.Contents[2].style.width])
}

HorizAccordion.Count = 0;
HorizAccordion.Get = function(obj)
{
	var oContainer = null;
	if (obj != null)
	{
		if (obj.HorizAccordionInstance != null)
			return obj.HorizAccordionInstance;
		for (oContainer = obj; oContainer != null; oContainer = oContainer.parentNode)
		{
			if (oContainer.id == 'HorizAccordionContainer')
				break;
		}
	}
	var oRv = null;
	if (oContainer != null && oContainer.HorizAccordionInstanceId != undefined)
		oRv = HorizAccordion[oContainer.HorizAccordionInstanceId];
	else
		oRv = new HorizAccordion(oContainer);
	obj.HorizAccordionInstance = oRv;
	return oRv;
}
//================================================================
//	END: Horizontal Accordion
//================================================================

//================================================================
//	Begin: Home page side menu accordion
//================================================================

var SideMenu =
{
	prevImage: null,
	_sOpenedSideMenuItemId: null,
	AnimationEnabled: (PioWeb.BrName != "IE" || PioWeb.BrVers > 7),
	ElementIdPrefix: "",

	OpenSideMenuItem: function(clId)
	{
		if (clId != SideMenu._sOpenedSideMenuItemId)
		{
			if (SideMenu._sOpenedSideMenuItemId != null)
			{
				SideMenu.f_changeImage(SideMenu._sOpenedSideMenuItemId);
				SideMenu.f_accordionup(SideMenu._sOpenedSideMenuItemId);
			}
			SideMenu.f_changeImage(clId);
			var oTmp = document.getElementById(SideMenu.ElementIdPrefix + clId);
			oTmp.style.display = "";
			SideMenu.f_accordiondown(clId, 0);
			SideMenu._sOpenedSideMenuItemId = clId;
		}
	},

	f_changeImage: function(clId)
	{
		var prevImage = document.getElementById(SideMenu.prevImage);
		var image = document.getElementById("img_" + clId);
		if (prevImage != null && prevImage.id != image.id)
		{
			prevImage.src = prevImage.src.replace("side_menu_category_bg.gif", "side_menu_category_bg_open.gif");
		}
		if (image.src.indexOf("side_menu_category_bg_open.gif") != -1)
		{
			image.src = image.src.replace("side_menu_category_bg_open.gif", "side_menu_category_bg.gif");
			/*hdnImage.value = "img_" + clId;*/
			SideMenu.prevImage = "img_" + clId;
		}
		else
		{
			image.src = image.src.replace("side_menu_category_bg.gif", "side_menu_category_bg_open.gif");
		}
	},
	f_accordionup: function(clId)
	{
		var divheight = 0;
		var offset = 20;
		if (!SideMenu.AnimationEnabled)
			offset = 100;
		var div = document.getElementById("div_" + clId);
		var span = document.getElementById("span_" + clId);
		if (div.style != null)
			divheight = parseInt(div.style.height);
		if (span != null && divheight == 0)
			divheight = span.offsetTop;
		if (divheight > 0)
		{
			divheight -= offset;
			if (divheight > 0)
			{
				div.style.display = "";
				div.style.height = divheight + "px";
			}
			else
			{
				div.style.display = "none";
				div.style.height = "0px";
			}
			timeId = window.setTimeout("SideMenu.f_accordionup('" + clId + "')", 40);
		}
		else
		{
			div.style.display = "none";
		}
	},
	f_accordiondown: function(clId, divheight)
	{
		var div = document.getElementById("div_" + clId);
		var span = document.getElementById("span_" + clId);
		var offset= 20;
		if (!SideMenu.AnimationEnabled)
			offset = 100;
		div.style.display = "";
		var iMaxHeight = span.offsetTop;
		if (divheight < iMaxHeight)
		{
			divheight += offset;
			div.style.height = divheight < iMaxHeight ? divheight + "px" : iMaxHeight + "px"
			timeId = window.setTimeout("SideMenu.f_accordiondown('" + clId + "'," + divheight + ")", 40);
		}
	}
};
//================================================================
//	End: Home page side menu accordion
//================================================================

PioWeb.attachEvent(window, "load", function()
{
	var oElementsWithTextOverflow = PioWeb.getElementsByClassName("text-overflow");
	if (oElementsWithTextOverflow != null)
	{
		for (var i = 0; i < oElementsWithTextOverflow.length; i++)
		{
			var oElement = oElementsWithTextOverflow[i];
			if (typeof (oElement.title) != "undefined" && oElement.offsetWidth < oElement.scrollWidth)
				oElement.title = PioWeb.getInnerText(oElement);
		}
	}
});

//=================================================================
//      Open Fly Send Job to Friend
//=================================================================

function careers_OpenFlySendToFriend(jobCode, prezItemID)
{
	var pnlFlyWindow = document.getElementById("flySendToFriend");
	var ctlJobCode = document.getElementById("sendtofriend_job_code");
	var inputs = document.getElementsByTagName("input"); //or document.forms[0].elements;
	for (var i = 0; i < inputs.length; i++)
	{
		if (inputs[i].type == "hidden" && inputs[i].id.indexOf("fldPrezItemID") != -1)
		{
			inputs[i].value = prezItemID;
			break;
		}
	}
	f_ModalBehaivor_Open();
	pnlFlyWindow.style.display = "";
	ctlJobCode.innerHTML = jobCode;
	pnlFlyWindow.style.visibility = "visible";
	careers_hdlResizeForFlyWindow(null, true);
}

function careers_CloseFlySendToFriend(button)
{
	var pnlFlyWindow = document.getElementById("flySendToFriend");
	f_ModalBehaivor_Close();
	pnlFlyWindow.style.visibility = "hidden";
	pnlFlyWindow.style.display = "none";
}

var inner_carrers_jobs_height;
function fn_attach_item()
{
	var oSideItem = $("#careers_jobs_side_item");
	if (oSideItem == null)
		return;
	
	try
	{
		if (oSideItem.innerHTML != "")
			$("#careers_jobs_items").innerHTML = oSideItem.innerHTML;
		oSideItem.innerHTML = "";
		$(document).ready(function()
		{
			inner_carrers_jobs_height = $("#inner_careers_jobs").height(); // height of full zone content
			var height2 = $("#careers_jobs_side_menu").attr('offsetHeight');  // height of right side table
			var height3 = $("#careers_jobs_items").attr('offsetHeight'); // height of attached items
			var height4 = $(".careers-jobs-separator").height(); // height of separator
			var height5 = $(".careers-breadcrumbs").height(); // height of breadcrumbs
			var height6 = $("#careers_main_title").attr('offsetHeight'); // height of Title
			//alert(inner_carrers_jobs_height + "," + (height2 + height3 + height4 + height5 + height6));
			if (inner_carrers_jobs_height < height2 + height3 + height4 + height5 + height6)
			$("inner_careers_jobs").style.height = (height2 + height3 + height4 + height5 + height6) + "px"; // Set the remaining height in test DIV.
		});
    }
    catch (e) { }
}

function fn_validation_name(fldNameId, err_fldNameId)
{
	if (document.getElementById(fldNameId).value == "")
	{
		document.getElementById(err_fldNameId).className = "error-label visible";
		return false;
	}
	else
	{
		document.getElementById(err_fldNameId).className = "error-label unvisible";
		return true;
	}
}

function fn_validation_email(fldEmailId, err_fldEmailId)
{
	if (!validateEmail(document.getElementById(fldEmailId).value))
	{
		document.getElementById(err_fldEmailId).className = "error-label visible";
		return false;
	}
	else
	{
		document.getElementById(err_fldEmailId).className = "error-label unvisible";
		return true;
	}
}
function validateEmail(email)
{
	var matches = email.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	return (matches != null && email == matches[0]);
}

