$(document).ready(function(){
	// IE6: Einblenden der Subnav, da kein li:hover unterstuetzt wird
	if ($.browser.msie && $.browser.version=="6.0") {
		$("div#nav-main ul li, div#nav-sub ul li, div#rubriken ul li, div#produktauswahl ul li").hover(
			function () {
				$(this).addClass("aktiv");
				$(this).children("ul").addClass("subnavaktiv");
			},
			function () {
				$(this).removeClass("aktiv");
				$(this).children("ul").removeClass("subnavaktiv");
			}
		);
	}
	
	// Marketing Support
	if (document.getElementById('ru')) {		
		prodname = $("option#graben").text();
		langname = $("option#ru").text();
		
		brochure_lang();
		brochure_prod();
	}
	
	if (document.getElementById('Produktgruppe_r')) { setLanguage(); }
	if (document.getElementById('Werbemittel_r')) { setImageWM(); }
	
});


// Seite in neuem Fenster oeffnen

function openWinCenter(url,name,breite,hoehe,x,y){
  var MyWindow =0;
  MyWindow = window.open(url,name,'toolbar=0,location=0,directories=0,statusbar=0,menubar=0,scrollbars=no,resizable=no,width='+breite+',height='+hoehe);
  if (MyWindow){
    MyWindow.moveTo(screen.width/2-(breite/2+x),screen.height/2-(hoehe/2+y));
    MyWindow.focus();
  }
}


// Marketing Support

var download_lang = '';
var langname = "";
var prodname = "";

// Initialisierung mit Sprache
function setLanguage () {
	if (document.getElementById('Sprache_r')) {
		download_lang = document.getElementById('Sprache_r').value;
	}
	if (document.getElementById('Produktgruppe_r')) {
		setImage();
	}
}

// Initialisierung ohne Sprache
function setImageWM() {
	var product_index = document.getElementById('Werbemittel_r').selectedIndex;
	if (document ['vorschaubild']) {
		document ['vorschaubild'].src = download_items_kat[product_index];
	}
	if (document.getElementById('Produktbeschreibung')) {
		document.getElementById('Produktbeschreibung').innerHTML = werbemittel_descr[product_index];
	}
}

function setImage () {
	var selected = document.getElementById('Produktgruppe_r').selectedIndex;
	changeImage (selected);
}

function changeLanguage (lang_object) {
	var img_index = document.getElementById('Produktgruppe_r').selectedIndex;
	var lang_index = lang_object.selectedIndex;
	
	download_lang = lang_object.value;		
	setImage (img_index);
	
	brochure_lang();
}

function changeLanguageKat (lang_object) {
	var lang_index = lang_object.selectedIndex;
	
	if (document ['vorschaubild']) {
		document ['vorschaubild'].src = download_items_kat[lang_index];
	}
}

function changeDescr (product_object) {
	var product_index = product_object.selectedIndex;
	
	if (document ['vorschaubild']) {
		document ['vorschaubild'].src = download_items_kat[product_index];
	}
	
	if (document.getElementById('Produktbeschreibung')) {
		document.getElementById('Produktbeschreibung').innerHTML = werbemittel_descr[product_index];
	}
}

function changeProduct (download_obj) {
	var img_index = download_obj.selectedIndex;
	changeImage (img_index);
	
	brochure_prod();
}

function changeImage (img_index) {
	if (document ['vorschaubild']) {		
		if (download_lang == 'de') {			
			document ['vorschaubild'].src = download_items_de[img_index];
		}
		if (download_lang == 'en') {
			document ['vorschaubild'].src = download_items_en[img_index];
		}
		if (download_lang == 'es') {			
			document ['vorschaubild'].src = download_items_es[img_index];
		}
		if (download_lang == 'fr') {
			document ['vorschaubild'].src = download_items_fr[img_index];
		}
		if (download_lang == 'ru') {
			document ['vorschaubild'].src = download_items_ru[img_index];
		}
	}
}


// Broschüren RU: Grabenfraesen nicht verfügbar
function brochure_lang () {
	var index = document.getElementById('Produktgruppe_r').selectedIndex;
	
	if (document.getElementById('Sprache_r').value == "ru") {
		$("option#graben").replaceWith('<span id="test2"></span>');
	}
	else {
		$("span#test2").replaceWith('<option id="graben" value="Grabenfraesen" >'+prodname+'</option>');
	}
	
	document.getElementById('Produktgruppe_r').value.selectedIndex = index;	
}

// Broschüren RU: Grabenfraesen nicht verfügbar
function brochure_prod () {
	var index = document.getElementById('Sprache_r').selectedIndex;
	
	if (document.getElementById('Produktgruppe_r').value == "Grabenfraesen") {
		$("option#ru").replaceWith('<span id="test"></span>');
	}
	else {
		$("span#test").replaceWith('<option id="ru" value="ru" >'+langname+'</option>');
	}
	
	document.getElementById('Sprache_r').value.selectedIndex = index;	
}

