//Login in
function signIn(){

	var u = document.getElementById('usuario').value;
	var p = document.getElementById('pass').value;

	if (u != '' && p != ''){
		getDataV1('login','ajax.php?object=signIn&u='+u+'&p='+p,'div_login_estado','inner');
	}
	
}

//Login out
function signOut(){	
	getDataV1('logout','ajax.php?object=signOut','','inner');
}

//Recuperar Contraseña
function recuperarContrasena(){	
    
	var email = document.getElementById('recuperar_contrasena').value;
	
	if(!validar_email2(email)) {
	  document.getElementById('div_email_estado').innerHTML = 'Formato de Email invalido';
	} else {
	  document.getElementById('div_email_estado').innerHTML = 'Email enviado con exito';
	  getDataV1('recuperar','ajax.php?object=recuperarContrasena&email='+email,'','inner');	
	}
	
}

// ALERT LOGUEO
function alertLogin(accion){

	//Ancho de la imagen de fondo del alert 
	var w_div = 288;
	var h_div = 215;

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

	
	if (accion == 'mostrar'){

		var inner_v = '';

		inner_v += '<form action="#" method="post" id="formLogin" >';
		inner_v += '	<div class="contenedorInputslogin">';
		inner_v += '		<a href="#" onclick="alertLogin(\'cerrar\'); return false;" class="cerrraLogin">Cerrar</a>';
		inner_v += '		<label style="width:194px; display:block;">C&eacute;dula</label>';
		inner_v += '		<input type="text" id="usuario" name="usuario" class="loginInput" />';
		inner_v += '		<label>Contrase&ntilde;a</label>';
		inner_v += '		<input type="password" id="pass" name="pass" class="loginInput" />';
		inner_v += '		<div id="div_login_estado" style="float:left; width:100%;"></div>';
		inner_v += '		<a href="index.php?tpl=predios" class="RegistroLogin"> Reg&iacute;strese</a>';
		inner_v += '		<a href="#" class="OlvidoLogin" onclick="alertPass(\'mostrar\'); return false;">¿Olvido su contrase&ntilde;a?</a>';
		inner_v += '		<div style="float:right;">';
		inner_v += '			<input type="submit" name="entrar" value="Entrar" onclick="signIn(); return false;" class="formLoginBoton">';
		inner_v += '		</div>';
		inner_v += '	</div>';
		inner_v += '</form>';
		
		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() != 'iexx'){
			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() == 'iexx')	document.body.removeChild(document.getElementById('iframe_bcg'));
		obj_fondo.style.display = 'none';
	}

}

//ALERT RECUPERAR CONTRASEÑA
function alertPass(accion){

	//Ancho de la imagen de fondo del alert 
	var w_div = 226;
	var h_div = 180;

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

	var obj_fondo = document.getElementById('div_bcg');

	if (accion == 'mostrar'){

		var inner_v = '';

		inner_v += '<form action="#" method="post" id="formLogin" >';
		inner_v += '	<div class="contenedorInputslogin">';
		inner_v += '		<a href="#" onclick="alertPass(\'cerrar\'); return false;" class="cerrraLogin">Cerrar</a>';
		inner_v += '		<p>Con esta opci&oacute;n su contrase&ntilde;a ser&aacute; enviada al correo electr&oacute;nico con el que se registr&oacute en el sistema.</p>';
		inner_v += '		<label style="width:194px; display:block;">Email</label>';
		inner_v += '		<input type="text" id="recuperar_contrasena" name="recuperar_contrasena" class="loginInput">';
		inner_v += '		<div id="div_email_estado" style="float:left;"></div>';
		inner_v += '		<input type="submit" name="entrar" value="Entrar" onclick="recuperarContrasena(); return false;">';
		inner_v += '	</div>';
		inner_v += '</form>';
		
		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() != 'iexx'){
			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() == 'iexx')	document.body.removeChild(document.getElementById('iframe_bcg'));
		obj_fondo.style.display = 'none';
	}

}

//RESETEAR FORMULARIO
function resetForm(id_form) {

  document.form_login.reset();
  document.form_register.reset();

}

// MOSTRAR / OCULTAR UNA DIV
function show_hide_div(accion,id_div) {

  if(accion == "mostrar") document.getElementById(id_div).style.display = '';
  else document.getElementById(id_div).style.display = 'none';

} 


// MOSTRAR / OCULTAR UN TEXTO
function show_hide_text(accion,obj,texto) {

  if(accion == "onblur") {  
    if(obj.value == '') obj.value = texto;  
  } else {   
    if(obj.value == texto) obj.value = '';   
  }

} 

//Boletín
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 getBrowser() {
	var sBrowser = navigator.userAgent;

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

//Espacios en blanco
function TrimLeft(texto) {

	var latin = Array("&nbsp;"," ");
	var web = Array("","");

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

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

//usa jquery.dimensions
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){

	email_split = email.split("@");

	var r = true;

  //Valida la @
	if (email_split.length != 2){
		alert('Email inv\xe1lido!');
		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('Email inv\xe1lido!');
			r = false;
		}
	}
	return r;
	
}

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

	var r = true;

  //Valida la @
	if (email_split.length != 2){
		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){
  		r = false;
  	}
	}
	
	return r;
}

