var selected_id = null; 
var dom = document.getElementById; 
function class_meniu(id, newclass) { 
	if (dom) { 
		if(selected_id != id) { 
			el = document.getElementById(id); 
			el.className = newclass; 
		} 
	} 
} 
function StatusObiect(obiect , identif){
	document.getElementById(obiect).className = identif;
}
function getRowDisplayStyle(){
	if (navigator.appName == 'Netscape'){
		//NETSCAPE, FIREFOX si altele
		sShowStyle = "table-row";
	}
	else {
		//IE
		sShowStyle = "inline";
	}
	return sShowStyle;
}
function sel_avion(tip){
	//StatusObiect('choose_airport',"off");
	document.getElementById('avion').style.display = getRowDisplayStyle();
	document.getElementById('hotel').style.display = 'none';
	document.getElementById('car').style.display = 'none';
	if (!tip){
		document.getElementById('btn_avion').className = 'txt_hotel_motor_hover';
		document.getElementById('avion').className = 'td_motor_hotel';
		document.getElementById('rezervare_avion').className = 'txt_hotel_motor_hover div_hotel_brd';
		document.getElementById('btn_hotel').className = 'txt_avion_motor';
		document.getElementById('rezervare_hotel').className = 'txt_avion_motor div_avion_brd';
		document.getElementById('btn_car').className = 'txt_car_motor';
		document.getElementById('rent_car').className = 'txt_car_motor div_car_brd';
	}
	else{	
		document.getElementById('btn_avion').className='txt_hotel_motor_hover div_hotel_brd';
		document.getElementById('btn_hotel').className='txt_avion_motor div_avion_brd';	
		document.getElementById('btn_car').className='txt_car_motor div_car_brd';
	}

}
function sel_hotel(tip){
	//StatusObiect('choose_airport',"off");
	//document.getElementById('avion').style.display = 'none';
	document.getElementById('hotel').style.display = getRowDisplayStyle();
	document.getElementById('car').style.display = 'none';
	if (!tip){
		//document.getElementById('btn_avion').className = 'txt_hotel_motor';
		//document.getElementById('avion').className = 'td_motor_hotel';
		document.getElementById('rezervare_hotel').className = 'txt_avion_motor_hover div_avion_brd';
		document.getElementById('btn_hotel').className = 'txt_avion_motor_hover';
		//document.getElementById('rezervare_avion').className = 'txt_hotel_motor div_hotel_brd';
		document.getElementById('btn_car').className = 'txt_car_motor';
		document.getElementById('rent_car').className = 'txt_car_motor div_car_brd';
	}
	else{	
		//document.getElementById('btn_avion').className='txt_hotel_motor_hover div_hotel_brd';
		document.getElementById('btn_hotel').className='txt_avion_motor div_avion_brd';	
		document.getElementById('btn_car').className='txt_car_motor div_car_brd';
	}

}
function sel_car(tip){
	//StatusObiect('choose_airport',"off");
	document.getElementById('hotel').style.display = 'none';
	document.getElementById('car').style.display = getRowDisplayStyle();
	if (!tip){
		document.getElementById('rent_car').className = 'txt_car_motor_hover div_car_brd';
		document.getElementById('btn_hotel').className = 'txt_avion_motor_hover';
		document.getElementById('rezervare_hotel').className = 'txt_avion_motor div_avion_brd';
		document.getElementById('btn_car').className = 'txt_car_motor';
	}
	else{	
		document.getElementById('btn_hotel').className='txt_avion_motor div_avion_brd';	
		document.getElementById('btn_car').className='txt_car_motor div_car_brd';
	}

}

function afisare_sosire(){
	//alert(document.getElementById('dus').checked);
	if (document.getElementById('dus').checked == true){
		document.getElementById('dus_tr').style.display = 'none';
		document.getElementById('dus_tr').className = 'invizibil';
		document.getElementById('dus_tr_2').style.display = 'none';
		document.getElementById('dus_tr_2').className = 'invizibil';
	}
	else{
		document.getElementById('dus_tr').style.display = getRowDisplayStyle();
		document.getElementById('dus_tr_2').style.display = getRowDisplayStyle();
	}
}

//functia folosita pentru mini motorul de cautare
function afisare_sosire_mic(){
	//alert(document.getElementById('dus').checked);
	if (document.getElementById('dus').checked == true){
		document.getElementById('dus_tr').style.display = 'none';
		document.getElementById('dus_tr').className = 'invizibil';
		document.getElementById('dus_tr_2').style.display = 'none';
		document.getElementById('dus_tr_2').className = 'invizibil';
	}
	else{
		document.getElementById('dus_tr').style.display = getRowDisplayStyle();
		document.getElementById('dus_tr_2').style.display = getRowDisplayStyle();
	}
}

