


//Tab navigation part:
var globalCurrentTabContentContainerIdForError = "";
function showTabContainer(tabContentContainerStart, tabId, defaultTabId, usedDefaultTabId, maxTabId, doNotSendOmnitureRequest)
{
	//does not work here since tabId is int: tabId = tabId.match(/^\d+/);
	//alert("tabId: " + tabId);
	//var tabContentContainerStart = "tabContentContainer_";
	var tabContentContainerId = tabContentContainerStart + tabId;
	
	var tabContentContainerInitialCheck = document.getElementById(tabContentContainerId);
	if (!tabContentContainerInitialCheck) 
	{
		if(globalCurrentTabContentContainerIdForError == tabContentContainerId)
		{
			//Error message has already been shown. 
		}
		else
		{
			alert("Error: No " + tabContentContainerId + " element.");
			globalCurrentTabContentContainerIdForError = tabContentContainerId;
		}
		return;
	}
	else
	{
		if("block" == tabContentContainerInitialCheck.style.display)
		{
			//alert("The current tab (" + tabContentContainerId + ") is already active.");
			return;
		}
	}
	
	
	var tabNavEntryStart = "tabNavEntry_";
	var tabContentContainerIdCountDone = 0;
	
	var urlTabId = "";
	//alert("showTabContainer() - tabId: " + tabId + "; usedDefaultTabId: "+usedDefaultTabId+"; defaultTabId: " + defaultTabId);
	if(0==usedDefaultTabId || defaultTabId!=tabId)
	{
		urlTabId="tabId="+tabId;
		location.hash = "#" + escape(urlTabId);
	}
	else
	{
		if (window.ActiveXObject) 
		{
			var ieVersion = getInternetExplorerVersion();
			//alert("ieVersion: " + ieVersion);
			if(8>ieVersion)
			{
				location.hash="";
				//alert("Cleared location.hash: "+location.hash);
			}
		}
	}
	
	for (var tabIdCounter = 0; 0 == tabContentContainerIdCountDone; tabIdCounter++)
	{
		
		var tabContentContainerIdHelper = tabContentContainerStart + tabIdCounter;
		
		var tabContentContainer = document.getElementById(tabContentContainerIdHelper);
		if (!tabContentContainer) 
		{
			//alert("Error: no " + tabContentContainerIdHelper + " element.");
			if(tabIdCounter > maxTabId)
			{
				tabContentContainerIdCountDone = 1;
			}
			continue;
		}
		else if(tabContentContainerIdHelper == tabContentContainerId)
		{
			tabContentContainer.style.display = "block";
		}
		else
		{
			tabContentContainer.style.display = "none";
		}
		
		var tabTabNavEntryIdHelperActive = tabNavEntryStart + tabIdCounter + "_active";
		var tabTabNavEntryActive = document.getElementById(tabTabNavEntryIdHelperActive);
		if (!tabTabNavEntryActive) 
		{
			//alert("No " + tabTabNavEntryIdHelperActive + " element.");
			if(tabIdCounter > maxTabId)
			{
				tabContentContainerIdCountDone = 1;
			}
			continue;
		}
		else if(tabContentContainerIdHelper == tabContentContainerId)
		{
			tabTabNavEntryActive.style.display = "block";
		}
		else
		{
			tabTabNavEntryActive.style.display = "none";
		}
		
		var tabTabNavEntryIdHelper = tabNavEntryStart + tabIdCounter;
		
		var tabTabNavEntry = document.getElementById(tabTabNavEntryIdHelper);
		if (!tabTabNavEntry) 
		{
			//alert("No " + tabTabNavEntryIdHelper + " element.");
			if(tabIdCounter > maxTabId)
			{
				tabContentContainerIdCountDone = 1;
			}
			continue;
		}
		else if(tabContentContainerIdHelper == tabContentContainerId)
		{
			tabTabNavEntry.style.display = "none";
		}
		else
		{
			tabTabNavEntry.style.display = "block";
		}
	}
	
	
	if(2 > doNotSendOmnitureRequest)
	{
		showTabContainerOmniture(tabId, doNotSendOmnitureRequest);
	}
	
	if (window.ActiveXObject) 
	{
		var ieVersion = getInternetExplorerVersion();
		//alert("ieVersion: " + ieVersion);
		if(8>ieVersion)
		{
			//IE history tab navigation via iframe: 
			//alert("showTabContainer() - ie - tabId: " + tabId + "; usedDefaultTabId: "+usedDefaultTabId+"; defaultTabId: " + defaultTabId);
			if(0==usedDefaultTabId || defaultTabId!=tabId)
			{
				window.frames["tab_nav_iframe"].window.location.search = "?" + escape(urlTabId);
			}
			else
			{
				//the iframe itself triggers the changes for ie < 8 and this condition
				//(else of if(0==usedDefaultTabId || defaultTabId!=tabId)) 
				//If window.frames["tab_nav_iframe"].window.location.search = ""; is called, 
				//a user has to push the back button two times in IE6
				//to leave the default page (without tabId in the url) after having navigated in 
				//the tabs of the page.
				//window.frames["tab_nav_iframe"].window.location.search = "";
			}
		}
		
	}	
	
	return false; 
}



