
// Permite obtener el valor del botón de radio chequeado.
function valor_pregunta_encuesta(valor) { 
   var varValor = valor;  //Contiene el valor del boton de radio.
   $("#resultado_encuesta_pricipal").load("ver.php", {paramTipo : 1, paramValor : varValor}); 
   //paramTipo es el parametro pasado por metodo POST
   
} // Fin de la función, valor_pregunta_encuesta.


function enviar_pregunta_encuesta(){
  document.getElementById('ver_res_enc').style.display = 'none';
  if(document.getElementById('pregunta_encuesta_1').checked == true){
   var val_pre_enc = document.getElementById('pregunta_encuesta_1').value;
  }
  
  if(document.getElementById('pregunta_encuesta_2').checked == true){
   var val_pre_enc = document.getElementById('pregunta_encuesta_2').value;
  }
  
  if(document.getElementById('pregunta_encuesta_3').checked == true){
   var val_pre_enc = document.getElementById('pregunta_encuesta_3').value;
  }
  
  document.getElementById('formulario_encuesta_pricipal').style.display = 'none';
  document.getElementById('resultado_encuesta_pricipal').style.display = '';
  valor_pregunta_encuesta(val_pre_enc);
}

function ver_resultados_encuesta(){
  document.getElementById('ver_res_enc').style.display = 'none';
  document.getElementById('formulario_encuesta_pricipal').style.display = 'none';
  document.getElementById('resultado_encuesta_pricipal').style.display = '';
  valor_pregunta_encuesta(0);
}

function ver_preguntas_encuesta(){
  document.getElementById('ver_res_enc').style.display = '';
  document.getElementById('formulario_encuesta_pricipal').style.display = '';
  document.getElementById('resultado_encuesta_pricipal').style.display = 'none';
}

function suscripcionBoletin(email){

	//Copia el contenido original en el backup para poder usar el volver
	document.getElementById('newsletter_orig').innerHTML = document.getElementById('newsletter_fieldset').innerHTML;

	if (email != 'E-mail'){
		if (validar_email(email)){
			getDataV1('suscripcionBoletin','ajax.php?object=suscripcionBoletin&email='+email,'newsletter_fieldset','');
		}
		else{
			document.getElementById('newsletter_fieldset_error').style.display = '';
			document.getElementById('newsletter_fieldset').style.display = 'none';
		}
	}
}

function newsletterVolver(){
	document.getElementById('newsletter_fieldset_error').style.display = 'none';
	document.getElementById('newsletter_fieldset').innerHTML = document.getElementById('newsletter_orig').innerHTML
	document.getElementById('newsletter_fieldset').style.display = '';
}

//Añadir a favoritos desde la pagina de detalle de catalogo, con reload
function addProdFavorito(e,id_prod,reload,nom_prod){
	
	var caso = '';
	if (reload == 1)	caso = 'addProdFavorito';

	if (userLogin()){
		if (id_prod > 0){
			getDataV1(caso,'ajax.php?object=addProdFavorito&id_prod='+id_prod,'favorito_rta','');
		
			var inner_v = '<p class="title">' + nom_prod + '</p><p>ha sido a&ntilde;adido a tu lista de favoritos</p>';
			alertLoginFav('mostrar',inner_v,e,reload);
		}
	}
	else{
		var inner_v = '<p class="alert_two"><span>Para a&ntilde;adir este producto a tus favoritos debes ingresar<br />';
		inner_v += 'con tu c&eacute;dula y contrase&ntilde;a en  la parte superior derecha.<br /><br />Si a&uacute;n no eres cliente <br />';
		inner_v += 'platinum has</span><a href="registro/cliente/"> click aqu&iacute; </a><span>para registrarte.</span>';
		inner_v += '</p>';
		alertLoginFav('mostrar',inner_v,e,0);
	}
}


// visualizar un alerta, en caso de no estar logueado, con reload.
function addCom(e,id_prod,reload,nom_prod){
	
	if (userLogin()){
		var url_com1 = location.href;
	    var url_com2  = url_com1.split('\#');
		location.href = url_com2[0]+'#add_comentario';
	}
	else{
		
	    var inner_v = '<a href="#" onclick="alertLogin(\'ocultar\',\'\',event);return false;" class="closed">cerrar</a>';
        inner_v += '<p>Para a&ntilde;adir un comentario usted debe ser un usuario registrado</p>';
        inner_v += '<a href="#" onclick="alertLogin(\'ocultar\',\'\',event);location.reload();return false;" class="options">Ingresar</a><a href="registro/cliente/" class="options">Registrarse</a>';
      
		alertLogin('mostrar',inner_v,e,0);
	}
}


