var js_debug = 0;

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();
}

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.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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_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_controlSound(x, _sndObj, sndFile) { //v3.0
  var i, method = "", sndObj = eval(_sndObj);
  if (sndObj != null) {
    if (navigator.appName == 'Netscape') method = "play";
    else {
      if (window.MM_WMP == null) {
        window.MM_WMP = false;
        for(i in sndObj) if (i == "ActiveMovie") {
          window.MM_WMP = true; break;
      } }
      if (window.MM_WMP) method = "play";
      else if (sndObj.FileName) method = "run";
  } }
  if (method) eval(_sndObj+"."+method+"()");
  else window.location = sndFile;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Play(url) {
	window.open(url, "Play", "dependent=yes, width=1, height=1, location=no, menubar=no, scrollbars=no, resizable=no, toolbar=no, status=no");
}
function Cart(Id) {
	url = "./cart_add.php?id_item=" + Id;
	if(js_debug != 0) {
		alert(url);
	} else {
		NewWin(url, "cart");
	}
}
function NewWin(url, name) {
	newwin = window.open(url, name, "dependent=yes, width=705, height=558, location=no, menubar=no, scrollbars=yes, resizable=yes, toolbar=no, status=no");
	newwin.focus();
}
function UserData() {
	url = "./";
	if(js_debug != 0) {
		alert(url);
	} else {
		cart = window.open(url, "cart", "dependent=yes, width=705, height=550, location=no, menubar=no, scrollbars=auto, resizable=yes, toolbar=no, status=no");
		cart.focus();
	}
}
function Check_Order(form) {
	return true;
}
function Check_Contact(form) {
	var illegalChars = /[\W_]/;
	var email_value = form.email.value;

	//email format testen
	if(email_value == "") {
		alert("please enter a return address.");
		form.email.focus();
		return false;
	}		
	if(email_value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert("please enter a valid return address.");
		form.email.select();
		form.email.focus();
		return false;
	}
	if(form.message.value == "") {
		alert("please enter a message.");
		form.message.focus();
		return false;
	}
	return true;
}
function Check_UserData(form) {
	var illegalChars = /[\W_]/;
	var email_value = form.email.value;

	//email format testen
	if(email_value == "") {
		alert("please input your email address.");
		form.email.focus();
		return false;
	}		
	if(email_value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert("please enter a valid email address.");
		form.email.select();
		form.email.focus();
		return false;
	}
	if(form.name.value == "") {
		alert("please input your last name.");
		form.name.focus();
		return false;
	}		
	if(form.vorname.value == "") {
		alert("please input your first name.");
		form.vorname.focus();
		return false;
	}		
	if(form.street.value == "") {
		alert("please input your address [street and number].");
		form.street.focus();
		return false;
	}		
	if(form.code.value == "") {
		alert("please input your address [postal code].");
		form.code.focus();
		return false;
	}		
	if(form.city.value == "") {
		alert("please input your address [city].");
		form.city.focus();
		return false;
	}		
	return true;
}
function Check_Password(form) {
	if(form.pwd_old.value == "" || form.pwd_new.value == "") {
		alert("please enter your old and desired new password.");
		form.pwd_old.focus();
		return false;
	}
	if(form.pwd_old.value.length < 4) {
		alert("your old password had at least 4 letters.");
		form.pwd_old.select();
		form.pwd_old.focus();
		return false;
	}
	if(form.pwd_new.value.length < 4) {
		alert("please enter a new password having at least 4 letters.");
		form.pwd_new.select();
		form.pwd_new.focus();
		return false;
	}
	return true;	
}
function Check_Future(form) {
	yes = confirm("sure ?");
	if(yes == false) { return false; } else { return true; }
}

function Sum1() {
	var sum_tmp = 0;
	var sum = 0;
	var i=0;
	while(i<=document.cart_show.elements.length) {
		if(document.cart_show.elements[i].name == document.cart_show.sum.name) {
			break;			
		} else {	
			if(isNaN(document.cart_show.elements[(i+1)].value)) {
				alert("please insert a number.");
				document.cart_show.elements[(i+1)].select();
				document.cart_show.elements[(i+1)].focus();
				break;
				return false;
			} else {	
				sum_tmp = document.cart_show.elements[i].value * document.cart_show.elements[(i+1)].value;  
				sum += sum_tmp;
				document.cart_show.elements[(i+2)].value = Nachkomma2(sum_tmp);
			}
		}	
		i++; i++; i++;
	}
	document.cart_show.sum.value = Nachkomma2(sum);
	return true;
}

function Nachkomma2(number) {	      
  number = Math.round( number * Math.pow(10, 2) ) / Math.pow(10, 2);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < 2){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= 2; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  return arr_int[0] + "." + arr_int[1];
}
function Check_Login(form, only_email) {
	var illegalChars = /[\W_]/;
	var email_value = form.email_login.value;
	var pwd_value = form.pwd_login.value

	//email format testen
	if(email_value == "") {
		alert("please enter your email address.");
		form.email_login.focus();
		return false;
	}		
	if(email_value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert("please enter a valid email address.");
		form.email_login.select();
		form.email_login.focus();
		return false;
	}
	if(only_email == 0) {
		if(pwd_value == "") {
			alert("please enter a password - without you won't get in.");
			form.pwd_login.focus();
			return false;
		}
		if(pwd_value.length < 4) {
			alert("please enter a password having at least 4 letters.");
			form.pwd_login.select();
			form.pwd_login.focus();
			return false;
		}
		if(illegalChars.test(pwd_value)) {
			alert("please use only letters and numbers for your password.");
			form.pwd_login.select();
			form.pwd_login.focus();
			return false;
		}	
	} else {
		document.forms.login.pwdlost.value = "pwdlost";
	}
	return true;

}
function Check_UserData(form) {
	var illegalChars = /[\W_]/;
	var email_value = form.email.value;

	//email format testen
	if(email_value == "") {
		alert("please input your email address.");
		form.email.focus();
		return false;
	}		
	if(email_value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		alert("please enter a valid email address.");
		form.email.select();
		form.email.focus();
		return false;
	}
	if(form.name.value == "") {
		alert("please input your last name.");
		form.name.focus();
		return false;
	}		
	if(form.vorname.value == "") {
		alert("please input your first name.");
		form.vorname.focus();
		return false;
	}		
	if(form.street.value == "") {
		alert("please input your address [street and number].");
		form.street.focus();
		return false;
	}		
	if(form.code.value == "") {
		alert("please input your address [postal code].");
		form.code.focus();
		return false;
	}		
	if(form.city.value == "") {
		alert("please input your address [city].");
		form.city.focus();
		return false;
	}		
	return true;
}
function Check_Password_New(form) {
	// alert(form.password_1.value + " --- " + form.password_2.value);

	if(form.password_1.value == "" || form.password_2.value == "") {
		alert("please enter password twice.");
		form.password_1.focus();
		return false;
	}
	if(form.password_1.value != form.password_2.value) {
		alert("passwords differ - please enter password twice.");
		form.password_2.select();
		form.password_2.focus();
		return false;
	}
	if(form.password_1.value.length < 4) {
		alert("please enter a password having at least 4 letters.");
		form.password_1.select();
		form.password_1.focus();
		return false;
	}
	if(form.password_2.length < 4) {
		alert("please enter a password having at least 4 letters.");
		form.password_2.select();
		form.password_2.focus();
		return false;
	}
	return true;	
}

function Down(feld) {
	alert(feld);
	var tmp = feld.value;
	tmp--;
	if(tmp < 0) tmp = 0;
	feld.value = tmp;
}

function Up(feld) {
	alert(feld);
	var tmp = feld.value;
	tmp++;
	feld.value = tmp;
}

function Paging(form) {
	// alert(form);
	window.location.href = form.options[form.options.selectedIndex].value;
}