function showTabContainerOmniture(tabId, doNotSendOmnitureRequest)
{
	//does not work here since tabId is int: tabId = tabId.match(/^\d+/);
	var currentTabHeaderId = "tabNavEntry_" + tabId + "_1_text_active";
	var currentTabHeader = document.getElementById(currentTabHeaderId);
	if (!currentTabHeader) 
	{
		alert("Error: showTabContainerOmniture: currentTabHeader("+currentTabHeaderId+") does not exist.");
		return;
	}
	
	var currentTabHeaderText = currentTabHeader.firstChild.nodeValue;
	if (!currentTabHeaderText) 
	{
		alert("Error: showTabContainerOmniture: currentTabHeaderText does not exist.");
		currentTabHeaderText = "";
		return;
	}
	
	var smSendOmnitureRequest = 0;
	currentTabHeaderText = currentTabHeaderText.replace (/^\s+/, "").replace (/\s+$/, "");
	
	currentTabHeaderText=removeHtmlTags(currentTabHeaderText);
	
	//alert("showTabContainerOmniture: currentTabHeaderText: " + currentTabHeaderText);
	
	// Page URL: 
	if (s.prop12) 
	{
		// Get the page URL as it is in the browser: 
		s.prop12 = window.location.href;
		smSendOmnitureRequest = 1;
	}
	
	//short URL (included pageId)
	if(s.prop9)
	{
		//alert("showTabContainerOmniture: s.prop9 before: " + s.prop9);
		//s.prop9  = "PSOptionProductDisplayView?pr=146189&pa=100001&ta=0";
		var s_prop9_part1 = "";
		var s_prop9_part2 = "";
		var taString = "&ta=";
		var taStartPosition = s.prop9.indexOf(taString);
		if(0<taStartPosition)
		{
			s_prop9_part1 = s.prop9.substring(0, taStartPosition);
			var taEndPosition = s.prop9.indexOf(";", taStartPosition);
			if(0<taEndPosition)
			{
				s_prop9_part2 = s.prop9.substring(taEndPosition);
			}
			s.prop9 = s_prop9_part1 + taString + tabId + s_prop9_part2;
		}
		else
		{
			s.prop9 = s.prop9 + taString + tabId;
		}
		//alert("showTabContainerOmniture: s.prop9: " + s.prop9);
		smSendOmnitureRequest = 1;
	}
	
	// Page Title for omniture (100 chars length): 
	if (s.prop3) 
	{
		//s.prop3 = "Tim Whole Body Suite (08857752)";
		var s_prop3Helper = smOriginalOmniturePageTitle + " " + currentTabHeaderText;
		if(100 < s_prop3Helper.length)
		{
			s_prop3Helper = s_prop3Helper.substring(0, 100);
		}
		s.prop3 = s_prop3Helper;
		//alert("showTabContainerOmniture: s.prop3: " + s.prop3);
	}
	
	//alert("showTabContainerOmniture: smOriginalOmniturePageTitle: " + smOriginalOmniturePageTitle);
	
	// Omniture page name
	if (s.pageName) 
	{
		//s.pageName = "|Tim Whole Body Suite (08857752)|US|BU_MR|001|PSOptionProductDisplayView?pr=146189&pa=100001&ta=0";
		
		var sPageNamePart2Start = s.pageName.indexOf("|");
		if(0 <= sPageNamePart2Start)
		{
			sPageNamePart2Start = s.pageName.indexOf("|", 1 + sPageNamePart2Start);
		}
		if(0 <= sPageNamePart2Start)
		{
			var sPageNamePart3Start = s.pageName.lastIndexOf("|");
			if(sPageNamePart2Start < sPageNamePart3Start)
			{
				var sPageNamePart1 = "";
				var sPageNamePart2 = "";
				var sPageNamePart3 = "";
				sPageNamePart2 = s.pageName.substring(sPageNamePart2Start, sPageNamePart3Start) + "|";
				sPageNamePart1 = "|" + s.prop3;
				sPageNamePart3 = s.prop9;
				
				var pageNameLength = sPageNamePart1.length + sPageNamePart2.length + sPageNamePart3.length;
				var maxOmniturePageNameLength = 99;
				if(maxOmniturePageNameLength < pageNameLength)
				{
					if( sPageNamePart1.length > (pageNameLength - maxOmniturePageNameLength) )
					{
						sPageNamePart1 = sPageNamePart1.substring(0, (sPageNamePart1.length - (pageNameLength - maxOmniturePageNameLength)) );
						s.pageName = sPageNamePart1 + sPageNamePart2 + sPageNamePart3;
						
						smSendOmnitureRequest = 1;
						//alert("showTabContainerOmniture: s.pageName=" + s.pageName);
					}
					else
					{
						alert("Error: pageNameLength is too long.");
					}
				}
				else
				{
					s.pageName = sPageNamePart1 + sPageNamePart2 + sPageNamePart3;
				}
			}
		}
		
		s.eVar13 = s.pageName; 
		
	} //of: if (s.pageName) 
	//alert("showTabContainerOmniture(): smSendOmnitureRequest: " + smSendOmnitureRequest + "; doNotSendOmnitureRequest: " + doNotSendOmnitureRequest);
	if(0 != smSendOmnitureRequest && 0 == doNotSendOmnitureRequest)
	{
		//alert("showTabContainerOmniture(): Sending the omniture request. s.pageName: " + s.pageName);
		s_code=s.t();
		//alert("s_code: " + s_code);
		//if(s_code)document.write(s_code);
		//if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-');
	}
	
}



function initialTabContainerOmniture(urlParameterTabId)
{
	//Do not send the omniture request, because the footer will do it during the 
	//full initial load of the page: 
	var doNotSendOmnitureRequest = 1;
	
	var tabId = "";
	if (1 < location.hash.length) 
	{
		var urlHashValue = unescape(location.hash.substring(1));
		//alert("initialTabContainerOmniture(): urlHashValue: " + urlHashValue );
		var tabIdString = "tabId=";
		var tabIdStartPosition = urlHashValue.indexOf(tabIdString);
		if(0<=tabIdStartPosition)
		{
			var tabIdEndPosition = urlHashValue.indexOf(";", tabIdStartPosition);
			if(0<tabIdEndPosition)
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length), tabIdEndPosition);
			}
			else
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length) );
			}
			tabId = tabId.match(/^\d+/);
		}
		else
		{
			//no tabId in the url's hash, therefore use the urlParameterTabId
			tabId = urlParameterTabId;
		}
	}
	else
	{
		//no tabId in the url's hash, therefore use the urlParameterTabId
		tabId = urlParameterTabId;
	}
	if(0 < (""+tabId).length)
	{
		//alert("initialTabContainerOmniture(): urlHashValue: " + urlHashValue + "; " + "tabId: " + tabId);
		showTabContainerOmniture(tabId, doNotSendOmnitureRequest);
	}
}



