window.addEvent('load', function() {
    //Functionality for Flash Master. Script should only start after page is load. 
    if (document.getElementById("flashcontent")) startFlash();
    if (document.getElementById("logo")) {
      $('logo').setProperty('class', 'linkHand');
      document.getElementById("logo").onclick = function () {
        document.location.href = "default.aspx?ni=62329";
      }
    }
    var highlight = document.getElementsByTagName("fieldset");
    for (var i = 0;i<highlight.length;i++) {

    var klassenName = highlight[i].className;
    if(klassenName=="line" || klassenName=="last" || klassenName=="second" || klassenName=="bgHi") {
      highlight[i].onclick = function () {
        reset();
        this.style.backgroundColor="#ffffff";
      }
    }    
    var highlightInput = highlight[i].getElementsByTagName("input");
    var highlightSelect = highlight[i].getElementsByTagName("select");
    var highlightTextarea = highlight[i].getElementsByTagName("textarea");

    for (var j = 0;j<highlightSelect.length;j++) {
      highlightSelect[j].onfocus = function () {
        reset();
        highLightFieldset(this);
      }
    }    
    for (var j = 0;j<highlightInput.length;j++) {
      highlightInput[j].onfocus = function () {
        reset();
        highLightFieldset(this);
      }
    }    
    for (var j = 0;j<highlightTextarea.length;j++) {
      highlightTextarea[j].onfocus = function () {
        reset();
        highLightFieldset(this);
      }
    }    
    }
   
    if (document.getElementById("quicklinks"))
    {
        $E('#quicklinks a').onclick = function(e) {
            new Event(e).stop();
            var menu = $E('#quicklinks ul');
            if(menu.getStyle('display') == 'none') {
                menu.setStyle('display', 'block');
                $(this).getParent().setStyle('z-index', '5');
            }
            else {
                menu.setStyle('display', 'none');
                $(this).getParent().setStyle('z-index', '');
            }
        };
    }
});

var highLightFieldset = function (x) {
  //TODO General Functionality for parent nodes
  if (x.parentNode.nodeName.toString().toUpperCase()=="FIELDSET") {
    x.parentNode.style.backgroundColor="#ffffff";
  }
  if (x.parentNode.parentNode.nodeName.toString().toUpperCase()=="FIELDSET") {
    x.parentNode.parentNode.style.backgroundColor="#ffffff";
  }
  if (x.parentNode.parentNode.parentNode.nodeName.toString().toUpperCase()=="FIELDSET") {
    x.parentNode.parentNode.parentNode.style.backgroundColor="#ffffff";
  }
  if (x.parentNode.parentNode.parentNode.parentNode.nodeName.toString().toUpperCase()=="FIELDSET") {
    x.parentNode.parentNode.parentNode.parentNode.style.backgroundColor="#ffffff";
  }
}

var reset = function () {
  var highlight = document.getElementsByTagName("fieldset");
  for (var i = 0;i<highlight.length;i++) {    
    var klassenName = highlight[i].className;
    if(klassenName=="line" || klassenName=="last" || klassenName=="second" || klassenName=="bgHi") {
      highlight[i].style.backgroundColor = "#f5f5f5";
    }
  }
}

function setupNeuAufbau() {
    window.onresize = neuAufbau;
    neuAufbau();
}

//window.onresize = neuAufbau;
function neuAufbau() {
    if (document.getElementById("footerContainer")) {
        if (window.getScrollHeight()<=window.getHeight()) {
            $('footerContainer').setStyle('position', 'absolute');
            $('footerContainer').setStyle('top', window.getScrollHeight()-45);
        } 
        //Buggy IE6 misst die scrollheight völlig anders. Mist
        else if (window.ie6 && (window.getScrollHeight()-4<=window.getHeight())) {
            $('footerContainer').setStyle('position', 'absolute');
            $('footerContainer').setStyle('top', window.getScrollHeight()-49);
        //Else relative Position
        } else {
            //$('footerContainer').setStyle('position', 'relative');
            //$('footerContainer').setStyle('top', 'auto');
            if (window.ie) $('footerContainer').setStyle('margin-bottom', -20);
        }
    }
}




var meldung = function () {
  //alert("Diese Funktionalität ist noch nicht implementiert!");
}

var change = function (x) {
  if (isNaN(x)) {
    document.location.href=x;
  } else {
    meldung();
  }
} 



