﻿var ddBi_ie = (document.styleSheets && document.all)?true:false;
var ddBi_ie6 = (ddBi_ie && document.compatMode && !window.XMLHttpRequest) ? true:false;
var ddBi_ie7 = (ddBi_ie && document.compatMode && window.XMLHttpRequest && !window.getComputedStyle) ? true:false;



// use more than one load event
function ddBi_addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function () {
			oldonload();
			func();
		};
	}
}

// clear default field values on focus
function ddBi_clearDefaultFieldValue(obj, defVal){
  if (obj.value == defVal)
    obj.value = "";
}

// set default field value on blur (if nothing entered)
function ddBi_setDefaultFieldValue(obj, defVal){
  if (obj.value == "")
    obj.value = defVal;
}

/*********************
	rollover images START
*********************/

function img_act(imgName, obj) {
	if (obj.firstChild.src){
		obj.firstChild.src=eval(imgName+".src");
	}
}

/*********************
	rollover images END
*********************/





function showRezeptListe(visibleItem){
	var top5_HL = $("ddBi_rezeptlisteContainer").getElementsByTagName("h4");
	var top5_HL_length = top5_HL.length
	var top5_table = $("ddBi_rezeptlisteContainer").getElementsByTagName("table");

	for (var i=0;i<top5_HL_length;i++){

		if (i == parseInt(visibleItem)) {
			top5_HL[i].firstChild.className = "curr";
			top5_table[i].style.display = "block";
		} else {
			top5_HL[i].firstChild.className = "";
			top5_table[i].style.display = "none";
		}
	}
}

function ddBi_showTop5Auswahl(){
	ddBi_hidePopupMsg();
	$("ddBi_Cover").style.height = $("ddBi_mainContentRow").offsetHeight + "px";
	$("ddBi_Cover").style.display = "block";
	$("ddBi_top5AuswahlPop").style.display = "block";
	try {
		$("ddBi_Cover").onclick = ddBi_hidePopupMsg;
	} catch (ex) {
		// ignore
	}
}

function ddBi_showNLschnellanmeldung(){
	ddBi_hidePopupMsg();
	$("ddBi_Cover").style.height = $("ddBi_mainContentRow").offsetHeight + "px";
	$("ddBi_Cover").style.display = "block";
	$("ddBi_nlSchnellanmeldung").style.display = "block";
	$("ddBi_NewsletterAnmeldung_Email").value = $F("ddBi_newsletterEmail");
	try {
		$("ddBi_Cover").onclick = ddBi_hidePopupMsg;
	} catch (ex) {
		// ignore
	}
}

function ddBi_showNLschnellabmeldung(){
	ddBi_hidePopupMsg();
	$("ddBi_Cover").style.height = $("ddBi_mainContentRow").offsetHeight + "px";
	$("ddBi_Cover").style.display = "block";
	$("ddBi_nlSchnellabmeldung").style.display = "block";
	try {
		$("ddBi_Cover").onclick = ddBi_hidePopupMsg;
	} catch (ex) {
		// ignore
	}
}

function ddBi_showPopupRegistrierung(){
	ddBi_hidePopupMsg();
	$("ddBi_Cover").style.height = $("ddBi_mainContentRow").offsetHeight + "px";
	$("ddBi_Cover").style.display = "block";
	$("ddBi_popupRegistrierung").style.display = "block";
	try {
		$("ddBi_Cover").onclick = ddBi_hidePopupMsg;
	} catch (ex) {
		// ignore
	}
}

function ddBi_showValidationError(txError){
	ddBi_hidePopupMsg();
	$("ddBi_Cover").style.height = $("ddBi_mainContentRow").offsetHeight + "px";
	$("ddBi_Cover").style.display = "block";
	$("ddBi_validation_error").style.display = "block";
	$("ddBi_validation_errorMsg").innerHTML = txError;
	try {
		$("ddBi_Cover").onclick = ddBi_hidePopupMsg;
	} catch (ex) {
		// ignore
	}
	ddBi_displayHelperIframe("ddBi_validation_error");
}

