var numImages = 0;
var numTitles = 0;
var numDivs = 0;
var screenWidth = 0;
var screenHeight = 0;
var centerX = 0;
var centerY = 0;
var lastMouseX = 0;
var lastMouseY = 0;
var mouseOffsetX = 20;
var mouseOffsetY = 20;
imgCache = new Array();
titleCache = new Array();
divCache = new Array();
if (document.getElementById)
{
   screenWidth = screen.availWidth;
   screenHeight = screen.availHeight;

   if (screenWidth > 1280)
   {
   	  screenWidth = 1280;
   }

   if (screenHeight > 1024)
   {
   	  screenHeight = 1024;
   }

   centerX = screenWidth/2;
   centerY = screenHeight/2;
}
function load_img(imgName, imgNormURL, imgHighURL)
{
   if (document.getElementById)
   {
      imgCache[numImages] = new Array(3);
      imgCache[numImages][0] = new Image();
      imgCache[numImages][0].src = imgNormURL
      imgCache[numImages][1] = new Image();
      imgCache[numImages][1].src = imgHighURL;
      imgCache[numImages][2] = imgName;
      numImages++;
   }
}
function load_title(imgName, imgNormURL)
{
   if (document.getElementById)
   {
      titleCache[numImages] = new Array(2);
      titleCache[numImages][0] = new Image();
      titleCache[numImages][0].src = imgNormURL
      titleCache[numImages][1] = imgName;
      numTitles++;
   }
}
function register_div(divName)
{
   if (document.getElementById)
   {
      divCache[numDivs] = divName;
      numDivs++;
   }
}
function set_nav(categoryName)
{
   imgName = 'cat_'+categoryName;
   if (document.getElementById(imgName))
   {
     if ((activeMainCategoryButton != '') && (activeMainCategoryButton != null))
     {
       low_img(activeMainCategoryButton);
     }
     activeMainCategoryName=categoryName;
     activeMainCategoryButton='cat_'+categoryName;
     high_img(activeMainCategoryButton);
     title_img(activeMainCategoryName);
   }
}
function high_nav(imgName, elementID)
{
   high_img(imgName, elementID);
}
function low_nav(imgName, elementID)
{
   if (activeMainCategoryButton != imgName)
   {
      low_img(imgName, elementID);
   }
}
function high_box(divID, divClass, imgName, elementID)
{
   change_class(divID, divClass);
   high_img(imgName, elementID);
}
function low_box(divID, divClass, imgName, elementID)
{
   change_class(divID, divClass);
   low_img(imgName, elementID);
}
function title_img(imgName, elementID)
{
   if (document.getElementById)
   {
      for (i=0; i<numTitles; i++)
      {
         if (titleCache[i][1] == imgName)
         {
            if (elementID)
            {
               if (document.getElementById(elementID))
               {
                  document.getElementById(elementID).src = titleCache[i][1].src;
               }
            }
            else
            {
               document.getElementById('cat_maintitle').src = titleCache[i][1].src;
            }
         }
      }
   }
}
function high_img(imgName, elementID)
{
   if (document.getElementById)
   {
      for (i=0; i<numImages; i++)
      {
         if (imgCache[i][2] == imgName)
         {
            if (elementID)
            {
               if (document.getElementById(elementID))
               {
                  document.getElementById(elementID).src = imgCache[i][1].src;
               }
            }
            else
            {
               document.getElementById(imgName).src = imgCache[i][1].src;
            }
         }
      }
   }
}
function low_img(imgName, elementID)
{
   if (document.getElementById)
   {
      for (i=0; i<numImages; i++)
      {
         if (imgCache[i][2] == imgName)
         {
            if (elementID)
            {
               if (document.getElementById(elementID))
               {
                  document.getElementById(elementID).src = imgCache[i][0].src;
               }
            }
            else
            {
               document.getElementById(imgName).src = imgCache[i][0].src;
            }
         }
      }
   }
}
function set_img(elementID, imgSrc, imgWidth, imgHeight)
{
   if (document.getElementById)
   {
      if (elementID)
      {
         if (document.getElementById(elementID))
         {
            document.getElementById(elementID).src = imgSrc;
            if ((imgWidth != null) && (imgWidth != ''))
            {
               document.getElementById(elementID).width = imgWidth;
            }
            if ((imgHeight != null) && (imgHeight != ''))
            {
               document.getElementById(elementID).height = imgHeight;
            }
         }
      }
   }
}

