
var oDay;
var oMonth;
var oYear;
var rDay;
var rMonth;
var rYear;
var sector1_o				= '';
var sector1_d				= '';
var sector2_o				= '';
var sector2_d				= '';
var swap_icon_ok			= true;
var calendarWindow			= null;
var sector_2_month_index 	= 1;
var sector_2_day_index  	= 1;
var sector_2_range_index  	= 0;

	var sector_2_org_prev		= -1;
	var sector_2_des_prev		= -1;
	var sector_2_m_prev			= 1;
	var sector_2_d_prev			= 1;
	var sector_2_r_prev			= sector_2_range_index;

var Dests = new Array ('AMS','ATH','BCN','BRI','BLQ','BDS','BRU','BUH','CAG','CMN','CTA','FOG','GOA','GVA','SAW','LUG','MAD','RAK','BGY','MXP','MUC','NAP','OLB','PMO','PAR','ORY','CDG','REG','RMI','FCO','SOF','TRN','VCE',0);
var sAMS = 'Amsterdam';
var sATH = 'Atene';
var sBCN = 'Barcelona';
var sBRI = 'Bari';
var sBLQ = 'Bolonia';
var sVBS = 'Brescia Montichiari';
var sBDS = 'Brindisi';
var sBRU = 'Brussels';
var sBBU = 'Bucuresti';
var sBUH = 'Bucuresti';
var sCAG = 'Cagliari';
var sCMN = 'Casablanca';
var sCTA = 'Catania';
var sHER = 'Creta';
var sFOG = 'Foggia';
var sGOA = 'Genova';
var sGVA = 'Ginevra';
var sIBZ = 'Ibiza';
var sSAW = 'Istanbul';
var sSUF = 'Lamezia Terme';
var sLMP = 'Lampedusa';
var sLUG = 'Lugano';
var sMAD = 'Madrid';
var sRAK = 'Marrakech';
var sMIL = 'Milano tutti aeroporti';
var sBGY = 'Milano Orio al Serio';
var sMXP = 'Milano Malpensa';
var sMUC = 'Monaco di Baviera';
var sNAP = 'Napoli';
var sOLB = 'Olbia';
var sPMO = 'Palermo';
var sPMI = 'Palma di Maiorca';
var sPNL = 'Pantelleria';
var sPAR = 'Paris tutti aeroporti';
var sORY = 'Paris Orly';
var sCDG = 'Paris CdG';
var sREG = 'Reggio Calabria';
var sRMI = 'Rimini';
var sRHO = 'Rodi';
var sROM = 'Roma tutti aeroporti';
var sCIA = 'Roma Ciampino';
var sFCO = 'Roma Fiumicino';
var sJTR = 'Santorini';
var sSOF = 'Sofia';
var sTRN = 'Torino';
var sVLC = 'Valencia';
var sVCE = 'Venetia';
var sZRH = 'Zurigo';


	var aAMS	= new Array('BRI','BBU','RMI','SOF',	0);
	var aATH	= new Array('BRI',	0);
	var aBCN	= new Array('BRI','VCE',	0);
	var aBRI	= new Array('AMS','ATH','BCN','BRU','BBU','CTA','GOA','SAW','MAD','BGY','CDG','VCE',	0);
	var aBLQ	= new Array('BDS','BBU','IBZ','CDG',	0);
	var aBOD	= new Array('VCE',	0);
	var aBDS	= new Array('BLQ','GVA','MUC','CDG','TRN','VCE', 0);
	var aBRU	= new Array('BRI','BBU',	0);
	var aBBU	= new Array('AMS','BRI','BLQ','BRU','CTA','BGY','NAP','CDG','RMI','FCO','SOF','VCE',	0);
	var aBUH	= new Array('BRI','BLQ','CTA','BGY','NAP','CDG','FCO','VCE',	0);
	var aCTA	= new Array('BRI','BBU','BGY','VCE',	0);
	var aCMN	= new Array('BGY','VCE',	0);
	var aCAG	= new Array('GVA','LUG','VCE',	0);
	var aHER	= new Array('BGY',	0);
	var aFOG	= new Array('GVA','MXP','BGY','PMO','TRN',	0);
	var aGOA	= new Array('BRI',	0);
	var aGVA	= new Array('BDS','FOG','LUG',	0);
	var aIBZ	= new Array('BLQ','BGY','VCE',	0);
	var aSAW	= new Array('BRI','BGY',	0);
	var aLMP	= new Array('BGY',	0);
	var aLUG	= new Array('GVA','FCO',	0);
	var aMAD	= new Array('BRI',	0);
	var aETZ	= new Array('VCE',	0);
	var aRAK	= new Array('BGY','VCE',	0);
	var aMIL	= new Array('BRI','BDS','BBU','CAG','CMN','CTA','SAW','MAD','RAK','NAP','PMO','REG',	0);
	var aBGY	= new Array('BRI','BBU','CMN','CTA','FOG','IBZ','SAW','RAK','NAP','OLB','PMO','REG', 	0);
	var aMXP	= new Array('FOG',	0);
	var aMUC	= new Array('BDS',	0);
	var aNAP	= new Array('BBU','BGY',	0);
	var aOLB	= new Array('BGY','VCE',	0);
	var aPMO	= new Array('FOG','BGY','VCE',	0);
	var aPMI	= new Array('FCO',	0);
	var aPNL	= new Array('BLQ','VCE',	0);
	var aPAR	= new Array('BRI','BLQ','BDS','BBU','KSC','RMI','VCE',	0);
	var aORY	= new Array('KSC','VCE',	0);
	var aCDG	= new Array('BRI','BLQ','BDS','BBU','RMI',	0);
	var aREG	= new Array('BGY',	0);
	var aRMI	= new Array('AMS','BBU','CDG',	0);
	var aRHO	= new Array('BGY',	0);
	var aCIA	= new Array('BBU',	0);
	var aFCO	= new Array('BBU','KSC','LUG',	0);
	var aJTR	= new Array('BGY','MXP',	0);
	var aSOF	= new Array('AMS','BBU','LCA','LIS','VCE',	0);
	var aSUF	= new Array('VCE',	0);
	var aTRN	= new Array('BDS','FOG',	0);
	var aVCE	= new Array('BCN','BRI','BDS','BBU','CAG','CMN','CTA','IBZ','RAK','OLB','PMO','ORY','SOF',	0);
	var aZRH	= new Array('DBV',	0);

