$(function(){
    if ($('.test').length){
        $(".test").hrzAccordion({
            eventTrigger    : "mouseover",
            openOnLoad      : 1,
            cycle           : true
        });
    }

    $('#nav-g > li').click(function(e) {
        e.preventDefault();
        var index = $('#nav-g > li').index(this) + 1;
        $('#description > div').addClass('hide');
        $('#description > div:nth-child(' + index + ')').removeClass('hide');
    });
	
    if ($('#ContactForm1').length){
        $("#ContactForm1").validate();
    }
	
    $("#QuickContactForm").validate();
		
    $("#toggleContactButton").click(function () {
        $("#toggleContactForm").toggle("fast");
    });

    if (window.location.hash.length > 0 && $(window.location.hash).length > 0){
        $('#description > div').addClass('hide');
        $(window.location.hash).removeClass('hide');
    }
	
    $('#scrollable-ad').cycle({
        fx: 'scrollLeft'
    });
	$('#main-img').cycle({
        fx: 'fade'
    });


    // thumbnail scrollable
    $(".thumbnails").each(function(i, v) {
        $(this).scrollable({
            clickable: false
        }).find(".overlay").each(function(index) {
            // thumbnail images trigger the overlay
            $(this).overlay({
                effect: 'apple',
                target: $(this).parents('.thumbnails').siblings('.box'),
                mask: {
                    maskId: 'mask'
                },
                // when box is opened, scroll to correct position (in 0 seconds)
                onLoad: function(e) {
                    this.getOverlay().children('.images').data("scrollable").seekTo(index, 0);
                }
            });
        });
    });
	
	    // thumbnail scrollable
    $(".thumbnails-home").each(function(i, v) {
        $(this).scrollable({
            clickable: false,
			circular: true
        })
		.find(".overlay").each(function(index) {
        });
    });

    // scrollable inside the box.
    $(".images").scrollable({
		mousewheel: false
	});
});

