/* ---

Schwarz E-Commerce GmbH & Co. KG
Stiftsbergstr. 1
74166 Neckarsulm

JavaScript Bibliothek

--- */

var Lidl = {
  Browser: {
    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
  },
  BrowserFeatures: {
    XPath: !!document.evaluate,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions:
      (document.createElement('div').__proto__ !==
       document.createElement('form').__proto__)
  }
}
Lidl.Browser.IE6=Lidl.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6;
Lidl.Browser.IE7=Lidl.Browser.IE && !Lidl.Browser.IE6;

function display_detail(DIVID) {
	new Effect.toggle('detail_' + DIVID, 'appear', {duration:0.3});
}


function zahlungsarten_alle_formulare_ausblenden() {
	$('kreditkarte').style.display = 'none';
	$('lastschrift').style.display = 'none';
}

function zahlungsart_einblenden(FELD) {
	zahlungsarten_alle_formulare_ausblenden();
	if($(FELD)) $(FELD).style.display = '';
}


function login_reg_alle_formulare_ausblenden() {
	$('login').style.display = 'none';
	$('reg').style.display = 'none';
}

function login_reg_einblenden(FELD) {
	login_reg_alle_formulare_ausblenden();
	if($(FELD)) $(FELD).style.display = 'block';
}


function ein_ausblenden() {
	args=ein_ausblenden.arguments;
	
	ein_aus = args[0];
	
	for(k=1;k<args.length;k++) {
		feld = args[k];
		if(ein_aus == 0) {
			$(feld).style.display = 'none';
		} else {
			$(feld).style.display = '';
		}
	}
}

function block_ein_ausblenden() {
	args=block_ein_ausblenden.arguments;
	ein_aus = args[0];
	for(k=1;k<args.length;k++) {
		feld = args[k];
		if(ein_aus == 0) {
			$(feld).style.display = 'none';
		} else {
			$(feld).style.display = 'block';
		}
	}
}

var actSearch;
function suche_alle_ausblenden() {
	$('pauschalreise').style.display = 'none';
	$('eigeneanreise').style.display = 'none';
	$('hotel').style.display = 'none';
	$('lastminute').style.display = 'none';
	$('fluege').style.display = 'none';
	$('mietwagen').style.display = 'none';
}
function suche_einblenden(FELD) {
	if(actSearch != FELD) {
		var queue = Effect.Queue;
		queue.each(function(e) { e.cancel() });
		suche_alle_ausblenden();
		if($(FELD)) show_ids(FELD);
		actSearch = FELD;
	}
}


function HideInfoBox(BoxId) {
	new Effect.BlindUp(BoxId, {duration:1});
	new Effect.toggle(BoxId, 'appear', {duration:1});
}
function ShowInfoBox(BoxId) {
	new Effect.BlindDown(BoxId, {duration:1});
	new Effect.toggle(BoxId, 'appear', {duration:1});
}
function PopupInfoBox(BoxId) {
	ShowInfoBox(BoxId);
	var myInfoTimeout = window.setTimeout("HideInfoBox(\'" + BoxId + "\')", 5000);
}

function ShowHideBox(Box) {
	if($(Box).visible()) {
		$(Box).style.display = 'none';
	} else {
		$(Box).style.display = 'block';
	}
}
function CheckTheBox(chkBox) {
	if(Lidl.Browser.Gecko) {
	if($(chkBox).checked == true) {
		$(chkBox).checked = false;
	} else {
		$(chkBox).checked = true;
	}
	}
}

function merkliste() {
	window.scrollTo(0, 0);
	PopupInfoBox('InfoMerkliste');
}

function show_detail_popup(obj, BoxId) {
	if($(BoxId).visible()) {
		$(BoxId).style.display = 'block';
		$(BoxId).style.height = '525px';
		new Effect.BlindUp(BoxId, {duration:1, scope: 'popup'});
		new Effect.toggle(BoxId, 'appear', {duration:1, scope: 'popup'});
	} else {
		$(BoxId).style.display = 'none';
		$(BoxId).style.height = '525px';
		$(BoxId).style.position = 'absolute';
		$(BoxId).style.left = '8px';
		$(BoxId).style.top = '68px';
		new Effect.BlindDown(BoxId, {duration:1, scope: 'popup'});
		new Effect.toggle(BoxId, 'appear', {duration:1, scope: 'popup'});
		$(BoxId).style.zIndex = 100000000;
	}
}

