function Einkaufanzeigen() 
{

	var val = urldecode(get_cookie('Aldi_Einkauf'));
	
	//alert(val);
	
	var result = "";

	if (!val){
		document.getElementById('shopbasket_cont').innerHTML = '<p>&nbsp;</p>';
	}else {
		result += '<table cellpadding=1 cellspacing=0>';
		
		
		var mySplitResult = val.split("|");
		
		var count_artikel = mySplitResult.length;
		if (count_artikel > 5){
			var displ_count = 5;
		} else {
			var displ_count = count_artikel;
		}
		
		for(i = 0; i < displ_count; i++){
			var mySplitParts = mySplitResult[i].split("***");
		
			if (mySplitParts[2] != undefined){
				if (mySplitParts[2] != ""){
					result += '<tr><td valign=top>&middot;</td><td>' + stripslashes(mySplitParts[2]) + '</td></tr>';
				}
			}
		}
		
		if (count_artikel > 5){
			result += '<tr><td colspan=2><a href=einkaufszettel.php>mais...</a></td></tr>';
		}
		
		result += '</table>';
	
		document.charset="utf-8";
		document.getElementById('shopbasket_cont').innerHTML = '<p>' + unescape(result) + '</p>';
	}
	
}

/**
 * Einkaufszettel Druckfunktionalitaet
 */