function init()
{
	var origBox		= document.search_form.sector1_o;
	var destBox		= document.search_form.sector1_d;
	var origIndex	= origBox.selectedIndex;
	var destIndex	= destBox.selectedIndex;
	if ( document.dest1Form.dIndex.value != "zz" )
	{
		destIndex	= document.dest1Form.dIndex.value;
	}
	else
	{
		document.dest1Form.dIndex.value = destIndex;
	}

	change_sector_2_fields( '', true );
	if (document.search_form.travel_type[1].checked)
	{
		swap_icon('calendar_2', 'frozen'); swap_icon_ok	= false;
	}
	 defaultStatus	= '||myair||';
	changeOrigDestList(origBox, destBox, 'Destinatie', true, 1, '', '' );
	//document.body.style.backgroundImage='url(http://webtest01.myair.com/cgi-bin/empty.cgi)';
}



function changeOrigDestList(origBox, destBox, labelDest, fromOnload, whichSector, labelOpenJaw, preferredDest)
{
	if (!document.images)
	{
		return;
	}

	var origIndex	= eval(origBox.selectedIndex);
	var destIndex;
	var initDest	= 0;
	if ( whichSector == 1 ) {
		destIndex	= document.dest1Form.dIndex.value;
	}
	else
	{
		destIndex	= eval(destBox.selectedIndex);
		initDest	= document.dest2Form.dIndex.value;
	}
	var orig     	= origBox.options[ origIndex ].value;
	var dest     	= destBox.options[ destIndex ].value;

	if (orig != "XXX")
	{
		orig						= eval(orig);
		destBox.length				= 1;
		var newDest					= new Option(labelDest);
		destBox.options[0]			= newDest;
		destBox.options[0].value	= "XXX";


		for (var i = 0; i < orig.length - 1; i++)
		{
			if ( orig[i] != "" )
			{
				destBox.length += 1;
					destBox.options[destBox.length - 1]
						= new Option( eval('s' + orig[i]) + " (" + orig[i] + ")" );					destBox.options[destBox.length - 1].value = orig[i];

					if ( dest == destBox.options[destBox.length - 1].value )
					{
						initDest = destBox.length - 1
					}
			}
		}

		if (fromOnload == true)
		{
			origBox.selectedIndex = origIndex;
			destBox.selectedIndex = destIndex;
			if (whichSector == 1)
			{
				document.dest1Form.dIndex.value = destIndex;
			}
		}
		else
		{
				destBox.selectedIndex	= ( initDest > destBox.options.length - 1)
									? destBox.options.length - 1 : initDest;
			if (whichSector == 1)
			{
				document.dest1Form.dIndex.value = initDest;
			}
			else
			{
				document.dest2Form.dIndex.value = initDest;
			}
		}
	}
	else
	{
		refillDestList( destBox, labelDest, labelOpenJaw);
	}


}



