function suscripcionBoletin(email){
	if (email == ''){
		alert('Email is required!');	
	}
	else{
		if(validar_email(email)){
			getDataV1('','ajax.php?object=suscripcionBoletin&email='+email,'email','value');
		}
		else	return false;
		
	}
}

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('Invalid E-mail!');
		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('Invalid E-mail!');
  		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 = "The following fields are required:\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;
	}
}


function showDivEmail(e){
	
	var IE = document.all ? true:false;
	var offset_x = 450;
	var offset_y = 100;

	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY

	
	document.getElementById('div_email').style.display == 'none' ? dis = '' : dis = 'none';
	
	document.getElementById('div_email').style.left = tempX - offset_x + 'px';
	document.getElementById('div_email').style.top = tempY - offset_y + 'px';
	document.getElementById('div_email').style.display=dis;

	
}

//Envia un contenido por email
function emailContenido(){
	
	you_f_n = document.getElementById('you_f_name').value;
	you_l_n = document.getElementById('you_l_name').value;
	you_e = document.getElementById('you_email').value;
	
	rec_f_n = document.getElementById('rec_f_name').value;
	rec_l_n = document.getElementById('rec_l_name').value;
	rec_e = document.getElementById('rec_email').value;
	
	copy_v = (document.getElementById('copy').checked == true) ? 1 : 0;
	t_contenido = document.getElementById('titulo_contenido').innerHTML;
	url = window.location.href;

	if (you_f_n != "" && you_l_n != "" && you_e != "" && rec_f_n != "" && rec_l_n != "" && rec_e != ""){
		
		document.getElementById('rta_div_email').innerHTML = "<img src='img/ajax.gif'>&nbsp;Sending...." 
		
		str = 'you_f_name='+you_f_n+'&you_l_name='+you_l_n+'&you_email='+you_e+'&rec_f_name='+rec_f_n+'&rec_l_name='+rec_l_n+'&rec_email='+rec_e+'&copy='+copy_v+'&t_contenido='+t_contenido+'&url='+url;

		getDataV1('','ajax.php?object=emailContenido&'+str,'rta_div_email','inner');
	}
	else	return false;

	
}

//Version Print Contenido
function printContenido(){
	
	var Url = location.href;
	 Url = Url.replace(/.*\?(.*?)/,"$1");
	 Variables = Url.split ("&");
	 for (i = 0; i < Variables.length; i++) {
	        Separ = Variables[i].split("=");
	        eval ('var '+Separ[0]+'="'+Separ[1]+'"');
	 }
	
	 window.open('index2.php?print=1&mod=showContent&id_c='+id_c,'','width=600,height=600,top=100,left=100,scrollbars=1');
}
