/*funciones para manejo de cookies
Julio Villalta 15JUN09
*/
function crearCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+
	";path=" + escape("/");
	
}

function leerCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
//crear las cookies
function crearCookies()
{
    var days = 1000;
	
    crearCookie('cTRIP_TYPE1', document.AIR_ENTRY_FORM.ROUND_TRIP.checked, days);
	crearCookie('cTRIP_TYPE2', document.AIR_ENTRY_FORM.ONE_WAY.checked, days);
    crearCookie('cB_LOCATION_1', document.getElementById('B_LOCATION_1').value.toUpperCase(), days);
    crearCookie('cE_LOCATION_1', document.getElementById('E_LOCATION_1').value.toUpperCase(), days);
    //crearCookie('cDepart', document.getElementById('Depart').value, days);
    //crearCookie('cReturn', document.getElementById('Return').value, days);
	if(document.getElementById('SEARCH_BY').value==1){
		crearCookie('cSEARCH_BY1', true, days);
		crearCookie('cSEARCH_BY2', false, days);
	}
	else{
		crearCookie('cSEARCH_BY1', false, days);
		crearCookie('cSEARCH_BY2', true, days);
	}
		
    crearCookie('cCABIN', document.getElementById('CABIN').value, days);
    crearCookie('cadults', document.getElementById('adults').value, days);
    crearCookie('cchild', document.getElementById('children').value, days);
    crearCookie('cinfant', document.getElementById('infants').value, days);
    crearCookie('cCuponNo', document.getElementById('CuponNo').value, days);
    crearCookie('cB_LOCATION_1P', document.getElementById('B_LOCATION_1').value.toUpperCase(), days);
    crearCookie('cE_LOCATION_1P', document.getElementById('E_LOCATION_1').value.toUpperCase(), days);
}
//cargar las cookies
function cargarCookies()
{
    if (leerCookie('cTRIP_TYPE1') != null || leerCookie('cTRIP_TYPE1') != "")
    { 
        if (leerCookie('cTRIP_TYPE1') == 'true'){
            document.AIR_ENTRY_FORM.ROUND_TRIP.checked = 'checked';
         
            }
        if (leerCookie('cTRIP_TYPE1') == 'false'){
               document.AIR_ENTRY_FORM.ONE_WAY.checked = 'checked';
            }
    }

    if (leerCookie('cB_LOCATION_1') != null){
     document.getElementById('B_LOCATION_1').value = leerCookie('cB_LOCATION_1');
    }
    if (leerCookie('cE_LOCATION_1') != null){
     document.getElementById('E_LOCATION_1').value = leerCookie('cE_LOCATION_1');
     }
    
    if (leerCookie('cSEARCH_BY1') != null)
    { 
        if (leerCookie('cSEARCH_BY1') == 'true'){
            document.getElementById('SEARCH_BY').value = 1;
        }
        if (leerCookie('cSEARCH_BY1') == 'false'){
          
            document.getElementById('SEARCH_BY').value = 2;
            }
    }
    if (leerCookie('cCABIN') != null) {document.getElementById('CABIN').value = leerCookie('cCABIN')};
    if (leerCookie('cadults') != null){ document.getElementById('adults').value = leerCookie('cadults')};
    if (leerCookie('cchild') != null){ document.getElementById('children').value = leerCookie('cchild')};
    if (leerCookie('cinfant') != null){ document.getElementById('infants').value = leerCookie('cinfant')};
    if (leerCookie('cCuponNo') != null){ document.getElementById('CuponNo').value = leerCookie('cCuponNo')};
	
}