var elfoco = false;     //Para saber que adulto - Niņo fue seleccionado
var IdSeat_foco;        //Que id del Adulto - Niņo fue seleccionado
var Avion_Select;       //Indica que Avion esta Revisando
var Tmpmoveobj;
var Tmpobj;             //objeto que se va a buscar la posicion..

function SubmitFromArray(formaArr){
        formaArr.submit() ;
        }


// Put Focus if Called
if (window.focus) {
	self.focus();
	}
	
function changeactionform(forma,url){
        forma.action = url;        
        }

// openWindow function for photo gallery
function openGallery(src) {
	popupWin = window.open(src,'gallery', 'top=25,left=25,width=415,height=385,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
// openWindow function for photo gallery
function openMeetingMap(src) {
	popupWin = window.open(src,'gallery', 'top=25,left=25,width=400,height=300,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
// openWindow function for calendar
function openCalendar(src) {
	popupWin = window.open(src,'calendar', 'top=35,left=35,width=373,height=380,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for room info
function openRoomInfo(src) {
	popupWin = window.open(src,'Rooms', 'top=25,left=25,width=415,height=300,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for billing and cancelation policies
function openTerms(src) {
	popupWin = window.open(src,'Terms', 'top=25,left=25,width=465,height=300,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for print rates
function openRates(src) {
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}


function openRatesHotelList_T1(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&dia_hasta=' + document.forma.dia_hasta.value +  '&mes_hasta=' + document.forma.mes_hasta.value + '&anio_hasta=' + document.forma.anio_hasta.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
         
function openRatesHotelList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=todito&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&dia_hasta=' + document.forma.dia_hasta.value +  '&mes_hasta=' + document.forma.mes_hasta.value + '&anio_hasta=' + document.forma.anio_hasta.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}


function openRatesHotelList_T1_2(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&nights=' + document.forma.nights.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesTourList_T1(asoc,idioma,destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Tours&View=List&Idioma=ESP&moneda=PE&destino=' + destino 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesTourList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=todito&Type=Tours&View=List&Idioma=ESP&moneda=PE&destino=' + destino 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

//http://www.e-travelsolution.com/reservations/partners.aspx?view=info&airport=cun&type=Transfers&Asoc=livcun

function openRatesTransferList_T1(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/reservations/partners.aspx?view=info&airport=' + destino +  '&type=Transfers&Asoc=t1msnmx&Menu=yes' 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')		
}



function openRatesTransferList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/reservations/partners.aspx?view=info&airport=' + destino +  '&type=Transfers&Asoc=todito&Menu=yes' 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}


// openWindow function for tour info
function openInfoTour(src) {
	popupWin = window.open(src,'Tour', 'top=25,left=25,width=550,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open('','newWindow',"width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function openWindowMap(src,imageWidth,imageHeight) {
	popupWin = window.open(src,'Map', 'top=25,left=25,width='+imageWidth+',height='+imageHeight+',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function Redirect(forma,url) {
	forma.action=url;
	forma.submit();
}


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];}
}

// openWindow function for tour info or hotel info asoc
function OpenPopAsoc(src, tipo) {
	popupWin = window.open(src,tipo, 'top=25,left=25,width=635,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// <a href="#" onClick="javascript:openCalendar('/_lib/asp/popCalendarTour/?clav_tour=2&clav_servicio=1&clav_ciudad_origen=CUN&Month=9&Year=2005');"

// openWindow function for tour info or Hotel asoc in Pop Up
function OpenPopAsocRedirect(forma, src, tipo) {
    //forma.target=window.open(src,tipo, 'top=25,left=25,width=635,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
    //forma.target='_blank';
	//forma.action=src;
	//forma.submit();
	}
function submitoptions(idioma,recalcular,action)
{

  error = false;

  if (document.forma.Check_transfer)
	{
	    if (document.forma.Check_transfer.checked == true & (document.forma.AirlineReturn.value == " || document.forma.AirlineGo.value == " ))
	     {
		    if (idioma == "ing")
		     {
		        alert("Please Indicate the airline and flight number for your airport shuttle") ;
		        return ;
		     }
		    if (idioma == "esp")
		    {
		        alert("Por favor indique la aerolinea y vuelo para su traslado del aeropuerto") ;
		        return ;
		    }
	     }
	    if (recalcular == "yes")
	    {
		    document.forma.submit();
		    return;
	    }

	    if (recalcular == "no")
	    {
	        document.forma.action = action;
	        document.forma.submit();
	    }
	    return true;
	
	}
	else
	{
        if (recalcular == "yes")
	    {
		    document.forma.submit();
		    return;
	    }

	    if (recalcular == "no")
	    {
	        document.forma.action = action;
	        //document.forma.submit();
	    }
		document.forma.submit();
	}
}

function ol(elURL)
  {
  window.open(elURL)
  }
  

// **********************************************************************************************************
//                       FUNCIONES PARA PAQUETES DE AVION + HOTEL
// **********************************************************************************************************
   
function showPage(sshow)
{
	//0 = Oculta
	//1 = Mostrar		
	var obj = document.getElementById('cajon')	
	//Si existe oculta el div de pagina espera
	if (obj != null) 
	{		
		if (sshow == 1)   {
			eval ("document.getElementById('cajon').style.display=''");  
		}
		else {
			eval ("document.getElementById('cajon').style.display='none'");  
		}
	}
 }
 
  //Mas Vuelos de paquetes
  function Next_Flights(maxGroups)
  { 
    var i = 0;
    var presiono;
    
    presiono = document.getElementById('cuenta').value;
    presiono++;
    
    document.getElementById('cuenta').value = presiono; //paso el valor nuevo al
       
     for (i=1; i<=maxGroups; i++)
     {
        //Si ya revaso el maximo ?
        if (presiono > maxGroups ) {             
          Hide_Flights(maxGroups);  //Oculto los Objetos
          document.getElementById('cuenta').value = 1;  //Regreso al primer valor
          eval ("document.getElementById('flight_group_1').style.display=''"); 
         } else
         {
          if (i == presiono) {
            eval ("document.getElementById('flight_group_" + i +"').style.display=''"); 
          } else
          {
            eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 
          }
         }
      }   
  }
  
  //Menos Vuelos de paquetes
  function Previus_Flights(maxGroups)
  { 
    var i = 0;
    var presiono;
    
    presiono = document.getElementById('cuenta').value;
    presiono--;
    
    document.getElementById('cuenta').value = presiono; //paso el valor nuevo al
        
    //debugger;        
    //Hide_Flights (maxGroups)
    
     for (i=1; i<=maxGroups; i++)
     {
        //Si ya revaso el maximo ?
        if (presiono < 1 ) {             
          Hide_Flights(maxGroups);  //Oculto los Objetos
          document.getElementById('cuenta').value = maxGroups;  //Regreso al primer valor
          eval ("document.getElementById('flight_group_" + maxGroups +  "').style.display=''"); 
         } else
         {
          if (i == presiono) {
            eval ("document.getElementById('flight_group_" + i +"').style.display=''"); 
          } else
          {
            eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 
          }
         }
      }
    //alert(presiono);      
  }
  
  //Oculta Todos los Vuelos
  function Hide_Flights (maxGroups) 
  { var i;
    for (i=1; i<=maxGroups; i++)
    {
        eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 
    }    
  }
  //Oculta Todos Asientos de Adultos - Niņos del Todos los Aviones
  function Hide_Adults_Childs(max) 
  { var i;
    for (i=1; i<=max; i++)
    {
        eval ("document.getElementById('Avion_SeatsAdNi_" + i +"').style.display='none'"); 
    }    
  }
  
  function Hide_Airplane(max) 
  { var i;
    for (i=1; i<=max; i++)
    {
        eval ("document.getElementById('avion_" + i +"').style.display='none'"); 
    }    
  }
  
  function Show_Airplane(avion,max)
  {        
      //elfoco  = false           //Bronca al poner el dato se queda con el enfoque anterior  del primer vuelo   
      Hide_Airplane(max);        //Oculto todos los Aviones 
      Hide_Adults_Childs(max);  //Oculto el Grupos de Asientos del Avion ( Adultos - Niņos )
      
      //Muestro el Avion del Vuelo Seleccionado
      eval ("document.getElementById('avion_" + avion +"').style.display=''");   
      //Muestro el Grupo de Asientos del Vuelo Seleccionado  ( Adultos - Niņos )
      eval ("document.getElementById('Avion_SeatsAdNi_" + avion +"').style.display=''");   
      //Busco el nombre del Vuelo seleccionado
      Name_Flight_Select(avion,max);
      //Cambio la Clase del Vuelos Seleccioando  
      change_class(avion,max);
      //Paso que Avion fue seleccionado    (Variable Global)      
      Avion_Select =  avion;  
           
  }
  
  //Busco y paso el nombre del Vuelo seleccionado
  function Name_Flight_Select(vuelo,max)
  { 
    var i;
    var myName="";
    for (i=1; i<=max; i++)
    {
        //Tomo el nombre del Vuelo Seleccionado 
        if (vuelo == i)
        {            
           myName = eval ("document.getElementById('Name_flight" + i +"').value");  //busco el nombre de vuelo selccionado           
           document.getElementById('Name_Selectflight').value = myName;   //paso el valor a un oculto           
        }   
    }     
      
  }
  
  function change_class(avion,max) 
  { var i; 
    
    //Hago  el barrido de todos los Vuelos
    for (i=1; i<=max; i++)
    {        
        //Cambio la clase del Vuelo Seleccionado
        if (avion == i)
        {
            //cambio la clase a SELECCIONADO
            eval ("document.getElementById('myclass_" + i +"').className='FlightSelect'"); //Vuelo Seleccionado
        }else
        {
            //cambio la clase a NO SELECCIONADO
            eval ("document.getElementById('myclass_" + i +"').className='FlightNonSelect'"); //Vuelo no seleccionado
        }        
    }    
  }
  
  // **********************************************************************************************************
  //                        VENTANA  EMERGENTE QUE INDICA EN QUE ASIENTO DEL AVION ESTOY UBICADO
  // **********************************************************************************************************
  /*var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie =  (appVer.indexOf('msie') != -1) && (!is_opera);*/

function getScrollXY() {
	var scrOfX = 35, scrOfY = 0;
	
	if( typeof( window.pageYOffset ) == 'number') 
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;		
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
			{
				//DOM compliant
				scrOfY = document.body.scrollTop;
				scrOfX = document.body.scrollLeft;
			} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
					{
					//IE6 standards compliant mode
					scrOfY = document.documentElement.scrollTop;
					scrOfX = document.documentElement.scrollLeft;
					}
	return [ scrOfX, scrOfY ];
}

function getWindowSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}

function $()
{
    //debugger;
	var _10=new Array();
	for(var i=0;i<arguments.length;i++)
	{ 	var _12=arguments[i];
		if(typeof _12=="string")
		{ _12=document.getElementById(_12);
		}
		if(arguments.length==1)
		{
		return _12;
		}
		_10.push(_12);
	}
	return _10;
}

function showPopupWithContent(content,obj,idhtml) 
{  

    var mleft;
    var mTop;
	var popupDiv = $('hdPopupDiv');  
	var popupContentDiv = $('hdPopupContent');
	//var popupTitleDiv = $('hdPopupTitle');
	//var popupActionsDiv = $('hdPopupActions');
	//var popupCloseButton = $('hdPopupCloseBtn');
	//var popupHeaderDiv = $('hdPopupHeader');	

	var popupWidthContainer = parseInt(popupWidth);
	//popupHeaderDiv.style.width = popupWidthContainer;
	//popupTitleDiv.innerHTML = '<strong>' + popupTitle + '</strong><img src="/_lib/images/info.gif" border="0" align="right" width="19">';
	//popupTitleDiv.style.overflow = "hidden";
	//popupTitleDiv.style.whiteSpace = "nowrap";
	//popupTitleDiv.style.width = popupWidth;//parseInt(popupWidth)-65;
    //popupActionsDiv.style.width = popupWidth;

	var popupHtml = content;
	//popupCloseButton.style.visibility = "visible";
	//popupCloseButton.style.display = "inline";
   	//popupCloseButton.style.left = ((popupWidth)/2)-56;
	//popupContentDiv.style.width = popupWidth-20;
	//popupContentDiv.style.height = parseInt(popupHeight)- 50;
	
	popupContentDiv.innerHTML = popupHtml;   //"<div>"+ popupHtml+"</div>";
	popupDiv.style.display = "block";
	
	var windowSize = getWindowSize();	
	//var scrollXY = getScrollXY();
	popupDiv.style.width = popupWidthContainer;
	popupDiv.style.position = "absolute";

	popupDiv.style.background = "#FFFFFF";
	//popupDiv.style.border = "1px solid #000000";	
	var posElementXY = getPositionElement(obj);
	
	//idhtml = vacio entonces arma el html en java
	if (idhtml == "")
	{    
	    mleft = (posElementXY[0] + 20);  //Left
        mTop = (posElementXY[1] + 20);	 //Top
	}
	else
	{   //Cuando envio el Html ( Tomo de la Pagina )
	    mleft = (posElementXY[0] + 50);  //Left
        mTop = (posElementXY[1] + 38);	 //Top
    }
	
	popupDiv.style.left = mleft; //left del Objeto  //((windowSize[0] - popupWidth ) / 2) + scrollXY[0];
	popupDiv.style.top = mTop;  //Top del Objeto  //((windowSize[1] - popupHeight) / 2) + scrollXY[1];
	popupDiv.style.zIndex = 100;
	
	displayLayer('hdPopupDiv',true);
}
function displayLayerAsObj(divObj, popup) 
{
    if(popup == true) 
	{
	 divObj.style.zIndex = 100;
	}
	divObj.style.visibility = "visible";
	divObj.style.display = "inline";
}
//Me da la Posicion Izquierda del elemento
function getPositionElement(elem)
{   
    var curleft=0;  //default left
    var curtop=0;   //default top       
    var obj = $(elem);   //tomo el nombre del elemento y convierto en objeto
    
    //Si tenemos al objeto
    if (obj != null)
     {       
        if (obj.offsetParent) 
        {
            curleft = obj.offsetLeft;  //tomo la posicion left del objeto
            curtop = obj.offsetTop;  //tomo el tope del objeto
            while (obj = obj.offsetParent) 
             {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
             }
        }
        curleft=parseInt(curleft);
        curtop=parseInt(curtop); 
    }   
    return [curleft, curtop];
} 

function displayLayer(layerName, popup) 
{
    var currentLayer = $(layerName);
	displayLayerAsObj(currentLayer, popup);
}
function hideLayer(layerName) 
{   
    var divObj = $(layerName)
       
	divObj.style.visibility = "hidden";
	divObj.style.display = "none";
}
function hidePopup(layerName) 
{      
    var Version =navigator.appVersion.substring(22,25);
	Version = parseInt(Version);
	if (navigator.appName=="Microsoft Internet Explorer")
		if (Version < 7)	    
            Mostrar_Elementos();
    hideLayer(layerName); 
}

function displayMesagge(event,ColBde_Tit,titseat,tittext,width,height,obj,idhtml) 
{  
 
    var ruta_imagen =  document.getElementById('Ruta_Imagen').value;  //Ruta de imagen del Sitio
    var content ="";
    var htmlTemp="";
        
	popupWidth = width;
	popupHeight = height;
		
	//Si no tiene valor  color le pongo Blanco
	if (ColBde_Tit=="")
	{
	 ColBde_Tit = "#FFFFFF";  //Blanco
	}
		
	
	//Significa que no trae Html debo pintar el que Armo en el Java
	if (idhtml =="")
	{
	
	    popupTitle = document.getElementById('Name_Selectflight').value;  //Nombre del Vuelo Seleccionado
    		
        //Armo el Html de la Ventana Emergente de las Cabinas de Avion		
    	
	    content += '<div style="height:100%; width:' + (popupWidth-5) + '; font-family: Trebuchet MS, Verdana;">'; 		
        content += '<table width="250" border="0" cellspacing="0" cellpadding="1" style="font-size:14px;">';
        content += '  <tr>';
        content += '    <td align="center" colspan="2" bgcolor="' + ColBde_Tit + '"><strong>' +  popupTitle +  '</strong></td>';
        content += '    <td bgcolor="'+  ColBde_Tit + '"><img src="' + ruta_imagen +    '/infoA.gif" width="19" height="19" border="0" align="right"></td>';
        content += '  </tr>';
        content += '  <tr>';
        content += '    <td valign="middle">';
        //'Segun el sitio pongo Ruta de Iamgen del Asiento      
        content += '<img src="' + ruta_imagen +    '/As_Disp.gif" border="0" vspace="2" hspace="2" align="right" />';
        content += '</td>';
        //Available Space
        content += '    <td style="font-size:12px">&nbsp;' +  tittext + '</td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';
        content += '  <tr>';
        content += '    <td >&nbsp;</td>';
        
        var num_seat = getSeat(obj);  //tomo el numero del asiento
        //Titulo Seat   y Numero de Asiento
        content += '    <td style="font-size:12px"><strong>' +  titseat  +  ':</strong>&nbsp;' + num_seat + '</td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';
        content += '  <tr>';
        content += '    <td align="center"><img src="' + ruta_imagen +    '/avionI.gif" width="26" height="22" border="0" align="left" /></td>';
        content += '    <td>&nbsp;</td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';
        content += '</table>';
        content += '</div>';
               
    
    }
	else  //Escupo el Html que le paso
	{	
	
	    ///alert('Id Html :  '  +  arrWindows_html[idhtml]);
	    htmlTemp = arrWindows_html[idhtml];
	    content += '<div style="height:100%; width:' + (popupWidth-5) + '; font-family: Trebuchet MS, Verdana;">'; 
	    content += htmlTemp;  //el Html que quiero mostrar
	    content += '</div>';
	    
	}	    
	    
	showPopupWithContent(content,obj,idhtml);	  //Escupo el Html que le pase o que Armo en Html   
  }
//Funcion que Regresa el Nombre del Asiento que recibe el enfoque  
function getSeat(obj)
{
    var val;
    var objseat = $(obj);   //Obtengo el Objeto asiento 
      
    val = objseat.alt;    //tomo su valor del alt        
    return val;  //Regreso el valor del asiento "ALT"   
}

//Pone el asiento selecionado al los Adultos - Niņos
function setSeatAdNi(obj,maxAd,maxNi)
{       
    //Nota:   obj = ( Nombre del Objeto 'V1_Seat1_1')
    var objseat = $(obj);           //Convierto en objeto el asiento
    var myseat = getSeat(obj);      //Obtengo el nombre del asiento           
    var maxObj = maxAd + maxNi;     //Sumo el total de Adultos + Niņos
    var armaObj;                    //Armo el nombre del objeto asiento
    var tmparmaObj;                 //Armo el nombre para cuando busco si el asiento fue asignado
    var arrayBusca;                  //Regreso true ķ false de encontardo y indice del  encontrado
    var obj_tomoval;                //Nombre del Objeto asiento de donde tomo el valor
    var armaObjPos;                 //Objeto donde esta ubicado el foco
    
    arrayBusca = Busca_Valor(myseat,maxObj);    //Busco si ya esta asignado el asiento asignado       
    armaObjPos = $('V' + Avion_Select + '_ubicado');   //elemento seleccionado ( Asiento )
    
    //Ya estaba ubicado anteriormente ? 
    if (armaObjPos.value=="")
    {
      elfoco = false;  //Obligo que sea automatico por lo tanto pondra al primer elemento vacio el asiento      
    } else
    {
     elfoco = true;  //Obligo que sea por seleccion     
     IdSeat_foco = armaObjPos.value;   //Obtengo la Posicion donde se quedo  Valor Hidden   
    }
                 
    //Elemento con FOCO ( Cuando se selecciono directamente el adulto - niņo )
    if  (elfoco == true) 
    {              
        armaObj = $('V' + Avion_Select + '_Seat_' + IdSeat_foco);           //asiento con el foco
        obj_tomoval = $('V' + Avion_Select + '_obj_click_' + IdSeat_foco);   //de que objeto asiento se tomo el valor
        tmparmaObj = $('V' + Avion_Select + '_Seat_' + arrayBusca[1]);      //Objeto en donde se encontro el valor
        
        //encontro el numero de asiento (ya se asigno anteriormente)
        if (arrayBusca[0] == true)        
          {         
            //Si son iguales los valores  limpio al adulto - Niņo          
            if (armaObj.value ==  tmparmaObj.value)
            { 
                          
              My_Seat(objseat,'AS_Disp.gif');   //Cambio su estado a disponible
              armaObj.value = "";               //limpio Numero de asiento Aduulto - Niņo                                                        
              obj_tomoval.value = "";           //Limpio el nombre del objeto de donde tomo el valor
            }               
          } 
        else
        {      
                     
              //si tiene dato ? SI ==  Tiene el objeto de donde tomo el valor
              if (obj_tomoval.value != "")
                { 
                  var obj_ant = $(obj_tomoval.value);  //Objeto anterior de donde se tomo el valor del asiento                        
                  My_Seat(obj_ant,'AS_Disp.gif');      //Cambio su estado a disponible                  
                } 
               
              My_Seat(objseat,'AS_Asign.gif');         //My asiento    
              armaObj.value =  myseat;                 //asigno el asiento al adulto - niņo  
              obj_tomoval.value = obj;                 //paso el nombre del objeto 
                                   
            //elfoco = false;                  //Llena de manera automatica 
        }       
       
    } else  //Elemento sin FOCO
    {                    
        //Recorro el Total de Objetos Adultos - Niņos
        for (var i=1; i<=maxObj; i++ )
        {           
            armaObj = $('V' + Avion_Select + '_Seat_' + i);                       //Obtengo el Objeto asiento
            obj_tomoval = $('V' + Avion_Select + '_obj_click_' + i);              //de que objeto asiento se tomo el valor           
            tmparmaObj = $('V' + Avion_Select + '_Seat_' + arrayBusca[1]);        //Objeto donde encontro el asiento
            
             //  ya fue asignado ? True = Asignado,     false = "NO Asignado"
             if (arrayBusca[0] == true) 
              {                              
                if (armaObj.value ==  tmparmaObj.value)
                {                  
                  break;  //no hago nada
                }               
              } 
              else
              {
                  //el Valor del Objeto esta Vacio ?  Si = Pongo valor del Asiento  
                  if (armaObj.value == "")  
                    {                         
                      My_Seat(objseat,'AS_Asign.gif');        //My asiento 
                      armaObj.value =  myseat;                //Pongo numero de asiento al Objeto asiento
                      obj_tomoval.value = obj;                //paso el nombre del objeto 
                      ImgApunta_AdultNinio(i,maxObj,'A');     //Apuntador (Imagen) -- Se si el Objeto tiene el Foco                      
                      break;
                    } 
              }           
        }
    }   
    
}
//Apunta la posicion del asiento con una imagen
function ImgApunta_AdultNinio(ind,max,tipo)  //ImgApunta_Asiento
{         
   //elfoco = false;  //por default no tiene el enfoque el asiento
      
    var ruta_img = document.getElementById('Ruta_Imagen').value;   //Obtengo la Ruta de imagen segun el sitio
    var img_Select =  ruta_img + '/arrowsmall.gif';  //Img Adulto seleccionado
    var img_NoSelect =  ruta_img + '/spacer.gif';   //Img Adulto No seleccionado        
    var armaObj;
    var armaObjPos;  //Indica cual es el Objeto que esta actualmente posicionado vuelo X Vuelo
       
    //Recorro el Total de Objetos Adultos - Niņos
    for (var i=1; i<=max; i++ )
    {     
      //Significa que es por asignacion por seleccion
      if (tipo ==  "")
      {        
      
        armaObjPos = $('V' + Avion_Select + '_ubicado');      
        armaObjPos.value = ind;  //Paso el Objeto en donde esta posicionado      
        armaObj = $('V' + Avion_Select + '_apunta_' + i);  //Objeto apuntado (  Imagen Bullet azul )
        armaObj.src =  img_Select;   //imagen arrow (seleccionado)
        
        //es el elemento Seleccionado ?  
        if (ind == i)  
          {
            IdSeat_foco = ind;                            //Asiento que tiene el foco
            elfoco = true;                                //Tiene el enfoque el objeto
          } else
          {
            armaObj.src = img_NoSelect;       //imagen spacer (No seleccionado)  
          }      
      }
      else  //Asignacion Automatica
      {       
        //elfoco = false;   //cambio a Manual        
        armaObj = $('V' + Avion_Select + '_apunta_' + i);  //apuntador Imagen Bullet Azul 
                
        var j = ind + 1;   //siguiente elemento        
        armaObj.src = img_NoSelect;  //apuntado Imagen no seleccionado
        
        if (j<=max)  //Si es menor del Maximo?  
        {              
          armaObj = $('V' + Avion_Select + '_apunta_' + j);  //apunto siguiente elemento "Imagen seleccionado"          
          armaObj.src =  img_Select;                        //Cambio la Imagen asiento a ( My Asiento )
        }   
      }      
    }              
}

//Busca en los Adultos el numero de asiento  y valida si ya fue asignado anteriormente
function Busca_Valor(val,maxObj)
{   

    //var qVuelo =  Avion_Select; //Variable Global con Vuelo Seleccionado  
    var encontro = false;  var encontroInd =0;
    var armaObj;  //Objeto Asiento seleccionado
    
    for (var i=1; i<=maxObj; i++ )
    {   
        armaObj = $('V' + Avion_Select + '_Seat_' + i);  //Armo el Objeto Asiento 
        
        //Valor que paso, es Igual al valor del elemento seleccionado ?
        if (val == armaObj.value)
        {        
            return [true,i];  //Fue encontrado y Regreso su indice 
            break;
        }               
    }           
    return [encontro,encontroInd];
}

//Busca Si los elementos estan llenos
function Cuenta_Vacios(maxObj,avion)
{       
    var contador=0;  //Contador de elementos vacios
    var armaObj;     //Objeto Asiento seleccionado
    
    for (var i=1; i<=maxObj; i++ )
    {   
        armaObj = $('V' + avion + '_Seat_' + i);          
        if (armaObj.value == "")
        {        
            contador += 1;
        }               
    }           
    return [contador];  //Regresa el numero de elemtos vacios ( Asientos )
}


//Cambia la Imagen del asiento que ya se asigno al pasajero
function My_Seat(objseat,imagen)
{ 
  var ruta_imagen = document.getElementById('Ruta_Imagen').value;  //Ruta de Imagen segun el sitio
  objseat.src =  ruta_imagen + '/'  +  imagen;                     //Cambio la imagen del asiento asignado
}

//Valida que se haya capturado los datos obligatorios de los Pasajeros
function ValidatePassengers(maxAd,maxni)
{
 
  var armaObj;     //Objetos de Datos de Pasajeros  
  var max = maxAd + maxni;
  var error= false;
    
    //Recorro todos los elementos Obligatorios de Datos Personales de Pasajeros
   for (var i=1; i<=max; i++ )
    {   
        //Valida (First Name )
        armaObj = $('first_name_' + i);
        if  (armaObj.value == "")
        { error= true;          
          break;
        }           
         //Valida (Last Name)
        armaObj = $('last_name_' + i);
        if  (armaObj.value == "")
        { error= true;          
          break;
        }  
         //Valida (Issue country)
        armaObj = $('issue_country_' + i);
        if  (armaObj.value == "")
        { error= true;          
          break;
        }  
        
        //Datos Adicionales de Adultos ( contact name - contact phone )
        if (i==1 & maxAd > 0 )
        { 
          //Valida ( Contact Name )       
          armaObj = $('contact_name_' + i);
          if  (armaObj.value == "")
           { error= true;             
             break;
           }  
          //Valida ( Contact Phone )       
          armaObj = $('contact_phone_' + i);
          if  (armaObj.value == "")
           { error= true;             
             break;             
           } 
           
           if (!validaPhone(armaObj.value))
           {
             error=true;                         
             Apunta_Pasajeros("si",i,max);
	     
	     
	     //Valido el Idioma para mandar el mensaje        
	       if (document.getElementById('Idioma').value.toLowerCase() == "esp" )
	         {
	           alert("Verifique el numero de telefono");
	         }  else
	         {
	           alert("The phone number is invalid");
       	         }
	     
	     
	     
	     armaObj.focus();
      	     return false;      
             break;
           }
           
        }      
        //Valida las Edades de los Niņos
        if (i>maxAd & maxni > 0)
        {
           //Valida ( Contact Name )       
          armaObj = $('EdadNino_' + i);
          if  (armaObj.value == -1)  //Sibolo "?"  No se capturo nada aun
           { error= true;             
             break;             
           }       
        }         
        
    } 
     
    //Convierte a imagenes sin apuntar
    if (error ==false)
    {  
      Apunta_Pasajeros("no",1,max);
    } else
    {      
      //Al final mando mensaje de datos faltantes
      Apunta_Pasajeros("si",i,max);
      SendMsgError();
      armaObj.focus();
      return false;
      
    }
    
    return true;
}


function validaPhone(value) {
  var str =value; // email string
  //var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  //var reg1 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
  
  var reg1 = /((\(\d{3,4}\)|\d{3,4}-)\d{4,9}(-\d{1,5}|\d{0}))|(\d{7,12})/;
  

  if (!reg1.test(str)) { // if syntax is valid  
    return false;
  }
    
  return true;
}





function SendMsgError()
{
  //Valido el Idioma para mandar el mensaje        
  if (document.getElementById('Idioma').value.toLowerCase() == "esp" )
    {
      alert("Por favor llenar todos los campos obligatorios");
    }  else
    {
      alert("Please fill all mandatory fields");
    }
}
//Apunta a los pasajeros en donde le hace falta algun dato obligatorio
function Apunta_Pasajeros(valida,ind,max)
{ 
  var armaObj;
  
  //1=  Cambia de imagen apuntando o No apuntando
  //0=  No importa y muestra todos sin apuntar
  
  //Recorro todos los elementos
  for (var i=1; i<=max; i++ )
   {
     armaObj = $('foco_' + i); 
     if (valida == "si")
     {
       //es el indice que estoy revisando
       if (ind == i)
        {
          armaObj.src = document.getElementById('Ruta_Imagen').value + "/arrowsmall.gif";
        }else
        {
          armaObj.src = document.getElementById('Ruta_Imagen').value + "/spacer.gif";
        }
     } else
     {  //Vuelo a cambiar a imagen sin apuntar
        armaObj.src = document.getElementById('Ruta_Imagen').value + "/spacer.gif";
     }       
     
   }  
}

//funcion que Pasa el Pais a todos los demas pasajeros que no tenga pais especificado
function LlenaPaisPasajeros(maxpas,ind)
{
    var armaObj;
    var armaObjVal;
    
     armaObjVal = $('issue_country' + ind);  //tomo su valor de este objeto
     
     //Si tiene dato pongo a los demas 
     if (armaObjVal.value != "")
     {
       for (var i=1; i<=maxpas; i++ )
        {
            //Tomo su valor y propago a los demas que no tengan  
            armaObj = $('issue_country_' + i);
            //Solo a los que no tengan valor 
            if (armaObj.value == "")
            {
                armaObj.value = armaObjVal.value;  //Le paso su valor a los demas
            }   
            
        }
     }
    
}

//Pasa la Clave iata del Aeropuerto cuando es Cancun, cabos y vallarta
function pasaCiudad()
{   
    var armaObjCiudades;  //objeto donde tomo su clave
    var armaObjClavCiudad; //objeto donde paso la clave
        
    armaObjCiudades = $('ciudades');                    //objeto ciudades (origen)
    armaObjClavCiudad = $('Clav_ciudad');               //objeto clav_ciudad (destino)
    armaObjClavCiudad.value = armaObjCiudades.value;    //paso su valor (origen a destino)
}


function ClearField(Obj,descripcion) 
{     
     var Cadena;
     Cadena  = Obj.value;    
     ///if ((Cadena == "City Name or Airport Code") || (Cadena == "Teclee el nombre de la ciudad ķ codigo del Aeropuerto")) {     
     if (Cadena == descripcion) {     
        Obj.value="";    
        //Obj.className="iputmust";
     }
     else {
        Obj.focus();
        Obj.select();
     }
}
var xElemt;
var offsetX;
var yElemt;
var offsetY;
var suelta=false;
function unDrag(event)
{
  suelta = false;
}
function Drag_Drop(e)
{
    //una ves soltado el objeto lo muevo de ubicacion
    if (suelta)
    {
        var x = xElemt + e.clientX - offsetX;
        var y = yElemt + e.clientY - offsetY;

        var popupDiv = $('help');  
        popupDiv.style.position = "absolute";					
	    mleft = x;  
        mTop = y;	
    	
	    popupDiv.style.left = mleft + "px";
	    popupDiv.style.top = mTop + "px";
	    popupDiv.style.zIndex = 100;
   }
}
//Toma las posiciones del objeto que se va a mover 
function inicializeDrag(e)
{      
   if (!e) e = window.event;   
   var popupDiv = $('help');
    offsetX = e.clientX;  
    offsetY = e.clientY;
    xElemt = parseInt(popupDiv.style.left);
    yElemt = parseInt(popupDiv.style.top);
    suelta = true;
    //document.onmousemove = Drag_Drop(e);    
    
}

//1.- La Declaracion del Arreglo debe estar en la Pagina
//2.- El div que se movera de ubicacion, debera existir en la Pagina
function displayHelp(obj,moveobj,idhtml) 
{   
    //debugger;    
    var Version =navigator.appVersion.substring(22,25);
		Version = parseInt(Version);
		if (navigator.appName=="Microsoft Internet Explorer")
			if (Version < 7)
	        Ocultar_Elementos();
    var content ="";      
    if (arrHelp != null || arrHelp.length > 0)
    {        
        content = arrHelp[idhtml];              //Obtengo el html 
        //obj = nombre del objeto como cadena      
        showPopHelp(obj,moveobj,idhtml, content) //Incrusto el Html al div con sus atributos
    }
   
    
}
//Mueve a la posicion el elemento que le pacen..
function setPositionElement(s)
{        
    //document.onresize= setPositionElement();
    //Que si tenga el nombre del objeto donde se posicionara el elemento
    var Tobj = typeof(Tmpobj);   
    //que exista el objeto
    if (Tobj != "undefined")
    {                   
        var popupDiv = $(Tmpmoveobj);  //Objeto como string  elemento que se mueve de Ubicacion
        var posElementXY = getPositionElement(Tmpobj);  //Objeto donde se pretende mover
	    var defWidth = popupDiv.clientWidth;  //Ancho del elemento
    			
	    mleft = (posElementXY[0] +20);  //Left 20
        mTop = (posElementXY[1] + 20);	 //Top
    		
	    popupDiv.style.left = mleft + "px"; //left del Objeto  //((windowSize[0] - popupWidth ) / 2) + scrollXY[0];
	    popupDiv.style.top = mTop + "px";  //Top del Objeto  //((windowSize[1] - popupHeight) / 2) + scrollXY[1];
	    popupDiv.style.zIndex = 100;	
	}
	  
}
//fucnion que mueve el objeto a la posicion de otro objeto
//obj = nombre del objeto como cadena
function showPopHelp(obj,moveobj,idhtml, content) 
{  
    //debugger;
    var mleft;
    var mTop;
    
	var popupDiv = $(moveobj);  	
	popupDiv.innerHTML = content;   //"<div>"+ popupHtml+"</div>";
	popupDiv.style.display = "block";
	
	//var windowSize = getWindowSize();	
	//var scrollXY = getScrollXY();		
	
	popupDiv.style.position = "absolute";
	
	var posElementXY = getPositionElement(obj);
	Tmpobj =  obj;  //Objeto que se va a mover
	Tmpmoveobj = moveobj;  //Paso que elemento me llamo anteriormente	
	var defWidth = popupDiv.clientWidth;
			
	mleft = (posElementXY[0] +20);  //Left 20
    mTop = (posElementXY[1] + 20);	 //Top
		
	popupDiv.style.left = mleft + "px"; //left del Objeto  //((windowSize[0] - popupWidth ) / 2) + scrollXY[0];
	popupDiv.style.top = mTop + "px";  //Top del Objeto  //((windowSize[1] - popupHeight) / 2) + scrollXY[1];
	popupDiv.style.zIndex = 100;
	
	displayLayer(popupDiv,true);
}



// funcion que muestra una ventana emergente para describir la categoria del hotel
// clavCategoria: clave de la BD, bordeInf: color del borde, obj: ID del objeto que llamo la funcion
function HelpCategory(clavCategoria, bordeInf, nombreCateg, obj) 
{  
    var ruta_imagen =  document.getElementById('Ruta_Imagen').value;  //Ruta de imagen del Sitio
	var idiomaCategoria = document.getElementById('Idioma').value;  //Idioma del Sitio: ING o ESP
	var numCateg = clavCategoria.substring(0, (clavCategoria.length - 1));
	var txtCategoria = descCateg[numCateg];  //Tomo el valor del arreglo
    var content = "";
	var idhtml = "";
	
	popupWidth = 340;
	popupHeight = 100;
		
	//Si no tiene valor le pongo naranja claro
	if (bordeInf=="")
	{
	 bordeInf = "#ff6700";
	}
		
	//Armo el Html de la Ventana Emergente de las Cabinas de Avion	
	//var nombreCateg = getSeat(obj);
	
	//Que si tenga descripcion de la categoria
	///alert("textCatego: " + textCatego);
	if (descCateg.lenght > 0 && txtCategoria != "" && txtCategoria != "undefined")
	 {	
	    content += '<div style="font-weight: bold; border-bottom: 1px solid ' + bordeInf + '; margin: 2px 5px 2px 5px; padding-bottom: 2px; font-size:13px;">';
	    content += '<img src="' + ruta_imagen + '/CategSmall_' + clavCategoria + '_' + idiomaCategoria + '.gif" border="0" align="absbottom"/>&nbsp;' + nombreCateg + '</div>';
	    content += '<div style="padding: 5px; font-size:10px;"><img src="' + ruta_imagen + '/Categ_' + clavCategoria + '_' + idiomaCategoria + '.gif" align="left" style="margin-right:5px;"/>' + descCateg[numCateg] + '</div>';
    	    
	    showPopupWithContent(content,obj,idhtml);	  //Escupo el Html que le pase o que Armo en Html   	
	}
}