/**
* Kęstutis Valinčius, made.By
* http://www.by.lt
* 2009
*/

// this event fires as soon as DOM is loaded successfully, so it's fired faster than $(window).ready()
jQuery(function(){
	
});

// this event is triggered only when all DOM elements are downloaded and loaded
$(window).ready(function (){
	$('.marker').hover(function(){
		$('span.markerTitle1', this).show(200);
	}, function() {
		if (!$('span.markerTitle1', this).hasClass('active')) {
			$('span.markerTitle1', this).hide(200);
		}
	});
	
	$('.markerActive').hover(function(){
		$('span.markerTitle1', this).show(200);
	}, function() {
		if (!$('span.markerTitle1', this).hasClass('active')) {
			$('span.markerTitle1', this).hide(200);
		}
	});

	$('div.scrollingHotSpotRight2').hover(function() {
		$('div#makeMeScrollable').smoothDivScroll('option', 'autoScrollInterval', '100');
	});
	
	$('div.scrollingHotSpotLeft2').hover(function() {
		$('div#makeMeScrollable').smoothDivScroll('option', 'autoScrollInterval', 200);
	});
	
	$('.selectMenu').click( function(){
		if($(this).hasClass('hover')){}
		else{
			$(this).addClass('hover');
			$('.selectMenu ul').slideDown(400);
		}
	});
	
	$('.selectMenu').hover(
		function () {}, 
		function () {
			if($(this).hasClass('hover')){
				$('.selectMenu ul').slideUp(400,function(){
							$('.selectMenu').removeClass('hover');
						});
			}
		}
	);
	
	$('a.colorbox').colorbox({transition:"elastic", current: '', previous: '', next: '', close: ''});
	
	
	// ------------form----------- //
	
	$(".button").mousedown(function(){
		$(this).addClass('active');
	}).mouseup(function(){
		$(this).removeClass('active');
    });
	
	$("input[type='text']").focus( function(){
		$(this).addClass('active');
	}).blur( function(){
		$(this).removeClass('active');
	})
	
	$("textarea").focus( function(){
		$(this).addClass('active');
	}).blur( function(){
		$(this).removeClass('active');
	})
	
	$("input[name='destination']").change(function() {
		selectedId = $("input[name='destination']:checked").attr('id');
		if(selectedId == "destination1"){
			$('.noCred').hide();
			$('.vilniusCred').show();
			$('.polandCred').hide();
		} else {
			$('.noCred').hide();
			$('.vilniusCred').hide();
			$('.polandCred').show();
		}
	});
	$("input[name='payment_type']").change(function() {
		selectedId = $("input[name='payment_type']:checked").attr('id');
		if(selectedId == "payment_type1"){
			$('#noPayment').hide();
			$('#bankCred').show();
			$('#creditcardCred').hide();
			$('#avcardCred').hide();
		}
		if(selectedId == "payment_type2"){
			$('#noPayment').hide();
			$('#bankCred').hide();
			$('#creditcardCred').show();
			$('#avcardCred').hide();
		}
		if(selectedId == "payment_type3"){
			$('#noPayment').hide();
			$('#bankCred').hide();
			$('#creditcardCred').hide();
			$('#avcardCred').show();
		}
	});
	$("input[name='paxBoard']").change(function() {
		selectedId = $("input[name='paxBoard']:checked").attr('id');
		if(selectedId == "paxBoard1"){
			$('.paxTable').show();
		} else {
			$('.paxTable').hide();
		}
	});
	$("input[name='fueling']").change(function() {
		selectedId = $("input[name='fueling']:checked").attr('id');
		if(selectedId == "fueling1"){
			$('.servicesFueling').show();
		} else {
			$('.servicesFueling').hide();
		}
	});
	$("input[name='paxCatering']").change(function() {
		selectedId = $("input[name='paxCatering']:checked").attr('id');
		if(selectedId == "paxCatering1"){
			$('.servicesPaxCatering').show();
		} else {
			$('.servicesPaxCatering').hide();
		}
	});
	$("input[name='crewCatering']").change(function() {
		selectedId = $("input[name='crewCatering']:checked").attr('id');
		if(selectedId == "crewCatering1"){
			$('.servicesCrewCatering').show();
		} else {
			$('.servicesCrewCatering').hide();
		}
	});
	$("input[name='cmTransportation']").change(function() {
		selectedId = $("input[name='cmTransportation']:checked").attr('id');
		if(selectedId == "cmTransportation1"){
			$('.servicesCmTransportation').show();
		} else {
			$('.servicesCmTransportation').hide();
		}
	});
	$("input[name='chAccommodation']").change(function() {
		selectedId = $("input[name='chAccommodation']:checked").attr('id');
		if(selectedId == "chAccommodation1"){
			$('.servicesChAccommodation').show();
		} else {
			$('.servicesChAccommodation').hide();
		}
	});
	$("input[name='phAccommodation']").change(function() {
		selectedId = $("input[name='phAccommodation']:checked").attr('id');
		if(selectedId == "phAccommodation1"){
			$('.servicesPhAccommodation').show();
		} else {
			$('.servicesPhAccommodation').hide();
		}
	});
	$("input[name='crewTransfer']").change(function() {
		selectedId = $("input[name='crewTransfer']:checked").attr('id');
		if(selectedId == "crewTransfer1"){
			$('.servicesCrewTransfer').show();
		} else {
			$('.servicesCrewTransfer').hide();
		}
	});
	$("input[name='clPassenger']").change(function() {
		selectedId = $("input[name='clPassenger']:checked").attr('id');
		if(selectedId == "clPassenger1"){
			$('.servicesClPassenger').show();
		} else {
			$('.servicesClPassenger').hide();
		}
	});
	$("input[name='destination']").change(function() {
		selectedId = $("input[name='destination']:checked").attr('id');
		if(selectedId == "destination1"){
			$('.vnoNote').show();
		} else {
			$('.vnoNote').hide();
		}
	});
	$("input[name='paxHandling']").change(function() {
		selectedId = $("input[name='paxHandling']:checked").attr('id');
		if(selectedId == "paxHandling2"){
			$('.servicesPaxHandling').show();
		} else {
			$('.servicesPaxHandling').hide();
		}
	});
	
	selectedId = $("input[name='destination']:checked").attr('id');
	if(selectedId == "destination1"){
		$('.noCred').hide();
		$('.vilniusCred').show();
		$('.polandCred').hide();
	}
	else{
		$('.noCred').hide();
		$('.vilniusCred').hide();
		$('.polandCred').show();
	}
	selectedId = $("input[name='payment_type']:checked").attr('id');
	if(selectedId == "payment_type1"){
		$('#noPayment').hide();
		$('#bankCred').show();
		$('#creditcardCred').hide();
		$('#avcardCred').hide();
	}
	if(selectedId == "payment_type2"){
		$('#noPayment').hide();
		$('#bankCred').hide();
		$('#creditcardCred').show();
		$('#avcardCred').hide();
	}
	if(selectedId == "payment_type3"){
		$('#noPayment').hide();
		$('#bankCred').hide();
		$('#creditcardCred').hide();
		$('#avcardCred').show();
	}
	selectedId = $("input[name='paxBoard']:checked").attr('id');
	if(selectedId == "paxBoard1"){
		$('.paxTable').show();
	} else {
		$('.paxTable').hide();
	}
	selectedId = $("input[name='fueling']:checked").attr('id');
	if(selectedId == "fueling1"){
		$('.servicesFueling').show();
	} else {
		$('.servicesFueling').hide();
	}
	selectedId = $("input[name='paxCatering']:checked").attr('id');
	if(selectedId == "paxCatering1"){
		$('.servicesPaxCatering').show();
	} else {
		$('.servicesPaxCatering').hide();
	}
	selectedId = $("input[name='crewCatering']:checked").attr('id');
	if(selectedId == "crewCatering1"){
		$('.servicesCrewCatering').show();
	} else {
		$('.servicesCrewCatering').hide();
	}
	selectedId = $("input[name='cmTransportation']:checked").attr('id');
	if(selectedId == "cmTransportation1"){
		$('.servicesCmTransportation').show();
	} else {
		$('.servicesCmTransportation').hide();
	}
	selectedId = $("input[name='chAccommodation']:checked").attr('id');
	if(selectedId == "chAccommodation1"){
		$('.servicesChAccommodation').show();
	} else {
		$('.servicesChAccommodation').hide();
	}
	selectedId = $("input[name='phAccommodation']:checked").attr('id');
	if(selectedId == "phAccommodation1"){
		$('.servicesPhAccommodation').show();
	} else {
		$('.servicesPhAccommodation').hide();
	}
	selectedId = $("input[name='crewTransfer']:checked").attr('id');
	if(selectedId == "crewTransfer1"){
		$('.servicesCrewTransfer').show();
	} else {
		$('.servicesCrewTransfer').hide();
	}
	selectedId = $("input[name='clPassenger']:checked").attr('id');
	if(selectedId == "clPassenger1"){
		$('.servicesClPassenger').show();
	} else {
		$('.servicesClPassenger').hide();
	}
	selectedId = $("input[name='destination']:checked").attr('id');
	if(selectedId == "destination1"){
		$('.vnoNote').show();
	} else {
		$('.vnoNote').hide();
	}
	selectedId = $("input[name='paxHandling']:checked").attr('id');
	if(selectedId == "paxHandling2"){
		$('.servicesPaxHandling').show();
	} else {
		$('.servicesPaxHandling').hide();
	}
	
	/*$('#destination1').change(function() {
	  if($(this).is(':checked')){
	  	  $('#vilniusCred').show();
		  $('#polandCred').hide();
	  }else{
		  $('#vilniusCred').hide();
		  $('#polandCred').show();
	  }
	});*/
	
});

function toggleAirport(allPorts, item, marker) {
	$('span.markerTitle1').removeClass('active');
	$('span.markerTitle1').hide();
	$('span.markerTitle1', marker).addClass('active');
	$('span.markerTitle1', marker).show();
	$(allPorts).hide();
	$(item).show();
}

function bindHint(selector, hint){
	elem = $(selector);

	elem.focus( function(){
		if($(this).val() == hint){
			$(this).val("");
		}
	});
	elem.blur( function(){
		if($(this).val() == ""){
			$(this).val(hint);
		}
	});
	elem.blur();
}
