function suscripcionBoletin(email){
	if (validar_email(email)){
		getDataV1('','ajax.php?object=suscripcionBoletin&email='+email,'suscripcionBoletin');
			
	}
}

function docwidth(){
	if (self.innerWidth)
	{
		WidthW = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		WidthW = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		WidthW = document.body.clientWidth;
	}

	WidthS = document.body.scrollWidth;

	if (WidthW > WidthS)	return WidthW;
	else					return WidthS;
	

}
function validar_email(email){
	email_split = email.split("@");

	var r = true;

  //Valida la @
	if (email_split.length != 2){
		alert('Formato de Email inválido');
		r =  false;
	}
	if (email_split.length > 1){
		email_split_2 = email_split[1].split(".");
  	//Valida si hay dominio
  	if (email_split_2.length < 2 || email_split_2[1].length < 2){
  		alert('Formato de Email inválido');
  		r = false;
  	}
	}
	return r
}

//Elementos: String que tiene nombre_campo_forma,etiqueta_campo
//campo_email: valor del campo de email a validar, vacio si la forma no tiene este campo
function validar_forma(elementos,campo_email){
	var ElementosForma = elementos.split(",");
	var Error = "Los siguientes campos son obligatorios:\n\n";
	var Error_i = 0;
	
	for (i=0;i<ElementosForma.length;i++){
			if (document.getElementById(ElementosForma[i]).type == "text" || document.getElementById(ElementosForma[i]).type == "password" || document.getElementById(ElementosForma[i]).type == "textarea" || document.getElementById(ElementosForma[i]).type == "select-multiple" || document.getElementById(ElementosForma[i]).type == "select-one" || document.getElementById(ElementosForma[i]).type == "file"){
  			if (document.getElementById(ElementosForma[i]).value == ""){
  				 Error += "- " + ElementosForma[i+1] + "\n";
  				 Error_i = 1;
  			}
			}
			else if (document.getElementById(ElementosForma[i]).type == "radio" || document.getElementById(ElementosForma[i]).type == "checkbox"){
				if (document.getElementById(ElementosForma[i]).checked == false){
  				 Error += "- " + ElementosForma[i+1] + "\n";
  				 Error_i = 1;
				}
			}
			
			i++;
	}
	
	if (Error_i == 1){
		 alert(Error);
		 return false;
	}
	else{
  	if (campo_email != ""){
  		 return validar_email(campo_email);
  	}
		else
			return true;
	}
}
