GlobalToolbar = '';

var artnrpreise = new Array();	


outhandler=false;

function show_callback() {
	$('.fragen2010 div').stop(true, true).fadeIn(200);
	
}

function hide_callback() {
	$('.fragen2010 div').stop(true, true).fadeOut(200);
}

function rootmenu() {
	$('.bereichsmenu div a').blur();
	if ($('.bereichsmenu div strong').width() == 52) $('.bereichsmenu div strong').animate({'width': '0px', 'opacity': 0},400);
	$('.bereichsmenu div.off').slideDown(400);
}

function rootmenu_off() {
	if ($('.bereichsmenu div strong').width() == 0) $('.bereichsmenu div strong').animate({'width': '52px', 'opacity': 1},400);
	$('.bereichsmenu div.off').stop(true, true).slideUp(400);
	if (outhandler) {
		window.clearTimeout(outhandler);
		outhandler=false;
	}
}

function change_input(obj, inhalt, feldart) {
	if (obj.value == inhalt) {
		obj.value = '';
		obj.focus();
	} else if (obj.value == '') {
		obj.value = inhalt; 
	}
}

$(window).ready(function(){
	$('div.bereichsmenu').mouseover(function() { 
		if (outhandler) {
			window.clearTimeout(outhandler);
			outhandler=false;
		}
		rootmenu();
	
	});
	$('div.bereichsmenu').mouseout(function() {	
		if (outhandler) {
			window.clearTimeout(outhandler);
			outhandler=false;
		}
		outhandler = window.setTimeout(function() { rootmenu_off() }, 2);	
	});
	
	$('div.bereichsmenu div, .bereichsmenu div strong, .bereichsmenu div a').mouseover(function() {
		if (outhandler) {
			window.clearTimeout(outhandler);
			outhandler=false;
		}
	});
});

function change_preis(obj, preisid, farbe) {	
	if (artnrpreise[preisid]['einzelpreis'] != 0) {
		document.getElementById('preis_' + obj).innerHTML = "<strong style=\"font-size:13px; font-weight:normal; text-decoration:line-through;\">" + artnrpreise[preisid]['name_alt'] + " " + artnrpreise[preisid]['einzelpreis'] + "&nbsp;&euro;</strong><br><strong style=\"font-size:18px; color:#b1221b; font-weight:normal;\">" + artnrpreise[preisid]['name_neu'] + " "  + artnrpreise[preisid]['norm'] + "&nbsp;&euro;</strong><br><span style=\"font-size:9px; color:#7c7c7c;\">zzgl. MwSt.<br>" + artnrpreise[preisid]['mwst'] + "&nbsp;&euro; brutto</span>";
	} else {
		document.getElementById('preis_' + obj).innerHTML = "<strong style=\"font-size:18px; font-weight:normal;\">" + artnrpreise[preisid]['norm'] + "&nbsp;&euro;</strong><br><span style=\"font-size:9px; color:#7c7c7c;\">zzgl. MwSt.<br>" + artnrpreise[preisid]['mwst'] + "&nbsp;&euro; brutto</span>";
	}
	document.getElementById('nummer_' + obj).innerHTML = "Artikelnummer: " + artnrpreise[preisid]['nummer'];
	//alert(document.getElementById('nummer_' + obj).innerHTML);
}

function gotopreis(obj) {
	
	//document.location.href = '#marke_' + obj;
	window.scrollTo(0,500);
	
}

function resizemenu () {
	var changeto = (document.getElementById('ibbenbueren').offsetHeight-23);
	document.getElementById('meinmenu').style.height = changeto+"px";
	
	if (document.getElementById('widthcheck').offsetWidth <= 900) {
		document.getElementById('topmenu').style.width = "900px";
		document.getElementById('ibbenbueren').style.width = "900px";
		document.getElementById('telefonnummer').style.width = "900px";
	} else {
		document.getElementById('topmenu').style.width = "90%";
		document.getElementById('ibbenbueren').style.width = "90%";
		document.getElementById('telefonnummer').style.width = "90%";
	}
	
}
 