function refillDestList(destBox, labelDest, unusedOption)
{
	var destValue				= destBox.options[ destBox.selectedIndex ].value;
	destBox.length				= 1;
	destBox.options[0]			= new Option(labelDest);
	destBox.options[0].value	= "XXX";
	var i						= 1;
	var selIndex				= 0;

	if ( unusedOption )
	{
		destBox.length				+= 1;
		var newOption				= new Option( unusedOption );
		destBox.options[i]			= newOption;
		destBox.options[i].value	= "XXX";
		i++;
	}

	for(var j = 0; j < (Dests.length - 1); j++)
	{
		destBox.length += 1;
			var newOption = new Option(eval('s' + Dests[j]) + " (" + Dests[j] + ")");		destBox.options[i + j]		= newOption;
		destBox.options[i + j].value	= Dests[j];
		if(destValue == Dests[j])
		{
			selIndex				= i + j;
		}
   	}

	destBox.selectedIndex = selIndex

}



function defaultOpenJawRoute(origBox, destBox, origBox2, destBox2, ojaw_flag){

	if (! document.images)
	{
		return;
	}


	var origIndex	= eval(origBox.selectedIndex);
	var destIndex	= eval(destBox.selectedIndex);
	var orig     	= origBox.options[ origIndex ].value;
	var dest     	= destBox.options[ destIndex ].value;
	var userFirst	= ojaw_flag.value;


	if (document.search_form.travel_type[0].checked == true)
	{
		if (userFirst == "true")
		{

			if ((origIndex != 0) && (destIndex != 0))
			{
				for (var i = 0; i <= origBox2.length-1; i++)
				{
					if (origBox2.options[ i ].value  == 'a' + dest)
					{
						origBox2.selectedIndex = i;
					}
				}
				changeOrigDestList(origBox2, destBox2, 'Destinatie', false, 2, '------------');
				for (var i = 0; i <= destBox2.length-1; i++)
				{
					if ('a' + destBox2.options[ i ].value  ==  orig)
					{
						destBox2.selectedIndex = i;
						document.dest2Form.dIndex.value = i;
					}
				}
			   ojaw_flag.value = "false";
			}
		}

	}
	else
	{
		ojaw_flag.value = "true"

	}

}



function setPassengerTypes()
{	var paxTypes = "";

			var paxTypeSelect = document.search_form.ADULT;
			var paxTypeADULTNum
				= paxTypeSelect.options[paxTypeSelect.selectedIndex].value;
			var paxTypeADULTCode	= "ADULT";
			paxTypes = paxTypes + paxTypeADULTNum
						+ paxTypeADULTCode;
				document.search_form.pT.value = paxTypes;

}