function ChooseCity(obiect, identif){
	id = obiect;
	StatusObiect('choose_airport',"vizibil");
	document.getElementById('cities').innerHTML  = '';	
	loadAjaxData('countrys','getTari.php?identif='+identif);
	//window.open('airport.php?identif='+identif,'','width=500,height=500,scrollbars=no');
}
function ChooseCityCAR(obiect, identif){
	id = obiect;
	StatusObiect('choose_car',"vizibil");
	document.getElementById('cities').innerHTML  = '';	
	loadAjaxData('countrys_car','getTariCAR.php?identif='+identif);
	//window.open('airport.php?identif='+identif,'','width=500,height=500,scrollbars=no');
}

function ChooseDestinatie(obiect, identif){
	id = obiect;
	StatusObiect('choose_oras',"vizibil");
	document.getElementById('cities').innerHTML  = '';	
	loadAjaxData('orase','getDest.php?identif='+identif);
	//window.open('airport.php?identif='+identif,'','width=500,height=500,scrollbars=no');
}

function AlegeLiniaAeriana(obiect, identif){
	//alert('obiect: '+obiect+' // identif: '+identif);
	id = obiect;
	StatusObiect('choose_linie',"vizibil");
	loadAjaxData('linie_aeriana','getLinii.php?identif='+identif);
	//window.open('airport.php?identif='+identif,'','width=500,height=500,scrollbars=no');
}


// pasagerii
var nr_max = 5;

function calcADT () {

	//adults
	var adt = document.getElementById("External_FlightFareSearch_NumberOfAdults");
	var nr_adt = adt.options.length;

	//children first
	var sel = document.getElementById("External_FlightFareSearch_NumberOfChilds");
	var old_inf = sel.value;
	while (sel.options.length>0) {
		sel.remove( 0 );
	}
	var nr_chd = nr_max - adt.value;
	for (var i=0;i<=nr_chd; i++ ) {
		if (i == old_inf) ind = true;
		else ind = false;
		var elem = new Option(i, i, false, ind);
		sel.options[i] = elem;
	}

	calcINF();
}

function calcCHD () {
	//adults
	var chd = document.getElementById("External_FlightFareSearch_NumberOfChilds");
	var nr_chd = chd.options.length;

	//children first
	var sel = document.getElementById("External_FlightFareSearch_NumberOfAdults");
	var old_inf = sel.value;
	while (sel.options.length>0) {
		sel.remove( 0 );
	}
	var nr_adt = nr_max - chd.value;
	for (var i=0;i<=nr_adt; i++ ) {
		if (i == old_inf) ind = true;
		else ind = false;
		var elem = new Option(i, i, false, ind);
		sel.options[i] = elem;
	}
	calcINF();
}

function calcINF() {
	//adults
	var ind = false;
	var adt = document.getElementById("External_FlightFareSearch_NumberOfAdults");
	var nr_adt = adt.options.length;

	var sel = document.getElementById("External_FlightFareSearch_NumberOfInfants");
	var old_inf = sel.value;
	while (sel.options.length>0) {
		sel.remove( 0 );
	}
	var nr_inf = adt.value;
	for (var i=0;i<=nr_inf; i++ ) {
		if (i == old_inf) ind = true;
		else ind = false;
		var elem = new Option(i, i, false, ind);
		sel.options[i] = elem;
	}
}

function update_categs(categ) {
	var arr_categ = new Array('External_FlightFareSearch_NumberOfAdults','External_FlightFareSearch_NumberOfChilds','External_FlightFareSearch_NumberOfInfants','External_FlightFareSearch_NumberOfYouths','External_FlightFareSearch_NumberOfSeniors','External_FlightFareSearch_NumberOfStudents');
	for (i=0; i<6; i++)
	{
		if ( (arr_categ[i] != categ) && !(((categ == 'External_FlightFareSearch_NumberOfAdults') || (categ == 'External_FlightFareSearch_NumberOfChilds') || (categ == 'External_FlightFareSearch_NumberOfInfants')) && (i<3)))
		{
			document.getElementById(arr_categ[i]).selectedIndex = 0;
		}

	}
	calcINF();
	calcCHD();

}
function HideDDLs(){
	var DDls=document.getElementsByTagName('SELECT');
	for(i=0;i<DDls.length;i++){
		DDls[i].style.visibility = "hidden";
	}
}



function ShowDDLs(){
	var DDls=document.getElementsByTagName('SELECT');
	for(i=0;i<DDls.length;i++){
		DDls[i].style.visibility = "visible";
	}
}
function verif_formular(){
	document.getElementById('form_cautare').submit();
}
function verif_formular_hotel(){
	document.getElementById('form_cautare_hotel').submit();
}
function verif_formular_car(){
	document.getElementById('form_cautare_car').submit();
}