function smTabCheck(tabContentContainerStart, urlParameterTabId, defaultTabId, usedDefaultTabId, maxTabId, doNotSendOmnitureRequest)
{
	var tabId = "";
	if (1 < location.hash.length) 
	{
		var urlHashValue = unescape(location.hash.substring(1));
		//alert("smTabCheck(): urlHashValue: " + urlHashValue );
		var tabIdString = "tabId=";
		var tabIdStartPosition = urlHashValue.indexOf(tabIdString);
		if(0<=tabIdStartPosition)
		{
			var tabIdEndPosition = urlHashValue.indexOf(";", tabIdStartPosition);
			if(0<tabIdEndPosition)
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length), tabIdEndPosition);
			}
			else
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length) );
			}
			tabId = tabId.match(/^\d+/);
		}
		else
		{
			//no tabId in the url's hash
		}
	}
	else
	{
		//no tabId in the url's hash
	}
	//alert("smTabCheck(): tabId: " + tabId + "; urlParameterTabId: " + urlParameterTabId);
	if(0 >= (""+tabId).length)
	{
		//No tabId is in the url's hash (no #tabId=...):
		if(0 < (""+urlParameterTabId).length)
		{
			//Take the tabId from the url parameter: 
			tabId=urlParameterTabId
		}
		else
		{
			//Since there is also no tabId in the url parameter, take the default tabId: 
			tabId=defaultTabId
		}
	}
	//alert("smTabCheck(): usedDefaultTabId: " + usedDefaultTabId);
	if(0 < (""+tabId).length)
	{
		showTabContainer(tabContentContainerStart, tabId, defaultTabId, usedDefaultTabId, maxTabId, doNotSendOmnitureRequest);	
	}
	
}



function removeHtmlTags(pageTitle)
{
	var customHtmlPattern = "<";
	var customHtmlEndePattern = ">";
	var pageTitleLength = pageTitle.length;
	var customHtmlPatternLength = customHtmlPattern.length;
	var customHtmlPatternStartPosition = pageTitle.indexOf(customHtmlPattern);
	if( (-1 < customHtmlPatternStartPosition) && ( (customHtmlPatternStartPosition+customHtmlPatternLength) < pageTitleLength) )
	{
		//The page title contains the customHtmlPattern which has to be filtered out: 
		
		var customPageTitle="";
		var customPageTitleOutput = false;
		
		//Get the page title without any <tags>: 
		
		if(0<customHtmlPatternStartPosition)
		{
			//Get the text before the <tag>:
			customPageTitle = pageTitle.substring(0, customHtmlPatternStartPosition);
		}
		for(var myHtmlPatternCounter=customHtmlPatternStartPosition; myHtmlPatternCounter<pageTitleLength; myHtmlPatternCounter++)
		{
			var customPageTitleCharacter = pageTitle.substring(myHtmlPatternCounter, (myHtmlPatternCounter+1));
			if(true == customPageTitleOutput)
			{
				//This character is part of the real link name and 
				//not of a tag:
				if(customPageTitleCharacter == customHtmlPattern)
				{
					//A new tag starts:
					customPageTitleOutput=false;
				}
				else
				{
					//Just a normal character:
					customPageTitle += customPageTitleCharacter;
				}
			}
			else
			{
				//This character is part of a tag:
				if(customPageTitleCharacter == customHtmlEndePattern)
				{
					//The current tag ends: 
					customPageTitleOutput=true;
				}
			}
		} //of: for(int myHtmlPatternCounter=customHtmlPatternStartPosition; myHtmlPatternCounter<pageTitleLength; myHtmlPatternCounter++)
		
		pageTitle=customPageTitle;
	}
	return pageTitle;
}



function addShareHashTabId(tabNavEntryShare1TextLinkId)
{
	var tabId = "";
	if (1 < location.hash.length) 
	{
		var urlHashValue = unescape(location.hash.substring(1));
		//alert("addShareHashTabId(): urlHashValue: " + urlHashValue );
		var tabIdString = "tabId=";
		var tabIdStartPosition = urlHashValue.indexOf(tabIdString);
		if(0<=tabIdStartPosition)
		{
			var tabIdEndPosition = urlHashValue.indexOf(";", tabIdStartPosition);
			if(0<tabIdEndPosition)
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length), tabIdEndPosition);
			}
			else
			{
				tabId = urlHashValue.substring( (tabIdStartPosition + tabIdString.length) );
			}
			tabId = tabId.match(/^\d+/);
		}
		else
		{
			//no tabId in the url's hash
		}
	}
	else
	{
		//no tabId in the url's hash
	}
	if(0 < (""+tabId).length)
	{
		tabNavEntryShare1TextLinkId = "tabNavEntry_share_1_text_link";
		var tabNavEntry_share_1_text_link = document.getElementById(tabNavEntryShare1TextLinkId);
		if (!tabNavEntry_share_1_text_link) 
		{
			alert("Error (in addShareHashTabId()): no " + tabNavEntry_share_1_text_link + " element.");
			return;
		}
		else
		{
			var mailtoLinkHelper = tabNavEntry_share_1_text_link.href;
			//IE6 automatically unescapes the string, therefore we have to unescape it for all 
			//browser and escape and prepare it again after adding the tabId: 
			mailtoLinkHelper = unescape(mailtoLinkHelper);
			var mailtoLinkHelperPosition = mailtoLinkHelper.indexOf("mailto", mailtoLinkHelperPosition);
			if(0 <= mailtoLinkHelperPosition)
			{
				mailtoLinkHelperPosition = mailtoLinkHelper.indexOf("&storeId=", mailtoLinkHelperPosition);
				if(0 <= mailtoLinkHelperPosition)
				{
					mailtoLinkHelperPosition = mailtoLinkHelper.indexOf(" ", mailtoLinkHelperPosition);
					if(0 <= mailtoLinkHelperPosition )
					{
						var mailtoLinkHelper2 = mailtoLinkHelper.substring(0, mailtoLinkHelperPosition);
						
						var mailtoLinkHelper2Position = mailtoLinkHelper2.indexOf("#");
						if(0 < mailtoLinkHelper2Position)
						{
							mailtoLinkHelper2 = mailtoLinkHelper2.substring(0, mailtoLinkHelper2Position);
						}
						mailtoLinkHelper2 += "#tabId=" + tabId;
						if(mailtoLinkHelperPosition < mailtoLinkHelper.length)
						{	
							mailtoLinkHelper2 += mailtoLinkHelper.substring(mailtoLinkHelperPosition);
						}
						
						mailtoLinkHelper2 = escape(mailtoLinkHelper2);
						
						if(0 <= mailtoLinkHelper2.indexOf("mailto%3A%3Fsubject%3D"))
						{
							mailtoLinkHelper2=mailtoLinkHelper2.replace(/mailto%3A%3Fsubject%3D/, "mailto:?subject=");
							if(0 <= mailtoLinkHelper2.indexOf("%26body%3D"))
							{
								mailtoLinkHelper2=mailtoLinkHelper2.replace(/%26body%3D/g, "&body=");
								//alert("#tabId added: " + mailtoLinkHelper2);
								
								//The string has been modified, escaped again and prepared for the mailto link again. 
								//We can set it back now: 
								tabNavEntry_share_1_text_link.href = mailtoLinkHelper2;
							}
						}
					}
				}
			}
		}
	}
	else
	{
		//no tabId in the url's hash
	}
	//return true;
}