function delProdFavorito(e,id_prod,reload,nom_prod){
	
	var caso = '';
	if (reload == 1)	caso = 'delProdFavorito';
	
	if (id_prod > 0){
		getDataV1(caso,'ajax.php?object=delProdFavorito&id_prod='+id_prod,'favorito_rta','');
		
		var inner_v = '<p class="title">' + nom_prod + '</p><p><span>Producto eliminado de tu lista de favoritos</span></p>';
		alertLoginFav('mostrar',inner_v,e,reload);
		
	}
}

function userLogin(){
	if (document.getElementById('btn_login_out') == undefined)	return false;
	else					return true;
}


function alertLogin(accion,inner,e,reload){

	var reload_js = '';
	if (reload == 1)	reload_js = 'location.reload()';
	
	//Ancho de la imagen de fondo del alert 
	var w_div = 340;
	var h_div = 142;

	//Valor de left para que siempre salga en el centro
	var left_v = (docwidth() - w_div) / 2;
	var top_v = (docVisibleHeight() - h_div) / 2;

	obj_fondo = document.getElementById('div_bcg');

	if (accion == 'mostrar'){

		var inner_v = inner;
		
		if ( obj_fondo == undefined){
			//Fondo negro
			fondo = document.createElement('div');

			fondo.id = 'div_bcg';
			fondo.style.background = "#6B6B6B";
			fondo.style.opacity = 0.50;
			fondo.style.filter = 'alpha(opacity=50)';
			fondo.style.width = docwidth()+'px';
			fondo.style.height = docheight()+'px';
			fondo.style.zIndex = 5;
			fondo.style.position = 'absolute';
			fondo.style.top = 0;
			fondo.style.left = 0;
			document.body.appendChild(fondo);
		}
		else{
			var alerta = document.getElementById('alert');
			if (alerta != undefined) document.body.removeChild(alerta);

			obj_fondo.style.display = '';
		} 

		var div = document.createElement('div');
		div.id = 'alert';
		div.style.zIndex = 500;
		div.style.left = left_v + 'px';
		div.innerHTML = inner_v;
		div.className = 'fixed';

		if (getBrowser() != 'ie'){
			div.style.top = top_v + 'px';
			div.style.position = 'fixed';
		}
		else{
			//crea el iframe para el combo de marca quede por debajo
			var iframe = document.createElement('iframe');
			iframe.id = 'iframe_bcg';
			iframe.style.width = docwidth() + 'px';
			iframe.style.height = docheight() + 'px';
			iframe.style.top = 0;
			iframe.style.left = 0;
			iframe.style.filter = 'alpha(opacity=0)';
			iframe.style.position = 'absolute';
			iframe.style.zIndex = 3;
			document.body.appendChild(iframe);

		}
		document.body.appendChild(div);
	}
	else{

		document.body.removeChild(document.getElementById('alert'));
		if (getBrowser() == 'ie')	document.body.removeChild(document.getElementById('iframe_bcg'));
		obj_fondo.style.display = 'none';
	}

}



