/*************************************************/
/** Funcion Siguiente(pagina)		     		**/
/** Funcion Siguiente2(pagina)		     		**/
/** 					     					**/
/** Funcion para los enlaces, se le pasa la  	**/
/** página a cargar. 			     			**/
/** 					     				    **/
/*************************************************/
function Siguiente(pagina){
document.location=pagina;
}

function Siguiente2(pagina){
document.url=pagina;
}


function AltaClienteMicrosite(){
var pagina = "/Altaonline.jsp";

//if (agente != ''){
//	pagina = pagina+"?agente="+agente;
//	if (colectivo != ''){
//		pagina = pagina+"&colectivo="+colectivo;
//	}
//}else{
//	if (colectivo != ''){
//		pagina = pagina+"?colectivo="+colectivo;
//	}
//}
//alert(pagina);
var hz=window.screen.height
var wz=window.screen.width	
 if( wz>800 && hz>600){
 wz=1000;
 hz=675;
	}else{
 wz=800;
 hz=600;
	}
window.open(pagina,'IberInformEo','toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes,location=no,hotkeys=no,resizable=yes,height='+hz+',width='+wz+',top=0,left=0,screenX=0,screenY=0')
}

function AltaAportadoresCuentas(URL){
var hz=window.screen.height
var wz=window.screen.width	
 if( wz>800 && hz>600){
 wz=1000;
 hz=675;
	}else{
 wz=800;
 hz=600;
	}
window.open(URL,'IberInformEo','toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes,location=no,hotkeys=no,resizable=yes,height='+hz+',width='+wz+',top=0,left=0,screenX=0,screenY=0')
//document.location.href=URL;
}


function abrir(pag,alto,ancho)
{
window.open(pag + ".htm","","height=" + alto +","+ "width=" + ancho); 
};

function EntrarUsuario() {
var home = "../Registrado/firmas/index.html";
document.location.href=home;
}

function EntrarUsuario2() {
var home = "Registrado/firmas/index.html";
document.location.href=home;
}

function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.iberinform.es/"; 
      var titulo="Iberinform";
      window.external.AddFavorite(url,titulo);
   } else { 
      //if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
} 

function busqueda(criterio) {
(criterio==1) ? document.form1.buscarNIFCIF.value="" : document.form1.buscarDenominacion.value="";
document.form1.submit();
}

/*************************************************/
/** Funcion PopUp(pagina,alto,ancho)	        **/
/** 					        			    **/
/** Recibe el nombre de la página, el alto      **/
/** y ancho en px, para abrirla en una página   **/
/** PopUp.									    **/
/**												**/
/*************************************************/
function PopUp(pagina,alto,ancho){
var winleft = (screen.width-alto)/2; 
var wintop = (screen.height-ancho)/2;
tmp = window.open(pagina, '_blank', 'width='+alto+',height='+ancho+',left='+winleft+', top='+wintop+',screenX='+winleft+',screenY='+wintop+''); 
tmp.focus();
}

function PopUpScroll(pagina,alto,ancho){
var winleft = (screen.width-alto)/2; 
var wintop = (screen.height-ancho)/2;
tmp = window.open(pagina, '_blank','scrollbars=yes ,width='+alto+',height='+ancho+',left='+winleft+', top='+wintop+',screenX='+winleft+',screenY='+wintop+''); 
tmp.focus();
}


function entsub(campo,boton) {
	//solo se hace este if para un problema ocasionado con el directorio de empresas fijo.Es un caso eventual.Lo que hacemos es crear un campo hidden mediante javascript para poder enviarle como parámetro el idioma de la webPublica.
	if(document.form1.idiomaWebPublica){
		var idioma = document.form1.idiomaWebPublica.value;
		
	}else{
		//creamos un campo de formulario y le añadimos atributos	
		var prueba = document.createElement("input");
		prueba.setAttribute('type','hidden');
		prueba.setAttribute('name','idiomaWebPublica');
		prueba.setAttribute('value','ES');
		prueba.setAttribute('id','idiomaWebPublica');
		//añadimos el campo al formulario
		document.form1.appendChild(prueba);
}

	if ((window.event && window.event.keyCode == 13) || boton) {
	switch (campo.name) {

		case 'buscarDenominacion' : 
				var deno = document.form1.buscarDenominacion.value;
				
				/*deno=deno.replace(/ñ/g,"n");
				deno=deno.replace(/Ñ/g,"N");
				deno=deno.replace(/'/g," ");*/
				document.form1.buscarDenominacion.value=deno;
				document.form1.buscarNIFCIF.value="";
				document.form1.submit();
			break;
			
		case 'buscarNIFCIF' : 
				document.form1.buscarDenominacion.value="";
				document.form1.submit();
			break;

		default : 
			break;	
		}		
	}
}

