function suscripcionBoletin(email,email_to){
	if (validar_email(email)){
		getDataV1('','ajax.php?object=suscripcionBoletin&email='+email+'&email_to='+email_to,'response_boletin','');
			
	}
}

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 docheight(){

	if (self.innerWidth)
	{
		HeightW = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		HeightW = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		HeightW = document.body.clientHeight;
	}	
	
	HeightS = document.body.scrollHeight;
	
	if (HeightW > HeightS)	return HeightW;
	else					return HeightS;
}
function validar_email(email){
	email_split = email.split("@");

	var r = true;

  //Valida la @
	if (email_split.length != 2){
		alert('Error!');
		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('Error!');
  		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 requeridos:\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 = 0;
	var offset_y = 300;

	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = e.clientX;
		tempY = e.clientY;
		
		if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft )){
	         tempX += document.documentElement.scrollLeft;
	         tempY += document.documentElement.scrollTop;
	    } 
	    else if( document.body && ( document.body.scrollTop || document.body.scrollLeft )){
	         tempX += document.body.scrollLeft;
	         tempY += 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
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');
}

//Version Print Producto
function printProducto(){
	
	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=2&mod=showProduct&id_c='+id_c,'','width=900,height=600,top=100,left=100,scrollbars=1');
}

//Version PDF Contenido
function pdfContenido(){
	
	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]+'"');
	 }
	
	 location.href='index2.php?pdf=1&mod=showContent&id_c='+id_c,'','width=600,height=600,top=100,left=100,scrollbars=1';
}

//Version PDF Producto
function pdfProducto(){
	
	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]+'"');
	 }
	
	 location.href='index2.php?pdf=2&mod=showProducto&id_c='+id_c,'','width=600,height=600,top=100,left=100,scrollbars=1';
}

function showDivEnlarge (div_id,accion){
	
	
	div = document.getElementById("div_" + div_id);
	tabla = document.getElementById("table_" + div_id);
	bcg = document.getElementById('div_bcg');

	//Tranparencia
	bcg.style.filter = "alpha(opacity:50)";
	bcg.style.opacity = 0.5;
	

	//var w_div = parseInt(div.style.width);
	var w_div = 601;

	//Valor de left para que siempre salga en el centro
	left = (docwidth() - w_div) / 2;


	if (accion == 'mostrar'){
	  
	  	div.style.left = left + 'px';
	  	
		bcg.style.width = docwidth() + 'px';
		bcg.style.height = docheight() + 'px';
		bcg.style.visibility = 'visible';

		tabla.style.left = 50;
	  	tabla.style.top = 10;
		tabla.style.visibility = 'visible';
		
	}
	else{
		tabla.style.visibility = 'hidden';
		bcg.style.visibility = 'hidden';
		div.style.visibility = 'hidden';
	}
}

//Coloca el url a donde debe ir al cambiar la fecha del archivo de noticias, esto se hace para evitar multiples mm_aa en el url
function setUrlComboArchive(valor){

	url = location.href;
	
	url_tmp = url.split('?');
	args = url_tmp[1];
	url_t = args.split('&');
	
	args = '';
	for (var i=0;i<url_t.length;i++){
		
		par = url_t[i].split("=");
		
		if (par[0] == 'mm_aa')	par[1] = valor;

		if (par[0].indexOf('num_pag') == -1){
			if (args == '')	args = par[0] + '=' + par[1];
			else			args += "&" + par[0] + '=' + par[1];
		} 	
	}

	//Check si esta el parametro mm_aa
	if (url.indexOf('mm_aa') == -1){
		args += '&mm_aa=' + valor;
	}
		
	return url_tmp[0] + '?' + args;
}

//Retorna el valor de un parametro dado el url y el nombre del parametro
function getUrlParameter(url,parameter){
	url_t = url.split("&");
	
	for (var i=0;i<url_t.length;i++){
		
		par = url_t[i].split("=");
		
		if (par[0] == parameter)	return par[1];	
	}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}