/*$(document).ready(function(){

	$('input[type=submit]').click(function(){

		if (!validate()) return false;
		
	});
		
	
	function validate() {

		var name = $('#name').val();
		var email = $('#email').val();
		var message = $('#message').val();
		var regexp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,6})$/;

		if (name == '') {
			showMsg('Please enter your name', 'name');
			return false;
		} else if (email == '') {
			showMsg('Please enter a valid email address', 'email');
			return false;
		} else if (regexp.test(email) === false) {
			showMsg('Email address you have entered is not valid', 'email');
			return false;
		} else if (message == '') {
			showMsg('Please enter your message', 'message');
			return false;
		} else {
			return true;
		}
		
	}

	function showMsg(msg,field) {

		$('.error').remove();
		$('#' + field).before('<span class="error">' + msg + '</span>');

	}

});*/

$(document).ready(function() {

	$('#menu ul.second').hide();

	$("#menu li").hover(function(){
		$("ul.second", this).slideDown(200);
	}, function() {
		$("ul.second", this).hide();
	});

	$('#menu li.third > ul').hide();

	$('#menu ul.second li').hover(function(){
		$('ul', this).fadeIn(150);
	}, function() {
		$('ul', this).hide();
	}
);

    $("#sidebar .select-destination").css({
        "width": "195px"
    });

    $("#choose-location-submit").addClass('hidden');

    $("#sidebar .select-destination").change(function() {
		$("#select-destination").submit();
    });

    $("#accordion .shide").addClass('hidden');

    $("#accordion ul li a").bind('click', function() {
        $(this).next("ul").slideToggle(100);
    });

    var g = 0;
    $("#accordion .show-all").text("[+]");
    $("#accordion .show-all").bind('click', function() {
        (g === 0) ? showAccordion() : hideAccordion();
        
    });

    function showAccordion() {
        $("#accordion ul li ul:hidden").slideToggle(100);
        $("#accordion .show-all").text("[-]");
        $("#accordion .btm").text("Hide all subcategories [-]").addClass('visible');
        g = 1;
    }

    function hideAccordion() {
        $("#accordion ul li ul:visible").slideUp(100);
        $("#accordion .show-all").text("[+]");
        $("#accordion .btm").addClass('hidden');
        g = 0;
    }

    $("ul#share li.print").bind('click', function() {
        window.print();
        return false;
    });
	
    var i = 0;

    function showMoreEvents() {
        $("#short-events").slideUp(300);
        $("#regular-events .all-events").slideDown(500);
        $("#regular-events .more").text("Less");
        i = 1;
    }

    function hideMoreEvents() {
        var a = $("#regular-events .more");
        var b = $(a).offset().top;
        $("html:not(:animated),body:not(:animated)").animate({
            scrollTop: 0
        },
        600).delay(200);
        $("#regular-events .all-events").delay(400).fadeOut(800);
        $("#regular-events .more").text("More");
        $("#short-events").slideDown(100);
        i = 0;
    }

    $("#regular-events .more").bind('click', function() {
        (i === 0) ? showMoreEvents() : hideMoreEvents();
    });

    $("#regular-events li a").bind('click', function() {
		$('#short-events').hide();
        $("#regular-events .all-events").show();
        $("#regular-events .more").text("less");
        i = 1;
    });
   
    function showError(a) {
        return $("#contact .error").text(a).fadeIn(200).delay(2000).fadeOut(180);
    }

    function validateEmailForm() {
        var a = $("#contact_name .txt").val();
        var b = $("#contact_email .txt").val();
        var c = $("#contact_message .txtarea").val();
        var d = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,6})$/;
        if ($.trim(a) === "") {
            showError("Please enter your name");
            return false
        } else if ($.trim(b) === "") {
            showError("Please enter your email address");
            return false;
        } else if (d.test(b) === false) {
            showError("Please enter a valid email address");
            return false;
        } else if ($.trim(c) === "") {
            showError("Please enter your message");
            return false;
        } else {
            $("#emailForm").submit();
            return true;
        }
    }
    $("#contact .submit").click(function() {
        validateEmailForm();
        (validateEmailForm === false) ?  $('input[type=submit]', this).attr('disabled', 'disabled') : $('input[type=submit]').css('disabled', 'enabled');
        return false;
    });

	$('#locations-list p, #featured p').addClass('hidden');
	$('#locations-list div, #featured div').bind('mouseenter mouseleave', function(){
		$(this).find('p').slideToggle(80);
	});

	$('div.month, #overview, div.place, #getting-around div.type').bind('mouseenter', function(){
		$(this).append('<button class="scrollTop">top &uarr;</button>');
	});

    $('.scrollTop').live('click', function() {
        $("html:not(:animated),body:not(:animated)").animate({
            scrollTop: 0
        },
        500);
    });

	$('div.month, #overview, div.place, #getting-around div.type').live('mouseleave', function(){
		$(this).find('.scrollTop').remove();
	});

});

function initialize(a, b, c) {
    var d = new google.maps.LatLng(a, b);
    var e = {
        zoom: c,
        center: d,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var f = new google.maps.Map(document.getElementById("map_canvas"), e);
}
function initializeSmallMap(a, b, c) {
    var d = new google.maps.LatLng(a, b);
    var e = {
        zoom: c,
        center: d,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var f = new google.maps.Map(document.getElementById("profile-map"), e);
}
