﻿$(document).ready(function () {
    /* sitemap even height */
    $('.sitemap ul ul li').addClass('child');
    var height = 0;
    var count = 0;
    $(".sitemap ul li:not('[class*=child]')").each(function () {
        if (count % 5 == 0)
            $(this).addClass('first');
        count++;

        if (parseInt($(this).height()) > height)
            height = parseInt($(this).height());
    });

    $(".sitemap ul li:not('[class*=child]')").css('height', height + 'px');

    /* event tab */
    $('#events-landing .tabs li a').click(function () {
        $('#events-landing .tabs li').removeClass('selected');
        $(this).parent().addClass('selected');

        var id = $(this).parent().attr('id');
        $('.tabs-content-events').hide();
        id = id.replace('events-category', 'events-landing');
        $('#' + id).show();

        return false;
    });

    /*companies*/
    $('table#companies tr').not('.details').click(function () {
        var id = $(this).attr('rel');
        if ($(this).hasClass('active')) {
            $(this).removeClass('active');
            $('#' + id).hide();
        }
        else {
            $('table#companies tr.details').hide();
            $('table#companies tr').not('.details').show().removeClass('active');

            $(this).addClass('active');
            $('#' + id).show();
        }
        return false;
    });

    /* application form */
    $('#application').submit(function () {
        if ($('#terms:checked').length > 0) {
            return true;
        }
        alert('Please agree to our terms and conditions');
        return false;
    });

});
