mousepos = "";
mousepos2 = "";



function get_cookie(cookieName)
{
    strValue = false;
    
    if( strCookie = document.cookie )
	{
		var r = '=([^;]*)';
        if( arrCookie = strCookie.match( new RegExp( cookieName+r)))
		{
			strValue = RegExp.$1;
		}
	}
    return(strValue);
}

function encode_utf8(rohtext) {
             // dient der Normalisierung des Zeilenumbruchs
             rohtext = rohtext.replace(/\r\n/g,"\n");
             var utftext = "";
             for(var n=0; n<rohtext.length; n++)
                 {
                // ermitteln des Unicodes des  aktuellen Zeichens
                 var c=rohtext.charCodeAt(n);
                 // alle Zeichen von 0-127 => 1byte
                 if (c<128)
                     utftext += String.fromCharCode(c);
                 // alle Zeichen von 127 bis 2047 => 2byte
                 else if((c>127) && (c<2048)) {
                     utftext += String.fromCharCode((c>>6)|192);
                    utftext += String.fromCharCode((c&63)|128);}
               // alle Zeichen von 2048 bis 66536 => 3byte
                 else {
                   utftext += String.fromCharCode((c>>12)|224);
                    utftext += String.fromCharCode(((c>>6)&63)|128);
                     utftext += String.fromCharCode((c&63)|128);}
                }
            return utftext;
}

function stripslashes(str) 
{
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\0/g,'\0');
	str=str.replace(/\\\\/g,'\\');
	return str;
}

function FensterOeffnen (Adresse) 
{
  Fenster1 = window.open(Adresse, "_blank", "width=500,height=519,left=200,top=100"); Fenster1.focus();
  Fenster1.focus();
}

function FensterOeffnenAdr (Zip,Town,Town2,Street,Country) 
{
  if (Zip.length==0 && Town.length==0 && Town2.length==0 && Street.length==0)
  {
    alert("Bitte füllen Sie mindestens eines der Felder aus");
  }
  else
  {
    if (Country == "P" || Country == "ES")
    {
      Fenster1 = window.open("http://www.yellowmap.de/Filialfinder/HTML/POIIsoPartner.aspx?Partner=Aldi-Nord&SecurityID=ZjP1IF/WCnhs4Sq0X5k13A==&GeoFormatDatabase=3&GeoFormatIn=3&Radius=1000000&BC=ALDN&Search=1Locale=de-DE&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=250000&BC=ALDN&Search=1Locale=de-DE&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;
}

function urldecode( str ) {

    var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
	
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF'; 
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
	
	histogram['<'] = '%3C'; 
	histogram['>'] = '%3E'; 
	histogram['/'] = '%2F'; 
	histogram['@'] = '%40';  
    histogram[' '] = '%20';	
	
	histogram['é'] = '%E9';
	histogram['è'] = '%E8';
	histogram['É'] = '%C9';
	histogram['È'] = '%C8';
	
	histogram['ß'] = '%C3%9F';	
	
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret); 
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    

 
    return ret;
}

function deactivate(id)
{
  pullup(id);
}

function activate(id)
{
  mousepos = id;
}

function pullup2(id)
{
  if (mousepos == "")
  {
    document.getElementById(id).style.visibility = "hidden";
  }
}

function pullup3(id)
{
    document.getElementById(id).style.visibility = "hidden";
}

function pullup(id,id2)
{
  if (id2 == "subnav5")
  {
    setTimeout("pullup3('"+id+"')",100);
  }
  else
  {
    mousepos2 = mousepos;
    mousepos = "";
    setTimeout("pullup2('"+id+"')",300);
  }
}

function pulldown(id,id2)
{
  if (mousepos2 != "" && mousepos2 != id2)
  {
    document.getElementById(mousepos2).style.visibility = "hidden";
    mousepos2 = "";
  }
  document.getElementById(id).style.visibility = "visible";
  mousepos = id;
}

function switchDiv(id)
{
  var img = 'img_' + id;
  if(document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
//  document.getElementById(img).src = 'img/overviewCal_up.png'; // Grafik referenzieren
  }
  else
  {
    document.getElementById(id).style.display = 'none';
//  document.getElementById(img).src = 'img/overviewCal_down.png'; // Grafik referenzieren
  }
}

function artikelScroll(id)
{
  document.getElementById(id).scrollIntoView(true);
  document.getElementById('allinclusive').scrollIntoView(true);
}