function submit_SB_Form()
{
	captureDates();

	if( window.calendarWindow )
	{
		window.calendarWindow.close();
	}

	sector1_o	= document.search_form.sector1_o.options[document.search_form.sector1_o.selectedIndex].value;
	sector1_d	= document.search_form.sector1_d.options[document.search_form.sector1_d.selectedIndex].value;
	if ( sector1_o.length > 3 )
	{
		sector1_o	= sector1_o.substring(1,4);
	}

	if ( rDay != 0 && rMonth != 0 && rYear != 0 )
	{
		sector2_o = sector1_d;
		sector2_d = sector1_o;
	}
	else
	{
		sector2_o = "XXX";
		sector2_d = "XXX";
	}

	if (checkCities() && checkDate() && checkPassenger() && enforceMaxPax() && finalDate() )
	{
		document.search_form.m1.value		= "" + oYear + oMonth + oDay + sector1_o + sector1_d;

		if( (sector2_o == "XXX") || (sector2_d == "XXX") )
		{
			document.search_form.m2.value	= "";
			document.search_form.nom.value	= "1";
		}
		else
		{
			document.search_form.m2.value	= "" + rYear + rMonth + rDay + sector2_o + sector2_d;
			document.search_form.nom.value	= "2";
		}

		setPassengerTypes();

		var s1r	= document.search_form.sector_1_range;
		if (s1r && s1r.options.length > 0)
		{
			document.search_form.m1DP.value = ( s1r.options[s1r.selectedIndex].value.substring(0,2) );
			document.search_form.m1DO.value = ( s1r.options[s1r.selectedIndex].value.substring(2,4) );
		}

		var s2r	= document.search_form.sector_2_range;
		if (s2r && s2r.options.length > 0)
		{
			document.search_form.m2DP.value = ( s2r.options[s2r.selectedIndex].value.substring(0,2) );
			document.search_form.m2DO.value = ( s2r.options[s2r.selectedIndex].value.substring(2,4) );
		}

		document.dest1Form.dIndex.value	= document.search_form.sector1_d.selectedIndex;
		document.search_form.submit();
	}
}



function captureDates()
{
	oDay 	= document.search_form.sector_1_d.options[document.search_form.sector_1_d.selectedIndex].value
	oMonth	= document.search_form.sector_1_m.options[document.search_form.sector_1_m.selectedIndex].value.substring(0,2)
	oYear	= document.search_form.sector_1_m.options[document.search_form.sector_1_m.selectedIndex].value.substring(2,6)
	rDay	= document.search_form.sector_2_d.options[document.search_form.sector_2_d.selectedIndex].value
	rMonth	= document.search_form.sector_2_m.options[document.search_form.sector_2_m.selectedIndex].value.substring(0,2)
	rYear	= document.search_form.sector_2_m.options[document.search_form.sector_2_m.selectedIndex].value.substring(2,6)
}



function change_sector_2_fields( whichDot, fromOnload )
{
	var roundtrip;


	if (whichDot == 0)
	{
		roundtrip = true
	}
	else if ( !whichDot && document.search_form.travel_type[0].checked == true )
	{
		roundtrip = true
	}
	else
	{
		roundtrip = false
	}

	if (roundtrip == true)
	{
		if (fromOnload != true)
		{

			var temp_m = document.search_form.sector_1_m.selectedIndex + 1;
			var temp_d = document.search_form.sector_1_d.selectedIndex + 1;
			if ( ( sector_2_month_index < temp_m ) ||
				 (( sector_2_month_index == temp_m) &&
				 ( sector_2_day_index < temp_d)))
			{
				document.search_form.sector_2_m.selectedIndex = temp_m;
				document.search_form.sector_2_d.selectedIndex = temp_d;
			}
			else
			{
				document.search_form.sector_2_m.selectedIndex = sector_2_month_index;
				document.search_form.sector_2_d.selectedIndex = sector_2_day_index;
			}
		}

		swap_icon_ok = true;

		if (document.images.calendar_2) {
			swap_icon('calendar_2', 'cold');
		}
	}
	else
	{

		sector_2_month_index = document.search_form.sector_2_m.selectedIndex;
		if (sector_2_month_index == 0)
		{
			sector_2_month_index = 1;
		}

		sector_2_day_index  = document.search_form.sector_2_d.selectedIndex;
		if (sector_2_day_index == 0)
		{
			sector_2_day_index = 1;
		}

		document.search_form.sector_2_m.selectedIndex = 0;
		document.search_form.sector_2_d.selectedIndex = 0;

		if (document.images.calendar_2) {
			swap_icon('calendar_2', 'frozen');
		}

		swap_icon_ok = false;
	}
}



	function force_travel_type()
	{
		return true;
	}






