//id einblenden

function show(what) {
		target = document.getElementById(what);
		if (target) {
		target.style.display = 'block';
		} else {
		what.lastChild.style.display = 'block';
		what.style.zIndex = '90';
		}
	}
	
function hide(what) {
		target = document.getElementById(what);
		if (target) {
		target.style.display = 'none';
		} else {
		what.lastChild.style.display = 'none';
		what.style.zIndex = '1';
		}
	}


function goto(where) {
 	var URL = document.forms['language'].selectlanguage.options[document.forms['language'].selectlanguage.selectedIndex].value;
	window.location.href = URL; 
}


function changeLink(what) {
  var value = document.getElementById(what).href;
  var target = document.getElementById(what);
  var up = value.split('show');
  var there = up.length;
    //alert (""+there+"");
	if (there >= "2") {
	that=value.replace(/show/g, "hide");
	target.className= 'up';
	}
	else {
	that=value.replace(/hide/g, "show");
	target.className= '';
	}
	document.getElementById(what).href = ''+that+'';
}



//id langsam einblenden

function fade (element, from, to, current) {
  if (typeof current == 'undefined') {
    current = from;
  }
  if (typeof element.style.opacity != 'undefined') {
    element.style.opacity = current;
  }
  else if (typeof element.style.filter != 'undefined') {
    element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (current * 100) + ')';
  }
  if (from > to) {
    current -= 0.1;
    current = Math.round(current * 100) / 100;
    if (current >= to) {
      setTimeout(function () { fade(element, from, to, current); }, 40);
    }
  }
  else {
    current += 0.1;
    current = Math.round(current * 100) / 100;
    if (current <= to) {
      setTimeout(function () { fade(element, from, to, current); }, 40);
    }
  }
}

//animation


function animate() {
	document.getElementById('fbid').className = 'nix';
	hide('fbidtext');
	hide('fbidimg');
	document.getElementById('callerid').className = 'farbig';
	show('calleridimg');
	if (document.getElementById('calleridtext').style.display == 'none') { //not first load
		setTimeout(function () { 
							  show('calleridtext');
							  fade(document.getElementById('calleridtext'), 0.1, 1 ); 
							  }, 2000);
	}
	setTimeout(function () { 
						 document.getElementById('callerid').className = 'nix';
						 hide('calleridtext');
						 hide('calleridimg');
						 document.getElementById('autosuggest').className = 'farbig';
						 show('autosuggestimg');
						 setTimeout(function () { 
											  show('autosuggesttext');
											  fade(document.getElementById('autosuggesttext'), 0.1, 1 ); 
											  }, 2000);
						 
						 setTimeout(function () { 
						 document.getElementById('autosuggest').className = 'nix';
						 hide('autosuggesttext');
						 hide('autosuggestimg');
						 document.getElementById('fbid').className = 'farbig';
						 show('fbidimg');
						 					  setTimeout(function () { 
											  show('fbidtext');
											  fade(document.getElementById('fbidtext'), 0.1, 1 ); 
											  }, 2000);
						 }, 5000);
						 
						 
						 }, 5000);


}



function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

//id langsam aufklappen

var i = 100; 
function scroll() 
{ 
 if(i > 80) 
  { 
   document.all.popbox.style.top = i; 
   i = i - 1 
   aktiv = window.setTimeout("scroll()",100); 
  } 
} 

// 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&uuml;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;
}


function numeralsOnly(evt) {
 evt = (evt) ? evt : event;
 var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
 if (charCode > 31 && (charCode < 48 || charCode > 57)) {
	 //alert("Enter numerals only in this field.");
     return false;
 }
 return true;
}


//rechenautomatik

var result;

function calc(src) {
		amount = src.value;
		revenue(amount);
	}

function revenue(amount) {

	if (amount == undefined) { amount = eval('document.calculator.amount.value'); }
	amount=amount.replace(/\./g, "");
	
	result = amount * 25;


target = eval('document.calculator.amount');
target.value = formatZahl(amount);

target = eval('document.calculator.result');
result = formatZahl(result);

setTimeout(function () { 
					 document.getElementById('result').innerHTML =  ''+result+' &#8364;';
					 }, 2000)

}
