function toggleAdd() {
	document.getElementById('toggle_sameadds').style.display = 'none';
	
	if (document.getElementById('sameadds').checked == false) {
		document.getElementById('toggle_sameadds').style.display = 'block';	
	}
}

function changeColor(id,color) {
	if (color == 'red') {
		document.getElementById(id).style.color = '#cb0016';
	} else {
		document.getElementById(id).style.color = '#ffffff';
	}
}

function checkForm() {
	var s = true;
	if (!validateEmail(document.getElementById('ord_email').value,1,0)) {
		changeColor("ord_email_span","red");
		s = false;
	} else {	
		changeColor("ord_email_span","");
	}
	
	
	if (document.getElementById('ord_name').value == '') {
		changeColor("ord_name_span","red");
		s = false;
	} else {	
		changeColor("ord_name_span","");
	}
	
	
	if (document.getElementById('ord_phone').value == '') {
		changeColor("ord_phone_span","red");
		s = false;
	} else {	
		changeColor("ord_phone_span","");
	}
	
	if (document.getElementById('t1_order').selectedIndex == 0 && document.getElementById('t4_order').selectedIndex == 0 && document.getElementById('rtl_order').selectedIndex == 0) {
		changeColor("makett_termekek","red");
		s = false;
	} else {
		changeColor("makett_termekek","");
	}
	
	
	if (document.getElementById('ord_zip').value == '' || document.getElementById('ord_city').value == '') {
		changeColor("ord_zip_span","red");
		s = false;
	} else {	
		changeColor("ord_zip_span","");
	}
	
	
	
	if (document.getElementById('ord_street').value == '') {
		changeColor("ord_street_span","red");
		s = false;
	} else {	
		changeColor("ord_street_span","");
	}
	
	
	if (document.getElementById('sameadds').checked == false) {
		// szamlazasi mas, ott is kell ellenorzes
		if (document.getElementById('ord_name_bill').value == '') {
			changeColor("ord_name_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_name_bill_span","");
		}
		
		if (document.getElementById('ord_zip_bill').value == '' || document.getElementById('ord_city_bill').value == '') {
			changeColor("ord_city_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_city_bill_span","");
		}
		
		if (document.getElementById('ord_street_bill').value == '') {
			changeColor("ord_street_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_street_bill_span","");
		}
	}
	
	
	if (s) {	
		document.getElementById('orderform').submit();
	} else {
		return false;
	}
}









function checkFormCap() {
	var s = true;
	if (!validateEmail(document.getElementById('ord_email').value,1,0)) {
		changeColor("ord_email_span","red");
		s = false;
	} else {	
		changeColor("ord_email_span","");
	}
	
	
	if (document.getElementById('ord_name').value == '') {
		changeColor("ord_name_span","red");
		s = false;
	} else {	
		changeColor("ord_name_span","");
	}
	
	
	if (document.getElementById('ord_phone').value == '') {
		changeColor("ord_phone_span","red");
		s = false;
	} else {	
		changeColor("ord_phone_span","");
	}
	
	if (document.getElementById('t1_order').selectedIndex == 0) {
		changeColor("makett_termekek","red");
		s = false;
	} else {
		changeColor("makett_termekek","");
	}
	
	
	if (document.getElementById('ord_zip').value == '' || document.getElementById('ord_city').value == '') {
		changeColor("ord_zip_span","red");
		s = false;
	} else {	
		changeColor("ord_zip_span","");
	}
	
	
	
	if (document.getElementById('ord_street').value == '') {
		changeColor("ord_street_span","red");
		s = false;
	} else {	
		changeColor("ord_street_span","");
	}
	
	
	if (document.getElementById('sameadds').checked == false) {
		// szamlazasi mas, ott is kell ellenorzes
		if (document.getElementById('ord_name_bill').value == '') {
			changeColor("ord_name_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_name_bill_span","");
		}
		
		if (document.getElementById('ord_zip_bill').value == '' || document.getElementById('ord_city_bill').value == '') {
			changeColor("ord_city_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_city_bill_span","");
		}
		
		if (document.getElementById('ord_street_bill').value == '') {
			changeColor("ord_street_bill_span","red");
			s = false;
		} else {	
			changeColor("ord_street_bill_span","");
		}
	}
	
	
	if (s) {	
		document.getElementById('orderformcap').submit();
	} else {
		return false;
	}
}












function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}