function show_popup(obj, BoxId) {
	var queue = Effect.Queue;
	queue.each(function(e) { e.cancel() });
	
	args=show_popup.arguments;
	if(args.length > 2) {
		for(i=2; i<args.length; i++) {
			Box = args[i];
			if($(Box).visible()) {
				if(Lidl.Browser.IE6) {
					$(Box).style.display = 'none';
				} else {
					$(Box).style.display = 'block';
					$(Box).style.height = '493px';
					HideInfoBox(Box);
				}
			}
		}
	}
	
	if($(BoxId).visible()) {
		if(Lidl.Browser.IE6) {
			$(BoxId).style.display = 'none';
		} else {
			$(BoxId).style.display = 'block';
			$(BoxId).style.height = '525px';
			HideInfoBox(BoxId);
		}
	} else {
		if(Lidl.Browser.IE6) {
			$(BoxId).style.position = 'relative';
			$(BoxId).style.left = '139px';
			$(BoxId).style.top = '0px';
			$(BoxId).style.display = 'block';
			var coors = Position.cumulativeOffset($(BoxId));
			window.scrollTo(0, coors[1]);
		} else {
			$(BoxId).style.display = 'none';
			$(BoxId).style.height = '525px';
			var coors = Position.cumulativeOffset(obj);
			$(BoxId).style.position = 'absolute';
			$(BoxId).style.left = coors[0] + 'px';
			$(BoxId).style.top = (coors[1] + 13) + 'px';
			ShowInfoBox(BoxId);
			$(BoxId).style.zIndex = 100000000;
		}
	}
}

function newsletter_themen(obj, BoxId) {
	var queue = Effect.Queue;
	queue.each(function(e) { e.cancel() });
	if(obj.checked == true) {
		$(BoxId).style.display = 'none';
		new Effect.toggle(BoxId, 'appear', {duration:0.3});
	} else {
		$(BoxId).style.display = 'block';
		new Effect.toggle(BoxId, 'appear', {duration:0.3});
	}
}

var anzahl_agb = 0;
function set_agb(anzahl) {
	anzahl_agb = anzahl;
}
function agb_all(obj) {
	if(obj.checked == true) {
		for(i=1; i<=anzahl_agb; i++) $('agb' + i).checked = true;
	} else {
		for(i=1; i<=anzahl_agb; i++) $('agb' + i).checked = false;
	}
}
function agb_check() {
	var all_agb_checked = true;
	for(i=1; i<=anzahl_agb; i++) {
		if($('agb' + i).checked == false) all_agb_checked = false;
	}
	if(all_agb_checked == true) {
		$('agb_gesamt').checked = true;
	} else {
		$('agb_gesamt').checked = false;
	}
}

var myTimer;
function show_ids() {
	args=show_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		new Effect.toggle(feld, 'appear', {duration:0.3});
	}
}
function display_ids() {
	args=display_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		$(feld).style.display = 'block';
	}
}
function hide_ids() {
	args=hide_ids.arguments;
	for(i=0;i<args.length;i++) {
		feld = args[i];
		$(feld).style.display = 'none';
	}
}

