function SNIP_MouseEvents(elemId)
{
	var snippets = document.getElementsByName("SnippetLinkHover");
	for(i = 0; i < snippets.length; i++)
	{
	    addEvent(snippets[i], "mouseover", function()
	    {
	        var tags;

	        if (elemId == "PriceOfferPrice" || elemId == "PolaroidHeader")
	            tags = this.parentNode.parentNode.getElementsByTagName("p");
	        else if (elemId == "TeaserHeader" || elemId == "PicturePrice")
	            tags = this.parentNode.parentNode.parentNode.getElementsByTagName("p");

	        for (i = 0; i < tags.length; i++)
	        {
	            if (tags[i].id == "PriceOfferPrice"
				    || tags[i].id == "PolaroidHeader"
				    || tags[i].id == "TeaserHeader"
				    || tags[i].id == "PicturePrice")
				{
	                tags[i].style.color = "#ff3300";
	            }
	        }
	    });

	    addEvent(snippets[i], "mouseout", function()
		{
		    var tags;

		    if (elemId == "PriceOfferPrice" || elemId == "PolaroidHeader")
		        tags = this.parentNode.parentNode.getElementsByTagName("p");
		    else if (elemId == "TeaserHeader" || elemId == "PicturePrice")
		        tags = this.parentNode.parentNode.parentNode.getElementsByTagName("p");

		    for (i = 0; i < tags.length; i++)
		    {
		        if (tags[i].id == "PriceOfferPrice"
				    || tags[i].id == "PolaroidHeader"
				    || tags[i].id == "TeaserHeader"
				    || tags[i].id == "PicturePrice")
				{
		            tags[i].style.color = "#000099";
		        }
		    }
		});
	}
}
	
function GetTableElem(elem)
{
	if(elem.tagName != null && elem.tagName != "TABLE")
		return GetTableElem(elem.parentNode);
	else
		return elem;
}

function swapInfoImage(strSourceID, showRollOver,ImageFalse,ImageTrue)
{
    var iconImageFalse=ImageFalse;
    var iconImageTrue=ImageTrue;
    var objImg = document.getElementById(strSourceID);
    if (objImg != null)
    {
        var tmpStr =iconImageFalse;
        if (showRollOver) tmpStr =iconImageTrue;
        if (tmpStr != '') objImg.src = tmpStr;
    }
}
	
function SNIP_BookButtonEvents()
{
	var snippets = document.getElementsByName("snipBtnLink");

	for(i = 0; i < snippets.length; i++)
	{
		var table = GetTableElem(snippets[i]);

		addEvent(table,"mouseover", function() { this.className = "C_hover" });
		addEvent(table,"mouseout", function() { this.className = "C_normal" });
	}
}

function tabSwitch(tabIndex)
{
	var tabContainer = document.getElementById("tabContainer");
	var tabStrip = tabContainer.getElementsByTagName("li");
	for(var i = 0; i < tabStrip.length; i++)
	{
		var type = '';
		if(i < tabIndex)
		{
			if(i == 0) type = "first";
			else type = "left";
		}
		else if(i > tabIndex)
		{
			if(i == tabStrip.length - 1) type = "last";
			else type = "right";
		}
		else
		{
			if(i == 0) type = "activeFirst";
			else if(i == tabStrip.length - 1) type = "activeLast";
			else type = "active";
		}

		tabStrip[i].className = type;
		var container = document.getElementById("tabContainer" + i);
		container.style.display = (i == tabIndex) ? "block" : "none";
	}
}

function buttonSwitch(buttonID, evt)
{
    if (evt == "mouseover")
	{
		document.getElementById(buttonID).firstChild.className = "C_hover";
    }
    else if (evt == "mouseout")
	{
		document.getElementById(buttonID).firstChild.className = "C_normal";
	}
}

function cssSwitch(id, newClass, eEvent)
{
	obj = document.getElementById(id)
	if (eEvent == "mouseover")
	{
		obj.className = newClass;
    }
    else if (eEvent == "mouseout")
	{
		obj.className = newClass;
	}
}

function fixLinkFocus()
{
   if (document.all) 
   {
       for (var a in document.links)
      {
           document.links[a].onfocus = document.links[a].blur;
      }
   }
}

function openPopupNoBars(url,id,height,width)
{
    var WindowObjectReference;
    if (url.length > 0)
    {
	    WindowObjectReference = window.open(url, id,'height='+height+',width='+width+',menubar=no,location=no,resizable=yes,scrollbars=no,status=no');
    }
}

function addEvent( obj, type, fn ) 
{
    if (obj.attachEvent)
	{ 
		obj['e'+type+fn] = fn; 
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
		obj.attachEvent( 'on'+type, obj[type+fn] );
    }
    else
	{
		obj.addEventListener( type, fn, false ); 
	}
}

function openHelpPopup(url)
{
	var WindowObjectReference;
	if (url.length > 0)
	{
	    WindowObjectReference = window.open(url, 'help','height=900,width=750,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no');
	}
}

var keyStr = "ABCDEFGHIJKLMNOP" +
            "QRSTUVWXYZabcdef" +
            "ghijklmnopqrstuv" +
            "wxyz0123456789+/" +
            "=";
  
function encode64(input) 
{
	input = escape(input);
    var output = "";
	if(input != "")
	{
		var chr1, chr2, chr3 = "";
		var enc1, enc2, enc3, enc4 = "";
		var i = 0;
		do 
		{
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
  
			if (isNaN(chr2)) 
			{
				enc3 = enc4 = 64;
			} 
			else if (isNaN(chr3)) 
			{
				enc4 = 64;
			}
  
			output = output +
				keyStr.charAt(enc1) +
				keyStr.charAt(enc2) +
				keyStr.charAt(enc3) +
				keyStr.charAt(enc4);
			chr1 = chr2 = chr3 = "";
			enc1 = enc2 = enc3 = enc4 = "";
        }
		while (i < input.length);
	}
    return output;
}  
  
