var skinPath = "/site_16/gifs/skin_1/";

// Set the splashpage language separators
function SetLanguageSeparator()
{
	var oLanguagues = document.getElementById('Languages');
	var ListElements = oLanguagues.getElementsByTagName('li');
	// Loop all languages contained in the languages holder EXCEPT the FIRST one!
	for (i = 1; i < ListElements.length; i++)
	{
			ListElements[i].style.backgroundImage = "URL('" + skinPath + "separator_vertical.gif')";
			ListElements[i].style.backgroundRepeat = "repeat-x";
	}
}
// Set the navigation separators for the content pages
function SetNavSeparator(p_iNavId)
{
	var oNav = document.getElementById('Nav' + p_iNavId);
	var ListElements = oNav.getElementsByTagName('li');
	// Loop all languages contained in the languages holder EXCEPT the LAST one!
	for (i = 0; i < ListElements.length - 1; i++)
	{
			ListElements[i].style.backgroundImage = "URL('" + skinPath + "separator_nav" + p_iNavId + ".gif')";
			ListElements[i].style.backgroundPosition = "right bottom";
			ListElements[i].style.backgroundRepeat = "no-repeat";
	}
	// Add a narrow icon at the end of the last top menu element
	if (p_iNavId == 1)
	{
		ListElements[ListElements.length - 1].style.className = "NavArrow";
	}
}

// <link> tag must have a title attribute the same as the name the parameter is passed to the function to disable other <link> tags that does not match the corresponding title
function SetActiveStyleSheet(p_sTitle, p_bReset)
{
	var i, a, main;
	// Loop through all <link> tags
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
	{
		// If the tag 'rel' attribute contains 'style' as value AND the tag has a 'title' attribute
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
		{
			// Disable the link tag
			a.disabled = true;
			// Unless it the one we one to be active
			if(a.getAttribute("title") == p_sTitle)
			{
				a.disabled = false;
			}
		}
	}
	// If we want to remove the user's preference for the text size to use
	if (p_bReset == 1)
	{
		CreateCookie("DGTextStyle", p_sTitle, 365);
	}
}

// Set the style based on the user's cookie
function SetStyle()
{
	var sStyle = ReadCookie("DGTextStyle");
	if (sStyle != null)
	{
		SetActiveStyleSheet(sStyle, 0);
		SetActiveStyleSheetImage(sStyle);
	}
	else
	{
		oImg = document.getElementById('text_small');
		oImg.src = "" + skinPath + "text_small_on.gif";
	}
}

// Swaps an image source to another
function SwapImage(p_sImgId, p_sImgSrc)
{
	var oImg = document.getElementById(p_sImgId);
	oImg.src = p_sImgSrc;
}

function SetActiveStyleSheetImage(p_sImgId)
{
	var oImg = null;
	var aTextSizes = Array("text_small", "text_medium", "text_large");
	for (i = 0; i < aTextSizes.length; i++)
	{
		oImg = document.getElementById(aTextSizes[i]);
		oImg.src = skinPath + aTextSizes[i] + "_off.gif";
	}
	p_sImgId = "text_" + p_sImgId; 
	oImg = document.getElementById(p_sImgId);
	oImg.src = skinPath + p_sImgId + "_on.gif";
}

// Cookie functions: start
// Creates a cookie
function CreateCookie(p_sName, p_sValue, p_iDays)
{
	if (p_iDays)
	{
		var date = new Date();
		date.setTime(date.getTime()+(p_iDays*24*60*60*1000));
		var expires = ";expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = p_sName+"="+p_sValue+expires+";path=/;";
}
// Read a cookie
function ReadCookie(p_sName)
{
	var nameEQ = p_sName + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
// Cookie functions: end