var teaser_aktiv = 1;
var teaser_anzahl = 1;
var auto_switch = true;
var switch_time = 5000;
function start_teaser() {
	var ts = $('TeaserSwitcher');
	var tsbg = $('TeaserSwitcherBG');
	tsbg.style.width = ((ts.offsetWidth * 1) + 4) + "px";
	tsbg.style.height = ((ts.offsetHeight * 1) + 4) + "px";
	window.setTimeout("auto_teaser_switch()", switch_time);
	
	var tslink = $('TeaserLink' + teaser_aktiv);
	tslink.className = "TeaserAktiv";
}
function auto_teaser_switch() {
	if(auto_switch == true) {
		change_teaser_next();
		window.setTimeout("auto_teaser_switch()", switch_time);
	}
}
function next_teaser() {
	auto_switch = false;
	change_teaser_next();
}
function prev_teaser() {
	auto_switch = false;
	change_teaser_prev();
}
function select_teaser(teaser) {
	auto_switch = false;
	if(teaser != teaser_aktiv) {
		var teaser_alt = teaser_aktiv;
		var teaser_neu = teaser;
		
		var queue = Effect.Queues.get('sliderteaser');
		queue.each(function(e) { e.cancel() });
		for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
		new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
		teaser_aktiv = teaser_neu;
		
		var tslink = $('TeaserLink' + teaser_alt);
		tslink.className = "";
		var tslink = $('TeaserLink' + teaser_neu);
		tslink.className = "TeaserAktiv";
	}
}
function change_teaser_next() {
	var teaser_alt = teaser_aktiv;
	var teaser_neu = teaser_aktiv + 1;
	if(teaser_neu > teaser_anzahl) teaser_neu = 1;
	
	var queue = Effect.Queues.get('sliderteaser');
	queue.each(function(e) { e.cancel() });
	for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
	new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
	teaser_aktiv = teaser_neu;

	var tslink = $('TeaserLink' + teaser_alt);
	tslink.className = "";
	var tslink = $('TeaserLink' + teaser_neu);
	tslink.className = "TeaserAktiv";
}
function change_teaser_prev() {
	var teaser_alt = teaser_aktiv;
	var teaser_neu = teaser_aktiv - 1;
	if(teaser_neu < 1) teaser_neu = teaser_anzahl;
	
	var queue = Effect.Queues.get('sliderteaser');
	queue.each(function(e) { e.cancel() });
	for(i=1; i<=teaser_anzahl; i++) { if(i != teaser_neu) { $('teaser' + i).style.display = 'none'; } }
	new Effect.toggle('teaser' + teaser_neu, 'appear', {duration:0.5, queue: {position:'end', scope: 'sliderteaser'}});
	
	teaser_aktiv = teaser_neu;

	var tslink = $('TeaserLink' + teaser_alt);
	tslink.className = "";
	var tslink = $('TeaserLink' + teaser_neu);
	tslink.className = "TeaserAktiv";
}
function set_teaser_max(anzahl) {
	teaser_anzahl = anzahl;
}

var detail_tabs = Array();
var act_tab = 0;
function set_detail_tabs() {
	args=set_detail_tabs.arguments;
	act_tab = args[0];
	for(i=0;i<args.length;i++) {
		var tab = args[i];
		detail_tabs[i] = tab;
		if(tab != act_tab) {
			$('link_' + tab).className = "";
			$(tab).style.display = "none";
		}
	}
}
function switch_tab(id) {
	if(id != act_tab) {
		var queue = Effect.Queue;
		queue.each(function(e) { e.cancel() });
		for(i=0;i<detail_tabs.length;i++) {
			feld = detail_tabs[i];
			$('link_' + feld).className = "";
			$(feld).style.display = "none";
		}
		$('link_' + id).className = "aktiv";
		new Effect.toggle(id, 'appear', {duration:0.5});
		act_tab = id;
	}
}

var detail_pics = 1;
var act_pic = 0;
function set_detail_pics(anzahl) {
	detail_pics = anzahl;
	for(i=1; i<=anzahl;i++) {
		$('link_Pic' + i).className = "";
		$('Pic' + i).style.display = "none";
	}
	$('link_Pic1').className = "PicAktiv";
	$('Pic1').style.display = "block";
	act_pic = 1;
}
function switch_pic(id) {
	if(id != act_pic) {
		var queue = Effect.Queue;
		queue.each(function(e) { e.cancel() });
		for(i=1; i<=detail_pics;i++) {
			$('link_Pic' + i).className = "";
			$('Pic' + i).style.display = "none";
		}
		$('link_Pic' + id).className = "PicAktiv";
		new Effect.toggle('Pic' + id, 'appear', {duration:0.5});
		act_pic = id;
	}
}

var weiterempfehlen_sichtbar = false;
function weiterempfehlen() {
	if(weiterempfehlen_sichtbar == false) {
		$('DetailTop').style.display = "none";
		new Effect.toggle('DetailRecommend', 'appear', {duration:0.5});
		weiterempfehlen_sichtbar = true;
	}
	window.scrollTo(0, 340);
}
function weiterempfehlen_ende() {
	$('DetailRecommend').style.display = "none";
	new Effect.toggle('DetailTop', 'appear', {duration:0.5});
	weiterempfehlen_sichtbar = false;
}