function on(objeto) {
objeto.style.background='#e6e6e6';
}
 
function off(objeto) {
objeto.style.background='#ffffff';
}

function over(objeto) {
objeto.className='filaover';
}

function no_over(objeto,celda) {
objeto.className=celda;
}



/* Funciones Fermin */
//ocultar
function ocultar(){
	clearInterval(timer);
	clearTimeout(tim_chkC);
	clearTimeout(tim_chkF);
	mouse_inC = false;
	mouse_inF = false;
	alto = 0;
	ref.style.clip='rect(0, 195px, 0, 0)';
}
//cortinilla
var timer=null;
var alto = 0;
var ref = null;


//inicializar (lo llamamos justo antes que lo del clicktracks)
function inicializar(){
  ref = document.getElementById('fondo_oculto');
  if (ref){
	  ref.onmouseover = alEntrarF;
	  ref.onmouseout = alSalirF;
  }
  ref = document.getElementById('cont_oculto');
  if (ref){
	  ref.onmouseover = alEntrarC;
	  ref.onmouseout = alSalirC;
  }
  ref = document.getElementById('acceso_oculto');
}


function entsubPrueba(evento,urlMicrosite,campo,boton) {

var act = escape("/ms/"+urlMicrosite+"/busqueda_empresas.htm");
document.form1.action = act;

	if ((evento.keyCode == 13 || evento.which == 13) || boton) {
	switch (campo.name) {

		case 'buscarDenominacion' : 
				var deno = document.form1.buscarDenominacion.value;

				if(deno==''){
					alert('Introduzca un t\u00E9rmino de b\u00FAsqueda');
				}else{
				document.form1.buscarDenominacion.value=deno;
				document.form1.buscarNIFCIF.value="";
				document.form1.submit();
				}
			break;
			
		case 'buscarNIFCIF' : 
				var nif = document.form1.buscarNIFCIF.value;
				nif = nif.toUpperCase();

				if(nif==''){
					alert('Introduzca un CIF/NIF');
				}else{				
					document.form1.buscarDenominacion.value="";
					document.form1.buscarNIFCIF.value=nif;
					document.form1.submit();
				}				
			break;

		default : 
			break;	
		}		
	}
}

function limp(objeto) {
var campo = objeto.name;
	switch (campo) {
		case 'buscarDenominacion' : 
			if (objeto.value=='Por Nombre') { objeto.value=""; objeto.select(); return; } 
			if (objeto.value=='') 				  { objeto.value="Por Nombre"; return; } 
			break;

		case 'buscarNIFCIF' : 
			if (objeto.value=='Por CIF/NIF') { objeto.value=""; objeto.select(); return; }		
			if (objeto.value=='') 		   { objeto.value="Por CIF/NIF"; return; }		
			break;
	}
 }


function configuraAnchoPaginasBusqueda(ancho){
//tenemos que considerar 300 px del alto del bloque de servicios.
//alert(ancho+'    navegador:'+navigator.appName);

    var divcontenedorGlobalFondo = document.getElementById('contenedorGlobalFondo');
	var divcontenedorContenido = document.getElementById('contenedorContenido');
	var divdentroContenedor = document.getElementById('dentroContenedor');
		
	if(ancho >= 672 || ancho >= 697){//si se supera el ancho preefijado en la hoja de estilos. 309 (explorer y mozilla) 284 para el resto nav.
		divcontenedorGlobalFondo.style.height = '1060px';
		divcontenedorContenido.style.minHeight = '870px';
		divdentroContenedor.style.height = '870px';
	}else if(ancho >= 474){//para navegador opera cuando solo se encuentran entre 3 y 8 firmas
		divcontenedorGlobalFondo.style.height = '940px';
		divcontenedorContenido.style.minHeight = '750px';
		divdentroContenedor.style.height = '750px';
	}else if(ancho < 474){//para navegador opera cuando solo se encuentran un par de firmas o ninguna
			divcontenedorGlobalFondo.style.height = '800px';
		divcontenedorContenido.style.minHeight = '610px';
		divdentroContenedor.style.height = '610px';
	}	


}

