$(document).ready(function() {
	$("#map area").hover(function () {
		showMap(this);
	}, function () {
		hideMap(this);
	});
	
	$("#map_list a").hover(function () {
		showMap(this);
	}, function () {
		hideMap(this);
	});
	
	$("div.dot").hover( function () {
		$(this).find("div").css("zIndex", 100);
		$(this).find("div").show();
	}, function () {
		$(this).find("div").hide();
	});
	
	$(".fkalender").datepicker({dateFormat: 'dd-mm-yy',numberOfMonths: 1,showButtonPanel: true,changeMonth: true,changeYear: true});
	
	
	$(".limit_chars").keyup(function(){
		myName = $(this).attr("name");
		count = $(this).val().length;
		limit = $(this).attr("rel");
		if(count > limit) {
			$(this).addClass("limit");
			showError();
			disableSubmit();
		} else {
			$(this).removeClass("limit");
			hideError();
			enableSubmit();
		}
	});
	$(".limit_words").keyup(function(){
		myName = $(this).attr("name");
		count = $(this).val().replace(/^\s+|\s+$/g,'').replace(/\s+/g,' ').split(" ").length;
		limit = $(this).attr("rel");
		if(count > limit) {
			$(this).addClass("limit");
			showError();
			disableSubmit();
		} else {
			$(this).removeClass("limit");
			hideError();
			enableSubmit();
		}
	});
	
	$('.banners').innerfade({
		  speed: 'slow'
		, timeout: 6000
	});
});

function showError(myName){
	$(".limit_message").show();
}
function hideError(){
	$(".limit_message").hide();
}

function enableSubmit() {
	$("#btnSubmit").attr("disabled", "");
}
function disableSubmit() {
	$("#btnSubmit").attr("disabled", "disabled");
}

function showMap(who) {
	m = $(who).attr("rel");
	$("#" + m).show();
	$(".pop_up_continent div").hide();
	$(".pop_up_continent").show();
	$("#pop" + m).show();
	
}
function hideMap(who) {
	m = $(who).attr("rel");
	$("#" + m).hide();
	$(".pop_up_continent").hide();
}
