function creAjax()
{
	var xmlhttp=false;
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } }
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); }
	return xmlhttp;
}

function conectAjax(url,param,method,target)
{
	  	$(target).innerHTML = '<img alt="loading" src="home/images/loading.gif" class="imgLoader" />';
	  	ajax = creAjax();
	  	var miUrl = (param != '' || param == 'home') ? url + '?' + param : url;
	  	ajax.onreadystatechange = function(){
	  		if (ajax.readyState == 4) {
	  			$(target).innerHTML = ajax.responseText;
	  		}
	  	}
	  	ajax.open(method, miUrl, true);
	  	ajax.send(null);
}

function insert_ft(destino,destinoCom)
{
	if(destino.indexOf(' - ')!=-1)
	{
		x = destino.split('-');
		p1 = x[0];
		p2 = x[1];
		p3 = x[2];
		if(p2&&p3==null)
		{
			if(p2.length == 3)
			{
				destino = p1;
			}
			else
			{
				destino = p1+'-'+p2;	
			}
		}
		if(p2&&p3)
		{
			destino = p1+'-'+p2;
		}
		cierraAz();
		$(freeNid).value = destino;		
		$(freeNid).focus();
		free_selected = 'az';
	}
	else if(destino.indexOf('/')!=-1)
	{	
		destino = destino.replace('/','-');
		cierraAz();
		$(freeNid).value = destino;
		$(freeNid).focus();
		free_selected = 'az';
	}
	else
	{
		cierraAz();
		$(freeNid).value = destino;
		$(freeNid).focus();
		free_selected = 'az';
	}	
	$('freetext').value = destinoCom;
}

function insert_ft_pais(destino,code)
{
	$(freeNid).value = destino;
	$('freetext').value = code;
	cierraAz();
}

function abreAz()
{
    ocultaForm('s');
	Diss('az-list-div');
}

function cierraAz()
{
	ocultaForm();
	noDiss('az-list-div');
}

function ocultaForm(x)
{
	if(x=='s'){x='hidden';y='none';}else{x='visible';y='block';}
	$('fechas').style.display = y;
	$('date_in').style.display = y;
	$('date_out').style.display = y;
	$('guest').style.display = y;
	$('avdest').style.display = y;
	$('go_search_results').style.display = y;
}

function abre(part)
{
	if(part=='der')
	{
		noDiss('az-list-divtotal-2');
		Diss('az-list-divtotal-1');
	}
	else
	{
		noDiss('az-list-divtotal-1');
		Diss('az-list-divtotal-2');		
	}	
}