//Warenkorb Accordion
window.addEvent('domready', function() {
    fixPng();
    
    //Bildet die Tooltipps
    var Tips1 = new Tips($$('.infoTipp'));

    //neuAufbau();
    if(!$('accordion') && !$('FAQ')) { //wenn es ein Akkordion gibt, warten bis es aufgebaut wurde
        setupNeuAufbau(); // ansonsten Neu-Aufbau fuer Footer sofort anstossen
    }
    var accordion = new Accordion('h3.toggler', 'div.element', {
	    opacity: false,
	    onActive: function(toggler, element){
		    //toggler.setStyle('color', '#ff3300');
		    temp = toggler.getChildren();
		    temp[0].src="images/btn_openTab.gif";
	    },
	    onBackground: function(toggler, element){
		    //toggler.setStyle('color', '#222');
		    temp = toggler.getChildren();
		    temp[0].src="images/btn_closeTab.gif";
	    },
	    onComplete: setupNeuAufbau
    }, $('accordion'));
    //accordion.display (0);
    //FAQ
    var FAQ = new Accordion('h4.toggler', 'div.element', {
	    opacity: false,
	    onActive: function(toggler, element){
		    toggler.setStyle('color', '#666666');
	    },
	    onBackground: function(toggler, element){
		    toggler.setStyle('color', '#000000');
	    },
	    onComplete: setupNeuAufbau
    }, $('FAQ'));
    //FAQ.display (0);
});

function popup_doc(docid){
    popup_klein('ContentPopup.aspx?popdocid=' + docid);
}

function popup_klein(url) {
    var options = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=480,height=400,top=10,left=10';
    if(url.indexOf('?')== -1)
        window.open(url + '?HideNavigation=1', 'new', options);
    else
        window.open(url + '&HideNavigation=1', 'new', options);
}

function popup_newwindow(url) {
    window.open(url, '_new');
}

function popup_newwindow_710_455(url) {
    var options = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=710,height=455,top=10,left=10';
    window.open(url + '&HideNavigation=1', 'popup_newwindow_710_455', options);
}

function CreateFlashControl(CLSID, ObjectID, WIDTH, HEIGHT, URL, XMLConfigPath, AUTOSTART ){
	var FlashCode = '<object classid="' + CLSID  + '" '
	+ 'id="' +		ObjectID + '" ' 
	+ 'width="' +	WIDTH + '" ' 
	+ 'height="' +	HEIGHT + '"/>'
	+ '<param name="movie" '
	+ 'value="' +	URL + '"/>'
	+ '<param name="autoStart" '
	+ 'value="' +	AUTOSTART + '"/>'
	+ '<param name="wmode" value="transparent"/>'
	+ '<param name="quality" value="high"/>'
	+ '<param name="xmlconfigpath" '
	+ 'value="' +	XMLConfigPath + '"/>'
	+ '<param name ="flashvars" value="datei=' + XMLConfigPath + '" />'
	+ '<embed '
	+ 'src="' +		URL + '" '
	+ 'width="' +	WIDTH + '" '
	+ 'height="' +	HEIGHT + '" '
	+ 'name="' +	ObjectID + '" '
	+ 'play="' +	AUTOSTART + '" '
	+ 'wmode="transparent" '
	+ 'quality="high" '
	+ 'loop="false" '
	+ 'quality="high" '
	+ 'allowScriptAccess="sameDomain" '
	+ 'type="application/x-shockwave-flash" '
	+ 'xmlconfigpath="' + XMLConfigPath + '" '
	+ 'flashvars="datei=' + XMLConfigPath + '" '
	+ 'pluginspage="http://www.macromedia.com/go/getflashplayer"/>'
	+ '<\/embed/>'
	+ '<\/object/>';
	//alert(FlashCode);
	
	document.write(FlashCode);
}

function fixPng() {
    if(window.ie6) { //mootools 1.11  (mootools 1.2: Browser.Engine.trident4)
        var msf = 'progid:DXImageTransform.Microsoft.AlphaImageLoader';
		$$('img[src$=png]').each(function(img){
			img.setStyles({
				'filter': msf + "(enabled='true',src='" + img.getProperty('src') + "',sizingMethod='crop')",
				width: img.getProperty('width'),
				height: img.getProperty('height')
			});
			img.setProperty('src', 'images/dot_trans.gif');
		}.bind(this));
	}
}

function DeliverCountries(productID)
{
	var DeliverCountriesPopUp = window.open("Pages/deliverycountries.aspx?ProductID=" + productID, "DeliverCountriesTarget" + productID, "width=440,height=500,top=50,left=50,scrollbars=yes,resizable=no");
	DeliverCountriesPopUp.focus();
}