function doYouWantRoundTrip( origBox, destBox )
{
	var origIndex	= eval(origBox.selectedIndex)
	var destIndex	= eval(destBox.selectedIndex)

	if (origBox.selectedIndex != 1)
	{
		sector_2_org_prev = origBox.selectedIndex;
	}
	if (destBox.selectedIndex != 1)
	{
		sector_2_des_prev = destBox.selectedIndex;
	}

	if ( document.search_form.travel_type[1].checked && origIndex != 1
		&& destIndex != 1 )
	{
		if (confirm("\nDoriti  un bilet Dus - Intors?\n"))
		{
			document.search_form.travel_type[0].checked = true;
			document.search_form.travel_type[1].checked = false;
			change_sector_2_fields( 0, false )
		}
		else
		{
			document.search_form.travel_type[0].checked = false;
			document.search_form.travel_type[1].checked = true;
			change_sector_2_fields( 1, false )
		}
	}
	else if ( document.search_form.travel_type[0].checked && origIndex == 1
		&& destIndex == 1 )
	{
		if (confirm("\nFara data/zbor de intoarcere? Doriti sa schimbati selectia\nin \'Doar Dus\' ?\n"))
		{
			document.search_form.travel_type[0].checked = false;
			document.search_form.travel_type[1].checked = true;
			change_sector_2_fields( 1, false )
		}
		else
		{
			if (sector_2_org_prev == -1)
			{
				for (i = 0; i<origBox.length; i++)
				{
					if (origBox.options[i].value == sector2_o)
					{
						sector_2_org_prev = i;
					}
				}
			}
			if (origBox.selectedIndex == 1)
			{
				origBox.selectedIndex = sector_2_org_prev;
			}

			changeOrigDestList(origBox, destBox, 'Destinatie', false, 2, '------------', '');

			if (sector_2_des_prev == -1)
			{
				for (i = 0; i < destBox.length; i++)
				{
					if (destBox.options[i].value == sector2_d)
					{
						sector_2_des_prev = i;
					}
				}
			}
			destBox.selectedIndex = sector_2_des_prev;
		}
	}
}




function enforceMaxPax()
{
		var paxTotal = 0;
				var paxSelect	= document.search_form.ADULT;
				paxTotal		= eval(paxTotal)
					+ eval(paxSelect.options[paxSelect.selectedIndex].value);

		if (paxTotal > 50)
		{
			alert("\nE\' permis un numar maxim de " +50 + " pasageri\npentru rezervarea online.\nDaca grupul Dvs.e mai numeros sunati la serviciul nostru de rezervari.\n");
			return false;
		}
		else
		{
			return true;
		}}



function correctDay(dayToSelect,mkt,monthText)
{
	var i		= 27;
	var okay 	= true;

	if (mkt == 1)
	{
		while (eval(document.search_form.sector_1_d.options[i].value) != dayToSelect)
		{
			i++;
		}
		alert("\nData de plecare nu e valabila.\n" + monthText + " are doar " + dayToSelect + " zile.")
		document.search_form.sector_1_d.options.selectedIndex = i
		okay = false;
		captureDates();
	}
	else if (mkt == 2)
	{
		while (eval(document.search_form.sector_2_d.options[i].value) != dayToSelect)
		{
			i++;
		}
		alert("\nData de intoarcere nu e valabila.\n" + monthText + " are doar " + dayToSelect + " zile.")
		document.search_form.sector_2_d.options.selectedIndex = i;
		captureDates();
		okay = false;
	}

	return okay;
}






function finalDate()
{
	var okay	= true;

		if ( oMonth == rMonth && oDay == rDay )
		{
			okay = confirm("\nData de intoarcere e \naceeasi cu data de plecare.\n\nE corect?\n");
		}


		var oMonthYear= "" + oYear + oMonth;

		if ( okay == true && oDay == 18 && oMonthYear ==200808 )
		{
			alert("\nDeoarece a fost selectata ziua de astazi,\npe pagina urmatoare vor fi afisate doar zborurile care au plecarea peste cel putin 3 ore00 minute\ndin momentul de fata.\n");

		}

	return okay;
}



