var orClass = new Array();

function saveCss() {
	orClass["divLi2"]  = document.getElementById('divLi2').getAttribute('class');
	orClass["divLi5"]  = document.getElementById('divLi5').getAttribute('class');
	orClass["divLi6"]  = document.getElementById('divLi6').getAttribute('class');
	orClass["divLi7"]  = document.getElementById('divLi7').getAttribute('class');
	orClass["divLi11"] = document.getElementById('divLi11').getAttribute('class');
}

function ltrim(s) {
   return s.replace(/^\s+/, "");
}

function rtrim(s) {
   return s.replace(/\s+$/, "");
}

function trim(s) {
   return rtrim(ltrim(s));
}


function send() {
	var d = document;
	var type1 = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
	var type2 = /^([0-9])*$/;
	var toFocus = "";
	var i = 0;
	var g = 0;
	var toMark  = new Array();
	var toHeal  = new Array();

	if(trim(d.getElementById('Field1').value)=="" || trim(d.getElementById('Field2').value)==""){
		toMark[i] = "divLi2";
		i++;
		toFocus = "Field1";
	}else{ toHeal[g]= "divLi2"; g++; }
	
	if(!type1.test(trim(d.getElementById('Field5').value))){
		toMark[i] = "divLi5";
		i++;
		if(toFocus=="") toFocus = "Field5";
	}else{ toHeal[g]= "divLi5"; g++; }
	
	if(!type2.test(trim(d.getElementById('Field6-1').value)) ||
		!type2.test(trim(d.getElementById('Field6-2').value))){
		toMark[i] = "divLi6";
		i++;
		if(toFocus=="") toFocus = "Field6-2";
	}else{ toHeal[g]= "divLi6"; g++; }
	
	if(!type2.test(trim(d.getElementById('Field7-1').value)) ||
		!type2.test(trim(d.getElementById('Field7-2').value)) ||
		!type2.test(trim(d.getElementById('Field7-3').value))){
		toMark[i] = "divLi7";
		i++;
		if(toFocus=="") toFocus = "Field7-3";
	}else{ toHeal[g]= "divLi7"; g++; }
	
	if(trim(d.getElementById('Field12').value)==""){
		toMark[i] = "divLi11";
		i++;
		if(toFocus=="") toFocus = "Field12";
	}else{ toHeal[g]= "divLi11"; g++; }
	
	if(i==0)
		d.getElementById("contacto").submit();
	else{
		for(var j=0;j<toMark.length;j++){
			d.getElementById(toMark[j]).setAttribute('class', orClass[toMark[j]] + 'error');
		}
		for(var j=0;j<toHeal.length;j++){
			d.getElementById(toHeal[j]).setAttribute('class', orClass[toHeal[j]]);
		}
		d.getElementById(toFocus).focus();
	}
}