function ddBi_displayHelperIframe(idMsgBox){
	if (ddBi_ie6) {
		var ddBi_helper_iframe = $("ddBi_helper_iframe");
		ddBi_helper_iframe.style.display = "block";
		ddBi_helper_iframe.style.top = $(idMsgBox).offsetTop + "px";
		ddBi_helper_iframe.style.left = $(idMsgBox).offsetLeft + "px";
		ddBi_helper_iframe.style.width = $(idMsgBox).offsetWidth + "px";
		ddBi_helper_iframe.style.height = $(idMsgBox).offsetHeight + "px";
	}
}

function ddBi_hidePopupMsg(){
	var ddBi_popups = document.getElementsByClassName("ddBi_popupMsg");
	for (var i=0;i<ddBi_popups.length;i++){
		ddBi_popups[i].style.display = "none";
	}
	if (ddBi_ie6) {
		try {
			$("ddBi_helper_iframe").style.display = "none";
		} catch (ex) {
			// ignore
		}
	}
	$("ddBi_Cover").style.display = "none";
}




function onlyNumbers(ev){
	// nur ziffern als eingabe erlauben
	var evt = ev || event;
	if (evt){
		var charCode = (evt.charCode || evt.charCode == 0) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : evt.which);
		if (charCode > 13 && (charCode < 48 || charCode > 57)){
			if (evt.returnValue){
				evt.returnValue = false;
			} else if (evt.preventDefault){
				evt.preventDefault();
			} else {
				return false;
			}
		}
	}
}


/* find position scripts START */
function ddBi_CSS() {}

ddBi_CSS.getOffsetAbsoluteLeft = function(obj) {
	var x = 0;
	var dx = 0;
	while(obj) {
		if (obj) {
			dx = parseInt(obj.offsetLeft);
			if (!isNaN(dx)) x += dx;
			if (obj.style) {
				if ("absolute"==obj.style.position) return x;
			}
		}
		obj = obj.offsetParent;
	}
	return x;
}

ddBi_CSS.getOffsetAbsoluteTop = function(obj) {
	var x = 0;
	var dx = 0;
	while(obj) {
		if (obj) {
			dx = parseInt(obj.offsetTop);
			if (!isNaN(dx)) x += dx;
			if (obj.style) {
				//if ("absolute"==obj.style.position) return x;
			}
		}
		obj = obj.offsetParent;
	}
	return x;
}
/* find position scripts END */


function ddBi_RedirectFilialsuche(strTarget)
{
	var ort = $F("ddBi_filialenOrt");
	var plz = $F("ddBi_filialenPLZ");
	var target = strTarget;
	
	if ( ort.toLowerCase() != 'ort')
		target += "&Ort=" + ort;
		
	if ( plz.toLowerCase() != 'postleitzahl')
		 target += "&PLZ=" + plz;
	
	self.location.href= target;
}






/* horizontale scrollbalken */

ddBi_addLoadEvent( ddBi_calcScrollbars );
window.onresize = ddBi_calcScrollbars;

function ddBi_calcScrollbars()
{
    var ciHgt= $("ddBi_contentInner").offsetHeight;
    var wHgt, wWth;
    //alert(cx);
    
    if (window.innerHeight) {
		wHgt = parseInt(window.innerHeight);
		wWth = parseInt(window.innerWidth);
	} else if (document.documentElement) {
	    wHgt = parseInt(document.documentElement.clientHeight);
	    wWth = parseInt(document.documentElement.clientWidth);
    }

    $("ddBi_content").style.height = (wHgt - 49) + "px";
    if (wWth < 1124)
            $("ddBi_content").style.overflowX = "auto";
    else
        $("ddBi_content").style.overflowX = "hidden";
}

/*ein ausklappen der tabelle  der billa marke*/
function aufklappen(element)
{ if (document.getElementByID(element).style.display == "none") { document.getElementById(element).style.display = "block"; } else { document.getElementById(element).style.display = "none"; } }

function openMarkenTabelle(element) {
    var div = $(element).up('.ddBi_table_marke');
    if (div.hasClassName('expanded')) {
        div.removeClassName('expanded');
    }
    else {
        div.addClassName('expanded');
    }
}
