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(id)
				{
			
					document.getElementById("sample" + id).style.display = "block";
					var elemento = document.getElementById("test_it" + id);
					var posAlto = getAbsoluteElementPositionY(elemento);
					posAlto = posAlto + 15;
					var posAncho = getAbsoluteElementPositionX(elemento);
					posAncho = posAncho - 140; 
					document.getElementById("sample" + id).style.top = posAlto+"px";
					document.getElementById("sample" + id).style.left = posAncho+"px";
				
					//document.getElementById('abierto').value = id;
				}



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 update() {

	if (navigator.appName != "Microsoft Internet Explorer") {
		var alto = window.innerHeight - 129;
		//document.getElementById("contenido").style.height = alto + 'px';
	} else {
			var alto = document.documentElement.clientHeight - 132;
			//contenido.style.height = alto + "px";
	}
	
}


function mostrar_ocultarUL(id){
   	if (document.getElementById('ul'+id).style.display == 'none' || document.getElementById('ul'+id).style.display == '' ) {
		document.getElementById('ul'+id).style.display ='block';
		document.getElementById('plus'+id).firstChild.nodeValue = '[-]';
	} else {
		document.getElementById('ul'+id).style.display='none';
		document.getElementById('plus'+id).firstChild.nodeValue = '[+]';
	}
}



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 mostrar_rel(id){
	if (document.getElementById('rel_'+id).style.display != 'none'){
		document.getElementById('rel_'+id).style.display = 'none';
		document.getElementById('plus_id_'+id).firstChild.nodeValue = '[+]';
	}	
	else {
		document.getElementById('rel_'+id).style.display = 'block'
		document.getElementById('plus_id_'+id).firstChild.nodeValue = '[-]';
	}
}

function mostrar_sub(id){
	if (document.getElementById('td_sub_'+id).style.display != 'none'){
		document.getElementById('td_sub_'+id).style.display = 'none';
		
	}	
	else {
		document.getElementById('td_sub_'+id).style.display = 'block'
		document.getElementById('imagen_'+id).src = '/fitnesskit/images/signo_menos.jpg'
	}
}


function cambiaFechaSalidaRes()
{
	dayIn = document.getElementById('dia_entrada');
	monthIn = document.getElementById('mes_entrada');
	dayOut = document.getElementById('dia_salida');
	monthOut = document.getElementById('mes_salida');
	
	if(dayIn.value != 31)
	{
		dayOut.selectedIndex = dayIn.value;	
		monthOut.selectedIndex = monthIn.selectedIndex;
	}
	else
	{
		dayOut.selectedIndex = 0;
		monthOut.selectedIndex = monthIn.selectedIndex+1;
	}
}

function enviarFrmReservas()
{
	diaFechaIni = document.getElementById("dia_entrada").value;
	arrFechaIni = document.getElementById("mes_entrada").value.split("-");
	mesFechaIni = arrFechaIni[0];
	anioFechaIni = arrFechaIni[1];
	var fecha_ini = document.createElement("input");
	fecha_ini.value = diaFechaIni + "/" + mesFechaIni + "/" + anioFechaIni;
	
	
	diaFechaFin = document.getElementById("dia_salida").value;
	arrFechaFin = document.getElementById("mes_salida").value.split("-");
	mesFechaFin = arrFechaFin[0];
	anioFechaFin = arrFechaFin[1];
	var fecha_fin = document.createElement("input");
	fecha_fin.value = diaFechaFin + "/" + mesFechaFin + "/" + anioFechaFin;
	
	var fechaAct = document.createElement("input");
	fechaAct.value = "08/10/2008";
	
	if("ru" == "es"){
		entrada_mayor_actual = decodificar_palabras_rusas("La fecha de entrada debe ser mayor o igual a la fecha actual");
		salida_mayor_actual = decodificar_palabras_rusas("La fecha de salida debe ser mayor a la fecha actual");
		entrada_mayor_salida = decodificar_palabras_rusas("La fecha de salida debe ser mayor a la fecha de entrada");
	} else
	{
		entrada_mayor_actual ="La fecha de entrada debe ser mayor o igual a la fecha actual";
		salida_mayor_actual ="La fecha de salida debe ser mayor a la fecha actual";
		entrada_mayor_salida ="La fecha de salida debe ser mayor a la fecha de entrada";
	}
		
		
	
	if (DiferenciaFechas ("Fecha Actual", fechaAct, "Fecha de entrada", fecha_ini, '/' , false) < 0)
	{
		alert (entrada_mayor_actual);
		return false;
	}
	
	if (DiferenciaFechas ("Fecha Actual", fechaAct, "Fecha de salida", fecha_fin, '/', false) < 1)
	{
		alert (salida_mayor_actual);
		return false;
	}
	
	if (DiferenciaFechas ("Fecha de entrada", fecha_ini, "Fecha de salida", fecha_fin, '/', false) < 1)
	{
		alert (entrada_mayor_salida);
		return false;
	}
	

	if(document.getElementById("hoteles").value == 58)
	{
		document.getElementById("action").value= "verFormApartamentos";
		document.getElementById("modul").value = "reservas";
		document.getElementById("template").value = "formApartamentos";
		document.getElementById("id_seccion").value = 44;
	}
	document.getElementById("frmBuscadorReserva").submit();
	return false;
}