//Function to retrieve the internet explorer revision version (from msdn): 
//http://msdn.microsoft.com/en-us/library/cc817582.aspx
//Returns the version of Windows Internet Explorer or a -1
//(indicating the use of another browser).
function getInternetExplorerVersion()
{
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		{
			rv = parseFloat(RegExp.$1);
		}
	}
	return rv;
}





//E34 ImageGallery part:



function startSliding(imageGalleryThumbnailsId, imageGalleryThumbnailsSliderId, newSlidingDirection)
{
	//alert("Debug: startSliding");
	currentlySliding = 1;
	slidingDirection = newSlidingDirection
	
	
	imageGalleryThumbnails = document.getElementById(imageGalleryThumbnailsId);
	if (!imageGalleryThumbnails) 
	{
		alert("Error: imageGalleryThumbnailsId("+imageGalleryThumbnailsId+") does not exist.");
		return false;
	}
	//only works with inline css: alert("Debug: imageGalleryThumbnails.style.width: " +imageGalleryThumbnails.style.width);
	//alert("Debug: imageGalleryThumbnails.offsetWidth: " +imageGalleryThumbnails.offsetWidth);
	imageGalleryThumbnailsSlider = document.getElementById(imageGalleryThumbnailsSliderId);
	if (!imageGalleryThumbnailsSlider) 
	{
		alert("Error: imageGalleryThumbnailsSliderId("+imageGalleryThumbnailsSliderId+") does not exist.");
		return false;
	}
	//alert("Debug: imageGalleryThumbnailsSlider.offsetWidth: " +imageGalleryThumbnailsSlider.offsetWidth);
	if(imageGalleryThumbnails.offsetWidth < imageGalleryThumbnailsSlider.offsetWidth)
	{
		//alert("Debug: sliding possible");
	}
	
//alert(	imageGalleryThumbnailsSlider.childNodes[0].id );
//alert(	imageGalleryThumbnailsSlider.childNodes.length );
//childNodes.length 
				//CSS:
//				thumbnailImage.style.opacity = "1.0";
				//IE:
//				thumbnailImage.style.filter = "alpha(opacity=100)";


	slidingTimer=window.setInterval("slidingCallback(imageGalleryThumbnails, imageGalleryThumbnailsSlider, slidingDirection)", slideTimerInterval);
}

