﻿// JScript-Datei
execOnLoad = function() {
 updateContentForNav();
 an_StartList();
// an_SetNavAndCrumbs();
// preloadImages();
// initPopups();
// Back/Forward remedy for javascript-controlled tabs. Only works for VI3 pages for now.
// if(usetabs = true) { return pollHash(); }
// if (window.location.href.match('../') || window.location.href.match('../') || window.location.href.match('../') || window.location.href.match('../') || window.location.href.match('../')) {
//   return pollHash();
// }
}

execNow = function() {
 updateContentForNav();
}

window.onload=execOnLoad;

// ------------------------------------------------------------------------- \\

function updateContentForNav() {
  if (document.getElementById("secondary_navigation")) {
    var cw = document.getElementById("content-wrapper");
	if(cw && cw.style) {
		cw.style.marginRight = "200px";
		if (!cw.attributes["id"].value) { cw.style.width = "100%"; } /* IE 5.5 needs this also */
	};
  }
}

function an_StartList() {
  if (document.all&&document.getElementById && !window.opera) {
    navRoot = document.getElementById("primary-navigation");
    if (navRoot) {
      for (i=0; i<navRoot.childNodes.length; i++) {
   	    node1 = navRoot.childNodes[i];
       	if (node1.nodeName=="UL") {
	      for (j=0; j<node1.childNodes.length; j++) {
    	    node2 = node1.childNodes[j];
        	if (node2.nodeName=="LI") {
	          node2.onmouseover=function() {
    	        this.className+=" over";
        	  }
	          node2.onmouseout=function() {
    	        this.className=this.className.replace(" over", "");
        	  }
    } } } } }
	navRoot = document.getElementById("sites");
    if (navRoot) {
      for (i=0; i<navRoot.childNodes.length; i++) {
        node = navRoot.childNodes[i];
		if (node.attributes["class"].value) { cls = node.attributes["class"].value; } /* IE 6 */
		else { cls = node.attributes["class"]+""; /* IE 5.5 */ }
		if (cls.indexOf("expand") >= 0) {
          if (node.nodeName=="LI") {
            node.onmouseover=function() {
              this.className+=" over";
            }
            node.onmouseout=function() {
              this.className=this.className.replace(" over", "");
            }
    } } } }
	cls = "";
    navRoot = document.getElementById("site-tools");
    if (navRoot) {
      for (i=0; i<navRoot.childNodes.length; i++) {
   	    node1 = navRoot.childNodes[i];
       	if (node1.nodeName=="UL") {
	      for (j=0; j<node1.childNodes.length; j++) {
    	    node2 = node1.childNodes[j];
			if (node2.attributes["class"].value) { cls = node2.attributes["class"].value; /* IE 6 */ }
			else { cls = node2.attributes["class"]+""; /* IE 5.5 */ }
			if (cls.indexOf("expand") >= 0) {
        	if (node2.nodeName=="LI") {
	          node2.onmouseover=function() {
    	        this.className+=" over";
        	  }
	          node2.onmouseout=function() {
    	        this.className=this.className.replace(" over", "");
        	  }
    } } } } } }
} }


function an_IE_GetAttribute(tag,attribute,removeOnlyIfTwo) {
  attribute = attribute.toLowerCase();
  // Find the first instance of the attribute.
  var startOfClass = tag.toLowerCase().indexOf(attribute);
  if (startOfClass == -1) { return tag; /* probably need some kind of timeout event or something because IE sucks */ }
  // Make sure there is another class assigned
  if (startOfClass != tag.toLowerCase().lastIndexOf(attribute) || !removeOnlyIfTwo) {
    // Find the first space after the first class
    var lengthOfClass = tag.substring(startOfClass).indexOf(" ");
    // The string to remove is from 'class' up to the next space
    var classString = tag.substr(startOfClass,lengthOfClass)+" ";
    tag = an_StringReplace(tag,classString,"");
  }
  return tag;
}

var promotion_index = 0;
function an_Promotions(step) {
 var promotions = document.getElementById("promotions-content");
 if (promotions && promotions.childNodes) {

  var len = 0; // number of LI child nodes -- Opera, Mozilla consider blank space as a text node
  for (var i = 0; i < promotions.childNodes.length; i++) { if (promotions.childNodes[i].nodeName == "LI") len++; }
  if (len == 1) return;

  var new_index = promotion_index + step;
  if (new_index < 0) new_index = len-1;
  if (new_index >= len) new_index = 0;

  var c = 0;
  for (i = 0; i < promotions.childNodes.length; i++) {
   if(promotions.childNodes[i].nodeName == "LI") {
    if (promotion_index == c) { promotions.childNodes[i].style.display = "none"; }
    if (new_index == c) { promotions.childNodes[i].style.display = "block"; }
    c++;
   }
  }
  promotion_index = new_index;
 }
}


