	//validare form
	function verCautare() {
		var mesaj = "";
		var f = document.forms['cautare'];
		var fsubmit = document.getElementById('fsubmit');
		fsubmit.src = "images/bt_wait.gif";
		
		f.From.value = trimStr(f.From.value);
		f.To.value = trimStr(f.To.value);
		//sursa OK?
		if (!(f.From.value.length>=3 && isAlphanumeric(f.From.value, 1))) {
			mesaj += 'Va rugam alegeti orasul sau aeroportul de plecare (minim 3 caractere).\n';
		} 
		//destinatia OK?
		if (!(f.To.value.length>=3 && isAlphanumeric(f.To.value, 1))) {
			mesaj += 'Va rugam alegeti orasul sau aeroportul de destinatie (minim 3 caractere).\n';
		} 
		//sursa != destinatie ?
		if (f.From.value==f.To.value && f.From.value.length) {
			mesaj += 'Orasul destinatie trebuie sa fie diferit de orasul de plecare!\n';
		}
		
		//datele
		var temp = gdta_min;
		temp = temp.split("/");
		if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
		temp[1] --;
		var mindta = new Date(temp[2], temp[1], temp[0]);
		temp = gdta_max;
		temp = temp.split("/");
		if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
		temp[1] --;
		var maxdta = new Date(temp[2], temp[1], temp[0]);
		temp = gdta_back;
		temp = temp.split("/");
		if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
		temp[1] --;
		var dtaback = new Date(temp[2], temp[1], temp[0]);
		
		//data de plecare
		temp = f.elements.DepartureDate.value.split("/");
		if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
		temp[1] --;
		var depdta = new Date(temp[2], temp[1], temp[0]);
		if (f.elements.DepartureDate.value=='' || depdta<mindta || depdta>maxdta) {
			mesaj += "Data de plecare invalida! Data trebuie sa fie in format zz/ll/aaaa, nu mai devreme de "+gdta_min+" si nu mai tarziu de "+gdta_max+".\n";
		}
		

		//data de sosire
		temp = f.elements.ArrivalDate.value.split("/"); 
		if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
		temp[1] --;
		var arrdta = new Date(temp[2], temp[1], temp[0]);
	
		if (f.elements.ArrivalDate.value=='' || arrdta<mindta || arrdta>dtaback) {
			mesaj += "Data de sosire invalida! Data trebuie sa fie in format zz/ll/aaaa, nu mai devreme de "+gdta_min+" si nu mai tarziu de "+gdta_back+".\n";
		} else if (arrdta<depdta) {
			mesaj += "Data de sosire invalida! Data trebuie sa fie in format zz/ll/aaaa, nu mai devreme decat data de plecare.\n";
		}
		
		//perioadele 
		var per = (arrdta - depdta)/(24*60*60*1000); 
		if (per<gzimin) mesaj += "Perioada de calatorie este sub perioada minima de sedere ("+gzimin+" zile).\n";
		if (gzimax && per>gzimax) mesaj += "Perioada de calatorie este mai mare decat perioada maxima de sedere ("+gzimax+" zile).\n";
		
		//sunday rule
		if (gsundayrule) {
			if (per<7) {
				var d1 = depdta.getDay();
				var d2 = arrdta.getDay();
				if (d2>=d1) {
					mesaj += "Promotia este valabila doar daca se petrece cel putin o sambata noapte la destinatie. Va rugam selectati perioada corespunzator acestei reguli.\n";
				}
			}
		}
		
		
		fsubmit.src = "images/bt_rezerva.gif";	
		//form ok?
		if (mesaj=="") {
			var tmp = new Date();
			var f = document.forms['cautare'];
			//tmp = "m_"+tmp.getTime();
			//FormLoadPopup(tmp);
			//f.setAttribute("target", tmp);
			f.submit();			
		} else {
			mesaj = "Atentie!\n"+mesaj;
			alert(mesaj);
		}
		return false;
	}
	
	function skimbaDta(dta1, dta2) {
	var temp = dta1.value.split("/");
	if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
	temp[1] --;
	odta1 = new Date(temp[2], temp[1], temp[0]);
	
	temp = dta2.value.split("/");
	if (temp[1].length>1 && temp[1].charAt(0)=="0") temp[1] = temp[1].charAt(1);
	temp[1] --;
	odta2 = new Date(temp[2], temp[1], temp[0]);
	
	if (odta2<odta1) {
		dta2.value = dta1.value;
	}
}

// pasagerii 
	
	function calcADT () {
		
		//adults
		var adt = document.getElementById("ADT");
		var nr_adt = adt.options.length;
		
		//children first
		var sel = document.getElementById("CHD");
		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("CHD");
		var nr_chd = chd.options.length;
		
		//children first
		var sel = document.getElementById("ADT");
		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("ADT");
		var nr_adt = adt.options.length;
		
		var sel = document.getElementById("INF");
		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;
		}
	}		
	var http = getHTTPObject(); 