function slidingCallback(imageGalleryThumbnails, imageGalleryThumbnailsSlider, slidingDirection)
{
	if(0 == currentlySliding)
	{
		window.clearInterval(slidingTimer);
	}
	//alert("Debug: slidingCallback");
	else if("right"==slidingDirection)
	{
		//window.clearInterval(slidingTimer);
		//alert("go");
		if(imageGalleryThumbnailsSlider.offsetWidth+parseInt(imageGalleryThumbnailsSlider.style.left)-slideSpeed >= imageGalleryThumbnails.offsetWidth)
		{
			imageGalleryThumbnailsSlider.style.left=parseInt(imageGalleryThumbnailsSlider.style.left)-slideSpeed+"px";
			
			//check if the active thumbnail leaves the viewable area: 
			var activeThumbnailImage = document.getElementById(activeThumbnailImageId);
			if (!activeThumbnailImage) 
			{
				alert("Error: thumbnailImage("+activeThumbnailImageId+") does not exist.");
				//return false;
			}
			//alert("Debug: activeThumbnailImage.offsetLeft: " + activeThumbnailImage.offsetLeft);
			//alert("Debug: imageGalleryThumbnailsSlider.offsetLeft: " + imageGalleryThumbnailsSlider.offsetLeft);
			//alert("Debug: imageGalleryThumbnails.offsetWidth: " + imageGalleryThumbnails.offsetWidth);
			if(0 > parseInt(activeThumbnailImage.offsetLeft) + parseInt(imageGalleryThumbnailsSlider.offsetLeft))
			{
				//The activeThumbnailImage is at least partially out of the viewable area: 
				var activeThumbnailImagePositionHelper = activeThumbnailImageId.lastIndexOf("_");
				var activeThumbnailImageStart = activeThumbnailImageId.substring(0, activeThumbnailImagePositionHelper);
				var activeThumbnailImageNumber = parseInt(activeThumbnailImageId.substring(1+activeThumbnailImagePositionHelper));
				activeThumbnailImageNumber++;
				var newActiveThumbnailImage = activeThumbnailImageStart + "_" + activeThumbnailImageNumber;
				//alert("Debug: newActiveThumbnailImage: " + newActiveThumbnailImage);					
				setActiveThumbnailImage(newActiveThumbnailImage)
			}
			
			//enable left sliding button if it is disabled: 
			activateThumbnailsArrow("_imageGalleryThumbnailsContainerLeftArrow", "left");
			
			
		}
		else if(imageGalleryThumbnailsSlider.offsetWidth+parseInt(imageGalleryThumbnailsSlider.style.left) > imageGalleryThumbnails.offsetWidth)
		{
			imageGalleryThumbnailsSlider.style.left=parseInt(imageGalleryThumbnails.offsetWidth)-parseInt(imageGalleryThumbnailsSlider.offsetWidth)+"px";
			//end position reached 
			window.clearInterval(slidingTimer);
			deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerRightArrow");
			//alert("Debug: sliding done");
		}
		else
		{
			//end position reached
			window.clearInterval(slidingTimer);
			deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerRightArrow");
			//alert("Debug: sliding done");
		}
	}
	else if("left"==slidingDirection)
	{
		//window.clearInterval(slidingTimer);
		//alert("go");
		
		if(parseInt(imageGalleryThumbnailsSlider.style.left) + slideSpeed <= 0)
		{
			imageGalleryThumbnailsSlider.style.left=parseInt(imageGalleryThumbnailsSlider.style.left)+slideSpeed+"px";
			
			//check if the active thumbnail leaves the viewable area: 
			var activeThumbnailImage = document.getElementById(activeThumbnailImageId);
			if (!activeThumbnailImage) 
			{
				alert("Error: thumbnailImage("+activeThumbnailImageId+") does not exist.");
				//return false;
			}
			//alert("Debug: activeThumbnailImage.offsetLeft: " + activeThumbnailImage.offsetLeft);
			//alert("Debug: imageGalleryThumbnailsSlider.offsetLeft: " + imageGalleryThumbnailsSlider.offsetLeft);
			//alert("Debug: imageGalleryThumbnails.offsetWidth: " + imageGalleryThumbnails.offsetWidth);
			if(parseInt(imageGalleryThumbnails.offsetWidth) < imageGalleryThumbnailsSlider.offsetLeft + parseInt(activeThumbnailImage.offsetLeft) + parseInt(activeThumbnailImage.offsetWidth) )
			{
				//The activeThumbnailImage is at least partially out of the viewable area: 
				var activeThumbnailImagePositionHelper = activeThumbnailImageId.lastIndexOf("_");
				var activeThumbnailImageStart = activeThumbnailImageId.substring(0, activeThumbnailImagePositionHelper);
				var activeThumbnailImageNumber = parseInt(activeThumbnailImageId.substring(1+activeThumbnailImagePositionHelper));
				activeThumbnailImageNumber--;
				var newActiveThumbnailImage = activeThumbnailImageStart + "_" + activeThumbnailImageNumber;
				//alert("Debug: newActiveThumbnailImage: " + newActiveThumbnailImage);					
				setActiveThumbnailImage(newActiveThumbnailImage)
			}
			
			//enable right sliding button if it is disabled: 
			activateThumbnailsArrow("_imageGalleryThumbnailsContainerRightArrow", "right");
			
		}
		else if(parseInt(imageGalleryThumbnailsSlider.style.left) < 0)
		{
			imageGalleryThumbnailsSlider.style.left=0+"px";
			//end position reached 
			window.clearInterval(slidingTimer);
			deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerLeftArrow");
			//alert("Debug: sliding done");
		}
		else
		{
			//end position reached
			window.clearInterval(slidingTimer);
			deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerLeftArrow");
			//alert("Debug: sliding done");
		}

	}

}



