infotext_is_displayed = 1;
function removeText() {
	if (infotext_is_displayed==1)
	{
		document.suche.suchbegriff.value = "";
		document.suche.suchbegriff.style.color = "#000000";
		infotext_is_displayed = 0;
	}
}

function checkForm() {
	if(document.suche.suchbegriff.value == "" || document.suche.suchbegriff.value == "Suchbegriff eingeben" || document.suche.suchbegriff.value == null)
	{
		alert("Bitte geben Sie einen Suchbegriff ein.");
		return false;
	}
	return true;
}


function openit(addr,h,b) {
	window.open("/bild/showpic.php?url="+addr, "open","width="+b+",height="+h+", scrollbars=0");
}


/* PNG-Fix für IE >= 5.5 */
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
if(window.ie == true) {
    window.attachEvent("onload", correctPNG);
}

/* Milieu-Tool */
function add_overlay(obj,x,y,mid) {
    if(window.ie == true) {
        var suffix = ".gif";
    } else {
        var suffix = ".png";
    }

    var filename = "circle"+suffix;

    var top = $(obj).getTop()+parseInt(y)-19;
    var left = $(obj).getLeft()+parseInt(x)-19;
    var fxMid = new Fx.Styles($(mid), {duration:200, wait:false});
    new Element('img', {
        'styles': {
			'opacity': 0.5,
            'position': 'absolute',
            'top': top,
            'left': left,
            'cursor': 'pointer'
        },
        'events': {
            'mouseenter': function(){
                fxMid.start({
                    'opacity': 1
                });
            }
        },
        'src': 'http://www.allnatura.de/bild/'+filename,
        'id': 'circle_'+mid,
        'class': 'noprint'
    }).injectInside($E('body'));
    $(mid).setStyles({
        'opacity': '0',
        'display': 'block',
        'top': top-19-50,
        'left': left-19
    }).injectInside($E('body'));
    $(mid).addEvents({
            'mouseleave': function(){
                fxMid.start({
                    'opacity': 0
                });
            }});
    // Faden lassen
    var fx_fade = function() {
        new Fx.Styles($('circle_'+mid), {duration:1600, wait:true}).start({'opacity': 0.01}).chain(function(){new Fx.Styles($('circle_'+mid), {duration:1600, wait:true}).start({'opacity': 0.8})});
    }
    fx_fade.periodical(3600);

}
function platziere_overlay(obj,x,y,mid) {
    var top = $(obj).getTop()+parseInt(y)-19;
    var left = $(obj).getLeft()+parseInt(x)-19;

    $('circle_'+mid).setStyles({
        'top': top,
        'left': left
    });

    //if(window.ie == true) var left = left-$('container').getLeft();
    $(mid).setStyles({
        'top': top-19-50,
        'left': left-19
    });
}

function setBookmark (where) { 
	burl = encodeURIComponent(location.href); 
	btitle = encodeURIComponent(document.title); 
	switch(where) { 
		case 'Delicious': window.open('http://del.icio.us/post?url='+burl+'&title='+btitle); break; 
		case 'Digg': window.open('http://digg.com/submit?phase=2&url='+burl+'&title='+btitle); break; 
		case 'Furl': window.open('http://www.furl.net/storeIt.jsp?u='+burl+'&t='+btitle); break; 
		case 'Linkarena': window.open('http://linkarena.com/bookmarks/addlink/?url='+burl+'&title='+btitle); break; 
		case 'Mrwong': window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url='+burl+'&bm_notice=&bm_description='+btitle); break;
		case 'Reddit': window.open('http://reddit.com/submit?url='+burl+'&title='+btitle); break; 
		case 'Slashdot': window.open('http://slashdot.org/bookmark.pl?url='+burl+'&title='+btitle); break; 
		case 'Spurl': window.open('http://www.spurl.net/spurl.php?title='+btitle+'&url='+burl); break; 
		case 'Stumbleupon': window.open('http://www.stumbleupon.com/submit?url='+burl+'&title='+btitle); break; 
		case 'Technorati': window.open('http://technorati.com/faves?add='+burl); break; 
		case 'Webnews': window.open('http://www.webnews.de/einstellen?url='+burl+'&title='+btitle); break; 
		case 'Yigg': window.open('http://yigg.de/neu?exturl='+burl); break; 
	} 
}

