// JavaScript Document
jQuery(document).ready(function($){
	if ($(".date-pick").length > 0){
		$(function() {
			$('.date-pick').datepicker({
				showOtherMonths: true, 
				selectOtherMonths: true,
				minDate:0 , 
				showOn: 'button', 
				buttonImage: webURL + 'images/calendar.jpg',
				buttonImageOnly: true
			});
		
			if (currentLang == 'el') {
				$('.date-pick').datepicker('option', $.datepicker.regional['el']);
			} else {
				$('.date-pick').datepicker('option', $.datepicker.regional['en-GB']);
			}			
		});
		
		var today = new Date();
		today.setDate(today.getDate()+1);
		var todayDate = '' + today.getDate();
		var todayDateStr = ( todayDate.length==1 ? '0'+todayDate : todayDate );
		var todayMonth = '' + (today.getMonth()+1);
		var todayMonthStr = ( todayMonth.length==1 ? '0'+todayMonth : todayMonth );
		
		var dateInEl = document.getElementById('date-in');
		var usDateInEl = document.getElementById('eu-date-in');
		
		if (usDateInEl) {
			if (usDateInEl.value == 'unknown') {
				dateInEl.value = todayDateStr + '/' + todayMonthStr + '/' +  today.getFullYear();
				usDateInEl.name = 'usdatein';
				usDateInEl.defaultValue = 'waiting'; 
				usDateInEl.value = usDateInEl.defaultValue;
			}
		}
	}
	
    $('#languages ul').each(function() {
        var html = $('<select onchange="window.location.href=this.value;" ></select>');

        $(this).find('a').each(function() {
            var option = $('<option ></option>');
            option.attr('value', $(this).attr('href')).html($(this).text());
			
			if ($(this).hasClass('active')) {
				option.attr('selected', 'selected');
			}
			
            html.append(option);
        });

        $(this).replaceWith(html);
    });
	
	/*$('#headerImages').find('.images').each(function() {
		$(this).css('background-image', 'url(' + webURL + 'images/' + $(this).attr('id') + '.jpg)');
	});*/

	rotateImages();
});	

function bookingOnSubmit() {
	var dateParts = $("#date-in").val().split('/');
	document.getElementById('eu-date-in').value = $("#date-in").val();
	document.getElementById('date-in').value = dateParts[1] + '/' + dateParts[0] + '/' + dateParts[2];
	document.getElementById('eu-date-in').name = 'eudatein';
	return true;
}

function rotateImages() {
	if ($('#headerImages .images').length > 1) {
		current = $('#headerImages .active');
		if (current.length == 0) {
			$('#headerImages .images:first').css('display', 'block').addClass('active');
		} else {
			if ($('#headerImages .images:last').hasClass('active')) {
				next = $('#headerImages .images:first');
			} else {
				next = current.next();
			}
			current.fadeOut(2000).removeClass('active')
			next.fadeIn(2000).addClass('active');
		}
		timeoutRotation = setTimeout('rotateImages();', 4000);
	} else {
		$('#headerImages .images:first').css('display', 'block').addClass('active');
	}
}

function showTab(id) {
	$('#tabTitles .active').removeClass('active');
	$('#tabTitles .' + id).addClass('active');
	$('#tabContents .tabContent').css('display', 'none');
	$('#' + id).css('display', 'block');
}
				var _gaq = _gaq || [];
				_gaq.push(['_setAccount', 'UA-26184681-1']);
				_gaq.push(['_trackPageview']);
				_gaq.push(['_trackPageLoadTime']);
				
				(function() {
					var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
					ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
					var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
				})();