function jumpSliding(imageGalleryThumbnailsId, imageGalleryThumbnailsSliderId, newSlidingDirection)
{
	//alert("Debug: jumpSliding");

	
	imageGalleryThumbnails = document.getElementById(imageGalleryThumbnailsId);
	if (!imageGalleryThumbnails) 
	{
		alert("Error: imageGalleryThumbnailsId("+imageGalleryThumbnailsId+") does not exist.");
		return false;
	}
	//only works with inline css: alert("Debug: imageGalleryThumbnails.style.width: " +imageGalleryThumbnails.style.width);
	//alert("Debug: imageGalleryThumbnails.offsetWidth: " +imageGalleryThumbnails.offsetWidth);
	imageGalleryThumbnailsSlider = document.getElementById(imageGalleryThumbnailsSliderId);
	if (!imageGalleryThumbnailsSlider) 
	{
		alert("Error: imageGalleryThumbnailsSliderId("+imageGalleryThumbnailsSliderId+") does not exist.");
		return false;
	}
	//alert("Debug: imageGalleryThumbnailsSlider.offsetWidth: " +imageGalleryThumbnailsSlider.offsetWidth);
	
	var imageGalleryThumbnailsSlidingSpace = imageGalleryThumbnailsSlider.offsetWidth - imageGalleryThumbnails.offsetWidth;
	if(0 < imageGalleryThumbnailsSlidingSpace)
	{
		//alert("Debug: sliding possible");
		//alert("Debug: imageGalleryThumbnailsSlider.offsetLeft :" + imageGalleryThumbnailsSlider.offsetLeft);
		
		var imageGalleryThumbnailsSliderOffsetLeft = imageGalleryThumbnailsSlider.offsetLeft;
		var currentJumpSlidingSteps = parseInt(imageGalleryThumbnailsSliderOffsetLeft / slidingStep);
		if(0 > currentJumpSlidingSteps)
		{
			currentJumpSlidingSteps = 0 - currentJumpSlidingSteps;
		}
		//alert("Debug: Initial currentJumpSlidingSteps: " + currentJumpSlidingSteps);
		
		if("right"==newSlidingDirection)
		{
			//var imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep = imageGalleryThumbnailsSliderOffsetLeft % slidingStep;
			//imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep = 0 - imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep;
			//if(0 < imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep)
			//{
			//	currentJumpslidingSteps--;
			//}
			currentJumpSlidingSteps = currentJumpSlidingSteps + jumpSlidingSteps;
			//alert("Debug: currentJumpSlidingSteps: " + currentJumpSlidingSteps);	
			
			var currentJumpSliding = currentJumpSlidingSteps * slidingStep;
			if(currentJumpSliding > imageGalleryThumbnailsSlidingSpace)
			{
				currentJumpSliding = imageGalleryThumbnailsSlidingSpace;
			}
			//alert("Debug: currentJumpSliding :" + currentJumpSliding );
			imageGalleryThumbnailsSlider.style.left="-"+currentJumpSliding+"px";
			if(currentJumpSliding == imageGalleryThumbnailsSlidingSpace)
			{
				//alert("Debug: End position reached.");
				window.clearInterval(slidingTimer);
				deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerRightArrow");
			}
			
			//check if the active thumbnail leaves the viewable area: 
			var activeThumbnailImage = document.getElementById(activeThumbnailImageId);
			if (!activeThumbnailImage) 
			{
				alert("Error: thumbnailImage("+activeThumbnailImageId+") does not exist.");
				//return false;
			}
			//alert("Debug: activeThumbnailImage.offsetLeft: " + activeThumbnailImage.offsetLeft);
			//alert("Debug: imageGalleryThumbnailsSlider.offsetLeft: " + imageGalleryThumbnailsSlider.offsetLeft);
			//alert("Debug: imageGalleryThumbnails.offsetWidth: " + imageGalleryThumbnails.offsetWidth);
			while( 0 > parseInt(activeThumbnailImage.offsetLeft) + parseInt(imageGalleryThumbnailsSlider.offsetLeft))
			{
				//The activeThumbnailImage is at least partially out of the viewable area: 
				var activeThumbnailImagePositionHelper = activeThumbnailImageId.lastIndexOf("_");
				var activeThumbnailImageStart = activeThumbnailImageId.substring(0, activeThumbnailImagePositionHelper);
				var activeThumbnailImageNumber = parseInt(activeThumbnailImageId.substring(1+activeThumbnailImagePositionHelper));
				activeThumbnailImageNumber++;
				var newActiveThumbnailImageId = activeThumbnailImageStart + "_" + activeThumbnailImageNumber;
				//alert("Debug: newActiveThumbnailImage: " + newActiveThumbnailImage);
				
				activeThumbnailImage = document.getElementById(newActiveThumbnailImageId);
				if (!newActiveThumbnailImageId) 
				{
					alert("Error: thumbnailImage("+newActiveThumbnailImageId+") does not exist.");
					break;
				}			
				setActiveThumbnailImage(newActiveThumbnailImageId);
			}
			
		}

		else if("left"==newSlidingDirection)
		{
			//var imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep = imageGalleryThumbnailsSliderOffsetLeft % slidingStep;
			//imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep = 0 - imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep;
			//if(0 < imageGalleryThumbnailsSliderOffsetLeftModuloSlidingStep)
			//{
			//	currentJumpslidingSteps--;
			//}
			currentJumpSlidingSteps = currentJumpSlidingSteps - jumpSlidingSteps;
			//alert("Debug: currentJumpSlidingSteps: " + currentJumpSlidingSteps);	
			var currentJumpSliding = currentJumpSlidingSteps * slidingStep;
			if(0 > currentJumpSliding)
			{
				currentJumpSliding = 0;
			}
			//alert("Debug: currentJumpSliding :" + currentJumpSliding );
			imageGalleryThumbnailsSlider.style.left="-"+currentJumpSliding+"px";
			if(0 == currentJumpSliding)
			{
				//alert("Debug: End position reached.");
				window.clearInterval(slidingTimer);
				deactivateThumbnailsArrow("_imageGalleryThumbnailsContainerLeftArrow");
			}
			
			//check if the active thumbnail leaves the viewable area: 
			var activeThumbnailImage = document.getElementById(activeThumbnailImageId);
			if (!activeThumbnailImage) 
			{
				alert("Error: thumbnailImage("+activeThumbnailImageId+") does not exist.");
				//return false;
			}
			//alert("Debug: activeThumbnailImage.offsetLeft: " + activeThumbnailImage.offsetLeft);
			//alert("Debug: imageGalleryThumbnailsSlider.offsetLeft: " + imageGalleryThumbnailsSlider.offsetLeft);
			//alert("Debug: imageGalleryThumbnails.offsetWidth: " + imageGalleryThumbnails.offsetWidth);
			while( imageGalleryThumbnails.offsetWidth < parseInt(activeThumbnailImage.offsetLeft) + parseInt(activeThumbnailImage.offsetWidth) + parseInt(imageGalleryThumbnailsSlider.offsetLeft))
			{
				//The activeThumbnailImage is at least partially out of the viewable area: 
				var activeThumbnailImagePositionHelper = activeThumbnailImageId.lastIndexOf("_");
				var activeThumbnailImageStart = activeThumbnailImageId.substring(0, activeThumbnailImagePositionHelper);
				var activeThumbnailImageNumber = parseInt(activeThumbnailImageId.substring(1+activeThumbnailImagePositionHelper));
				activeThumbnailImageNumber--;
				var newActiveThumbnailImageId = activeThumbnailImageStart + "_" + activeThumbnailImageNumber;
				//alert("Debug: newActiveThumbnailImage: " + newActiveThumbnailImage);
				
				activeThumbnailImage = document.getElementById(newActiveThumbnailImageId);
				if (!newActiveThumbnailImageId) 
				{
					alert("Error: thumbnailImage("+newActiveThumbnailImageId+") does not exist.");
					break;
				}			
				setActiveThumbnailImage(newActiveThumbnailImageId);
			}			
			
		}
		else
		{
			alert("Error: Unsupported newSlidingDirection: " + newSlidingDirection);
		}
		
	}
}



