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;
			}
		}
	}
	
	if ($('#mainPhoto .offer').length > 1){
		$('#mainPhoto').cycle();
	}
	
	$('#deals li:first').addClass('active');
	
	$('.subnav1 a').click(function() {
		_gaq.push(['_trackEvent', 'Factsheet', 'click', 'factsheet-download']);
	});
	
	$('.subnav3 a').click(function() {
		_gaq.push(['_trackEvent', 'Tickets', 'click', 'book-tickets']);
	});
	
});	

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';
	
	_gaq.push(['_trackEvent', 'online booking', 'Submit', 'booking form']);
	
	return true;
}

$('h1 > a').live('mouseover', function(){
	$(this).animate({marginTop:'0px'}, 'fast');
}).live('mouseout', function(){
	$(this).animate({marginTop:'-7px'}, 'fast');
});

$('.dealButton').live('click', function() {
	if ($(this).attr('id') == 'dealNext') {
		if ($('#deals .active').attr('id') == $('#deals li:last').attr('id')) {
			$('#deals .active').removeClass('active');
			$('#deals li:first').addClass('active');
		} else {
			$('#deals .active').removeClass('active').next().addClass('active');
		}
	} else {
		if ($('#deals .active').attr('id') == $('#deals li:first').attr('id')) {
			$('#deals .active').removeClass('active');
			$('#deals li:last').addClass('active');
		} else {
			$('#deals li.active').removeClass('active').prev().addClass('active');
		}
	}
});

$("#auctionFormSubmit").live('click', function(){
	$('.required').removeClass('error');

	var hasError = false;
	var itemVal = $('#item').val();
	var formToolsIdVal = $("#id").val();
	var initializeVal = $("#initialize").val();

	var nameVal = $('#name').val();
	if(nameVal == '') {
		$('#name').addClass('error');
		hasError = true;
	}

	var surnameVal = $('#surname').val();
	if(surnameVal == '') {
		$('#surname').addClass('error');
		hasError = true;
	}

	var phoneVal = $('#phone').val();
	if(phoneVal == '') {
		$('#phone').addClass('error');
		hasError = true;
	}

	var emailVal = $('#email').val();
	if(emailVal == '') {
		$('#email').addClass('error');
		hasError = true;
	}

	var offerVal = $('#offer').val();
	if(offerVal == '') {
		$('#offer').addClass('error');
		hasError = true;
	}

	var professionVal = $('#profession').val();
	if(professionVal == '') {
		$('#profession').addClass('error');
		hasError = true;
	}

	if(hasError == false) {
		$.post('http://net360.gr/formtools/process.php', {Name: nameVal, Surname: surnameVal, phone: phoneVal, email: emailVal, offer: offerVal, profession: professionVal, item: itemVal, form_tools_form_id:formToolsIdVal});
		return true;
	}

	return false;
});	
				var _gaq = _gaq || [];
				_gaq.push(['_setAccount', 'UA-23889774-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);
				})();