function configuraAnchoPaginasNoticias(ancho){
//alert(ancho+'    navegador:'+navigator.appName);

    var divcontenedorGlobalFondo = document.getElementById('contenedorGlobalFondo');
	var divcontenedorContenido = document.getElementById('contenedorContenido');
	var divdentroContenedor = document.getElementById('dentroContenedor');
		
	if(ancho < 315){//si se supera el ancho preefijado en la hoja de estilos. 309 (explorer y mozilla) 284 para el resto nav.
		divcontenedorGlobalFondo.style.height = '680px';
		divcontenedorContenido.style.minHeight = '490px';
		divdentroContenedor.style.height = '490px';
	}else if(ancho > 1000){
		divcontenedorGlobalFondo.style.height = ancho+460+'px';
		divcontenedorContenido.style.minHeight = ancho+270+'px';
		divdentroContenedor.style.height = ancho+270+'px';
		
		}else{
		divcontenedorGlobalFondo.style.height = ancho/2+660+'px';
		divcontenedorContenido.style.minHeight = ancho/2+470+'px';
		divdentroContenedor.style.height = ancho/2+470+'px';
	
	}


}

function configuraAnchoPaginasPerfilEmpresa(ancho){
//tenemos que considerar 300 px del alto del bloque de servicios.
//alert(ancho+'    navegador:'+navigator.appName);

    var divcontenedorGlobalFondo = document.getElementById('contenedorGlobalFondo');
	var divcontenedorContenido = document.getElementById('contenedorContenido');
	var divdentroContenedor = document.getElementById('dentroContenedor');
		
	if(ancho < 615){//si se supera el ancho preefijado en la hoja de estilos. 309 (explorer y mozilla) 284 para el resto nav.
		divcontenedorGlobalFondo.style.height = '1070px';
		divcontenedorContenido.style.minHeight = '880px';
		divdentroContenedor.style.height = '880px';
	}else if(ancho > 700){
		divcontenedorGlobalFondo.style.height = ancho+560+'px';
		divcontenedorContenido.style.minHeight = ancho+370+'px';
		divdentroContenedor.style.height = ancho+370+'px';
		
		}else{
		divcontenedorGlobalFondo.style.height = '990px';
		divcontenedorContenido.style.minHeight = '800px';
		divdentroContenedor.style.height = '800px';
	
	}


}


/*google maps*/
function ver(){
/*en el caso de que google maps encuentre la direccion solicitada, se mostrara un texto con un enlace
el cual al pulsarle desplegará el mapa de google con la hubicación,si se decide pulsar el enlace se ocultará el mapa*/
	var objeto = document.getElementById('map');
    
	
	if(botonVisible==true && (objeto.className=="mapNone")){
		//document.getElementById('map').style.visibility='visible';
		//document.getElementById('map').style.display='block';
		objeto.className="mapBlock";
		document.getElementById('texto_google').innerHTML = "Ocultar Google Maps";
		document.getElementById('boton_google').title="Ocultar mapa";
		//cuando oculto mapa gmpas tengo que disminuir el tamaño de las capas
		configuraAnchoPaginasPerfilEmpresa(750);
	}else{
		//document.getElementById('map').style.visibility='hidden';
		//document.getElementById('map').style.display='none';
		objeto.className="mapNone";
		document.getElementById('texto_google').innerHTML = "Ver en Google Maps";
		document.getElementById('boton_google').title="Mostrar mapa";
		//cuando oculto mapa gmpas tengo que disminuir el tamaño de las capas
		configuraAnchoPaginasPerfilEmpresa(620);
	}

}


 function ocultaMapaCarga(){
 //una vez cargado el mapa en la funcion load, ocultamos el div que lo incluye 
 //para evitar que se muestre el mapa sino recupera datos
 //y además habilitar un boton para mostrar/ocultar el mapa.
 var objeto = document.getElementById('map');
 objeto.className="mapNone";
 //document.getElementById('map').style.visibility='hidden';
 //document.getElementById('map').style.display='none';
 }



