﻿var gs_ColorObjectId = null;

function OpenDialog(as_Url, as_Name, ai_Width, ai_Height)
{
	var ls_Top = "";
	var ls_Left = "";
	try
	{
		ls_Left = ",left=" + (screen.Width / 2 - ai_Width);
		ls_Top = ",top=" + (screen.Height / 2 - ai_Height);
	}
	catch (e)
	{}
	
	window.open(as_Url, as_Name, "directories=no,location=no,menubar=no,scrollbars=no,status=yes,toolbar=no,resizable=yes,width=" + ai_Width + ",height=" + ai_Height + ls_Left + ls_Top);
}

var gk_WindowObjectReference = null;

function OpenRequestedPopup(as_Url, as_Name, ai_Width, ai_Height)
{
	var ls_Top = "";
	var ls_Left = "";
	try
	{
		ls_Left = ",left=" + (screen.Width / 2 - ai_Width);
		ls_Top = ",top=" + (screen.Height / 2 - ai_Height);
	}
	catch (e)
	{}

	try
	{
		if(gk_WindowObjectReference == null || gk_WindowObjectReference.closed)
		{
			gk_WindowObjectReference = window.open(as_Url, as_Name,"directories=no,location=yes,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes,width=" + ai_Width + ",height=" + ai_Height + ls_Left + ls_Top);
		}
		else
		{
			gk_WindowObjectReference.focus();
		}
	}
	catch (e)
	{}
}


function ChangeColor(as_ObjectId, ab_Change)
{
	document.getElementById(as_ObjectId).className = ab_Change ? "ContentMenuItem1" : "ContentMenuItem";
}

function ChangeBackgroundColor(as_ObjectId, ab_Change, as_CssNormal, as_CssOver)
{
	document.getElementById(as_ObjectId).className = ab_Change ? as_CssOver : as_CssNormal;
}

function SendMail(as_Email) 
{
	location.href = DecodeMail(as_Email);
}

function DecodeMail(as_Email) 
{
	var li_Code = 0;
	var ls_Output = "";
	
	for(var i=0; i < as_Email.length; i++) 
	{
		li_Code = as_Email.charCodeAt(i);
		if (li_Code >= 8364) {li_Code = 128;}
		ls_Output += String.fromCharCode(li_Code-(2));
	}
	
	return ls_Output;
}

function DisplayCountry(ab_Country)
{
    if (ab_Country != null)
	{
	    document.getElementById("europe").style.visibility = ab_Country == "EU" ? "visible" : "hidden";
	    document.getElementById("america").style.visibility = ab_Country == "US" ? "visible" : "hidden";
	    document.getElementById("EuDiv").style.color = ab_Country == "EU" ? "White" : "Black";
	}
	else
	{
		document.getElementById("EuDiv").style.color = "Black";
		document.getElementById("europe").style.visibility = "hidden";
		document.getElementById("america").style.visibility = "hidden";
	}
}

function FireOnClick(as_UniqueID)
{
  __doPostBack(as_UniqueID,"");
}

function ShowBlockPrice(as_ShowObjectId, as_HideObjectId) 
{
	if (document.getElementById(as_ShowObjectId).style.visibility == "hidden") 
	{
		document.getElementById(as_HideObjectId).style.visibility = "hidden";
		document.getElementById(as_ShowObjectId).style.visibility = "visible";
	}
	else 
	{
		document.getElementById(as_HideObjectId).style.visibility = "visible";
		document.getElementById(as_ShowObjectId).style.visibility = "hidden";
	}
}

function SetItemHeight()
{
	if (document.getElementById) 
	{
		var lk_DivElement = document.body.getElementsByTagName("DIV");
	
		for (i=0; i< lk_DivElement.length; i++)
		{	
			if (lk_DivElement[i].id != "")
			{
				if (lk_DivElement[i].id.indexOf("PriceScaleDiv") != -1)
					IncreaseHeight(lk_DivElement[i].parentNode, lk_DivElement[i]);
			}
		}
	}
}

function SetHeight(objId, style, value)
{ 
    document.getElementById(objId).style[style] = value; 
} 