//agregar a favoritos
var url="http://jespelet.atraczion.com.ar";
var titulo="MotosprintShop.com - find your equipment";
function agregar_favoritos(){
 if (navigator.appName=="Microsoft Internet Explorer") 
 { 
 	if(parseInt(navigator.appVersion)>=4) { //si es IE 
		window.external.AddFavorite(url,titulo);
		}
	else { //si es FireFox 
      if(navigator.appName == "Netscape") 
		 window.sidebar.addPanel(titulo,url,'');
   }
  }
}
	// <![CDATA[
	$(document).ready(function(){
		
			$('select[name="por_pagina"]').change(function(){
				document.location = document.location + "&por_pagina="+$(this).val();
				return false;
			});
						
			
			// EMPIEZA Validacion & Ajax Form del Boletin
			$('input#mailboletin').click(function(){
				if(!$(this).hasClass('modificado'))
				{
					$(this).val('');
					$(this).addClass('modificado');
				}
			});

			$('form#formboletin').validate({
				onfocusout: false,
				onkeyup: false,
				onclick: false,
				focusInvalid: false,
				focusCleanup: true,
				submitHandler: function(form) {
					$.getJSON($(form).attr('action')+'?'+$(form).formSerialize(),
						function(data){
							switch(data.msg)
							{
								case 1:
									alert("Gracias por registrarte.");
									break;
								case 2:
									alert("No se introdujo un mail correcto.");
									break;
								case 3:
									alert("El mail ya se encuentra registrado.");
									break;
							}
					});
				}
			});
			
			
			
			$('input#mailboletin_pie').click(function(){
				if(!$(this).hasClass('modificado'))
				{
					$(this).val('');
					$(this).addClass('modificado');
				}
			});

			$('form#formboletin_pie').validate({
				onfocusout: false,
				onkeyup: false,
				onclick: false,
				focusInvalid: false,
				focusCleanup: true,
				submitHandler: function(form) {
					$.getJSON($(form).attr('action')+'?'+$(form).formSerialize(),
						function(data){
							switch(data.msg)
							{
								case 1:
									alert("Gracias por registrarte.");
									break;
								case 2:
									alert("No se introdujo un mail correcto.");
									break;
								case 3:
									alert("El mail ya se encuentra registrado.");
									break;
							}
					});
				}
			});		
							
	});		
	// ]]>

	function getAbsoluteElementPositionY(element) {
	
				if (typeof element == "string")
				{
					element = document.getElementById(element)
				}
				if (!element) return 0;
				var y = 0;
				var x = 0;
				while (element.offsetParent) {
					x += element.offsetLeft;
					y += element.offsetTop;
					element = element.offsetParent;
				}
				return y;
			}
			
			function getAbsoluteElementPositionX(element) {
			
				if (typeof element == "string")
				{
					element = document.getElementById(element)
				}
				if (!element) return 0;
				var y = 0;
				var x = 0;
				while (element.offsetParent) {
					x += element.offsetLeft;
					y += element.offsetTop;
					element = element.offsetParent;
				}
				return x;
			}

			function ensenar(id)
				{
			
					document.getElementById("sample" + id).style.display = "block";
					var elemento = document.getElementById("test_it" + id);
					var posAlto = getAbsoluteElementPositionY(elemento);
					posAlto = posAlto + 15;
					var posAncho = getAbsoluteElementPositionX(elemento);
					posAncho = posAncho - 140; 
					document.getElementById("sample" + id).style.top = posAlto+"px";
					document.getElementById("sample" + id).style.left = posAncho+"px";
				
					//document.getElementById('abierto').value = id;
				}


				function esconder(id)
				{
					document.getElementById("resumen").style.display = "none";
				}
				
				function borrar(id){
					
					if(document.getElementById(id+'_control').value==0){
							document.getElementById(id).value='';
							document.getElementById(id+'_control').value=1;
					}

				}
	
	
			//agregar a favoritos
			var url="http://jespelet.atraczion.com.ar";
			var titulo="MotosprintShop.com - find your equipment";
			function agregar_favoritos(){
			 if ((navigator.appName=="Microsoft Internet Explorer") && 
					 (parseInt(navigator.appVersion)>=4)) { //si es IE 
					window.external.AddFavorite(url,titulo);
					}
				else { //si es FireFox 
				  if(navigator.appName == "Netscape") 
					 window.sidebar.addPanel(titulo,url,'');
			   }
			
			}
			// <![CDATA[
			$(document).ready(function(){
				
			
			// EMPIEZA Validacion & Ajax Form del Boletin
			$('input#mailboletin').click(function(){
				if(!$(this).hasClass('modificado'))
				{
					$(this).val('');
					$(this).addClass('modificado');
				}
			});
			
			$('a[id="btn_localizar"]').click(function(){
				
				if($('select[name="operador"]').val() != 0)
				{
					window.open($('select[name="operador"]').val(),'_blank','width=700, height=500');					
				}
				
				return false;
			});

			
			$('form#formboletin').validate({
				onfocusout: false,
				onkeyup: false,
				onclick: false,
				focusInvalid: false,
				focusCleanup: true,
				submitHandler: function(form) {
					$.getJSON($(form).attr('action')+'?'+$(form).formSerialize(),
						function(data){
							switch(data.msg)
							{
								case 1:
									alert("Gracias por registrarte.");
									break;
								case 2:
									alert("No se introdujo un mail correcto.");
									break;
								case 3:
									alert("El mail ya se encuentra registrado.");
									break;
							}
					});
				}
			});
						
							
	});		
	// ]]>


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
















