
	/*****************************************************************************
	*
	*  Update select pentru tara in TAB OFERTE TURISTICE 
	*  sel1 = id de la selectul pentru tara
	*
	*****************************************************************************/
	var LAST_COUNTRY_OFERTE_TURISTICE = 'moldova';
	
	function updateOfTuristOrash(sel1, sel2){
		
		var functionPath = appPath + 'ajax/update_offtur_orash';
		
		var country = $(sel1).getSelected().getProperty('value');
		
		var request = new Request/*.JSON*/({
			url: functionPath,
			onRequest: function (){ 	
				$(sel2).innerHTML = '<option>Please wait...</option>';
			},
			onComplete: function(jsonObj) {
				
				$('url_search_oferteturistice_0').value = country;
				$('url_search_oferteturistice_2').value = 'all';
			
				LAST_COUNTRY_OFERTE_TURISTICE = country;
				var pn = document.getElementById(sel2).parentNode; 
				$(sel2).destroy();
				
				pn.innerHTML = '';
				pn.innerHTML += '<select id="sel_offtur_regiune" onchange="updateOfTuristSearchBtn(this, \'regiune\');"><option value="all">Toate...</option>'+ jsonObj +'</select>';				
				
				updateLinkOferteTuristiceCautare();
			}
		}).send('country=' + country);
	}
	
	/*****************************************************************************
	*  function updateOfTuristSearchBtn()
	*  update link for region, period, type
	*
	*****************************************************************************/
	
	function updateOfTuristSearchBtn(el, seg) { //alert(el + ":" + seg);
		if (!el) return false;
		var value2set = '';
		switch (seg) {
			case "regiune": case "tip": value2set = el.options[el.selectedIndex].value; break;
			case "from": case "until": value2set = el; break;				
		}
		var id2set = '';
		switch (seg) {
			case "regiune": id2set = 2; break;
			case "tip":	id2set = 5;	break;
			case "from": id2set = 3; break;
			case "until": id2set = 4; break;				
		}
		var el2set = document.getElementById('url_search_oferteturistice_' + id2set);
		if (!el2set) return false;
		el2set.value = value2set; //alert(el2set.id + ":" + value2set);
		updateLinkOferteTuristiceCautare();
		return true;
	}
	
	/*****************************************************************************
	*  function updateLinkOferteTuristiceCautare()
	*  update link for OFERTE TURISTICE TAB SEARCH
	*
	*****************************************************************************/
	
	function updateLinkOferteTuristiceCautare(){
		
		var url0 = document.getElementById('url_search_oferteturistice_0').value;
		var url2 = document.getElementById('url_search_oferteturistice_2').value;
		var url3 = document.getElementById('url_search_oferteturistice_3').value;
		var url4 = document.getElementById('url_search_oferteturistice_4').value;
		var url5 = document.getElementById('url_search_oferteturistice_5').value;
		
		
		var url = url0 + '/';		
		if (url2.length > 0){			
			url += url2 + '/';		
		}		
		if (url5.length > 0) {
			if (url2.length = 0)			
				url += 'all/';		
			url += url5 + '/';
		}
		if(url3.length > 0 || url4.length>0){
			url += '?from=' + url3 + '&until=' + url4;
		}
		
		var l1 = document.getElementById('cautare_oferteturistice_url');
		var l2 = document.getElementById('cautare_oferteturistice_url2');
		var l3 = document.getElementById('cautare_oferteturistice_url3');
		
		if (l1) l1.href = prefix_oferteturistice_link  + url;
		if (l2) l2.href = prefix_oferteturistice_link + url;
		if (l3) l3.href = prefix_oferteturistice_link + url;
	}
	
	/****************************************************************************************************************
	*  
	*  // Date picker pt oferte turistice
	*  // http://www.monkeyphysics.com/mootools/script/2/datepicker
	*  
	****************************************************************************************************************/
	window.addEvent('domready', function(){
		/***********************************************************************************/	
		$('login').setStyle('height','auto');
			var mySlide = new Fx.Slide('login').hide();  //starts the panel in closed state  

			$('toggleLogin').addEvent('click', function(e){
				e = new Event(e);
				mySlide.toggle();
				e.stop();
			});

			$('closeLogin').addEvent('click', function(e){
				e = new Event(e);
				mySlide.slideOut();
				e.stop();
			});



		/******************************************************************/	
		
		$$('input.DatePicker').each( function(el){
			var today = new Date();
			var min_date = (today.getDate() + 100 + "").substring(1) + '-' + (today.getMonth() + 101 +"").substring(1) + '-' + today.getFullYear();
			var x_offset = (el.id == 'text_offtur_from')?-25:-100;
			var period = (el.id == 'text_offtur_from')?'from':'until';
			new DatePicker(el, {
				//debug: true,
				allowEmpty: true,
				pickerClass: 'datepicker_vista',
				format: 'd-m-Y', /* 1:31-1:12-xxxx */
				inputOutputFormat: 'd-m-Y',
				minDate: { date: min_date, format: 'd-m-Y' },
				positionOffset: { x: x_offset, y: -3 },
				onSelect: function (date) {
						updateOfTuristSearchBtn((date.getDate() + 100 +"").substring(1) + '-' + (date.getMonth() + 101 +"").substring(1) + '-' + date.getFullYear(), period);
				}
			});
		});
	});
	
	function showRezerveazaDialog(id_elem, titlu , tip, w, h, offer_id){
		if ($(id_elem)){
			$(id_elem).addEvent('click', function(e){
				var url = appPath + id_elem + '/'+offer_id+'/';
				new Event(e).stop();
				new MochaUI.Window({
					id: 'win_' + id_elem,
					title: titlu,
					loadMethod: 'iframe',
					contentURL: url,
					type: tip,
					width: w,
					height: h
				});
			});
		}
	}

	var SlideShow = {
		start: function(){
			if (this.mf) {
				mf.update();
				return;
			}
			var ss = $('slide_show');
			if (!ss) return;
			var els = ss.getChildren();
			this.mf = new MooFlow(ss, {
				bgColor: '#fff',
				heightRatio: 0.6,
				useSlider: (els.length > 2)?true:false,
				useAutoPlay: true,
				useCaption: false,
				useResize: true,
				useWindowResize: true,
				useMouseWheel: true,
				useKeyInput: true,
				useViewer: true
			});
			this.mf.attachViewer();
		}		
	};
	window.addEvent('domready', SlideShow.start);
	
	function emptyUpdate() {}
	
