function primeraCombinacio(lpar, l_id ){
	var aux=l_id.substring(0,l_id.length-1);
	if(document.getElementById(aux+"b").disabled==true){	//accionar la resta de  desplagables
		document.getElementById(aux+"b").disabled=false;
		//alert("Rate_per_Source_Word"+l_id.substring(l_id.length-2,l_id.length-1));
		document.getElementById("Rate_per_Source_Word"+l_id.substring(l_id.length-2,l_id.length-1)).disabled=false;
		document.getElementById("Rate"+l_id.substring(l_id.length-2,l_id.length-1)).disabled=false;
		//document.getElementById("Rateb"+l_id.substring(l_id.length-2,l_id.length-1)).disabled=false;
		}
	if(l_id.substring(l_id.length-1,l_id.length)=="a"){
		setAllNull(aux+"b");
		setSelectValorsInicials(aux+"b",l_id);
		for (var index=0; index<document.getElementById(aux+"b").options.length;index++ ){
			if(document.getElementById(aux+"b").options[index].text==lpar){
				document.getElementById(aux+"b").remove(index);
				}
			/*if(){
				}	
				*/
			//alert(document.getElementById(aux+"b").options[index].text);	
			}
		}
	if(l_id.substring(l_id.length-1,l_id.length)=="b"){
		addParellaIdiomes(aux);
		/*setAllNull(aux+"a");
		setSelectValorsInicials(aux+"a");
		for (var index=0; index<document.getElementById(aux+"a").options.length;index++ ){
			if(document.getElementById(aux+"a").options[index].text==lpar){
				document.getElementById(aux+"a").remove(index);
				}
			//alert(document.getElementById(aux+"b").options[index].text);	
			}
			*/
		}
	//lpar.options[selectedIndex].text
	}//fi primeraCombinacio
			  
//id del tag seleg l_idSelect
function setSelectValorsInicials(l_idSelect,l_id){
	addItem(l_idSelect,"...Languages...",l_id);
	addItem(l_idSelect,"Bulgarian",l_id);
	addItem(l_idSelect,"Catalan",l_id);
	addItem(l_idSelect,"Chinese (Simplified)",l_id);
	addItem(l_idSelect,"Chinese (Traditional)",l_id);
	addItem(l_idSelect,"Danish",l_id);
	addItem(l_idSelect,"Dutch",l_id);
	addItem(l_idSelect,"English (Australia / NZ)",l_id);
	addItem(l_idSelect,"English (UK)",l_id);
	addItem(l_idSelect,"English (US)",l_id);
	addItem(l_idSelect,"Finnish",l_id);
	addItem(l_idSelect,"French (Canada)",l_id);
	addItem(l_idSelect,"French (France)",l_id);
	addItem(l_idSelect,"German",l_id);
	addItem(l_idSelect,"Greek",l_id);
	addItem(l_idSelect,"Italian",l_id);
	addItem(l_idSelect,"Japanese",l_id);
	addItem(l_idSelect,"Polish",l_id);
	addItem(l_idSelect,"Portuguese (Brazil)",l_id);
	addItem(l_idSelect,"Portuguese (Portugal)",l_id);
	addItem(l_idSelect,"Spanish (Latin America) \b              \b ",l_id);
	addItem(l_idSelect,"Spanish (Spain)",l_id);
	addItem(l_idSelect,"Swedish",l_id);//*/
}//Fi setSelectValorsInicials

function addItem(l_item,l_text,l_id){
	itemNou = document.createElement('option');
	itemNou.text = l_text;
	itemNou.value = l_text;
	if((
		(parellaIdiomes1[0]==document.getElementById(l_id).value) && parellaIdiomes1[1]==l_text)||
		((parellaIdiomes2[0]==document.getElementById(l_id).value) && parellaIdiomes2[1]==l_text)||
		((parellaIdiomes3[0]==document.getElementById(l_id).value) && parellaIdiomes3[1]==l_text)||
		((parellaIdiomes4[0]==document.getElementById(l_id).value) && parellaIdiomes4[1]==l_text)||
		((parellaIdiomes1[1]==document.getElementById(l_id).value) && parellaIdiomes1[0]==l_text)||
		((parellaIdiomes2[1]==document.getElementById(l_id).value) && parellaIdiomes2[0]==l_text)||
		((parellaIdiomes3[1]==document.getElementById(l_id).value) && parellaIdiomes3[0]==l_text)||
		((parellaIdiomes4[1]==document.getElementById(l_id).value) && parellaIdiomes4[0]==l_text)
		){
		//alert(parellaIdiomes1[1]);
		}
	else{
		try{
			document.getElementById(l_item).add(itemNou,null);//*/
			}
		catch(ex) {
			document.getElementById(l_item).add(itemNou);//*/
			}
		}
	}//fi addItem
	
function setAllNull(l_idSelect){
	while(document.getElementById(l_idSelect).options.length>0){
		document.getElementById(l_idSelect).remove(0)!=null
		}
	}//Fi setSelectNull