function change_class(elementID, className)
{
   if (document.getElementById && document.getElementById(elementID))
   {
      document.getElementById(elementID).className = className;
   }
}
function change_style(elementID, styleContent)
{
   if (document.getElementById && document.getElementById(elementID))
   {
      document.getElementById(elementID).style = styleContent;
   }
}
function change_height(elementID, newHeight)
{
   if (document.getElementById && document.getElementById(elementID))
   {
      document.getElementById(elementID).style.height = newHeight + 'px';
   }
}
function showElement(elementID, imageElement, imageSrc, shiftX, shiftY)
{
   if ((shiftX != null) && (shiftX != ""))
   {
     mouseOffsetX = shiftX;
   }
   else
   {
     mouseOffsetX = 20;
   }
   if ((shiftY != null) && (shiftY != ""))
   {
     mouseOffsetY = shiftY;
   }
   else
   {
     mouseOffsetY = 20;
   }
   if ((imageElement != null) && document.getElementById(imageElement))
   {
      document.getElementById(imageElement).src = imageSrc;
   }
   if (document.getElementById(elementID))
   {
      document.getElementById(elementID).style.visibility = 'visible';
   }
}
function hideElement(elementID, imageElement, imageSrc)
{
   if (document.getElementById(elementID))
   {
      document.getElementById(elementID).style.visibility = 'hidden';
   }
   if ((imageElement != null) && document.getElementById(imageElement))
   {
      document.getElementById(imageElement).src = imageSrc;
   }
}
function toggleElement(elementID, showHide, elementID2, showHide2)
{
   if (document.getElementById(elementID))
   {
   	  if (showHide == true)
   	  {
         document.getElementById(elementID).style.display = 'block';
      }
      else
      {
         document.getElementById(elementID).style.display = 'none';
      }
   }

   if ((elementID2 != "") && document.getElementById(elementID2))
   {
   	  if (showHide2 == true)
   	  {
         document.getElementById(elementID2).style.display = 'block';
      }
      else
      {
         document.getElementById(elementID2).style.display = 'none';
      }
   }
}
function onOffElement(elementID, displayMode, numElements)
{
   if (displayMode == '' || displayMode == null)
   {
      displayMode='';
   }
   
   if (numElements != null)
   {
   	  for (i=1; i<=numElements; i++)
   	  {
         if (document.getElementById(elementID + i))
         {
            if (document.getElementById(elementID + i).style.display == 'none')
    	    {
               document.getElementById(elementID + i).style.display = displayMode;
            }
            else
            {
               document.getElementById(elementID + i).style.display = 'none';
            }
         }
   	  }
   }
   else
   {
      if (document.getElementById(elementID))
      {
         if (document.getElementById(elementID).style.display == 'none')
    	 {
            document.getElementById(elementID).style.display = displayMode;
         }
         else
         {
            document.getElementById(elementID).style.display = 'none';
         }
      }
   }
}
function handleMouseMove(myEvent)
{
	x = document.all ? window.event.x : myEvent.pageX;
	y = document.all ? window.event.y : myEvent.pageY;
	if (document.all)
   {
      if ((typeof document.compatMode != 'undefined') && (document.compatMode != 'BackCompat'))
      {
         x += document.documentElement.scrollLeft;
         y += document.documentElement.scrollTop;
      }
      else
      {
         x += document.body.scrollLeft;
         y += document.body.scrollTop;
      }
   }
	for (i=0; i<numDivs; i++)
   {
      if (document.getElementById(divCache[i]) && (document.getElementById(divCache[i]).style.visibility == 'visible'))
      {
         divX = x + mouseOffsetX;
         divY = y + mouseOffsetY;
         document.getElementById(divCache[i]).style.left = divX + "px";
         document.getElementById(divCache[i]).style.top = divY + "px";
      }
   }
   lastMouseX = x;
   lastMouseY = y;
}

