function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }
  return {top:y,left:x};
}


function ensenar()
{
	document.getElementById("resumen").style.display = "block";
  	var elemento = document.getElementById("otrosEnlaces");
  	var pos = getAbsoluteElementPosition(elemento);
	pos.top = pos.top - 150;
	document.getElementById("resumen").style.top = pos.top+"px";
	document.getElementById("resumen").style.left = pos.left+"px";
}

function esconder()
{
	document.getElementById("resumen").style.display = "none";
}

function mostrar(id)
{
	if (document.getElementById('td_sub_' + id)!= 'null'){
		if (document.getElementById('td_sub_' + id).style.display != ''){
			document.getElementById('td_sub_' + id).style.display ='';
			document.getElementById('vinculo' + id).className ="link1_over";
		}
		else {
			document.getElementById('td_sub_' + id).style.display='none';
			document.getElementById('vinculo' + id).className ="link1";
		}
	}
}

function mostrarocultar()
{
 	   if (document.getElementById("subterminos").style.display != 'none'){
			document.getElementById("subterminos").style.display ='none';
		}
		else {
			document.getElementById("subterminos").style.display='block';
		}
}


function changed(number)
	{
	var l=document.form1.LandID;
			var h=document.form1.HafenID;
			var r=document.form1.RevierID;
	
			if(number!=1){ l.options.selectedIndex=0; }
			if(number!=2){ h.options.selectedIndex=0; }
			if(number!=3){ r.options.selectedIndex=0; }
	
	}
	
	function y2k(number)
	{
	return (number < 1000) ? number + 1900 : number;
	}
	
	var today = new Date();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = y2k(today.getYear());
	var curfield = 1;
	var AllDay=true;
	var LangCode='es';
	function padout(number) { return (number < 10) ? '0' + number : number; }
	
	function restart() {
		if (curfield == 1)
		{
		 document.form1.fechaBus.value = padout(day) + "/" + padout(month - 0 + 1) + "/" + year;
	
			  if(AllDay)
			  {
					fechafin = new Date();
					fechafin.setFullYear(year);
					fechafin.setMonth(month);
					fechafin.setDate(day);
					fechafin.setHours(0);
					fechafin.setMinutes(0);
	
					fechafin.setTime(fechafin.getTime()+60000*60*24*7);
	
					year2 = fechafin.getFullYear();
					month2= fechafin.getMonth();
					day2 = fechafin.getDate();
					//document.form1.DateTo.value = '' + padout(day2) + '-' + padout(month2 - 0 + 1) + '-' + year2;
			 }
			else
			 {
					document.form1.DateTo.value = '' + padout(day) + '/' + padout(month - 0 + 1) + '/' + year;
		  }
		}
		else
		  document.form1.DateTo.value = '' + padout(day) + '/' + padout(month - 0 + 1) + '/' + year;
		mywindow.close();
	}
	
	function newWindowDepart() {
		curfield = 1;
	//    if (mywindow != null) mywindow.close();
		mywindow=open("http://www.todoveleros.com/cal.htm","myname","resizable=no,width=280,height=280, left=100, top=100");
		if (mywindow.opener == null) mywindow.opener = self;
		mywindow.focus();
	}
	
	function newWindowReturn() {
		curfield = 2;
	//    if (mywindow != null) mywindow.close();
		mywindow=open("http://www.todoveleros.com/cal.htm","myname","resizable=no,width=280,height=280, left=100, top=100");
		if (mywindow.opener == null) mywindow.opener = self;
		mywindow.focus();
	}
	
	
	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_reloadPage(init) {  //reloads the window if Nav4 resized
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
	//-->

	function activaImg(nombre){
	  	document.images[nombre].src="http://www.todoveleros.com/img/"+nombre+"_on.gif";
	}
	function desactivaImg(nombre){
	  	document.images[nombre].src="http://www.todoveleros.com/img/"+nombre+".gif";
	}

	function info(){
		window.open('http://www.todoveleros.com/infoGnral.php?opcion=3','info','toolbar=no, width=400, height=300');
	}		

	function idioma(){
		window.open('http://www.todoveleros.com/infoGnral.php?opcion=1','cuerpo');
		window.open('http://www.todoveleros.com/cabecera.php','cabecera');
		window.open('http://www.todoveleros.com/pie.php','pie');				
	}	
	



	function editar(id) {
			document.form1.idBarco.value = id;
			document.form1.operacion.value	= "EDITAR";			
			window.setTimeout('document.form1.submit()',100);		
		}	
		function reservar(id) {
			window.open('http://www.todoveleros.com/reservas.php?idBarco='+id,'_self');
		}	
		function buscar() {
			msg = 'Por favor revise el valor de los siguientes campos:\n';
			ok=true;		
			if ((document.form1.fechaBus.value!='') && (document.form1.semanas.value==0)){
				ok=false;
				msg = msg +'\n - Debe indicar fecha de salida y número de semanas';
			}
			if (!ok) {
				alert(msg);
			} else {
				document.form1.operacion.value	= "LISTADO";			
				window.setTimeout('document.form1.submit()',100);		
			}			
		}		
		function cancelar() {
			document.form1.reset();
		}
		function volverInforme() {
			document.form1.operacion.value	= "LISTADO";			
			window.setTimeout('document.form1.submit()',100);		
		}	
		function volver() {					
			//document.form1.departamento.value	= 0;	
			document.form1.operacion.value	= "INICIO";		
			window.setTimeout('document.form1.submit()',100);		
		}		
		function mostrar(num) {
		for (i=1;i<=3;i++)
			document.all('examinar'+i).style.display='none';		
		if (document.all('examinar'+num).style.display=='none') 
			document.all('examinar'+num).style.display='block';
		else 
			document.all('examinar'+num).style.display='none';
	}		
	function openCalendar() {					
		zona 		= document.form1.zona.value;
		marca 		= document.form1.marca.value;
		casco 		= document.form1.casco.value;
		eslora		= document.form1.eslora.value;
		camarotes	= document.form1.camarotes.value;
	//	categoria 	= document.form1.categoria.value;
	//	patron 		= document.form1.patron.value;
		fechaBus 	= document.form1.fechaBus.value;																										
	//	window.open('calendar_busqueda.php?zona='+zona+'&marca='+marca+'&casco='+casco+'&categoria='+categoria+'&eslora='+eslora+'&camarotes='+camarotes+'&patron='+patron,'calendarB','toolbar=no, resize=true, scroll=auto, width=180, height=150');		
		window.open('http://www.todoveleros.com/calendar_busqueda.php?zona='+zona+'&marca='+marca+'&casco='+casco+'&eslora='+eslora+'&camarotes='+camarotes,'calendarB','toolbar=no,  dependent=yes, alwaysRaised=yes, resize=true, scroll=auto, width=180, height=150');		
	}	
	function abrirFoto(id,ancho,alto){
		window.open('http://www.todoveleros.com/fotos.php?idFichero='+id+'&ancho='+ancho+"&alto="+(alto+30),'foto','resizable=yes, dependent=yes, alwaysRaised=yes, toolbar=no, width='+ancho+', height='+(alto+30));
	}			
	function abrirGestion(){
		window.open('http://www.todoveleros.com/introBarco.php','intro','resizable=yes, dependent=yes, alwaysRaised=yes, toolbar=no, width=700, height=450');
	}	
	function recomendar(id)  {
		window.open('http://www.todoveleros.com/recomendar.php?idBarco='+id,'recomenda','toolbar=no, width=300, height=300');
	}		
	
	
		
		function favorito(){ 
			if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
				var url="http://www.todoveleros.com";
				var title="Todoveleros S.L., Alquiler de veleros";
				window.external.AddFavorite(url,title); 	
			}else {
				var msg = "No olvide añadirnos a sus favoritos!";
				if(navigator.appName == "Netscape") msg += "  (CTRL-D)";
				document.write(msg);
			}
		}
		
			function editar(id) {
			document.form1.idBarco.value = id;
			document.form1.operacion.value	= "EDITAR";			
			window.setTimeout('document.form1.submit()',100);		
		}	
		function reservar(id) {
			window.open('http://www.todoveleros.com/reservas.php?idBarco='+id,'_self');
		}	
		function buscar() {
			msg = 'Por favor revise el valor de los siguientes campos:\n';
			ok=true;		
			if ((document.form1.fechaBus.value!='') && (document.form1.semanas.value==0)){
				ok=false;
				msg = msg +'\n - Debe indicar fecha de salida y número de semanas';
			}
			if (!ok) {
				alert(msg);
			} else {
				document.form1.operacion.value	= "LISTADO";			
				window.setTimeout('document.form1.submit()',100);		
			}			
		}		
		function cancelar() {
			document.form1.reset();
		}
		function volverInforme() {
			document.form1.operacion.value	= "LISTADO";			
			window.setTimeout('document.form1.submit()',100);		
		}	
		function volver() {					
			//document.form1.departamento.value	= 0;	
			document.form1.operacion.value	= "INICIO";		
			window.setTimeout('document.form1.submit()',100);		
		}		
		function mostrar(num) {
		for (i=1;i<=3;i++)
			document.all('examinar'+i).style.display='none';		
		if (document.all('examinar'+num).style.display=='none') 
			document.all('examinar'+num).style.display='block';
		else 
			document.all('examinar'+num).style.display='none';
	}		
	function openCalendar() {					
		zona 		= document.form1.zona.value;
		marca 		= document.form1.marca.value;
		casco 		= document.form1.casco.value;
		eslora		= document.form1.eslora.value;
		camarotes	= document.form1.camarotes.value;
	//	categoria 	= document.form1.categoria.value;
	//	patron 		= document.form1.patron.value;
		fechaBus 	= document.form1.fechaBus.value;																										
	//	window.open('calendar_busqueda.php?zona='+zona+'&marca='+marca+'&casco='+casco+'&categoria='+categoria+'&eslora='+eslora+'&camarotes='+camarotes+'&patron='+patron,'calendarB','toolbar=no, resize=true, scroll=auto, width=180, height=150');		
		window.open('http://www.todoveleros.com/calendar_busqueda.php?zona='+zona+'&marca='+marca+'&casco='+casco+'&eslora='+eslora+'&camarotes='+camarotes,'calendarB','toolbar=no,  dependent=yes, alwaysRaised=yes, resize=true, scroll=auto, width=180, height=150');		
	}	
	function abrirFoto(id,ancho,alto){
		window.open('http://www.todoveleros.com/fotos.php?idFichero='+id+'&ancho='+ancho+"&alto="+(alto+30),'foto','resizable=yes, dependent=yes, alwaysRaised=yes, toolbar=no, width='+ancho+', height='+(alto+30));
	}			
	function abrirGestion(){
		window.open('http://www.todoveleros.com/introBarco.php','intro','resizable=yes, dependent=yes, alwaysRaised=yes, toolbar=no, width=700, height=450');
	}	
	function recomendar(id)  {
		window.open('http://www.todoveleros.com/recomendar.php?idBarco='+id,'recomenda','toolbar=no, width=300, height=300');
	}	