
var MandatoryFields = new Array("category", "prodofinterest", "comments", "firstname", "lastname", "emailaddress", "confirmemailaddress", "phonenumber", "countryorigin");

var sem=1;
function popupWindow2() {
	var location = String(window.location);
	location = location.substr(location.lastIndexOf("/")+1,5);
	 
	var cc = location.split("_")[0];
	var ll = location.split("_")[1];

	if (cc == "de") {
		var MandatoryFields = new Array("category", "prodofinterest", "comments", "emailaddress", "confirmemailaddress", "countryorigin");
	}
	else {
		var MandatoryFields = new Array("category", "prodofinterest", "comments", "firstname", "lastname", "emailaddress", "confirmemailaddress", "phonenumber", "countryorigin");
	}
	
	return MandatoryFields;
}

MandatoryFields = popupWindow2();


function fillInfo()
{
var str = window.location.toString();
document.getElementById("formURL").value = str;
document.getElementById("countrycode").value = str.substring(str.lastIndexOf('/')+1,str.lastIndexOf('/')+3);
document.getElementById("languagecode").value = str.substring(str.lastIndexOf('/')+4,str.lastIndexOf('/')+6);
document.getElementById("submissiondate").value = Date();
if (str.lastIndexOf('opt=1') > 0) {
	document.getElementById("productsoption").value = "1";
}
else {
	if (str.lastIndexOf('opt=2') > 0) {
		document.getElementById("productsoption").value = "2";
	}
	else {
		document.getElementById("productsoption").value = "0";
	}
}
}

function switchForm() 
{
 var ccll = document.getElementById("countryloclist").value;
 window.location = ccll + ".html"; 
}

function validEmail(id) 
{sem=1;
   var str = document.getElementById(id).value;
   if ((str.indexOf(".") > 2) && (str.indexOf("@") > 0)) {
	  document.getElementById("error_" + id).className = "field";
	  document.getElementById("emailNotValid").className = "invisible";
	  sem=1;
	
	}
	else {
	  document.getElementById("error_" + id).className = "error";
	  document.getElementById("emailNotValid").className = "visible";
	  sem=0;

	}
}

function emailMatch()
{
   if (document.getElementById("emailaddress").value != document.getElementById("confirmemailaddress").value) {
     document.getElementById("error_emailaddress").className = "error";
     document.getElementById("error_confirmemailaddress").className = "error";
     document.getElementById("emailNoMatch").className = "visible";
	
     return false;  
   }
  else {
     document.getElementById("error_emailaddress").className = "field";
     document.getElementById("error_confirmemailaddress").className = "field";
     document.getElementById("emailNoMatch").className = "invisible";
	 return true;
   }
}

function processFormFields() 
{ if(sem==0)
{
	errorsFound=true;
	 document.getElementById("emailNotValid").className = "visible";
	 return false;
}
else
{
  if (emailMatch()){	 
    var errorsFound = false;
    for (element in MandatoryFields)
      if (document.getElementById(MandatoryFields[element]).value == "" || document.getElementById(MandatoryFields[element]).value =="select") {
	    document.getElementById("error_" + MandatoryFields[element]).className = "error";
	    errorsFound = true;
	   }
      else {
        document.getElementById("error_" + MandatoryFields[element]).className = "field";
	   }
  
	if (errorsFound) {
      document.getElementById("wrongInfoText").className = "visible";
	  return false;
	  }
	else {
      document.getElementById("wrongInfoText").className = "invisible";
	  return true;
	  }
  }
  	else 
  return false;
  return true;
}
}


function popupWindow(url,w,h)
{
 window.open(url,"",'width=450px,height=300px,top=200px,left=200px,menubar=no,location=no,resizable=no,scrollbars=no,status=no');
}