function alertLoginFav(accion,inner,e,reload){

	var reload_js = '';
	if (reload == 1)	reload_js = 'location.reload()';
	
	//Ancho de la imagen de fondo del alert 
	var w_div = 340;
	var h_div = 142;

	//Valor de left para que siempre salga en el centro
	var left_v = (docwidth() - w_div) / 2;
	var top_v = (docVisibleHeight() - h_div) / 2;

	obj_fondo = document.getElementById('div_bcg');

	if (accion == 'mostrar'){

		var inner_v = '<div class="log">' + inner + '</div>';
		inner_v += '<a href="#" onclick="alertLoginFav(\'ocultar\',\'\',event);'+reload_js+';return false;"><div class="bot_acept"><p>Aceptar</p></div></a>';


		if ( obj_fondo == undefined){
			//Fondo negro
			fondo = document.createElement('div');

			fondo.id = 'div_bcg';
			fondo.style.background = "#6B6B6B";
			fondo.style.opacity = 0.50;
			fondo.style.filter = 'alpha(opacity=50)';
			fondo.style.width = docwidth()+'px';
			fondo.style.height = docheight()+'px';
			fondo.style.zIndex = 5;
			fondo.style.position = 'absolute';
			fondo.style.top = 0;
			fondo.style.left = 0;
			document.body.appendChild(fondo);
		}
		else{
			var alerta = document.getElementById('alert');
			if (alerta != undefined) document.body.removeChild(alerta);

			obj_fondo.style.display = '';
		} 

		var div = document.createElement('div');
		div.id = 'alert';
		div.style.zIndex = 500;
		div.style.left = left_v + 'px';
		div.innerHTML = inner_v;
		div.className = 'fixed';

		if (getBrowser() != 'ie'){
			div.style.top = top_v + 'px';
			div.style.position = 'fixed';
		}
		else{
			//crea el iframe para el combo de marca quede por debajo
			var iframe = document.createElement('iframe');
			iframe.id = 'iframe_bcg';
			iframe.style.width = docwidth() + 'px';
			iframe.style.height = docheight() + 'px';
			iframe.style.top = 0;
			iframe.style.left = 0;
			iframe.style.filter = 'alpha(opacity=0)';
			iframe.style.position = 'absolute';
			iframe.style.zIndex = 3;
			document.body.appendChild(iframe);

		}
		document.body.appendChild(div);
	}
	else{

		document.body.removeChild(document.getElementById('alert'));
		if (getBrowser() == 'ie')	document.body.removeChild(document.getElementById('iframe_bcg'));
		obj_fondo.style.display = 'none';
	}

}


// Función para crear alertas de todo tipo.
function alertPago(accion,e,reload,idioma){

	var reload_js = '';
	if (reload == 1)	reload_js = 'location.reload()';
	
	//Ancho de la imagen de fondo del alert 
	var w_div = 663;
	var h_div = 341;

	//Valor de left para que siempre salga en el centro
	var left_v = (docwidth() - w_div) / 2;
	var top_v = (docVisibleHeight() - h_div) / 2;

	obj_fondo = document.getElementById('div_bcg');

	if (accion == 'mostrar'){

	var inner_v  = '';
	
	if(idioma == 1) {
	inner_v  += '<div id="alert">';     
	inner_v  += '    <a class="close_alert" href="#" onclick="alertPago(\'ocultar\',\'event\',0,1); return false;">Cerrar</a>';
    inner_v  += '    <div id="text_alert">';     
    inner_v  += '    <h2> Instrucciones  </h2><br />';
	inner_v  += '    Los art&iacute;culos de la Revista Colombiana de Anestesiolog&iacute;a es un servicio exclusivo '; 
	inner_v  += '    <br />para nuestros socios. Para asociarse debe presentar en su regional m&aacute;s cercana:';
    inner_v  += '    <ol>';
    inner_v  += '    <li>Fotocopia de la c&eacute;dula</li>';
    inner_v  += '    <li>Fotocopia del diploma que lo acredita como M&eacute;dico(a)</li>';
    inner_v  += '    <li>Fotocopia del diploma que lo acredita como Anestesi&oacute;logo(a)</li>'; 
    inner_v  += '    <li>Copias de las actas de grado</li>';     
    inner_v  += '    </ol><br />';   
    inner_v  += '    Los documentos se deben presentar a la Junta directiva de cada seccional junto con el <br />'; 	
	inner_v  += '    recibo de pago de su cuota anual de sostenimiento.  Para m&aacute;s informaci&oacute;n, comun&iacute;quese <br />'; 	
	inner_v  += '    con las direcciones seccionales:<br /><br />'; 	
	inner_v  += '	 Sociedad Colombiana de Anestesiolog&iacute;a y Reanimaci&oacute;n<br /><br />';  
    inner_v  += '	 <a href="https://www.zonapagos.com/t_scare/pagos.asp" target="_blank" style="color:#08336c;">Suscribirme</a>';  	
    inner_v  += '	</div>';    
    inner_v  += '</div>  ';	
	} else {
	
	inner_v  += '<div id="alert">';     
	inner_v  += '    <a class="close_alert" href="#" onclick="alertPago(\'ocultar\',\'event\',2); return false;">Cerrar</a>';
    inner_v  += '    <div id="text_alert">';     
    inner_v  += '    <h2> Instructions  </h2><br />';
	inner_v  += '    The articles of the Colombian Journal of Anesthesiology is an exclusive service '; 
	inner_v  += '    <br />for our partners. To join you must submit your nearest regional:';
    inner_v  += '    <ol>';
    inner_v  += '    <li>Photocopy of identity card</li>';
    inner_v  += '    <li>hotocopy of diploma accredits you as Medical</li>';
    inner_v  += '    <li>Photocopy of diploma accredits you as Anesthesiologist</li>'; 
    inner_v  += '    <li>Copies of the minutes of degree</li>';     
    inner_v  += '    </ol><br /><br />';   
    inner_v  += '    The documents must be submitted to the Board of each branch along with the <br />'; 	
	inner_v  += '    receipt for payment of their annual support. For more information, contact <br />'; 	
	inner_v  += '    with addresses sectional:<br /><br />'; 	
	inner_v  += '	 Sociedad Colombiana de Anestesiolog&iacute;a y Reanimaci&oacute;n<br /><br />';
    inner_v  += '	 <a href="https://www.zonapagos.com/t_scare/pagos.asp" target="_blank" style="color:#08336c;">subscribe</a>';	
    inner_v  += '	</div>';    
    inner_v  += '</div>  ';	
	}
	
	
		
		if ( obj_fondo == undefined){
			//Fondo negro
			fondo = document.createElement('div');

			fondo.id = 'div_bcg';
			fondo.style.background = "#6B6B6B";
			fondo.style.opacity = 0.50;
			fondo.style.filter = 'alpha(opacity=50)';
			fondo.style.width = docwidth()+'px';
			fondo.style.height = docheight()+'px';
			fondo.style.zIndex = 5;
			fondo.style.position = 'absolute';
			fondo.style.top = 0;
			fondo.style.left = 0;
			document.body.appendChild(fondo);
		}
		else{
			var alerta = document.getElementById('alert');
			if (alerta != undefined) document.body.removeChild(alerta);

			obj_fondo.style.display = '';
		} 

		var div = document.createElement('div');
		div.id = 'alert';
		div.style.zIndex = 500;
		div.style.left = left_v + 'px';
		div.innerHTML = inner_v;
		div.className = 'fixed';

		if (getBrowser() != 'ie'){
			div.style.top = top_v + 'px';
			div.style.position = 'fixed';
		}
		else{
			//crea el iframe para el combo de marca quede por debajo
			var iframe = document.createElement('iframe');
			iframe.id = 'iframe_bcg';
			iframe.style.width = docwidth() + 'px';
			iframe.style.height = docheight() + 'px';
			iframe.style.top = 0;
			iframe.style.left = 0;
			iframe.style.filter = 'alpha(opacity=0)';
			iframe.style.position = 'absolute';
			iframe.style.zIndex = 3;
			document.body.appendChild(iframe);

		}
		document.body.appendChild(div);
	}
	else{

		document.body.removeChild(document.getElementById('alert'));
		if (getBrowser() == 'ie')	document.body.removeChild(document.getElementById('iframe_bcg'));
		obj_fondo.style.display = 'none';
	}

}