function emailAnfrage(scrambledMail)
{
	var mailParts = scrambledMail.split('@');
	var unscrambledMail='';
	for (i=mailParts[0].length-1; i>=0; i--)
	{
		unscrambledMail = unscrambledMail + mailParts[0].charAt(i);
	}
	unscrambledMail = unscrambledMail+'@';
	for (i=mailParts[1].length-1; i>=0; i--)
	{
		unscrambledMail = unscrambledMail + mailParts[1].charAt(i);
	}
	self.location.replace('mai'+'lto:'+unscrambledMail);
}

function openPopup(URL)
{
   if (document.images)
   {
	   popupWidth = 600;
	   popupHeight = 500;
	   popupCenterX = centerX - popupWidth/2;
	   popupCenterY = centerY - popupHeight/2;
	   popupWindow = window.open(URL, "Popupwindow", "width="+popupWidth+",height="+popupHeight+",left="+popupCenterX+",top="+popupCenterY+",location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");
   }
}
function openXXLPopup(URL, width, height)
{
   if (document.images)
   {
	   popupWidth = 685;
	   popupHeight = 530;
   	   if (width != null)
   	   {
	     popupWidth = width;
   	   }
   	   if (height != null)
   	   {
	     popupHeight = height;
   	   }
	   popupCenterX = centerX - popupWidth/2;
	   popupCenterY = centerY - popupHeight/2;
	   xxlWindow = window.open(URL, "xxlwindow", "width="+popupWidth+",height="+popupHeight+",left="+popupCenterX+",top="+popupCenterY+",location=no,menubar=no,resizable=no,scrollbars=yes,status=yes,toolbar=no");
   }
}

function openComparePopup(URL)
{
   if (document.images)
   {
	   popupWidth = screenWidth - 100;
	   popupHeight = screenHeight - 100;
	   popupCenterX = centerX - popupWidth/2;
	   popupCenterY = centerY - popupHeight/2;
	   popupWindow = window.open(URL, "comparewindow", "width="+popupWidth+",height="+popupHeight+",left="+popupCenterX+",top="+popupCenterY+",location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");
   }
}

function openVideoPopup(URL)
{
   if (document.images)
   {
	   popupWidth = 600;
	   popupHeight = 360;
	   popupCenterX = centerX - popupWidth/2;
	   popupCenterY = centerY - popupHeight/2;
	   popupWindow = window.open(URL, "videowindow", "width="+popupWidth+",height="+popupHeight+",left="+popupCenterX+",top="+popupCenterY+",location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
   }
}

function openXXLVideoPopup(URL)
{
   if (document.images)
   {
	   popupWidth = 600;
	   popupHeight = 360;
	   popupCenterX = centerX - popupWidth/2;
	   popupCenterY = centerY - popupHeight/2;
	   popupWindow = window.open(URL, "videowindow", "width="+popupWidth+",height="+popupHeight+",left="+popupCenterX+",top="+popupCenterY+",location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
   }
}

function confirmAction(questionTest, URL)
{
	confirmResult = confirm(questionTest);
	
	if (confirmResult == true)
	{
		self.location.replace(URL);
	}
}

function confirmSubmitAction(questionTest, formID)
{
	confirmResult = confirm(questionTest);
	
	if (confirmResult == true)
	{
		document.getElementById(formID).submit();
	}
}

function loadURL(URL)
{
	self.location.replace(URL);
}

function clearDirty()
{
}