$(document).ready(function(){

	if ( $("#eznotiz").length > 0 ) {
		document.getElementById('eznotiz').value=GetCookie('eznotiz');
	}

	$("input:radio[name=druckbild]").click(
	function(){
		var wahl = $(this).val();
		$("div.wkproduct").toggleClass('wkproduct-aslist');
		$("div.wkproduct").toggleClass('links');
		$("div.wkimg").toggleClass('nodisplay');		
		$("div.wkproduct div").toggleClass('links');		
		$("div.wktitle").toggleClass('wktitle-grid');		
		$("div.wktitle").toggleClass('wktitle-aslist');		
//		$("div.content_box_mitte p").toggleClass('print_pagebreak_a');
	});

/* Auf der Seite Neu im Sortiment die Header farblich abwechseln */
if ($("h2").hasClass("NEU")){
    $("h2:odd").css({'background-color':'#009'});
    $("h2:even").css({'background-color':'#af0000'});
};
/* Lightbox */
$('a.lightbox').lightBox();

/* *** Start Headershow *** */
if ($('.headershowbox .item').length > 0){

  var hsb = $('.headershowbox .item');
  var hsbl = hsb.length;
  var slides = hsb.parent().next().find('.slidetabs');

   hsb.each(function(index){
	 slides.append('<a href="#"></a>');
	});

  if (hsbl > 1){

 	hsb.parent().parent().find("span").eq(1).text(hsbl);
	hsb.parent().parent().find('.steuerung').show();
  }else{
	hsb.parent().parent().find('.steuerung').hide();
  } 
$(".headershowtabs").tabs(".headershowbox .item", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		//fadeInSpeed:    1000,
		//fadeOutSpeed:   3000,
		//autoplay:       true,
	
		// start from the beginning after the last tab
		rotate: true

	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({interval:7500});
};
/* *** end Headershow *** */
  
/* *** Start Kachelshow01 *** */	
if ($('.aldishow01 .item').length > 0){

  var as01 = $('.aldishow01 .item');
  var as01l = as01.length;
  var as01slides = as01.parent().find('.slidetabs');
  
  as01.each(function(index){
	as01slides.append('<a href="#"></a>');
	});

  if (as01l > 1){

 	as01.parent().find("span").eq(1).text(as01l);
	as01.parent().find('.steuerung').show();
  }else{
	as01.parent().find('.steuerung').hide();
  } 


  $(".slidetabs01").tabs(".aldishow01 .item", {
		// enable "cross-fading" effect
		effect: 'fade',
		clickable: false,
		fadeInSpeed:    2000,
		interval:       2000,
		fadeOutSpeed:   2000,
		autoplay:       true,
	
		// start from the beginning after the last tab
		rotate: true
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow();

};

/* *** end Kachelshow01 *** */	

/* *** Start Kachelshow02 *** */	
if ($('.aldishow02 .item').length > 0){

  var as02 = $('.aldishow02 .item');
  var as02l = as02.length;
  var as02slides = as02.parent().find('.slidetabs');
  
  as02.each(function(index){
	as02slides.append('<a href="#"></a>');
	});

 if (as02l > 1){

 	as02.parent().find("span").eq(1).text(as02l);
	as02.parent().find('.steuerung').show();
  }else{
	as02.parent().find('.steuerung').hide();
  } 

	$(".slidetabs02").tabs(".aldishow02 .item", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		clickable: false,
		fadeInSpeed:    2000,
		interval:       2000,
		fadeOutSpeed:   2000,
		autoplay:       true,
	
		// start from the beginning after the last tab
		rotate: true
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow();
};
/* *** end Kachelshow02 *** */	

});

var scrollContent = null;
var scrollIcon = null;
var last_scrollContent = null;
var last_scrollIcon = null;

Fisch_Open = new Image(13,13);
Fisch_Open.src = "images/slider_open.gif";

Fisch_Closed = new Image(13,13);
Fisch_Closed.src = "images/slider_close.gif";

function AniVert(content, ico){

	var interval = 10;
	var step = 10;

    if (scrollContent == null)
    {
        scrollContent = document.getElementById(content);
        scrollIcon = document.getElementById(ico);
        
        var expand = (document.getElementById(content).style.display == "none");
        
        if (last_scrollContent != null)
        {
            last_scrollContent.style.display = "none";
            last_scrollIcon.src = Fisch_Open.src;
        }

        if (expand)
            document.getElementById(content).style.display = "block";

        var max_height = document.getElementById(content).offsetHeight;
        var step_height = step + (expand ? 0 : -max_height);
 
        document.getElementById(content).style.height = Math.abs(step_height) + "px";
        
        scrollIcon.src = Fisch_Closed.src;

        setTimeout("PannelAniVert("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);

    }
}


function PannelAniVert(interval, step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        scrollContent.style.height = Math.abs(step_height) + "px";
        setTimeout("PannelAniVert("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    else
    {
        if (step_height_abs<step)
            scrollContent.style.display = "none";

        scrollContent.style.height = "";

        last_scrollContent = scrollContent;
        last_scrollIcon = scrollIcon;
        
        scrollContent = null;
        scrollIcon = null;
    }
}


/* start Popup Zentriert aufrufen */

var newwindow=false;
function wincenter(url,breite,hoehe) {
  if(newwindow&&newwindow.closed==false)
    newwindow.close()
    var l = (screen.width - breite) / 2;
    var t = (screen.height - hoehe) / 2;
    newwindow = window.open(url,"newwindow","width=" + breite + ",height=" + hoehe + ",left=" + l + ",top=" + t + ";");
  newwindow.focus();
}

/* end Popup Zentriert aufrufen */

function FensterOeffnen (Adresse) 
{
  Fenster1 = window.open(Adresse, "_blank", "width=500,height=519,left=200,top=100"); Fenster1.focus();
  Fenster1.focus();
}

  function FensterOeffnen_460x379 (Adresse) 
{ Fenster1 = window.open(Adresse, "_blank", "width=460,height=379,left=200,top=100"); Fenster1.focus(); } 
 
function fensteropen_560x393 (Adresse) 
{ Fenster1 = window.open(Adresse, "_blank", "width=560,height=393,left=200,top=100"); Fenster1.focus(); } 
 

function FensterOeffnenAdr (Zip,Town,Town2,Street,Country,Radius,oDefaults) 
{
  Radius = Radius || 250000; 
  oDefaults = oDefaults || {};
  
  if (Zip.length==0 && Town.length==0 && Town2.length==0 && Street.length==0){
    alert("Preencha no mínimo um dos campos");
  }else if(
		  typeof(oDefaults.defaults) == "object" &&  
		  oDefaults.defaults.zip == Zip && oDefaults.defaults.town == Town 
		  ){
	  alert("Preencha no mínimo um dos campos");
  }
  else
  {
    if (Country == "P" || Country == "E")
    {
      Fenster1 = window.open("http://www.yellowmap.de/Filialfinder/HTML/POIIsoPartner.aspx?Partner=Aldi-Nord&SecurityID=ZjP1IF/WCnhs4Sq0X5k13A==&GeoFormatDatabase=3&GeoFormatIn=3&Radius=1000000&BC=ALDI&Search=1Locale=pt-PT&Country="+Country+"&Zip="+Zip+"&Town="+Town+"&Town2="+Town2+"&Street="+Street, "Zweitfenster", "width=800,height=600,left=200,top=100,scrollbars=yes"); Fenster1.focus();
      Fenster1.focus();
    }
    else
{
      Fenster1 = window.open("http://www.yellowmap.de/Filialfinder/HTML/POIIsoPartner.aspx?Partner=Aldi-Nord&SecurityID=ZjP1IF/WCnhs4Sq0X5k13A==&Radius="+Radius+"&BC=ALDI&Search=1Locale=pt-PT&Country="+Country+"&Zip="+Zip+"&Town="+Town+"&Town2="+Town2+"&Street="+Street, "Zweitfenster", "width=800,height=600,left=200,top=100,scrollbars=yes"); Fenster1.focus();
      Fenster1.focus();
    }
  }
  return false;
}

/* ********** YELLOWMAP ******************** */
function FensterOeffnenAdr_new (Zip,Town,Town2,Street,Country,Radius,oDefaults) 
  {
  Radius = Radius || 5000;
  oDefaults = oDefaults || {};
  
  if (Zip.length==0 && Town.length==0 && Town2.length==0 && Street.length==0){
    alert("Preencha no mínimo um dos campos");
  }else if(
		  typeof(oDefaults.defaults) == "object" &&  
		  oDefaults.defaults.zip == Zip && oDefaults.defaults.town == Town 
		  ){
	  alert("Preencha no mínimo um dos campos");
  }
  else
  {
    if (Country == "P" || Country == "E")
    {
    	url = "http://www.yellowmap.de/Partners/AldiNord/Search.aspx?GeoFormatDatabase=3&GeoFormatIn=3&Radius="+Radius+"&BC=ALDN&Search=1&Locale=pt-PT&Country="+Country+"&Zip="+Zip+"&Town="+Town+"&Town2="+Town2+"&Street="+Street+"&PoiListMinSearchOnCountZeroMaxRadius=50000";
    }
    else
    {
    	url = "http://www.yellowmap.de/Partners/AldiNord/Search.aspx?Radius="+Radius+"&BC=ALDN&Search=1&Locale=pt-PT&Country="+Country+"&Zip="+Zip+"&Town="+Town+"&Town2="+Town2+"&Street="+Street+"&PoiListMinSearchOnCountZeroMaxRadius=50000";
    }
    
    Fenster1 = window.open(url, "Zweitfenster", "width=800,height=600,left=200,top=100,scrollbars=yes"); 
    Fenster1.focus();
    
//    try {
//    	console.log(url);
//    }
//    catch(e){};
    url = '';    
    
  }
  return false;
}
/* *************************************** */

function FensterOeffnenEmail (email) 
{
  if (email.length==0)
  {
    alert("Introduza um e-mail válido.");
  }
  else
  {
    document.newsletterform.submit();
  }
  return false;
}
function filename(path)
{
	var thefile= path.substring( path.lastIndexOf('/') +1, path.length  );
	if (thefile == "") { thefile = "index.shtml" };
	return thefile;
}

function pathname(path)
{
	return path.substring( 0,path.lastIndexOf('/') );
}

function drucken()
{
	var path = document.location.pathname ; 
	var printfile = pathname(path)+"/P_"+filename(path) ;
	printfile = printfile + document.location.search ;
	Fenster1 = window.open(printfile,"ALDIdrucken","width=760,height=500,left=50,top=50,scrollbars=yes,location=no,menubar=no,resizeable=yes,status=no,toolbar=no");
  Fenster1.focus();
}

function drucken2(server)
{
	Fenster2 = window.open("http://"+server+"/EINKAUFSZETTEL_D/P_index.shtml","ALDIdrucken","width=760,height=500,left=50,top=50,scrollbars=yes,location=no,menubar=no,resizeable=yes,status=no,toolbar=no");
  Fenster2.focus();
}

function empfehlen()
{
	Fenster3 = window.open("/PHP/empfehlen.php?page="+document.location.pathname,"ALDIempfehlen","width=400,height=550,left=50,top=50");
  Fenster3.focus();	
}

function FensterOeffnen3 (Adresse) 
{
  Fenster4 = window.open(Adresse, "Zweitfenster", "width=400,height=550,left=200,top=100");
  Fenster4.focus();
}

/**
 * JQuery Helper Funktion:
 * @author tr
 */
$.urlParam = function(name){
	try {
		var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
		return results[1] || null;
	}
	catch (e){
		return null;
	}
};

/**
 * Umkreissuche Übertrag
 * @author tr 
 * @param myform
 */
function aldiRadiusBox_TransferValues(olink){
	oForm = document.radiussearchform;
	p1 = (oForm.Zip.value == 'Código postal') ? '' : oForm.Zip.value;
	p2 = (oForm.Town.value == 'Localidade') ?  '' : oForm.Town.value;
	t='';
	bisCms = ($.urlParam("pid")!=null) ? true : false;
	
	if (p1 !='' || p2 !=''){
		if (!bisCms) {
			t = '?Zip=' +encodeURIComponent(p1) + '&Town='+encodeURIComponent(p2);			
		}else{
			t = '&Zip=' +encodeURIComponent(p1) + '&Town='+encodeURIComponent(p2);
		}
	}
	x= olink.href + t;
	document.location.href = x;
	return false;
}

/**
 * 
 * @author tr
 */
function aldiRadiusBBox_IniValues(){

    $(document).ready(function(){
    	oForm = document.radiussearchformdetail;	    	
    	zip = $.urlParam("Zip");
    	town = $.urlParam("Town");
        if (zip != null){
        	oForm.Zip.value = decodeURIComponent(zip);
        }
        if (town != null){
        	oForm.Town.value = decodeURIComponent(town);        	
        }
    });
}


/**
* Das Notizfeld des Einkaufszettels limitieren
*/

function limitNotice(textarea,limit, Event){
	var val=textarea.value.replace(/\r/g,'').split('\n');
	var bool = false;
	if (textarea.value.length > 300) {
		if (( Event.keyCode.toString().search(/^(8|37|38|39|40|46)$/) != (-1) ) ) {
		
		} else {
			Event.returnValue=false;
			return false;			
		}		
		
		
	}
	val=textarea.value.replace(/\r/g,'').split('\n');
	if(val.length>limit){
		if (( Event.keyCode.toString().search(/^(10|13)$/) != (-1) ) ) {
			Event.returnValue=false;
			return false;
		} else {
		}
	} else if (bool){
	}
	
}