//usa jquery.dimensions
function docwidth(){
	return $(document).width();
}
function docheight(){
	return $(document).height();
}
function docVisibleHeight(){

	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;
	*/

	return HeightW;
}

function validar_email(email_text){

	//re = /(\w+@[0-9a-zA-Z_]+?\.[a-zA-Z]{2,6})/;
	re = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;

	if(email_text.match(re))	return true
	else				return false;
}

function validarNum(e)
{
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla == 8) return true;
	patron = /\d/;
	te = String.fromCharCode(tecla);
	return patron.test(te);
}


//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,idioma){
	var ElementosForma = elementos.split(",");
	
	if(idioma == 2)
	var Error = "The following fields are required:\n\n";
	else 
	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 != ""){
			if(!validar_email(campo_email)){
				alert('Formato de Email incorrecto');
				return false;
			}	 
		}
		else
			return true;
	}
}

function validarFormContacto(){
		
	//Check email
	var e1 = document.getElementById("email").value;
	var e2 = document.getElementById("email2").value;

	if(e1 != e2){
		alert("Los email no coinciden");
		document.getElementById("email").focus();
		return false;
	}

	return validar_forma('nombre,Nombre,apellido,Apellido,email,Email,ciudad,Ciudad,comentario,Comentario',document.getElementById('email').value,1);
}	

function getClickX(e){

	var IE = document.all ? true:false;
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = e.clientX;

		if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft )){
			tempX += document.documentElement.scrollLeft;
		} 
		else if( document.body && ( document.body.scrollTop || document.body.scrollLeft )){
			tempX += document.body.scrollLeft;
		}
	} 
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
	}

	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}

	return tempX;
}