function tosite() { 
	document.location.href = document.getElementById('this_site').value; 
} 

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function change_reiter(oldobj,newobj) {
	
	document.getElementById('reiter_' + oldobj).style.display = 'none';
	document.getElementById('tab_' + oldobj).className = "off"; 
	/*
	document.getElementById('tab_' + oldobj).style.backgroundColor = '#f2f2f2'; 
	document.getElementById('tab_' + oldobj).style.color = '#575656';
	document.getElementById('tab_' + oldobj).style.border = '0px'; 
	document.getElementById('tab_' + oldobj).style.borderBottom = '1px solid #cccccc'; 
	document.getElementById('tab_' + oldobj).style.padding = '6px 11px 4px 11px';
	*/
	document.getElementById('openreiter').value = newobj;	
	
	document.getElementById('reiter_' + newobj).style.display = 'block';
	document.getElementById('tab_' + newobj).className = "an"; 
	/*
	document.getElementById('tab_' + newobj).style.backgroundColor = '#ffffff'; 
	document.getElementById('tab_' + newobj).style.color = '#061e4f';
	document.getElementById('tab_' + newobj).style.border = '1px solid #cccccc'; 
	document.getElementById('tab_' + newobj).style.borderBottom = '0px'; 
	document.getElementById('tab_' + newobj).style.padding = '5px 10px 5px 10px';
	*/
	lastreiter = newobj;
	
}


function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function inkorb(change, selected) {	
	if(document.getElementById(change).selectedIndex==0) {
		document.getElementById(change).selectedIndex = selected;		
	}
}

function createWin(loc) {
	callbackwin = window.open(loc,'nav_win',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,maximize=no,width=450,height=200');
	callbackwin.creator = self;
}

function openWin(loc) {
	picwin = window.open(loc,'newwin', '');
	picwin.creator = self;
}

function createDSLWin(loc) {
	window.open(loc,'dslwin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,maximize=no,width=480,height=600');
}

function createpicWin(loc) {
	picwin = window.open(loc,'picwin',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,maximize=no,width=600,height=550');
	picwin.creator = self;
}

function nix() {
	cat = 1;
}

function openPictureWin(loc) {
	picturewin = window.open(loc,'nav_win',
	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,maximize=no,width=150,height=150');
	picturewin.creator = self;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

document.onkeydown = checkkeypress;

function checkkeypress(Ereignis) {
		keyvalue=window.event.keyCode;
		if ((keyvalue==19) || (keyvalue==123)) {
			if (document.getElementById('showlogin').value==1) {
				// MM_showHideLayers('startcmspass','','hide');
				document.getElementById('startcmspass').style.display = "none";
				document.getElementById('showlogin').value = 0;
			} else {
				// MM_showHideLayers('startcmspass','','show');				
				document.getElementById('startcmspass').style.display = "block";
				document.getElementById('showlogin').value = 1;
				document.getElementById('lms_user').focus();
			}
		}
}

function HideToolbar(Obj) {
	document.getElementById(Obj).style.display = 'none';
	
	avoidselect=true; 
	bounding_hide=false;
	
	get_structure(); 
	layer_cache();
	event_area_enable('edit');
	
}

function ShowToolbar(Obj) {
	document.getElementById(Obj).style.display = 'block';
}

function OpenToolbar(Obj) {
	if ((GlobalToolbar != Obj) && (GlobalToolbar != '')) {
		HideToolbar(GlobalToolbar);
	}
	//var todo = HideToolbar(Obj);
	closethis = Obj;
	timer = window.setTimeout('HideToolbar(closethis);',1000);
	GlobalToolbar = Obj;
	ShowToolbar(Obj);
}

function high_menu(LinkObject) {
	LinkObject.style.background='rgb(240,240,240)';
	window.clearTimeout(timer);
	timer = window.setTimeout('HideToolbar(closethis);',10000);
}

function low_menu(LinkObject) {
	LinkObject.style.background='rgb(255,255,255)';
	window.clearTimeout(timer);
	timer = window.setTimeout('HideToolbar(closethis);',500);
}


// Startseite

var lastobj = 'start';

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion); 
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;

// In MSIE, the true version is after "MSIE" in userAgent
if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Microsoft Internet Explorer";
 fullVersion = nAgt.substring(verOffset+5);
}

majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
 fullVersion  = ''+parseFloat(navigator.appVersion); 
 majorVersion = parseInt(navigator.appVersion,10);
}

function bereich_over(pointer, obj) {
	if (typeof(lastpointer)!="undefined") lastpointer.className = 'main_normal';
	if (browserName == 'Microsoft Internet Explorer' && majorVersion <= 6) {
		pointer.className = 'main_over_nopng';
	} else {
		pointer.className = 'main_over';
	}
	
	document.getElementById(lastobj).style.zIndex = 1;
	lastobj = obj;
	lastpointer = pointer;
	document.getElementById(obj).style.zIndex = 20;
}

function bereich_start(pointer, obj) {
	pointer.className = 'main_normal';
	document.getElementById(obj).style.zIndex = 1;
	lastobj = 'start';
	document.getElementById('start').style.zIndex = 20;
}

function url(pfad) {
	document.location.href = pfad;

}