var parellaIdiomes1 = new Array(2);
var parellaIdiomes2 = new Array(2);
var parellaIdiomes3 = new Array(2);
var parellaIdiomes4 = new Array(2);

function addParellaIdiomes(l_aux){
	if(l_aux.substring(l_aux.length-1,l_aux.length)==1){
		//alert("1");
		parellaIdiomes1[0] = document.getElementById(l_aux+"a").value;
		parellaIdiomes1[1] = document.getElementById(l_aux+"b").value;
		}
	if(l_aux.substring(l_aux.length-1,l_aux.length)==2){
		//alert("2");
		parellaIdiomes2[0] = document.getElementById(l_aux+"a").value;
		parellaIdiomes2[1] = document.getElementById(l_aux+"b").value;
		}
	if(l_aux.substring(l_aux.length-1,l_aux.length)==3){
		//alert("3");
		parellaIdiomes3[0] = document.getElementById(l_aux+"a").value;
		parellaIdiomes3[1] = document.getElementById(l_aux+"b").value;
		}
	if(l_aux.substring(l_aux.length-1,l_aux.length)==4){
		//alert("4");
		parellaIdiomes4[0] = document.getElementById(l_aux+"a").value;
		parellaIdiomes4[1] = document.getElementById(l_aux+"b").value;
		}
	}//Fi addParellaIdiomes

function afegirTraduccions(){
	if(document.getElementById('Combinations2').style.display='none'){
		document.getElementById('Combinations2').style.display='inline';
		}
	if(document.getElementById('Combinations3').style.display='none'){
		document.getElementById('Combinations3').style.display='inline';
		}
	if(document.getElementById('Combinations4').style.display='none'){
		document.getElementById('Combinations4').style.display='inline';
		}
	}//Fi afegirTraduccions
	
	
	
	




	
function emailConsistency(){
	if(document.getElementById('Email2').value == document.getElementById('Email').value) return true;
	return false;
	}

function emailFormat(){
	var address = document.getElementById('Email').value;
	if ((address.indexOf("@") != -1) && (address.indexOf(".")!= -1) && (address.length>5)) return true;
	
	return false;
	}


function tool(){
	
	if(document.getElementById('tool').style.display=='inline' ){
		if(!document.getElementById("CAT_tools_yes").checked)
		document.getElementById('tool').style.display='none';
		}
	else{
		if(document.getElementById("CAT_tools_yes").checked)
		document.getElementById('tool').style.display='inline';
		}
	}//Fi tool
	
	
///////////////////////////////////////////////////////////////////////////////////////////