function setActiveThumbnailImage(thumbnailImageId)
{
	var thumbnailImage = document.getElementById(thumbnailImageId);
	if (!thumbnailImage) 
	{
		alert("Error: thumbnailImage("+thumbnailImageId+") does not exist.");
		return false;
	}
	//CSS:
	thumbnailImage.style.opacity = inactiveThumbnailImageStyleOpacity;
	//IE:
	thumbnailImage.style.filter = inactiveThumbnailImageStyleFilter;
	
	var thumbnailImagePositionHelper = thumbnailImageId.lastIndexOf("_");
	
	var thumbnailImageStart = thumbnailImageId.substring(0, thumbnailImagePositionHelper);
	var thumbnailImageNumber = thumbnailImageId.substring((1+thumbnailImagePositionHelper));
	
	//alert("Debug: thumbnailImageStart: " + thumbnailImageStart);
	//alert("Debug: thumbnailImageNumber: " + thumbnailImageNumber);
	
	thumbnailImagePositionHelper = thumbnailImageId.indexOf("_ImageGalleryThumbnailImage" + "_");
	
	var currentModuleId = thumbnailImageId.substring(0, thumbnailImagePositionHelper);
	//alert("Debug: currentModuleId: " + currentModuleId);
	
	var normalImageStart = currentModuleId + "_ImageGalleryNormalImage";
	
	//alert("Debug: normalImageStart: " + normalImageStart);
	
	var thumbnailImageCountDone = 0;
	//Iterate through the other thumbnails and set them to (in)active if necessary and
	//also iterate through the normal images and set them to display: block or display: none: 
	for (var thumbnailImageCounter = 0; 0 == thumbnailImageCountDone; thumbnailImageCounter++)
	{
		var thumbnailImage = document.getElementById(thumbnailImageStart + "_" + thumbnailImageCounter);
		if (!thumbnailImage) 
		{
			//alert("Debug: done: " + thumbnailImageStart + "_" + thumbnailImageCounter);
			thumbnailImageCountDone = 1;
			continue;
		}
		else
		{
			//alert("Debug: continue: " + thumbnailImageStart + "_" + thumbnailImageCounter);
			if(thumbnailImageCounter==thumbnailImageNumber)
			{
				//CSS:
				thumbnailImage.style.opacity = "1.0";
				//IE:
				thumbnailImage.style.filter = "alpha(opacity=100)";
				
				activeThumbnailImageId = thumbnailImageId;
				
			}
			else
			{
				if(! (inactiveThumbnailImageStyleOpacity == thumbnailImage.style.opacity))
				{
					//CSS:
					thumbnailImage.style.opacity = inactiveThumbnailImageStyleOpacity;
				}
				if(! (inactiveThumbnailImageStyleFilter == thumbnailImage.style.filter))
				{
					//CSS:
					thumbnailImage.style.filter = inactiveThumbnailImageStyleFilter;
				}
			}
		} //of: else of: if (!thumbnailImage) 
		
		var normalImage = document.getElementById(normalImageStart + "_" + thumbnailImageCounter);
		if (!normalImage) 
		{
			alert("Error: no normal image: " + normalImageStart + "_" + thumbnailImageCounter);
		}
		else
		{
			if(thumbnailImageCounter==thumbnailImageNumber)
			{
				normalImage.style.display = "block";
			}
			else
			{
				if(! ("none" == normalImage.style.display))
				{
					//CSS:
					normalImage.style.display = "none";
				}
			}
		} //of: else of: if (!normalImage) 
		
	} //of: for (var thumbnailImageCounter = 0; 0 == thumbnailImageCountDone; thumbnailImageCounter++)
	
	return true;
	
} //of: function setActiveThumbnailImage(thumbnailImageId)



function activateThumbnailsArrow(thumbnailsArrowId, newSlidingDirection)
{
	
	var thumbnailsArrow = document.getElementById(thumbnailsArrowId);
	if (!thumbnailsArrow) 
	{
		alert("Error: thumbnailsArrow("+thumbnailsArrowId+") does not exist.");
		return false;
	}
	//alert("Debug: thumbnailsArrow.onmouseover: " +thumbnailsArrow.onmouseover);
	if(!thumbnailsArrow.onmouseover || thumbnailsArrow.onmouseover == "")
	{	
		if("left"==newSlidingDirection)
		{
		
			thumbnailsArrow.onmouseover= function() { return startSliding("IK_imageGalleryThumbnailsInnerFrame", "IK_imageGalleryThumbnailsSlider", "left");};
			thumbnailsArrow.onmouseout= function() { return currentlySliding=0;}
			thumbnailsArrow.onclick= function() { return jumpSliding("IK_imageGalleryThumbnailsInnerFrame", "IK_imageGalleryThumbnailsSlider", "left");};
			thumbnailsArrow.className="IK_imageGalleryThumbnailsContainerLeftArrow";
		}
		else if("right"==newSlidingDirection)
		{
			thumbnailsArrow.onmouseover= function() { return startSliding("IK_imageGalleryThumbnailsInnerFrame", "IK_imageGalleryThumbnailsSlider", "right");};
			thumbnailsArrow.onmouseout= function() { return currentlySliding=0;}
			thumbnailsArrow.onclick= function() { return jumpSliding("IK_imageGalleryThumbnailsInnerFrame", "IK_imageGalleryThumbnailsSlider", "right");};
			thumbnailsArrow.className="IK_imageGalleryThumbnailsContainerRightArrow";
		}
		else
		{
			alert("Error: activateThumbnailsArrow: unsupported newSlidingDirection.");
		}
		//CSS:
		//thumbnailsArrow.style.opacity = "1.0";
		//IE:
		//thumbnailsArrow.style.filter = "alpha(opacity=100)";
	}	
}