function checkDate()
{
	var okay = true;
	var oMonthYear= '' + oYear + oMonth;
	var rMonthYear= '' + rYear + rMonth;




	if ( ! checkCalendarDate("1",oDay,oMonth,oYear) )
	{
		okay = false;
	}
	if ( ! checkCalendarDate("2",rDay,rMonth,rYear) )
	{
		okay = false;
	}
	if ( oDay < 18 && oMonthYear <=200808 )
	{
		alert("\nData selectata a trecut deja.\n\nApasati OK pentru a schimba data.\n");
		document.search_form.sector_1_d.options.selectedIndex =17;
		captureDates();
		okay = false;
	}



	if ( ( rDay < oDay && rMonthYear <= oMonthYear ) || rMonthYear < oMonthYear )
	{
		if ( rDay != 0 && rMonth != 0 )
		{
			alert("\nAsigurati-va ca data de intoarcere\nsa fie succesiva celei de plecare.\n\nApasati OK pentru a schimba data de intoarcere.\n")
			document.search_form.sector_2_d.options.selectedIndex
				= eval(document.search_form.sector_1_d.options.selectedIndex) + 1;
			document.search_form.sector_2_m.options.selectedIndex
				= eval(document.search_form.sector_1_m.options.selectedIndex) + 1;
			captureDates();
			okay = false;
		}
	}
	else if ( ( sector2_o == 'XXX' || sector2_d == 'XXX' )
		&& ( rMonth != 0 || rDay != 0 ) )
	{
		alert("\nAti ales o calatorie dus - intors, dar nu ati\nintrodus orasul pentru zborul de intoarcere.\nVa rugam selectati ambele orase.\n");
		okay = false;
	}

	return okay;
}



function checkCalendarDate(mkt,day,month,year)
{
	var okay = true;
	var isLeapYear = ( year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 ) )
		? true : false;

	if ( month == 2 && day > 29 && isLeapYear )
	{
		okay = correctDay(29,mkt,"In acest an, Februarie")
	}
	else if ( month == 2 && day > 28 && !isLeapYear)
	{
		okay = correctDay(28,mkt,"In acest an, Februarie")
	}
	else if ( month == 4 && day > 30 )
	{
		okay = correctDay(30,mkt,"Aprilie")
	}
	else if ( month == 6 && day > 30 )
	{
		okay = correctDay(30,mkt,"Iunie")
	}
	else if ( month == 9 && day > 30 )
	{
		okay = correctDay(30,mkt,"Septembrie")
	}
	else if ( month == 11 && day > 30 )
	{
		okay = correctDay(30,mkt,"Noiembrie")
	}

	return okay;
}



function checkCities()
{


	if (sector1_o == 'XXX')
	{
		alert ("\nSelectati orasul de plecare.\n");
		okay = false;
	}
	else if (sector1_d == 'XXX')
	{
		alert ("\nAlegeti destinatia.\n");
		okay = false;
	}





	else if ( ( sector2_o == 'XXX' && sector2_d != 'XXX' )
		|| ( sector2_o != 'XXX' && sector2_d == 'XXX' ) )
	{
		alert ("\nLipseste un oras pentru zborul de intoarcere. Va rugam\nalegeti doua orase sau anulati pe cel selectat.\n");
		okay = false;

	}

	else
	{
		okay = true;
	}

	return okay;

}



function checkPassenger()
{
	var totalPax		= 0;
	var adults			= 0;
			var paxTypeSelect = document.search_form.ADULT;
			totalPax += paxTypeSelect.options[paxTypeSelect.selectedIndex].value;adults = paxTypeSelect.options[paxTypeSelect.selectedIndex].value

	if ( totalPax <= 0 )
	{
		alert("\nTrebuie sa introduceti  cel putin un pasager.\n");
		return false;
	}

	var infants			= 0;
	var infant_select	= document.search_form.INFANT;

        var childs                      = 0;
        var childs_select       = document.search_form.CHILD;

	if ( infant_select )
	{
		infants			= infant_select.options[infant_select.selectedIndex].value;
	}

	if ( (adults  / infants) < 1 )
	{
		alert("\nDaca doriti sa rezervati pentru un numar de nou nascuti superior\ncelui adultilor, contactati \nserviciul nostru de rezervari pentru eventuale solutii.\n");
		return false;
	}

        if ( childs_select )
        {
                childs                  = childs_select.options[childs_select.selectedIndex].value;
        }

        if ( (adults  / childs) < 1 )
        {
                alert("\nCu aceasta promotie numarul de \'Copii\' trebuie sa fie inferior sau egal cu cel al Adultilor.\nCopiii in plus se vor rezerva ca Adulti.\n");
                return false;
        }

	return true;
}