var name_counter;
var name_counter_time = 3000;
var name_count = 1;
function StartNameBrowser(anzahl) {
	name_counter = anzahl;
	window.setTimeout("NameBrowserNext()", name_counter_time);
	$('name1').style.display = 'block';
	$('name2').style.display = 'block';
	$('name3').style.display = 'block';
}

function NameBrowserNext() {
	if(Lidl.Browser.IE6) {
		$('name' + name_count).style.display = 'none';
	} else {
		new Effect.BlindUp('name' + name_count, {duration:0.5, scaleContent: true});		
	}
	name_count = name_count + 1;
	if(name_count > name_counter) name_count = 1;
	var name_count_next = name_count + 2;
	if(name_count_next > name_counter) name_count_next = name_count_next - name_counter;
	if(Lidl.Browser.IE6) {
		$('name' + name_count_next).style.display = 'block';
	} else {
		new Effect.BlindDown('name' + name_count_next, {duration:0.75, scaleContent: true});
	}
	window.setTimeout("SortBrowser()", 1000);
	window.setTimeout("NameBrowserNext()", name_counter_time);
}

function SortBrowser() {
	var umsort = name_count - 1;
	if(umsort < 1) umsort = name_counter;
	var Knoten = $('name' + umsort);
	var MainField = Knoten.parentNode;
	var oldField = MainField.removeChild(Knoten);
	MainField.appendChild(oldField);
}



/* --- Bier Funktionen --- */
function hidepicker(id){
	$(id).style.display = "none";
	$(id).innerHTML = "";
}

function setcolor(id,color, produktID){
	hidepicker('colorpicker_' + id);
	$('fontcolor[' + id + ']').value = color;
	xajax_changeLabel($('beerlabelID').value ,produktID,xajax.getFormValues('bestell_form'));
}

function promptCheck(){
Check = confirm("Wenn Sie das Etikett wechseln gehen Ihre Eingaben verloren.\r\nMöchten Sie das Etikett wechseln?");
if (Check == true)
  xajax_showCarousel();
}

function showBeerlabelPreview(labelID, produktID, formvalues){
	
	var inputs = document.forms.bestell_form.getElementsByTagName("input"); 

	for (i=0; i < inputs.length; i++){
		
		var globalCheck = true;
		
		if(inputs[i].id.substr(0,4) == 'text'){
			var id_add = inputs[i].id.substr(4,inputs[i].id.length);
			
			var Check = false;
					
			if ($('text' + id_add) && $('text' + id_add).value == $('defaulttext' + id_add ).value){		 
				Check = confirm("Möchten Sie wirklich den Beispieltext \"" + $('defaulttext' + id_add).value + "\" verwenden ?");
			} else {
				Check = true;
			}
			
			if (Check != true){
				globalCheck = false;
			}
			
		}
	}
	
	if (globalCheck == true){
		xajax_changeLabel(labelID,produktID,formvalues);
	}	
}

/* --- Adventskalender Funktionen --- */
function showAKPreviewFirst(adventsID, formvalues){
	$('carousel').style.display = "none";
	$('workbenchpreview').innerHTML = '';
	$('workbench').style.display = "block";

	xajax_change_adventskalender(adventsID, formvalues);
}
function showAKPreview(adventsID, formvalues){
	
	if ($('adventstext').value == $('defaultadventstext').value){
		Check = confirm("Möchten Sie wirklich den Beispieltext verwenden?");
	} else {
		Check = true;
	}
	
	if (Check == true){
		$('carousel').style.display = "none";
		$('workbenchpreview').innerHTML = '';
		$('workbench').style.display = "block";
		xajax_change_adventskalender(adventsID, formvalues);
	}
}
function showAKCarousel(){
	$('carousel').style.display = "block";
	$('workbench').style.display = "none";
	$('workbenchfields').innerHTML = '';
	$('hiddenadventsnname').value = 0;
}
function clearAdventsText(){
	if ($('adventstext').value == $('defaultadventstext').value){
		$('adventstext').value = '';
	}
}
function UnclearAdventsText(){
	if ($('adventstext').value == ''){
		$('adventstext').value = $('defaultadventstext').value;
	}
}
