// usage: format_zahl( number [, number]  [, bool]  )

function formatZahl(zahl, k, fix)
{
    if(!k) k = 0;
    var neu = '';
    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt( zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
    // Komma ermittlen
    var idx = zahl.indexOf('.');
    // fehlende Nullen einf?gen
    if(fix)
    {
         zahl += (idx == -1 ? '.' : '' )
         + f.toString().substring(1);
    }
    // Nachkommastellen ermittlen
    idx = zahl.indexOf('.');
    if( idx == -1) idx = zahl.length;
    else neu = ',' + zahl.substr(idx + 1, k);
 
    // Tausendertrennzeichen
    while(idx > 0)
    {
        if(idx - 3 > 0)
        neu = '.' + zahl.substring( idx - 3, idx) + neu;
        else
        neu = zahl.substring(0, idx) + neu;
        idx -= 3;
    }
    return neu;
}

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")



/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"




 function kommCheck() {
  if (document.bestellen.kommentar.value == "Hier hast Du Platz für Fragen, Anmerkungen und/oder Kommentare zu Deiner Bestellung!") {
   document.bestellen.kommentar.value = '';
  }
 }
 
 function gesamtbetrag(text,bestellsumme) {
 	ende = text.indexOf("€");
 	anfang = ende- 4;
 	versand = text.slice(anfang,ende);
 	versand = versand.replace(",",".");
 	versand = parseFloat(versand);
 	gesamt = versand + bestellsumme;
 	gesamt = formatZahl(gesamt,2,true);
	document.getElementById('gesamt').innerHTML = gesamt + ' &euro;';
	if (document.getElementById('gutschein').innerHTML !== '') {
		gutschein = parseFloat(document.getElementById('gutschein').innerHTML);
		gutscheinfloat = versand + bestellsumme - gutschein;
		gutscheingesamt = formatZahl(gutscheinfloat,2,true);
		gutscheindisplay = Math.abs(gutscheinfloat);
		gutscheindisplay = formatZahl(gutscheindisplay,2,true);
		document.getElementById('gutscheingesamt').innerHTML = gutscheindisplay;
		if (gutscheinfloat <= 0) {
			document.getElementById('gutscheintext').innerHTML = 'Restwert Deines Gutscheins:';
		} else {
			document.getElementById('gutscheintext').innerHTML = 'Gesamtbetrag nach Abzug Deines Gutscheins:';
		}
	}
}
 
 /***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=35

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",60)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
