function valida_envia(miform){ 
    //valido los campos
    var nombre = miform.nombre.value;
	var apellido = miform.apellido.value;
    var empresa = miform.empresa.value;
    var domicilio = miform.domicilio.value;
    var cod_postal = miform.cod_postal.value;
    var localidad = miform.localidad.value;
    var pais = miform.pais.value;
    var telefono = miform.telefono.value;
    var email = miform.email.value;
	var rubro = miform.rubro.value;
	var otro_rubro = miform.otro_rubro.value;
	var cargo = miform.cargo.value;
	var otro_cargo = miform.otro_cargo.value;
	var area = miform.area.value;
	var otro_area = miform.otro_area.value;
	var pais = miform.pais.value;
	var otro_pais = miform.otro_pais.value;
	var como = miform.como.value;
	var otro_como = miform.otro_como.value;
  
  if (nombre.length<2){ 
       alert("Tiene que completar el campo 'Nombre'"); 
       miform.nombre.focus();
       return false; 
  }
  if(apellido.length<2){ 
       alert("Tiene que completar el campo 'Apellido'"); 
       miform.apellido.focus();
       return false; 
  }
  if (empresa.length<2){ 
       alert("Tiene que completar el campo 'Empresa'"); 
       miform.empresa.focus();
       return false; 
  }
  if(rubro == "Otro" && otro_rubro == ""){
	   alert("Tiene que completar el campo 'Rubro'"); 
	   miform.otro_rubro.focus();
       return false; 
  }
  if(cargo == "Otro" && otro_cargo == ""){
	   alert("Tiene que completar el campo 'Cargo'"); 
	   miform.otro_cargo.focus();
       return false; 
  }
  if(area == "Otro" && otro_area == ""){
	   alert("Tiene que completar el campo 'Area'"); 
	   miform.otro_area.focus();
       return false; 
  }  
  if (domicilio.length<2){ 
       alert("Tiene que completar el campo 'Domicilio'"); 
       miform.domicilio.focus();
       return false; 
  }
  if (cod_postal.length<2){ 
       alert("Tiene que completar el campo 'Código Postal'"); 
       miform.cod_postal.focus();
       return false; 
  }
  if (localidad.length<2){ 
       alert("Tiene que completar el campo 'Localidad'"); 
       miform.localidad.focus();
       return false; 
  }
  if(pais == "Otro" && otro_pais == ""){
	   alert("Tiene que completar el campo 'Pais'"); 
	   miform.otro_pais.focus();
       return false; 
  }
  if (telefono.length<2){ 
       alert("Tiene que completar el campo 'Teléfono'"); 
       miform.telefono.focus();
       return false; 
  }
  if (!checkMail(email)){ 
       alert("Formato de email incorrecto"); 
       miform.email.focus();
       return false; 
  }
  if(como == "Otro" && otro_como == ""){
	   alert("Tiene que completar el campo 'Como conocio..'"); 
	   miform.otro_como.focus();
       return false; 
  }
  return true; 
} 

function valida_noticia(miform){ 
    //valido los campos
    var categorias = miform.categorias.value;
    var titulo = miform.titulo.value;
    var copete = miform.copete.value;
    var texto = miform.texto.value;
    var fuente = miform.fuente.value;
    var fecha = miform.fecha.value;
 
  if (categorias == 0){ 
       alert("Tiene que seleccionar una categoría"); 
       miform.categorias.focus();
       return false; 
  }
  if(titulo.length<2){ 
       alert("Tiene que completar el campo 'Título'"); 
       miform.titulo.focus();
       return false; 
  }
  if (copete.length<2){ 
       alert("Tiene que completar el campo 'Copete'"); 
       miform.copete.focus();
       return false; 
  }
  if (texto.length<2){ 
       alert("Tiene que completar el campo 'Texto'"); 
       miform.texto.focus();
       return false; 
  }
  if (fuente.length<2){ 
       alert("Tiene que completar el campo 'Fuente'"); 
       miform.fuente.focus();
       return false; 
  }
  if (!checkDate(fecha)){ 
       alert("Tiene que completar el campo 'Código Postal'"); 
       miform.cod_postal.focus();
       return false; 
  }
  return true; 
} 


function checkMail(x){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x))
	return true;
	return false;
}


function checkDate(fecha){
	YourDate= fecha;
	var YourDateParts = new Array();
	YourDateParts = YourDate.split('/');
	var myDayStr = YourDateParts[2];
	var myMonthStr = YourDateParts[1];
	var myYearStr = YourDateParts[0];
	var myMonth = new Array('01','02','03','04','05','06','07','08','09','10','11','12'); 
	var myDateStr = myYearStr + '/' + myMonth[myMonthStr-1] + '/' + myDayStr;
	
	var myDate = new Date();
	myDate.setFullYear( myYearStr, (myMonthStr), myDayStr );

	if ( myDate.getMonth() != myMonthStr || myYearStr < 1900 )
	  return false;
	else
	  return true;	
} 

function checkFloat(value) {
	if(isNaN(parseFloat(value))) return false;
    else return true;
}

function eleccion(){ 
    var puesto 
    puesto = document.getElementById('puesto').value 
    if (puesto == 'Otro') { 
       document.getElementById('otro_puesto').disabled = false
	   document.getElementById('otro_puesto').style.background = '#ffffff'
   }else{ 
       document.getElementById('otro_puesto').disabled = true 
	   document.getElementById('otro_puesto').style.background = '#e5e4e5'
    } 
} 

function eleccionP(){ 
    var pais 
    pais = document.getElementById('pais').value 
	if (pais != 'Argentina')
	{
	   document.getElementById('provincia').disabled = true
	}else{
		document.getElementById('provincia').disabled = false
	}
		
	if (pais == 'Otro') { 
       document.getElementById('otro_pais').disabled = false
	   document.getElementById('otro_pais').style.background = '#ffffff'
   }else{ 
       document.getElementById('otro_pais').disabled = true 
	   document.getElementById('otro_pais').style.background = '#e5e4e5'
    } 
} 

function eleccionOtro(campo){ 
    var vv 
    vv = document.getElementById(campo).value 
    if (vv == 'Otro') { 
       document.getElementById('otro_'+campo).disabled = false
	   document.getElementById('otro_'+campo).style.background = '#ffffff'
   }else{ 
	   document.getElementById('otro_'+campo).disabled = true 
	   document.getElementById('otro_'+campo).style.background = '#e5e4e5'
    } 
} 


