function changeImage(bild) {
	bigphoto.src = bild;
}
function changeImageZufall(bild,zufall) {
	document[''+zufall+''].src = bild;
}
function mail(part1,part2,part3) {
window.open('mailto:'+part1+'&#64;'+part2+'.'+part3,'');
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
function format(pp)
{
var p0;
var p1;
var intLength;
intLength = String(pp).length;
p0=String(pp).substr(0,intLength-2);
p1=String(pp).substr(intLength-2,intLength);
  return(p0+','+p1);
}
function formatiere(pp)
{
  p=String(pp).split(",");
  if (!p[1]) p[1]='00';
  if (p[1].length==1) p[1]=p[1]+'0';
  p[1]=p[1].substr(0,2);
  //alert(p[0]+''+p[1]);
  if (p[0] == "0"){
    return(p[1]);
  } else {
  return(p[0]+''+p[1]);
  }
}

function insert_next(feldname,auswahl_wert,updatefeld,from)
{
var feldname;
var updatefeld;
if (document.kalkulator1[feldname].value != "0" && document.kalkulator1[feldname].value != "") {
document.kalkulator1[updatefeld].selectedIndex = document.kalkulator1[from].selectedIndex;
insert(updatefeld,document.kalkulator1[updatefeld].value,'');
} else {
insert(updatefeld,' ','');
}
}
function update_kondition(feldname,auswahl_wert,updatefeld,konditionfeld,konditionwert,ergebnis)
{
var feldname;
var updatefeld;
var malerg;
var mal_1;
var mal_2;
var ergebnis;

if(konditionwert == "x") {

if (document.kalkulator1[feldname].value != "" && document.kalkulator1[feldname].value != "0" && document.kalkulator1[feldname].value != "inklusive" && document.kalkulator1[updatefeld].value != "inklusive" && document.kalkulator1[updatefeld].value != "" && document.kalkulator1[updatefeld].value != "0") {
mal_1 = parseInt(document.kalkulator1[updatefeld].value);
mal_2 = parseInt(formatiere(document.kalkulator1[feldname].value));
malerg = mal_1*mal_2;

malerg = format(malerg);
insert(updatefeld,malerg,ergebnis);
} else {
if (document.kalkulator1[updatefeld].value == "inklusive") {
insert(updatefeld,'inklusive',ergebnis);
} else {
insert(updatefeld,' ',ergebnis);
}
}
} else {

if (document.kalkulator1[konditionfeld].value != konditionwert) {
document.kalkulator1[updatefeld].selectedIndex = document.kalkulator1[feldname].selectedIndex;
insert(updatefeld,document.kalkulator1[updatefeld].value,ergebnis);
} else {
insert(updatefeld,' ',ergebnis);
}

}

}
	
function update(feldname,auswahl_wert,updatefeld,ergebnis)
{
var feldname;
var ergebnis;
var updatefeld;
document.kalkulator1[updatefeld].selectedIndex = document.kalkulator1[feldname].selectedIndex;
insert(updatefeld,document.kalkulator1[updatefeld].value,ergebnis);
}
function insert(feldname,auswahl_wert,ergebnis)
{
var ergebnis;
var feldname;
feldname = feldname+'_wert';
if (auswahl_wert == "0") {
auswahl_wert = " ";
}
if (ergebnis == ""){
document.kalkulator1[feldname].value=auswahl_wert;
} else {
document.kalkulator1[ergebnis].value=auswahl_wert;
}
ausrechnen(document.kalkulator1['kriterium_anzahl'].value,document.kalkulator1['produkt_anzahl'].value);
}
function ausrechnen(kriterium,wahl)
{
var summe;
summe = null;
var var_kriterium;
var_kriterium = new Array();
var temp;
var error;

for(i = 0; i < kriterium; i++)
{
temp = "kriterium_"+i+"_wert";
if (document.kalkulator1[temp].value == "") {
}
if (i == "0") {
x=document.kalkulator1[temp].value;
if (x != "nV" && x != "nach_Verbrauch" && x != "inklusive" && x != "nicht_erlaubt"){
summe = parseInt(formatiere(document.kalkulator1[temp].value));
} else {
summe = 0;
}
} else {
x=document.kalkulator1[temp].value;
if (x != "nV" && x != "nach_Verbrauch" && x != "inklusive" && x != "nicht_erlaubt"){
summe += parseInt(formatiere(document.kalkulator1[temp].value));
}
}
}
if (error != "ja") {
for(i = 0; i < wahl; i++)
{
temp_wahl = "wahl_"+i+"_wert";
if (document.kalkulator1[temp_wahl].value == "") {
}
if (summe == "") {
y=document.kalkulator1[temp_wahl].value;
if (y != "nV" && y != "nach_Verbrauch" && y != "inklusive" && y != "nicht_erlaubt"){
summe = parseInt(formatiere(document.kalkulator1[temp_wahl].value));
} else {
summe = 0;
}
} else {
y=document.kalkulator1[temp_wahl].value;
if (y != "nV" && y != "nach_Verbrauch" && y != "inklusive" && y != "nicht_erlaubt"){
summe += parseInt(formatiere(document.kalkulator1[temp_wahl].value));
}
}
}
}
if (error != "ja") {
if (format(summe) == ",0") {
document.kalkulator1.summe.value="0,00";
} else {
document.kalkulator1.summe.value=format(summe);
}
}
}
function multi_choose(feldname,auswahl_wert,updatefeld,konditionfeld,ergebnis)
{
//////bei feldname wird ausgewählt, diese auwahl nummer wird auf das updatefeld angewandt, welches dann mit dem konditionsfeld auswahl wert au multipliziert wird///////
var feldname;
var updatefeld;
var malerg;
var mal_1;
var mal_2;
var ergebnis;

document.kalkulator1[updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']'].selectedIndex = auswahl_wert;
insert(updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']',document.kalkulator1[updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']'].value,ergebnis);
}
function multi(feldname,auswahl_wert,updatefeld,konditionfeld,ergebnis)
{
//////bei feldname wird ausgewählt, diese auwahl nummer wird auf das updatefeld angewandt, welches dann mit dem konditionsfeld auswahl wert au multipliziert wird///////
var feldname;
var updatefeld;
var malerg;
var mal_1;
var mal_2;
alert('updatefeld '+updatefeld);
alert('konditionfeld '+konditionfeld);
document.kalkulator1[updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']'].selectedIndex = auswahl_wert;
update_kondition(updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']',document.kalkulator1[updatefeld+'['+document.kalkulator1[konditionfeld].selectedIndex+']'].value,konditionfeld,document.kalkulator1[konditionfeld].value,'x',ergebnis);
}
function erwachsene(feldname) {
var feldname;

if (feldname == "wahl_0") {

if (document.kalkulator1.wahl_0.selectedIndex=="0") {
document.kalkulator1.wahl_1__1.style.visibility='hidden';
document.kalkulator1.wahl_1__2.style.visibility='hidden';
document.kalkulator1.wahl_1.style.visibility='visible';
document.kalkulator1.wahl_1__1.style.width='0px';
document.kalkulator1.wahl_1__1.style.height='0px';
document.kalkulator1.wahl_1__2.style.width='0px';
document.kalkulator1.wahl_1__2.style.height='0px'
document.kalkulator1.wahl_1.style.width='97px';
document.kalkulator1.wahl_1.style.height='20px';
document.kalkulator1.wahl_1.style.position='absolute';
document.kalkulator1.wahl_1.style.left='147px';
document.kalkulator1.wahl_1.style.top='154px';
insert(feldname,document.kalkulator1['wahl_1'].value,'wahl_1_wert');
} else if (document.kalkulator1.wahl_0.selectedIndex=="1") {
document.kalkulator1.wahl_1.style.visibility='hidden';
document.kalkulator1.wahl_1__2.style.visibility='hidden';
document.kalkulator1.wahl_1__1.style.visibility='visible';
document.kalkulator1.wahl_1__2.style.width='0px';
document.kalkulator1.wahl_1__2.style.height='0px';
document.kalkulator1.wahl_1.style.width='0px';
document.kalkulator1.wahl_1.style.height='0px'
document.kalkulator1.wahl_1__1.style.width='97px';
document.kalkulator1.wahl_1__1.style.height='20px';
document.kalkulator1.wahl_1__1.style.position='absolute';
document.kalkulator1.wahl_1__1.style.left='147px';
document.kalkulator1.wahl_1__1.style.top='154px';
insert(feldname,document.kalkulator1['wahl_1__1'].value,'wahl_1_wert');
} else {
document.kalkulator1.wahl_1.style.visibility='hidden';
document.kalkulator1.wahl_1__1.style.visibility='hidden';
document.kalkulator1.wahl_1__2.style.visibility='visible';
document.kalkulator1.wahl_1__1.style.width='0px';
document.kalkulator1.wahl_1__1.style.height='0px';
document.kalkulator1.wahl_1.style.width='0px';
document.kalkulator1.wahl_1.style.height='0px';
document.kalkulator1.wahl_1__2.style.width='97px';
document.kalkulator1.wahl_1__2.style.height='20px';
document.kalkulator1.wahl_1__2.style.position='absolute';
document.kalkulator1.wahl_1__2.style.left='147px';
document.kalkulator1.wahl_1__2.style.top='154px';
insert(feldname,document.kalkulator1['wahl_1__2'].value,'wahl_1_wert');
}

} else if (feldname == "wahl_1") {

document.kalkulator1.wahl_1__1.selectedIndex=document.kalkulator1.wahl_1.selectedIndex;
document.kalkulator1.wahl_1__2.selectedIndex=document.kalkulator1.wahl_1.selectedIndex;

} else if (feldname == "wahl_1__1") {

document.kalkulator1.wahl_1.selectedIndex=document.kalkulator1.wahl_1__1.selectedIndex;
document.kalkulator1.wahl_1__2.selectedIndex=document.kalkulator1.wahl_1__1.selectedIndex;

}  else if (feldname == "wahl_1__2") {

document.kalkulator1.wahl_1__1.selectedIndex=document.kalkulator1.wahl_1__2.selectedIndex;
document.kalkulator1.wahl_1.selectedIndex=document.kalkulator1.wahl_1__2.selectedIndex;

}  

}
/////////////
function count () 
{
 wert = document.getElementsByName("smstext")[0].length;
 var anz=0;
 var laenge=0;
 var s;
 var aktwert = document.getElementsByName("smstext")[0].value;
 
 if (!wert) 
  {
   wert = 142;
}
 
 for (var i=0; i<aktwert.length; i++) 
  {
     if (anz>(wert-1)) 
      {
       break; 
      }
     anz++;
     laenge = i+1;
  }
 
 if (aktwert.length> laenge) 
  {
   document.getElementsByName("smstext")[0].value = aktwert.substring(0,laenge);
  }
 document.all.zeichen.value = wert-anz;
}

function login(url) {
var pwd;
if(document.all['pwd'].value==document.all['pwd_value'].value){
document.location.href=url;
} else {
alert('Falsches Passwort');
} 
}
function login_window(url) {
var pwd;
if(document.all['pwd'].value==document.all['pwd_value'].value){
window.open(url,'communicator','resizable=yes,width=760,height=420');
} else {
alert('Falsches Passwort');
} 
}
function setCookie( name, value )
{
	// '=' is identifier between name and value for real cookie.
	document.cookie = name + '=' + value
}
function getCookie( name, value )
{
	var flag = document.cookie.indexOf( name+'=' )
	if( flag != -1 ) {
		flag += name.length + 1
		end = document.cookie.indexOf( "; ", flag )
		if( end == -1 ) end = document.cookie.length
		return document.cookie.substring( flag, end )
	}
}

function setSubCookie( uName, name, value )
{
	uValue = getCookie( uName )
	if( uValue ) {
		// ':' is breaker for sub cookie each
		uCookies = uValue.split( ':' )
		var found = -1 // whether sub-cookie for the name is present
		for( c = 0; c < uCookies.length; c++ )
		{
			// '-' is identifier between name and value for sub cookie.
			t = uCookies[c].split( '-' )
			tName = t[0]
			tValue = t[1]
			if( tName == name ) {
				found = 1
				tValue = value
				t[1] = tValue
				uCookies[c] = t.join( '-' )
			}
		}
		if( found == -1 )
			uCookies[uCookies.length] = name + '-' + value
		uValue = uCookies.join( ':' )
	} else {
		uValue = name + '-' + value
	}
	// update real cookie
	setCookie( uName, uValue )
}
function getSubCookie( uName, name )
{
	uValue = getCookie( uName )

	var flag = uValue.indexOf( name+'-' )
	if( flag != -1 ) {
		flag += name.length + 1
		end = uValue.indexOf( ':', flag )
		if( end == -1 ) end = uValue.length
		return uValue.substring( flag, end )
	}
}