function comprovarValors(){
	

	var error = false;
	
	var msg_base = "The form cannot be sent, as the data is incomplete:";
	var error_msg = msg_base + "";
	var bullet = "- ";

	var msg_Mandatory_Title = "You must specify a title";
	var msg_Mandatory_FirstName = "You must specify your first name";
	var msg_Mandatory_LastName = "You must specify your last name";
	var msg_Mandatory_Country = "You must specify your country of residence";
	var msg_Mandatory_NativeLang = "You must indicate which is your native language or native languages if more than one.";
	var msg_Mandatory_SourceLanguage = "You have to specify a source language in the \'From\' field";
	var msg_Mandatory_TargetLanguage = "You have to specify a target language in the \'into\' field";
	var msg_Mandatory_Combination = "You must specify at least one translation combination.";
	var msg_Mandatory_Rate_01 = "You have to indicate what your working rate is for the translation combination added.";
	var msg_Mandatory_Rate_02 = "You have to indicate what your working rate is for the translation combination added.";
	var msg_Mandatory_Rate_03 = "You have to indicate what your working rate is for the translation combination added.";
	var msg_Mandatory_Rate_04 = "You have to indicate what your working rate is for the translation combination added.";
	var msg_Mandatory_CAT = "You must indicate whether you use CAT tools for translating or not.";
	var msg_Mandatory_Email = "You have to specify an email address";
	var msg_Mandatory_Email2 = "You have to rewrite your email address for confirmation purposes";
	var msg_Email_Consistency = "The two fields for the email address do not match";
	var msg_Email_Format = "The format of the email address is not valid";
	


	
	if(document.getElementById('First_Name').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_FirstName;
	}
	if(document.getElementById('Last_Name').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_LastName;
	}
	if(document.getElementById('Country_of_Residence').value=="··· Country ···"){ 
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Country;
	}


	if(document.getElementById('Native_Languages1').value=="...Languages..." && document.getElementById('Native_Languages2').value=="...Languages..." && document.getElementById('Native_Languages3').value=="...Languages..."){ 
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_NativeLang;
	}

	if(document.getElementById('Combinations11a').value=="...Languages..." 
		&& document.getElementById('Combinations12a').value=="...Languages..."
		&& document.getElementById('Combinations13a').value=="...Languages..."
		&& document.getElementById('Combinations14a').value=="...Languages..."){ 
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Combination;
	}	
	if(document.getElementById('Combinations11a').value!="...Languages..." 
		|| document.getElementById('Combinations12a').value!="...Languages..."
		|| document.getElementById('Combinations13a').value!="...Languages..."
		|| document.getElementById('Combinations14a').value!="...Languages..."){ 
		if(document.getElementById('Combinations11b').value=="...Languages..." 
			|| document.getElementById('Combinations12b').value=="...Languages..."
			|| document.getElementById('Combinations13b').value=="...Languages..."
			|| document.getElementById('Combinations14b').value=="...Languages..."
			){
				error= true;
				error_msg = error_msg + "\n" + bullet + msg_Mandatory_TargetLanguage;
			}
	}
	if(document.getElementById('Combinations11a').value!="...Languages..."){ 
		if(document.getElementById('Rate_per_Source_Word1').value=="" || document.getElementById('Rate1').value==""){
			error= true;
			error_msg = error_msg + "\n" + bullet + msg_Mandatory_Rate_01;
			}
	}
	if(document.getElementById('Combinations12a').value!="...Languages..."){ 
		if(document.getElementById('Rate_per_Source_Word2').value=="" || document.getElementById('Rate2').value==""){
			error= true;
			error_msg = error_msg + "\n" + bullet + msg_Mandatory_Rate_02;
			}
	}	
	if(document.getElementById('Combinations13a').value!="...Languages..."){ 
		if(document.getElementById('Rate_per_Source_Word3').value=="" || document.getElementById('Rate3').value==""){
			error= true;
			error_msg = error_msg + "\n" + bullet + msg_Mandatory_Rate_03;
			}
	}
	if(document.getElementById('Combinations14a').value!="...Languages..."){ 
		if(document.getElementById('Rate_per_Source_Word4').value=="" || document.getElementById('Rate4').value==""){
			error= true;
			error_msg = error_msg + "\n" + bullet + msg_Mandatory_Rate_04;
			}
	}
		
		
	
	
	
	
	if( (document.getElementById("CAT_tools_no").checked==false) && (document.getElementById("CAT_tools_yes").checked==false) ) {
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_CAT;
	}

	


	
	
	if(document.getElementById('Email').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Email;
	} else {
			if(document.getElementById('Email2').value=="") {
				error= true;
				error_msg = error_msg + "\n" + bullet + msg_Mandatory_Email2;
				} else {
					if(emailFormat()== false) {
					error = true;
					error_msg = error_msg + "\n" + bullet + msg_Email_Format;
					} else {
						if(emailConsistency()== false) {
						error = true;
						error_msg = error_msg + "\n" + bullet + msg_Email_Consistency;
						}
					}
				}
	}

	
					
			
	
	if(error==true) {
		alert (error_msg);
		return false;
	}


	return true;
	}


//////////////////////////////////////////////////////////////////////////////////////////


function comprovarValors2(){

	var error = false;
	
	var msg_base = "The form cannot be sent, as the data is incomplete:";
	var error_msg = msg_base + "";
	var bullet = "- ";

	var msg_Mandatory_Title = "You must specify a title";
	var msg_Mandatory_FirstName = "You must specify your first name";
	var msg_Mandatory_LastName = "You must specify your last name";
	var msg_Mandatory_Company = "You must specify your company or organisation";
	var msg_Mandatory_SourceLanguage = "You have to specify a source language in the \'From\' field";
	var msg_Mandatory_TargetLanguage = "You have to specify a target language in the \'into\' field";
	var msg_Mandatory_Email = "You have to specify an email address";
	var msg_Mandatory_Email2 = "You have to rewrite your email address for confirmation purposes";
	var msg_Email_Consistency = "The two fields for the email address do not match";
	var msg_Email_Format = "The format of the email address is not valid";


	if(document.getElementById('Title').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Title;
	}
	if(document.getElementById('First_Name').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_FirstName;
	}
	if(document.getElementById('Last_Name').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_LastName;
	}
	if(document.getElementById('Company').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Company;
	}
	if(document.getElementById('From').value=="none"){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_SourceLanguage;
	}	
	if(document.getElementById('Into').value=="none"){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_TargetLanguage;
	}
	if(document.getElementById('Email').value==""){
		error= true;
		error_msg = error_msg + "\n" + bullet + msg_Mandatory_Email;
	} else {
			if(document.getElementById('Email2').value=="") {
				error= true;
				error_msg = error_msg + "\n" + bullet + msg_Mandatory_Email2;
				} else {
					if(emailFormat()== false) {
					error = true;
					error_msg = error_msg + "\n" + bullet + msg_Email_Format;
					} else {
						if(emailConsistency()== false) {
						error = true;
						error_msg = error_msg + "\n" + bullet + msg_Email_Consistency;
						}
					}
				}
	}

	
					
			
	
	if(error==true) {
		alert (error_msg);
		return false;
	}


	return true;
	}
	


	

function reset(){
	//alert("");
	document.getElementById("CAT_tools").CHECKED="CHECKED";
	};
	
	
	
	
	
	
	