function IncreaseHeight(ak_AddToHeight, ak_WhichHeightTd)
{    
    var li_CurrHeight = parseInt(ak_WhichHeightTd.offsetHeight);
    var li_AddToOffsetHeight = parseInt(ak_AddToHeight.offsetHeight);
    
    var li_NewHeight = 0;
    var li_Count = 6;
    
    if (li_AddToOffsetHeight <= li_CurrHeight)
    {
		li_NewHeight = li_CurrHeight + li_Count;
		SetHeight(ak_AddToHeight.id, "height", li_NewHeight + "px"); 
	}
}

var gk_CurrentCachedImages = new Array();

function GetCachedImage(as_ImageUrl)
{
	if (gk_CurrentCachedImages[as_ImageUrl] == null)
	{
		gk_CurrentCachedImages[as_ImageUrl] = new Image();
		gk_CurrentCachedImages[as_ImageUrl].src = as_ImageUrl.replace(/url\(/g, "").replace(/\)/g, "");
	}
	return gk_CurrentCachedImages[as_ImageUrl].src;
}

function SetTextButtonOver(as_LeftCellId, as_MiddleCellId, as_RightCellId, as_ImgOverLeft, as_ImgOverMiddle, as_ImgOverRight)
{
	document.getElementById(as_LeftCellId).style.background = "url("+GetCachedImage(as_ImgOverLeft)+")";
	document.getElementById(as_MiddleCellId).style.background = "url("+GetCachedImage(as_ImgOverMiddle)+")";
	document.getElementById(as_RightCellId).style.background = "url("+GetCachedImage(as_ImgOverRight)+")";
}

function SetTextButtonNormal(as_LeftCellId, as_MiddleCellId, as_RightCellId, as_ImgLeft, as_ImgMiddle, as_ImgRight)
{
	document.getElementById(as_LeftCellId).style.background = "url("+GetCachedImage(as_ImgLeft)+")";
	document.getElementById(as_MiddleCellId).style.background = "url("+GetCachedImage(as_ImgMiddle)+")";
	document.getElementById(as_RightCellId).style.background = "url("+GetCachedImage(as_ImgRight)+")";
}

function ShowUpdateBlockPrice(as_PriceObjectId, as_DescriptionObjectId)
{
	try
	{
		if(document.getElementById(as_PriceObjectId).style.visibility == "visible")
		{
		
			document.getElementById(as_DescriptionObjectId).style.visibility = "visible";
			document.getElementById(as_PriceObjectId).style.visibility = "hidden";
		}
		else
		{
			document.getElementById(as_DescriptionObjectId).style.visibility = "hidden";
			document.getElementById(as_PriceObjectId).style.visibility = "visible";
		}
	}
	catch (e)
	{}
}

function openHelp(helpdisplayURL, ServerPath )
{
	CompleteURL = ServerPath + "Help/HelpFrame.aspx?displaypage=" + helpdisplayURL ; 
	Helpwindow = window.open(CompleteURL,'SK_help','resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=no,height=560,width=850');	
	Helpwindow.focus();
}

function ChangeDisplay(as_Visible, as_Invisible)
{
	document.getElementById(as_Visible).style.display = "inline";
	document.getElementById(as_Invisible).style.display = "none";
}

function ChangeDisplayAndLink(as_Visible, as_Invisible)
{
	var lk_Visible = document.getElementById(as_Visible);
	var lk_Invisible = document.getElementById(as_Invisible);
	var lk_VisibleLink = lk_Visible.parentNode;
	var lk_InvisibleLink = lk_Invisible.parentNode;
	lk_VisibleLink.Href = lk_InvisibleLink.Href;
	lk_Visible.style.display = "inline";
	lk_Invisible.style.display = "none";
}


function ChangeScreenshots(ak_BigScreen, ak_Thumb, ai_Width, ai_Height)
{
	ak_BigScreen.src = ak_Thumb.src;
	ak_BigScreen.alt = ak_Thumb.alt;
	ak_BigScreen.onclick = ak_Thumb.onclick;
	ak_BigScreen.style.pointer = ak_Thumb.style.pointer;
	ak_BigScreen.style.height = ai_Height +"px";
	ak_BigScreen.style.width = ai_Width +"px";
}