function getClickY(e){

	var IE = document.all ? true:false;
	if (IE) { // grab the x-y pos.s if browser is IE
		tempY = e.clientY;

		if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft )){
			tempY += document.documentElement.scrollTop;
		} 
		else if( document.body && ( document.body.scrollTop || document.body.scrollLeft )){
			tempY += document.body.scrollTop;
		}
	} 
	else {  // grab the x-y pos.s if browser is NS
			tempY = e.pageY
	}

	// catch possible negative values in NS4
	if (tempY < 0){tempY = 0}

	return tempY;
}

function showDivEmail(e){

	var IE = document.all ? true:false;
	var offset_x = (docwidth() - (370)) / 2 ;
	var offset_y = 480;

	tempX = getClickX(e);
	tempY = getClickY(e);

	var obj = document.getElementById('sendToFriend');

	if (IE)	var disp = obj.currentStyle.display;
	else	 var disp = document.defaultView.getComputedStyle(obj, null).getPropertyValue("display"); 

	(disp == 'none') ? dis = 'block' : dis = 'none';

	obj.style.left = offset_x + 'px';
	var top =  (docVisibleHeight() - offset_y) / 2 ;

	obj.style.display = dis;
	
	obj.className='fixed';
	if (getBrowser() != 'ie'){
		obj.style.top = top + 'px';
		obj.style.position = 'fixed';
	}
	var obj_fondo = document.getElementById('div_bcg');

	if ( obj_fondo == undefined){
		//Fondo negro
		fondo = document.createElement('div');

		fondo.id = 'div_bcg';
		fondo.style.background = "#6B6B6B";
		fondo.style.opacity = 0.50;
		fondo.style.filter = 'alpha(opacity=50)';
		fondo.style.width = docwidth()+'px';
		fondo.style.height = docheight()+'px';
		fondo.style.zIndex = 5;
		fondo.style.position = 'absolute';
		fondo.style.top = 0;
		fondo.style.left = 0;
		document.body.appendChild(fondo);
	}
	else{
		obj_fondo.style.display = '';
	} 
	

}

function hideDivEmail(){
	document.getElementById('sendToFriend').style.display='none';
	document.getElementById('div_bcg').style.display='none';

	return false;
}

//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;
	url = window.location.href;

	if(validar_email(you_e) && validar_email(rec_e)){
		if (you_f_n != "" && you_l_n != "" && you_e != "" && rec_f_n != "" && rec_l_n != "" && rec_e != ""){

			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+'&url='+url;

			getDataV1('','ajax.php?object=emailContenido&'+str,'rta_div_email','inner');
		}
		else	return false;
	}
	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){


	var div = document.getElementById("div_" + div_id);
	var obj_fondo = document.getElementById('div_bcg');

	//var w_div = parseInt(div.style.width);
	var w_div = 521;
	var h_div = 400;
	//Valor de left para que siempre salga en el centro
	var left = (docwidth() - w_div) / 2;
	var top = (docVisibleHeight() - h_div) / 2;

	if (accion == 'mostrar'){
		div.style.left = left + 'px';
		div.style.display = '';
		div.className='fixed';
		if (getBrowser() != 'ie'){
			div.style.top = top + 'px';
			div.style.position = 'fixed';
		}

		if ( obj_fondo == undefined){
			//Fondo negro
			fondo = document.createElement('div');

			fondo.id = 'div_bcg';
			fondo.style.background = "#6B6B6B";
			fondo.style.opacity = 0.50;
			fondo.style.filter = 'alpha(opacity=50)';
			fondo.style.width = docwidth()+'px';
			fondo.style.height = docheight()+'px';
			fondo.style.zIndex = 5;
			fondo.style.position = 'absolute';
			fondo.style.top = 0;
			fondo.style.left = 0;
			document.body.appendChild(fondo);
		}
		else{

			obj_fondo.style.display = '';
		} 
	}
	else{
		div.style.display = 'none';
		obj_fondo.style.display = 'none';
	}
}

//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];	
	}
}

//Login in
function signIn(){
	var u = document.getElementById('usuario').value;
	var p = document.getElementById('pass').value;

	if (u != 'Usuario' && p != 'Contrase&ntilde;a'){

		//coloca imagen loading
		//document.getElementById('btn_login').style.display = 'none';
		//document.getElementById('btn_login_loading').style.display = '';

		getDataV1('login','ajax.php?object=signIn&u='+u+'&p='+p,'top_login','inner');

	}
}

