// JavaScript Document
function go_URL(fn){
  url = document.fn.value;
  window.location.href = url;  
}

function popup(u){
	popup_window = window.open(u,"popup","left=0,top=0");
	p = popup_window.focus();
}
	

function confirm_check(url_del,text){
  check = window.confirm(text);
  if (check) window.location.href = url_del;
}

function build_url_n(u){
	type = document.filter.type_.value;
	engine = document.filter.engine.value;
	url = u + "&type_=" + type + "&engine=" + engine;
	window.location.href = url;
}

function build_url(u){
	make = document.filter.make.value;
	engine = document.filter.engine.value;
	price = document.filter.price.value;
	category = document.filter.category.value;
	types = document.filter.types.value;
	url = u + "&make=" + make + "&engine=" + engine + "&price=" + price + "&category=" + category + "&types=" + types;
	window.location.href = url;
}

function del_text(what){
  document.getElementById(what).value = "";
}

function check_input(id,f){
  check = true;
  for (var i = 0; i < document.getElementById(id).length; i++){
	  if (document.forms[f].elements[i].value == ""){
		  check = false;
	  }
  }
  if (!check) alert("Bitte alle Formularfelder ausfüllen!");
  return check;
}

function enable_field(f,id,t){
	if (document.forms[f].elements[id].checked){
		document.getElementById(t).style.display = "";
	}
	else {
		document.getElementById(t).style.display = "none";
	}
}

function check_browse(f){
  check = true;
  if (document.forms[f].elements[0].value == ""){
		  check = false;
	
  }
  if (!check) alert("Bitte eine Zip-Datei auswählen!");
  return check;
}

function check_pw(fn){
  if (document.forms[fn].pass.value == document.forms[fn].re_pass.value){
    if (document.forms[fn].pass.value.length >= 6) return true;
	else alert("Das Passwort muss mindestens 6 Zeichen haben");
  }
  else{
    alert("Die Passwörter stimmen nicht überein");
	return false;
  }
  return false;
}

function checkMail(f)
{
	var x = document.getElementById(f).value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		email_check = true;
	}
	else {
		email_check = false;
		alert("Keine gültige Emailadresse");
	}
	return email_check;
}

function checkifNewsletter(check,email){
	  if (document.getElementById(check).checked){
		  newsletter_yes = checkMail(email);
	  } 
	  else {
		  newsletter_yes = true;
	  } 
	  return newsletter_yes;
}

function exch_image(i1, i2){
	document.getElementById(i1).src = document.getElementById(i2).src;
}

function print_details(u,index){
	p_window = window.open("actions/" + u + "print.php?index=" + index, "Print", "width=650,height=600,left=50,top=100");
	p = window.p_window.focus();
}

function print_coupon(pic){
	p_window = window.open("actions/coupon_print.php?pic=" + pic, "Print", "width=650,height=600,left=50,top=100");
	p = window.p_window.focus();
}

function show_more(id, id_more){   
   if (document.getElementById(id_more).firstChild.data == "+ mehr"){
	  document.getElementById(id_more).firstChild.data = "- weniger";                    
   } 
   else {           
     document.getElementById(id_more).firstChild.data = "+ mehr";                  
   }  
   if (document.getElementById(id).style.display == "none"){
     document.getElementById(id).style.display  = "";
   }
   else {
	 document.getElementById(id).style.display  = "none";
   }
}          