function ChangeLightBox(as_ScreenNormal, as_ScreenOver, as_ThumbNormal, as_ThumbOver, as_Href)
{
	var lk_ScreenNormal = document.getElementById(as_ScreenNormal);
	var lk_ScreenOver = document.getElementById(as_ScreenOver);
	var lk_ThumbNormal = document.getElementById(as_ThumbNormal);
	var lk_ThumbOver = document.getElementById(as_ThumbOver);

	lk_ScreenNormal.parentNode.href = as_Href;
	lk_ScreenOver.parentNode.href = as_Href;
	
	lk_ScreenNormal.src = lk_ThumbNormal.src;
	lk_ScreenNormal.alt = lk_ThumbNormal.alt;
	lk_ScreenOver.src = lk_ThumbOver.src;
	lk_ScreenOver.alt = lk_ThumbOver.alt;

}

function StartSlideshow(as_ContainerId, ai_Timeout)
{
	ShowSlide(as_ContainerId, ai_Timeout, 0, -1);
}

function ShowSlide(as_ContainerId, ai_Timeout, ai_Step, ai_LastStep)
{
	var lk_Container = document.getElementById(as_ContainerId);
	var lk_Imgs = lk_Container.getElementsByTagName("Img");
	if (ai_LastStep != -1 && lk_Imgs.length > 1)
		Effect.DropOut(lk_Imgs[ai_LastStep].id,{ duration: 2.0 });
	if(ai_Step >= lk_Imgs.length)
		ai_Step = 0;
	Effect.Appear(lk_Imgs[ai_Step].id, { duration: 2.0 })

	if(lk_Imgs.length > 1)
		window.setTimeout("ShowSlide('" + as_ContainerId + "', " + ai_Timeout + ", " + (ai_Step + 1) + ", " + ai_Step + ")", ai_Timeout);
}

function ShowTabItem(ai_Index, as_ContainerId, ak_HeaderId)
{
	var lk_Container = document.getElementById(as_ContainerId);
	var lk_Tabs = lk_Container.getElementsByTagName("li");
	var lk_TabHeader = document.getElementById(ak_HeaderId);
	var lk_TabHeaders = lk_TabHeader.getElementsByTagName("td");
	for (var i = 0; i < lk_Tabs.length; i++)
	{
		if (i == ai_Index - 1) 
		{
			lk_Container.style.height = lk_Tabs[i].style.height;
			Effect.Appear(lk_Tabs[i].id, { duration: 1.0 });
			ActiveTabItem(lk_TabHeaders[i]);
		}
		else
		{
			lk_Tabs[i].style.display = "none";
			InactiveTabItem(lk_TabHeaders[i]);
		}
	}
}


function HoverTabItem(ak_Element)
{
	var lk_Tabs = ak_Element.getElementsByTagName("Div");
	for (var i = 0; i < lk_Tabs.length; i++)
	{
		lk_Tabs[i].className = lk_Tabs[i].className.replace("Inactive", "Over");
	}
}

function RemoveHoverTabItem(ak_Element)
{
	var lk_Tabs = ak_Element.getElementsByTagName("Div");
	for (var i = 0; i < lk_Tabs.length; i++)
	{
		lk_Tabs[i].className = lk_Tabs[i].className.replace("Over", "Inactive");
	}
}

function ActiveTabItem(ak_Element)
{
	var lk_Tabs = ak_Element.getElementsByTagName("Div");
	for (var i = 0; i < lk_Tabs.length; i++)
	{
		lk_Tabs[i].className = lk_Tabs[i].className.replace("Over", "Active");
		lk_Tabs[i].className = lk_Tabs[i].className.replace("Inactive", "Active");
	}
}
function InactiveTabItem(ak_Element)
{
	var lk_Tabs = ak_Element.getElementsByTagName("Div");
	for (var i = 0; i < lk_Tabs.length; i++)
	{
		lk_Tabs[i].className = lk_Tabs[i].className.replace("Active", "Inactive");
	}
}

function SetOver(ak_Img)
{
	ak_Img.src = ak_Img.src.replace("normal", "over");
}

function SetOut(ak_Img)
{
	ak_Img.src = ak_Img.src.replace("over", "normal");
}