//Login out
function signOut(){
	//coloca imagen loading
	//document.getElementById('btn_login_out').style.display = 'none';
	//document.getElementById('btn_login_loading').style.display = '';

	getDataV1('logout','ajax.php?object=signOut','top_login','inner');
}

function focusLogin(obj){
	if(obj.value == 'Usuario')	obj.value = '';
}

function blurLogin(obj){
	if(obj.value == '') obj.value = 'Usuario';
}

function focusPassword(obj){

	var spane = document.getElementById("input_pass");
	
	if(obj.value == 'Contrase\xf1a'){
		spane.innerHTML = '<input name="pass" type="password" id="pass" value="" onfocus="focusPassword(this)" onblur="blurPassword(this)" class="input1" />';
		
	}

	setTimeout("document.getElementById('pass').focus()",10);
}

function blurPassword(obj){

	var spane = document.getElementById("input_pass");
	
	if(obj.value == ''){
		spane.innerHTML = '<input name="pass" type="text" id="pass" value="Contrase\xf1a" onfocus="focusPassword(this)" onblur="blurPassword(this)" class="input1" />';
	}
}


//Login volver
function loginVolver(){
	//coloca imagen loading
	//document.getElementById('btn_login_volver').style.display = 'none';
	//document.getElementById('btn_login_loading').style.display = '';

	getDataV1('','ajax.php?object=signOut','top_login','inner');
}


function changeInputType(oldObject, oType) {
	var newObject = document.createElement('input');
	newObject.type = oType;
	if(oldObject.size) newObject.size = oldObject.size;
	if(oldObject.value) newObject.value = oldObject.value;
	if(oldObject.name) newObject.name = oldObject.name;
	if(oldObject.id) newObject.id = oldObject.id;
	if(oldObject.className) newObject.className = oldObject.className;
	oldObject.parentNode.replaceChild(newObject,oldObject);

	return newObject;
}

function getBrowser() {
	var sBrowser = navigator.userAgent;

	if (sBrowser.toLowerCase().indexOf('msie') > 0)
		return 'ie';
	else
		return;
}

//Lista equivalente de tildes
//á = \xe1
//é = \xe9
//í = \xed
//ó = \xf3
//ú = \xfa
//ñ = \xf1
function latinChars(texto){

	var latin = Array("a","e","i","o","u","n");
	var web = Array("\xe1","\xe9","\xed","\xf3","\xfa","\xf1");


	for(var i=0;i<latin.length;i++){
		texto.replace(/latin[i]/,web[i]);
	}

	return texto;
}

function filtroContenidoHome(){
	var obj = document.getElementById('filtro_home');
	var id = obj.options[obj.selectedIndex].value;
	location.href = '?cf='+id;
}

function filtroProducto(url){
    var pagina="http://"+location.host+'/'
	var url_tmp  = url.split('?cf');
	var url_tmp2 = url_tmp[0].split('?pa');
	var obj = document.getElementById('filtro_p');
	var id = obj.options[obj.selectedIndex].value;
	var cont = url_tmp2[0].length;
	var cad_temp = url_tmp2[0].substr(cont-1, 1);
	if(cad_temp == '/')
	location.href = pagina+url_tmp2[0]+ '?cf='+id;
	else
	location.href = pagina+url_tmp2[0]+ '/?cf='+id;
}



function filtroProducto2(url){
    var pagina="http://"+location.host+'/';
	var url_tmp  = url.split('?cf');
	var url_tmp2 = url_tmp[0].split('?pa');
	var obj = document.getElementById('filtro_p');
	var id = obj.options[obj.selectedIndex].value;
	var cont = url_tmp2[0].length;
	var cad_temp = url_tmp2[0].substr(cont-1, 1);
	if(cad_temp == '/')
	location.href = pagina+url_tmp2[0]+ '?cf='+id;
	else
	location.href = pagina+url_tmp2[0]+ '?cf='+id;
}



function filtroContenidoHomeConsola(url){
	var obj = document.getElementById('filtro_home');
	var id = obj.options[obj.selectedIndex].value;
	location.href = url+ '?cf='+id;
}

function filtroContenidoSearch(url,crt){
	var obj = document.getElementById('filtro_home');
	var id = obj.options[obj.selectedIndex].value;
	location.href = url + '?crt='+crt+'&cf='+id;
}