function deactivateThumbnailsArrow(thumbnailsArrowId)
{
	
	var thumbnailsArrow = document.getElementById(thumbnailsArrowId);
	if (!thumbnailsArrow) 
	{
		alert("Error: thumbnailsArrow("+thumbnailsArrowId+") does not exist.");
		return false;
	}
	if(thumbnailsArrow.onmouseover || thumbnailsArrow.onmouseover != "")
	{	
		thumbnailsArrow.onmouseout="";
		thumbnailsArrow.onmouseover="";
		thumbnailsArrow.onclick="";
		if(0<thumbnailsArrowId.indexOf("RightArrow"))
		{
			thumbnailsArrow.className="IK_imageGalleryThumbnailsContainerRightArrowInactive";
		}
		else
		{
			thumbnailsArrow.className="IK_imageGalleryThumbnailsContainerLeftArrowInactive";
		}
		//CSS:
		//thumbnailsArrow.style.opacity = "0.3";
		//IE:
		//thumbnailsArrow.style.filter = "alpha(opacity=30)";
	}
}



function initializeThumbnailsArrows(thumbnailsLeftArrowId, thumbnailsRightArrowId, imageGalleryThumbnailsId, imageGalleryThumbnailsSliderId)
{
	
	var imageGalleryThumbnails = document.getElementById(imageGalleryThumbnailsId);
	if (!imageGalleryThumbnails) 
	{
		alert("Error: imageGalleryThumbnailsId("+imageGalleryThumbnailsId+") does not exist.");
		return false;
	}
	var imageGalleryThumbnailsSlider = document.getElementById(imageGalleryThumbnailsSliderId);
	if (!imageGalleryThumbnailsSlider) 
	{
		alert("Error: imageGalleryThumbnailsSliderId("+imageGalleryThumbnailsSliderId+") does not exist.");
		return false;
	}
	
	var thumbnailsLeftArrow = document.getElementById(thumbnailsLeftArrowId);
	if (!thumbnailsLeftArrow) 
	{
		alert("Error: thumbnailsArrow("+thumbnailsLeftArrowId+") does not exist.");
		return false;
	}
	
	var thumbnailsRightArrow = document.getElementById(thumbnailsRightArrowId);
	if (!thumbnailsRightArrow) 
	{
		alert("Error: thumbnailsArrow("+thumbnailsRightArrowId+") does not exist.");
		return false;
	}
	
	
	//alert("Debug: imageGalleryThumbnailsSlider.offsetWidth: " +imageGalleryThumbnailsSlider.offsetWidth);
	if(imageGalleryThumbnails.offsetWidth < imageGalleryThumbnailsSlider.offsetWidth)
	{
		if(0 > imageGalleryThumbnailsSlider.offsetLeft)
		{
			activateThumbnailsArrow(thumbnailsLeftArrowId, "left");
		}
		else
		{
			deactivateThumbnailsArrow(thumbnailsLeftArrowId);
		}
		if(imageGalleryThumbnails.offsetWidth - imageGalleryThumbnailsSlider.offsetLeft < imageGalleryThumbnailsSlider.offsetWidth )
		{
			activateThumbnailsArrow(thumbnailsRightArrowId, "right");
		}
		else
		{
			deactivateThumbnailsArrow(thumbnailsRightArrowId);
		}
	}
	else
	{
		deactivateThumbnailsArrow(thumbnailsLeftArrowId);
		deactivateThumbnailsArrow(thumbnailsRightArrowId);
	}
	
}

function loadBigImage(bigImageNumber, bigImageMaxNumber, width, imageGalleryText)
{
	var bigImageInc = jsBigImages[bigImageNumber];
	//alert(bigImageInc);
	// set layer to right size
	$('layer-content').setStyle({
		margin: '14px 0 0px 44px',
		width: width + 'px',
		overflow: 'visible'
	});
	
	$('layer-header').setStyle({
		paddingTop: '20px', 
		paddingBottom: '16px', 
		paddingLeft: '12px', 
		font: '18px Siemens Slab, Arial',
		color: '#333333'
	});
	//$('layer-header').innerHTML = imageGalleryText;
	//$('layer-header')..firstChild.nodeValue = imageGalleryText;
	$('layer-header').update(imageGalleryText);
	
	$('layer-body').setStyle({
		paddingLeft: '12px',
		paddingRight: '12px',
		paddingBottom: '12px'
	});
	
	//Activate embedded javascript again: 
	bigImageInc=bigImageInc.replace(/customscripttagreplacement/g, "script");
	
	//$('layer-body').innerHTML = "<div id='layer-body-swf'>" + bigImageInc + "</div>";
	//$('layer-body').firstChild.nodeValue = "<div id='layer-body-swf'>" + bigImageInc + "</div>";
	$('layer-body').update("<div id='layer-body-swf'>" + bigImageInc + "</div>");
	
	
	jQuery('#layer-zone').toggle();
	
	//swfobject.embedSWF(url, "layer-body", "640", "480", "9.0.0", null, null, null);
}

function changeBigImage(bigImageNumber)
{
	bigImageNumber = parseInt(bigImageNumber);
	var bigImageInc = jsBigImages[bigImageNumber];
	
	//Activate embedded javascript again: 
	bigImageInc=bigImageInc.replace(/customscripttagreplacement/g, "script");
	
	//$('layer-body').innerHTML = "<div id='layer-body-swf'>" + bigImageInc + "</div>";	
	$('layer-body').update("<div id='layer-body-swf'>" + bigImageInc + "</div>");
}