function validarEntero(valor){
    
    valor = parseInt(valor);
	
	//Compruebo si es un valor numérico
	if (isNaN(valor)) {
	
		//entonces (no es numero) devuelvo el valor cadena vacia
		return true;
	
	} else {

	    //En caso contrario (Si era un número) devuelvo el valor
		return false;
	}
	
} 

//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 validar_forma_registrar(elementos,campo_email,campo_confirmar,campo_cedula,campo_telefono,campo_celular) {

	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 != "" && !validar_email2(campo_email)){
		
			return validar_email(campo_email);
		
		} else if(campo_cedula != "" && validarEntero(campo_cedula)) {
            
			alert('El campo cedula debe contener sólo números');
			return false;
			
		} else if(campo_telefono != "" && validarEntero(campo_telefono)) {
            
			alert('Formato de teléfono invalido');
			return false;
			
		} else if(campo_celular != "" && validarEntero(campo_celular)) { 
		
		    alert('Formato de celular inválido');
			return false;
		
		} else if(campo_confirmar != "") { 
					
            var contrasena = document.getElementById('password').value;
			
			if(contrasena != campo_confirmar){
			
				alert('Las contrase\xf1as no coinciden');
				return false;
				
			} else { return true; }
				
		} else { return true; };
		
	}
	
}

function validar_forma_actualizar_personales(elementos,campo_email,campo_confirmar,campo_cedula,campo_telefono,campo_celular) {
    
	var elementos2 = document.getElementById('validar_form').value;
	var ElementosForma = elementos2.split(",");
	var Error = "Los siguientes campos son requeridos:\n\n";
	var Error_i = 0;
    var nom_id = '';
	
	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"){
		    
			nom_id = ElementosForma[i].substr(0,4);
            
			if (document.getElementById(ElementosForma[i]).value == "" && nom_id != 'matr' && nom_id != 'chip'){
				Error += "- " + ElementosForma[i+1] + "\n";
				Error_i = 1;
			}
			
			else if (document.getElementById(ElementosForma[i]).value == "" && document.getElementById(ElementosForma[i+2]).value == "AAA" && nom_id == 'matr'){
				
				Error += "- " + ElementosForma[i+1] + " O " + ElementosForma[i+3] + "\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 != "" && !validar_email2(campo_email)){
		
			return validar_email(campo_email);
		
		} else if(campo_cedula != "" && validarEntero(campo_cedula)) {
            
			alert('El campo cedula debe contener sólo números');
			return false;
			
		}  else if(campo_telefono != "" && validarEntero(campo_telefono)) {
            
			alert('Formato de telefono invalido');
			return false;
			
		} else if(campo_celular != "" && validarEntero(campo_celular)) { 
		
		    alert('Formato de celular invalido');
			return false;
		
		} else if(campo_confirmar != "") { 
					
            var contrasena = document.getElementById('password').value;
			
			if(contrasena != campo_confirmar){
			
				alert('Las contrase\xf1as no coinciden');
				return false;
				
			} else { return true; }
				
		} else { return true; };
		
	}
	
}

function validar_forma_actualizar_predio(elementos){
    
	var ElementosForma = elementos.split(",");
	var Error = "Los siguientes campos son requeridos:\n\n";
	var Error_i = 0;
	var nom_id = '';
	
	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"){
		    
			nom_id = ElementosForma[i].substr(0,4);
			
			if (document.getElementById(ElementosForma[i]).value == "" && nom_id != 'matr' && nom_id != 'chip'){
				Error += "- " + ElementosForma[i+1] + "\n";
				Error_i = 1;
			}
			
			else if (document.getElementById(ElementosForma[i]).value == "" && document.getElementById(ElementosForma[i+2]).value == "" && nom_id == 'matr'){
				Error += "- " + ElementosForma[i+1] + " O " + ElementosForma[i+3] + "\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 {
	
		return true;
	}
}

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

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

}

function hideDivEmail(){
	document.getElementById('div_email').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;
	//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;Enviando...." 
		
		//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;
		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');
	}
	
	return false;
	
}

//Version Print
function printContenido(skin){
	
	var Url = location.href;
	var id_c_existe = 0;
	
	 Url = Url.replace(/.*\?(.*?)/,"$1");
	 Variables = Url.split ("&");
	 for (i = 0; i < Variables.length; i++) {
	        Separ = Variables[i].split("=");
	        eval ('var '+Separ[0]+'="'+Separ[1]+'"');
	        
	        if (Separ[0] == 'id_c')	id_c_existe = 1;
	 }
     
     if (id_c_existe == 0)	window.open('index2.php?print=1&mod=showContent&tpl='+tpl+'&skin='+skin,'','width=600,height=600,top=100,left=100,scrollbars=1');	
     else		   			window.open('index2.php?print=1&mod=showContent&id_c='+id_c+'&skin='+skin,'','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 w_div = 601;
	
	//Valor de left para que siempre salga en el centro
	left = (docwidth() - w_div) / 2;
	
	div = document.getElementById("div_" + div_id);
	tabla = document.getElementById("table_" + div_id);
	bcg = document.getElementById('div_bcg');

	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';
	}
}

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

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