function check() {
	if (document.getElementById('mod').value == "" || document.getElementById('mod').value == null) {
		alert("Sie müssen eine Länge angeben um den Teppich in den Warenkorb legen zu können.");
		document.getElementById('mod').focus();
		return false;
	}
}

function zahl() {
	var zahl = document.getElementById('mod');
	for (var i = 0; i < zahl.value.length; i++) {
		var z = zahl.value.substring(i, i + 1);
		if (z < "0" || "9" < z)  {
			var zahl2 = zahl.value.substring(0, zahl.value.length-1);
			zahl.value = zahl2;
			zahl.focus();
			return false;
		}
	}
}

function runden(x) {
	var k = (Math.round(x * 100) / 100).toString();
	k += (k.indexOf('.') == -1)? '.00' : '00';
	var p = k.indexOf('.'), m = k.indexOf('-.');
	var f = (p == 0 || m == 0)? '0,' : ',';
	return k.substring(0, p) + f + k.substring(p+1, p+3);
}

function calc(qmpreis_value) {
	var selObj			= document.getElementById('dropdown1');
	var selIndex 		= selObj.selectedIndex;
	var rollenbreite 	= selObj.options[selObj.selectedIndex].text.replace(/cm/g,"");
	var laenge 			= document.getElementById('mod').value.replace(/[^\d]/g,'');

	if (laenge.length==0 || laenge==null) { 
		alert("Geben Sie bitte die gewünschte Länge in Zentimetern ein!"); 
	} else { 
		var qm = ((laenge * rollenbreite) /10000);
		var summe = (qm * qmpreis_value);
		document.orderform.price.value = runden(summe); 
	}
	return true;
}

function checkArticleConfig() {
	if (document.getElementById('mod').value == '') {
		alert("Bitte geben Sie eine Länge ein.");
		return false;
	}
	return true;
}

function urldecode (str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous
    // +   improved by: Orlando
    // %        note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    var hash_map = {}, 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 hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';
    hash_map['%20'] = '+';
    hash_map['\u00DC'] = '%DC';
    hash_map['\u00FC'] = '%FC';
    hash_map['\u00C4'] = '%D4';
    hash_map['\u00E4'] = '%E4';
    hash_map['\u00D6'] = '%D6';
    hash_map['\u00F6'] = '%F6';
    hash_map['\u00DF'] = '%DF';
    hash_map['\u20AC'] = '%80';
    hash_map['\u0081'] = '%81';
    hash_map['\u201A'] = '%82';
    hash_map['\u0192'] = '%83';
    hash_map['\u201E'] = '%84';
    hash_map['\u2026'] = '%85';
    hash_map['\u2020'] = '%86';
    hash_map['\u2021'] = '%87';
    hash_map['\u02C6'] = '%88';
    hash_map['\u2030'] = '%89';
    hash_map['\u0160'] = '%8A';
    hash_map['\u2039'] = '%8B';
    hash_map['\u0152'] = '%8C';
    hash_map['\u008D'] = '%8D';
    hash_map['\u017D'] = '%8E';
    hash_map['\u008F'] = '%8F';
    hash_map['\u0090'] = '%90';
    hash_map['\u2018'] = '%91';
    hash_map['\u2019'] = '%92';
    hash_map['\u201C'] = '%93';
    hash_map['\u201D'] = '%94';
    hash_map['\u2022'] = '%95';
    hash_map['\u2013'] = '%96';
    hash_map['\u2014'] = '%97';
    hash_map['\u02DC'] = '%98';
    hash_map['\u2122'] = '%99';
    hash_map['\u0161'] = '%9A';
    hash_map['\u203A'] = '%9B';
    hash_map['\u0153'] = '%9C';
    hash_map['\u009D'] = '%9D';
    hash_map['\u017E'] = '%9E';
    hash_map['\u0178'] = '%9F';
    hash_map['\u00C6'] = '%C3%86';
    hash_map['\u00D8'] = '%C3%98';
    hash_map['\u00C5'] = '%C3%85';
 
    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

function gup( name ) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return urldecode(results[1]);
}

