﻿$(function () {
    rentcycle.site.init();
});

if (!rentcycle) var rentcycle = {};
if (!rentcycle.site) rentcycle.site = {};

rentcycle.site.init = function () {
    // setup global defaults
    rentcycle.site.setGlobalDefaults();
}

rentcycle.site.setGlobalDefaults = function () {
    // nav
    if ((navSection != null) && (navSection.length > 0)) {
        // try to find an element in the nav
        var selectedNavItem = $("#menu li." + navSection).addClass("selected");
    }

    // layout height
    if (
		$('.left-site-navigation').length > 0 &&
		$('.main-content').length > 0
	) {
        //we get our sizes:
        var left_col_height = $('.left-site-navigation').outerHeight();
        var content_height = $('.main-content').outerHeight();

        //we then verify if the main is bigger than the search:
        if (content_height > left_col_height) {
            //we adjust the search height:
            $('.left-site-navigation').css('height', content_height);
        }
    }

    $('#try-1').click(function () {
        $('#rentals').lightbox_me({
            centered: false,
            closeSelector: ".close",
            onLoad: function () {
                $('#sign_up').find('input:first').focus()
            }
        });
        return false;
    });



    // default datepicker
    $("input.datepicker-default").each(function () {
        $(this).datepicker();
    });

    // validate forms
    $("form").each(function () {
        if ($(this).attr('data-default-validate') != 'false') {
            $(this).validate();
        }
    });

    // jquery ui tabs
    $(".jquery-ui-tabs").each(function () {
        $(this).tabs();
    });

    // button with icons in data-icon attribute
    $('button.js-icon').each(function () {
        addButtonIcon($(this));
    });


}
