$(document).ready(function(){
	$('#videoplay a.video_new').click(function() {	
													$('#choose_video').slideDown();
													return false;
												});
												
	$('#video_SD a').fancybox({
		width: 550,
		height: 350
	});	
	
	$('#video_HD a').fancybox({
		width: 1280,
		height: 750
	});
	
	//   B O O K I N G   F O R M
	$("#bf select, #newsletter select").uniform();
	start(); 
	
	
	// ALLARGO IL BOX NERO PER LA VISUALIZZAZIONE DEL TESTO, NEL CASO IN CUI L'ALTEZZA DEL BOX SIA MAGGIARE DI 360 (380-20)
	var height_image = $('.container-page').css('height');
	if (height_image) {
		var H_image = height_image.replace('px','');
		if (Number(H_image)>360) {
			$('.box-text').css('width','500px');
			$('.container-page').css('width','480px');
		}
	}
	
	
	conta=0;
	$(".blocks li").each(function() {	
		conta= conta+1;	
	});
	conta=conta-1;
	$('#arrow_right a').removeAttr('id');
	$('#arrow_right a').attr({id: (conta)});
	//$('#arrow_right a').attr({id:"("+conta+")"});
	
	
	// JAVASCRIPT DELLO SCROLLER
	var originalSizes = new Array();
	$('#pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
	// this initialises the demo scollpanes on the page.
	$('a.jumper').click(function(){	
		var pos = $(this).attr('id');
		//alert("onLoad");
		var c = $("#pane7");
		c[0].scrollTo("li:eq("+pos+")");
		return false;
	});
	
	//$('#pane7').jScrollHorizontalPane({showArrows:true});
	
	
	// AL RESIZE DELlA FINESTRA RICALCOLO LA LARGHEZZA DELLO SCROLL
	$(window).resize(function(){
		 // JAVASCRIPT DELLO SCROLLER
		var originalSizes = new Array();
		$('#pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
		// this initialises the demo scollpanes on the page.
		$('a.jumper').click(function(){	
			var pos = $(this).attr('id');
			var c = $("#pane7");
			c[0].scrollTo("li:eq("+pos+")");
			return false;
		});
	});

	
	

	/* *******************************************************************************
			M E N U 
	   ******************************************************************************/
	$('.no-reload a').click (function() {
		//alert('-- menu --');
		
		if (document.all){ // EXPLORER
			$('#box_hidden #flash #pane7').add();
		}
		
		// RICERCA DELLA VOCE DI MENU SELEZIONATA, COSė HO LA POSSIBILITA' DI 
		// NASCONDERE IL SELEZIONATO DALLA VOCE E RIMETTERLO QUANDO CHIUDO LA 
		// FINESTRA CHE SI E' APERTA!
		id_menu_sel = "no-class";
		$('.reload a').each(function() {
			$(this).parent('li').removeClass('current');
			id_menu = $(this).attr('id');
			class_sel = $('#' + id_menu).attr('class');
			if (class_sel.indexOf('current')>0) {
				$(this).removeClass('current');
				id_menu_sel = $(this).attr('id');
			}
		});
		
		
		// CICLO PER SEGNARMI L'id DEL MENU' DEL FOOTER SELEZIONATO
		$('#footer_menu li a').each(function() {
			class_sel = $(this).attr('class');
			if (class_sel.indexOf('current')>0) {
				$(this).removeClass('current');
				id_menu_sel = $(this).attr('class');
				id_menu_sel = id_menu_sel.replace("footer ","");
				id_menu_sel = id_menu_sel.replace("last","");
			}
		});
		
	
		
		// MI SEGNO CHE VOCE DI MENų HO SELEZIONATO, MI SERVIRA' DOPO PER RICHIAMARE 
		// IL js DELLA GOOGLEMAPS (RIGA 131)
		loc = $(this).attr('class');
		
		
		// SETTO LA LARGHEZZA DEL #BOX-HIDDEN = ALLA LARGHEZZA DEL #HOMEPAGE
		var w_home = $('#homepage').css('width');
		var w_home_flash = $('#flash').css('width');
		
		if (w_home=="auto") {
			if (document.all){ // EXPLORER
				$('#box_hidden').css('width','100%');	// con IE widht=AUTO non funziona bene!
			}
		} else {
			if (w_home_flash) {
				$('#box_hidden').css('width',w_home_flash);	
			} else {
				$('#box_hidden').css('width',w_home);
			}
		}
		
		
		// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
		$('.menu-element a').each(function() {
			$(this).removeClass('current');
		});
		$(this).addClass('current');
		
		
		// ID VOCE MENU PER ATTIVARE IL COLORE SUL MENU
		/*
		var id_menu = $(this).attr('id');
		$('#'+id_menu).addClass('menu-red');
		*/
		
		
		// MARGIN TOP DIVERSI TRA IE E GLI ALTRI BROWSER
		if (document.all){ // EXPLORER
			$('#box_hidden').animate({ top: "0"}, 1500); // IE -> 0 || FF -> -4px
		} else {
			$('#box_hidden').animate({ top: "-4px"}, 1500); // IE -> 0 || FF -> -4px
		}
		
		
		// DOPO AVER VISUALIZZATO IL BOX_HIDDEN CI CARICO DENTRO IL CONTENUTO!
		$('#box_hidden').load($(this).attr('href') + ' #flash', function() {
			
			// NASCONDO IL BOX PRESENTE IN HOMEPAGE
			setTimeout(function() { 
				$('#homepage').fadeOut("slow");
				//$('#flash').fadeOut("slow");
				$('#box_hidden #flash').fadeIn("slow");
				$('#content > #flash').fadeOut("slow");
			}, 500); 
			
			
			// CONTROLLO SE E' LA CATEGORIA location PER RICHIAMARE IL js DELLA GOOGLEMAPS
			if (loc.indexOf('cat-id-21')>0) {
				initialize();
			}
			
			
			/* riaggiorno l'ID della freccia destra per lo scroller */
			cont=1;
			$("#box_hidden .blocks > li").each(function() {	
				cont=cont+1;	
			});
			cont=cont-2;
			//alert(cont);
			$('#arrow_right a').removeAttr('id');
			//$('#arrow_right a').attr({id:""+cont+""});
			$('#arrow_right a').attr({id:cont});
			

			// NELLA callback APPLICO ANCORA IL js PER LO SCROLLER
				//alert($('#content > #flash').css('display'));
				
				
				
				var originalSizes = new Array();
				$('#box_hidden #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
				//$('#box_hidden #pane7').css("border","1px solid red");
				// this initialises the demo scollpanes on the page.
				$('a.jumper').click(function(){		
					var pos = $(this).attr("id");
					//alert("1");
					var c = $("#box_hidden #pane7");
					c[0].scrollTo("li:eq("+pos+")");
					return false;
				});	
				
			/*	
				$('#arrow_right a').removeAttr('id');
				//$('#arrow_right a').attr({id:""+cont+""});
				$('#arrow_right a').attr({id:cont});

				var originalSizes = new Array();
				$('#content > #flash #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
				//$('#box_hidden #pane7').css("border","1px solid red");
				// this initialises the demo scollpanes on the page.
				$('a.jumper').click(function(){		
					var pos = $(this).attr("id");
					alert("2");
					var c = $("#content > #flash #pane7");
					c[0].scrollTo("li:eq("+pos+")");
					return false;
				});	
			*/
			
			
			
			
			/* NASCONDO/MOSTRO LE FRECCIE! */
			//alert($('#box_hidden .jScrollPaneTrack').css('display'));
			if (!$('#box_hidden .jScrollPaneTrack').css('display')) {
				setTimeout(function() { 
				/*
					$('#arrow_right').fadeOut(300);
					$('#arrow_left').fadeOut(300);*/
				}, 500); 
			} else {
				setTimeout(function() { 
					$('#arrow_right').fadeIn(300);
					$('#arrow_left').fadeIn(300);
				}, 200); 
			}
			
			
			
			
			/*******************************************************************************
			********************* 				F A Q 			****************************
			********************************************************************************/				
			// NASCONDO TUUTE LE RISPOSTE DELLE FAQ
			$(".faq_box .answer").each(function() {	
				$(this).css("display","none");
			});
			
			// VISUALIZZO LA RISPOSTA DELLA FAQ
			$(".faq_box .body a").click(function(){
				// nascodo tutte le risposte aperte
				//console.log("qui");
				$(".faq_box .answer").each(function() {	
					$(this).hide(1000);
				});
				var hidden_id = parseInt($(this).parent('.body').attr('id').replace('h_', ''), 10); 
				$(".faq_box #risp_" + hidden_id).show(500);
				return false;
			});
			
			
			// NASCONDO LA SCROLLBAR "appena caricata"
			$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
			//$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('border','1px solid red');
			//$('#box_hidden .jScrollPaneTrack').css('display','block');
			setTimeout(function() { 
				$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').fadeIn(500);
			}, 1500); 
			
			
			// ALLARGO IL BOX NERO PER LA VISUALIZZAZIONE DEL TESTO, NEL CASO IN CUI L'ALTEZZA DEL BOX SIA MAGGIARE DI 360 (380-20)
			var height_i = $('#box_hidden .container-page').height();
			if (height_i) {
				if (height_i>360) {
					$('.box-text').css('width','500px');
					$('.container-page').css('width','480px');
					//alert($('#box-text').css('width'));
				}
			}
			
			
			// *************************************************************************************************
			// 			R O O M S   D E T A I L    B U T T O N
			// *************************************************************************************************
			$('.categories .menu-element a').live ('click',function() {
				//alert('--click--');
					
					//$('#box_hidden').fadeOut(300);
					
					$('#box_hidden').load($(this).attr('href') + ' #flash', function() {
						
						setTimeout(function() { 
							$('#box_hidden').fadeIn(300);
							$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').fadeIn(300);
						}, 200); 
						
						// NELLA callback APPLICO ANCORA IL js PER LO SCROLLER
						var originalSizes = new Array();
						$('#box_hidden #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
						//$('#box_hidden #pane7').css("border","1px solid red");
						// this initialises the demo scollpanes on the page.
						$('a.jumper').click(function(){		
							var pos = $(this).attr("id");
							//alert("5");
							var c = $("#box_hidden #pane7");
							c[0].scrollTo("li:eq("+pos+")");
							return false;
						});	
						
						// CLOSE BUTTON DETAIL ROOM
						$('.close a').click(function(){
							//alert('-close details rooms-');							
							$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
							
							// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
							$('.menu-element a').each(function() {
								$(this).removeClass('current');
							});
							// METTO CURRENT SULLA CATEGORIA CHE COMPARE SOTTO QUANDO CHIUDO LA SEZIONE ROOMS
							$('#'+ id_menu_sel).addClass('current');
				
							// METTO VISIBILE I CONTENUTI SOTTO
							$('#homepage').fadeIn("slow");					 	
							$('#content > #flash').fadeIn("slow");
							
							// RIMUOVO IL BOX_HIDDEN
							$('#box_hidden').animate({ top: "430px"}, 1500);										   
							// NASCONDO LA SCROLLBAR QUIIIIIIIIII
							$('#homepage .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
							// DOPO tot SECONDI VISUALIZZO LA SCROLL BAR
							setTimeout(function() { 
								$('#homepage .jScrollPaneContainer .jScrollPaneTrack').fadeIn(500);
							}, 1500); 
							
							// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
							$('.menu-element a').each(function() {
								$(this).removeClass('menu-red');
							});
							
							
							
							if (document.all){ // EXPLORER
								$('#flash #pane7').remove();
							} 
							
							var homepage_display = $('#homepage').css('display');
							
							if (homepage_display=="block") {
								//alert("quiiiiiiiiiiiiiiiiii");
								//$("#pane7").css("border","1px solid red");
							/**/
								$('#arrow_right a').attr({id:4});
								var originalSizes = new Array();
								//$('#content_box #content #homepage #flash .holder .jScrollPaneContainer #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
								// this initialises the demo scollpanes on the page.
								
								$('a.jumper').click(function(){	
									var pos = $(this).attr('id');
									//alert("-4--");
									var c = $('#homepage #pane7');
									c[0].scrollTo("li:eq("+pos+")"); 
									return false;
								});
								
							} else {
								
								/* QUANDO RITORNO NELLA PAGINA SPECIAL OFFERS DA ROOMS */
								cont=0;
								$("#content > #flash .blocks li").each(function() {	
									cont=cont+1;	
								});
								cont=cont-2;
								//alert(cont);
								$('#arrow_right a').removeAttr('id');
								//$('#arrow_right a').attr({id:"("+cont+")"});
								$('#arrow_right a').attr({id:cont});
							
								var originalSizes = new Array();
								$('#content > #flash #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
								//$('#box_hidden #pane7').css("border","1px solid red");
								// this initialises the demo scollpanes on the page.
								$('a.jumper').click(function(){		
									var pos = $(this).attr("id");
									//alert("3____");
									var c = $("#content > #flash #pane7");
									c[0].scrollTo("li:eq("+pos+")");
									return false;
								});
							}
							
							return false;
						});	
						
					});
					
				return false;
			});

			
			
			// CLICK SUL CLOSE DEL BOX_HIDDEN
			$('.close a').click(function(){
										 
				$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
			//	alert('-close-');
				
				// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
				$('.menu-element a').each(function() {
					$(this).removeClass('current');
				});
				
				// CICLO PER DELESEZIONARE TUTTE LE VOCI ANCHE DEL FOOTER
				$('#footer_menu a').each(function() {
					$(this).removeClass('current');
				});
				//alert(id_menu_sel);
				
				// METTO current IL MENU CHE ERA APERTO PRIMA
				$('#'+ id_menu_sel).addClass('current');
				
				// FOOTER
				//alert('#footer_menu .'+ id_menu_sel);
				$('#footer_menu .'+ id_menu_sel).addClass('current');
				
				
				// METTO VISIBILE I CONTENUTI SOTTO
				$('#homepage').fadeIn("slow");	
				$('#content > #flash').fadeIn("slow");
					
				// RIMUOVO IL BOX_HIDDEN
				$('#box_hidden').animate({ top: "430px"}, 1500);										   
				// NASCONDO LA SCROLLBAR QUIIII
				$('#homepage .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
				// DOPO tot SECONDI VISUALIZZO LA SCROLL BAR
				setTimeout(function() { 
					$('#homepage .jScrollPaneContainer .jScrollPaneTrack').fadeIn(500);
				}, 1500); 
				
				// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
				$('.menu-element a').each(function() {
					$(this).removeClass('menu-red');
				});
				
				
				/* riaggiorno l'ID della freccia destra per lo scroller */
				cont=0;
				$("#pane7 .blocks li").each(function() {	
					cont=cont+1;	
				});
				cont=cont-2;
				//alert(cont);
				$('#arrow_right a').removeAttr('id');
				//$('#arrow_right a').attr({id:"("+cont+")"});
				$('#arrow_right a').attr({id:cont});
				
				
				/* NASCONDO/MOSTRO LE FRECCIE! */
				//alert("qu");
				//alert($('#flash .jScrollPaneTrack').css('display'));
				
				if (!$('.jScrollPaneTrack').css('display')) {
					setTimeout(function() { 
						/*$('#arrow_right').fadeOut(300);
						$('#arrow_left').fadeOut(300);*/
					}, 500); 
				} else {
					setTimeout(function() { 
						$('#arrow_right').fadeIn(300);
						$('#arrow_left').fadeIn(300);
					}, 200); 
					
				}
				
				
				
				if (document.all){ // EXPLORER
					//$('#box_hidden').append('');
					$('#flash #pane7').remove();
				} 
				
				var homepage_display = $('#homepage').css('display');
				
				if (homepage_display=="block") {
					//alert("quiiiiiiiiiiiiiiiiii");
					//$("#pane7").css("border","1px solid red");
				/**/
					
					
					cont=0;
					$("#homepage #pane7 .blocks li").each(function() {	
						cont=cont+1;	
					});
					cont=cont-2;
					$('#arrow_right a').removeAttr('id');
					//$('#arrow_right a').attr({id:"("+cont+")"});
					$('#arrow_right a').attr({id:cont});
					
					//$('#arrow_right a').attr({id:4});
					//alert("quiii");
					
					
					var originalSizes = new Array();
					//$('#content_box #content #homepage #flash .holder .jScrollPaneContainer #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
					// this initialises the demo scollpanes on the page.
					
					$('a.jumper').click(function(){	
						var pos = $(this).attr('id');
						//alert("-4");
						var c = $('#homepage #pane7');
						c[0].scrollTo("li:eq("+pos+")"); 
						return false;
					});
					
				} else {
					
					/* QUANDO RITORNO NELLA PAGINA SPECIAL OFFERS */
					cont=0;
					$("#content > #flash .blocks li").each(function() {	
						cont=cont+1;	
					});
					cont=cont-2;
					$('#arrow_right a').removeAttr('id');
					//$('#arrow_right a').attr({id:"("+cont+")"});
					$('#arrow_right a').attr({id:cont});
				
					var originalSizes = new Array();
					$('#content > #flash #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
					//$('#box_hidden #pane7').css("border","1px solid red");
					// this initialises the demo scollpanes on the page.
					$('a.jumper').click(function(){		
						var pos = $(this).attr("id");
						//alert("3");
						var c = $("#content > #flash #pane7");
						c[0].scrollTo("li:eq("+pos+")");
						return false;
					});
				}
				
				
				return false;
			});
									
		}); /* -- fine callback */
		return false;
	});
		


	
	
	
	
	
	// *********************************************************************************************************
	//			O F F E R S
	// *********************************************************************************************************
	$('.offers a').click(function(){
		//alert('offer');
		
		// SETTO LA LARGHEZZA UGUALE A QUELLA DEL CONTENUTO DELLA PAGINA VISUALIZZATA (in questo caso #flash)
		var w_home = $('#flash').css('width');
		if (w_home=="auto") {
			if (document.all){ // EXPLORER
				$('#box_hidden').css('width','100%');	// con IE widht=AUTO non funziona bene!
			}
		} else {
			$('#box_hidden').css('width',w_home);
		}
		
		// NASCONDO I CONTENUTI DELLA PAGINA PRINCIPALE (es: offers) 
		if (document.all){ // EXPLORER
		//	$('#content #flash').fadeOut(1800);
		} else {
			$('#content #flash').fadeOut(1800);
		}
		
		// MARGIN TOP DIVERSI TRA IE E GLI ALTRI BROWSER
		if (document.all){ // EXPLORER
			$('#box_hidden').animate({ top: "0"}, 1500); // IE -> 0 || FF -> -4px
		} else {
			$('#box_hidden').animate({ top: "-4px"}, 1500); // IE -> 0 || FF -> -4px
		}
		
			
		// CARICO I CONTENUTI NEL BOX_HIDDEN (quello che compare da sotto)
		$('#box_hidden').load($(this).attr('href') + ' #flash', function() {
			
			
			// NASCONDO IL BOX PRESENTE IN HOMEPAGE
			setTimeout(function() { 					
				$('#content > #flash').fadeOut("slow");
				$('.primo-piano').fadeOut(500);
			}, 500); 
			
			
			cont=1;
			$("#box_hidden li").each(function() {	
				cont=cont+1;	
			});
			cont=cont-2;
			//alert(cont);
			$('#arrow_right a').removeAttr('id');
			//$('#arrow_right a').attr({id:""+cont+""});
			$('#arrow_right a').attr({id:cont});
			
			
			
			// NELLA callback APPLICO ANCORA IL js PER LO SCROLLER
			var originalSizes = new Array();
			$('#box_hidden #pane7').jScrollHorizontalPane({scrollbarHeight:10, scrollbarMargin:0});
			// this initialises the demo scollpanes on the page.
			$('a.jumper').click(function(){		
				var pos = $(this).attr("id");
				var c = $("#box_hidden #pane7");
				c[0].scrollTo("li:eq("+pos+")");
				return false;
			});	
			
			
			setTimeout(function() { 
				$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').fadeIn(500);
			}, 1200); 	
			
			
			$('.close a').click(function(){
				//alert('-- close --');
				
				if (document.all){ // EXPLORER
					//$('#box_hidden').append('');
					$('#flash #pane7').remove();
				}
				
				cont=1;
				$("#content > #flash li").each(function() {	
					cont=cont+1;	
				});
				cont=cont-2;
				//alert(cont);
				$('#arrow_right a').removeAttr('id');
				//$('#arrow_right a').attr({id:""+cont+""});
				$('#arrow_right a').attr({id:cont});
				
				//$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
				
				var originalSizes = new Array();
				$('#box_hidden .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
				//$('#box_hidden #pane7').css("border","1px solid red");
				// this initialises the demo scollpanes on the page.
				$('a.jumper').click(function(){	
					var pos = $(this).attr('id');
					var c = $('#content > #flash #pane7');
					//alert("close offert");
					c[0].scrollTo("li:eq("+pos+")"); 
					return false;
				});
				
				
				
				$('.primo-piano').fadeIn("slow");
				// METTO VISIBILE I CONTENUTI SOTTO
				//$('#content #flash').css('display','block');
				$('#content #flash').show(300);
				
				// RIMUOVO IL BOX_HIDDEN
				$('#box_hidden').animate({top: "430px"}, 1500);										   
				// NASCONDO LA SCROLLBAR
		//		$('#flash .jScrollPaneContainer .jScrollPaneTrack').css('display','none');
				// DOPO tot SECONDI VISUALIZZO LA SCROLL BAR
				setTimeout(function() { 
		//			$('#flash .jScrollPaneContainer .jScrollPaneTrack').fadeIn(500);
				}, 1500); 
				
				// CICLO PER DESELEZIONARE TUTTE LE VOCI DEL MENU
				$('.menu-element a').each(function() {
					$(this).removeClass('menu-red');
				});
				return false;
			});							 
			
		});

		return false;
	});
	
	
	
	
	
	
	
	
	
/*******************************************************************************
********************* 		C A L E N D A R 		****************************
********************************************************************************/


/*Gestione calendario nella booking*/
$(function() {
jQuery(function(){
	
	// initialise the "Select date" link
	jQuery('.date-pick')
		.datePicker(

			//associate the link with a date picker
			{
				createButton:false,
				startDate:'<?php echo date("d/m/Y"); ?>',
				endDate:'<?php echo date("d/m/Y",time() + 63000000); ?>'
			}
		).bind(
			// when the link is clicked display the date picker
			'click',
			function()
			{
				updateSelects(jQuery(this).dpGetSelected()[0]);
				jQuery(this).dpDisplay();
				return false;
			}
		).bind(
			// when a date is selected update the SELECTs
			'dateSelected',
			function(e, selectedDate, $td, state)
			{
				updateSelects(selectedDate);
			}
		).bind(
			'dpClosed',
			function(e, selected)
			{
				updateSelects(selected[0]);
			}
		);
		
//		$('.selector').datepicker({ showOptions: {direction: 'up' });
		
	var updateSelects = function (selectedDate)
	{
		var selectedDate = new Date(selectedDate);
		jQuery('#d option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected');
		jQuery('#m option[value=' + (selectedDate.getMonth()+1) + ']').attr('selected', 'selected');
		jQuery('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
	}
	// listen for when the selects are changed and update the picker
	jQuery('#d, #m, #y')
		.bind(
			'change',
			function()
			{
				var d = new Date(
							jQuery('#y').val(),
							jQuery('#m').val()-1,
							jQuery('#d').val()
						);
				jQuery('#date-pick').dpSetSelected(d.asString());
			}
		);
	
	// default the position of the selects to today
	var today = new Date();
	updateSelects(today.getTime());
	
	// and update the datePicker to reflect it...
	jQuery('#d').trigger('change');
	});
});


function check_date() {
	//var date_input = document.input_date.value;
	var date_input = document.idForm.input_date.value
	var dd = date_input.substring(0,2);
	var mm = date_input.substring(3,5);
	var yy = date_input.substring(6,10);
	document.idForm.fromday.value = dd;
	document.idForm.frommonth.value = mm;
	document.idForm.fromyear.value = yy;
	//alert(dd + "/" + mm + "/" + yy);
}
	

$('#date-pick').change(function(){	
	check_date(document.idForm);
});

	
});