function askAboutRoundTrip( returnOptionField, fromOpenJaw )
{

	var returnOptionFieldIndex = returnOptionField.options.selectedIndex

	if (document.search_form.sector_2_d.selectedIndex != 0)
	{
		sector_2_d_prev = document.search_form.sector_2_d.selectedIndex;
	}
	if (document.search_form.sector_2_m.selectedIndex != 0)
	{
		sector_2_m_prev = document.search_form.sector_2_m.selectedIndex;
	}

	if (document.search_form.travel_type[1].checked)
	{
		if (confirm("\nDoriti  un bilet Dus - Intors?\n"))
		{
			document.search_form.travel_type[0].checked = true;
			document.search_form.travel_type[1].checked = false;
			change_sector_2_fields( 0, false );
			returnOptionField.selectedIndex = returnOptionFieldIndex;
		}
		else
		{
			document.search_form.travel_type[0].checked = false;
			document.search_form.travel_type[1].checked = true;
			returnOptionField.selectedIndex = 0;
		}
	}



	else if ( document.search_form.travel_type[0].checked
		&& returnOptionField.selectedIndex == 0 )
	{
		if (confirm("\nFara data/zbor de intoarcere? Doriti sa schimbati selectia\nin \'Doar Dus\' ?\n"))
		{
			document.search_form.travel_type[0].checked = false;
			document.search_form.travel_type[1].checked = true;
			change_sector_2_fields( 1, false );
		}
		else
		{
			if (document.search_form.sector_2_d.selectedIndex == 0)
			{
				document.search_form.sector_2_d.selectedIndex = sector_2_d_prev;
			}
			if (document.search_form.sector_2_m.selectedIndex == 0)
			{
				document.search_form.sector_2_m.selectedIndex = sector_2_m_prev;
			}
		}
	}
}



function reconcile_dates()
{
	captureDates();
	if ( rDay != 0 )
	{
		if ( ( rMonth < oMonth && rYear == oYear ) || rYear < oYear )
		{
			document.search_form.sector_2_m.options.selectedIndex
				= document.search_form.sector_1_m.options.selectedIndex + 1;
			document.search_form.sector_2_d.options.selectedIndex
				= document.search_form.sector_1_d.options.selectedIndex + 1;
		}
		else if ( rDay < oDay && rMonth == oMonth && rYear == oYear )
		{
			document.search_form.sector_2_d.options.selectedIndex
				= document.search_form.sector_1_d.options.selectedIndex + 1;
		}
	}
}






	function open_calendar(sector)
	{
		if ( document.search_form.travel_type[0].checked || sector == 1 )
		{
			if ( window.calendarWindow && ! calendarWindow.closed )
			{
				calendarWindow.focus();
			}
			else
			{
				calendarWindow 	= window.open("http://www.myair.com/skylights/cgi-bin/skylights.cgi?module=SB&page=CALENDAR&language=RO&mode=&sid=A18b36b6fda373279a803d25c9d44469cc560e9a4b&form_name=search_form","calendar","width=250,height=251,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,resizable=0");
				document.calForm.month_selected.value
					= document.search_form['sector_' + sector + '_m'].selectedIndex - sector + 1;
				document.calForm.sector.value 	= sector;
			}
		}
	}

if (document.images)
{
		calendar_1_icon_cold		= new Image();
		calendar_1_icon_cold.src 	= '../../images/calendario.gif';
		calendar_1_icon_warm		= new Image();
		calendar_1_icon_warm.src	= '../../images/calendario.gif';
		calendar_1_icon_hot			= new Image();
		calendar_1_icon_hot.src		= '../../images/calendario.gif';
		calendar_1_icon_frozen		= new Image();
		calendar_1_icon_frozen.src	= '../../images/calendario.gif';
		calendar_2_icon_cold		= new Image();
		calendar_2_icon_cold.src 	= '../../images/calendario.gif';
		calendar_2_icon_warm		= new Image();
		calendar_2_icon_warm.src	= '../../images/calendario.gif';
		calendar_2_icon_hot			= new Image();
		calendar_2_icon_hot.src		= '../../images/calendario.gif';
		calendar_2_icon_frozen		= new Image();
		calendar_2_icon_frozen.src	= '../../images/calendario.gif';
}



function swap_icon(icon_name, icon_state)
{
	if (document.images)
	{
		if ( icon_name == 'calendar_1' || swap_icon_ok )
		{
			icon = eval(icon_name + "_icon_" + icon_state + ".src");
			if (icon)
			{
				document.images[icon_name].src = icon;
			}
		}
	}
}