﻿////////////////////////////////////////////
// Custom dropdown
////////////////////////////////////////////
$(document).ready(function () {
    $(".customDropdown").customDropDown();
});
////////////////////////////////////////////
// Dialog
////////////////////////////////////////////
$(document).ready(function () {
    var dlg = $(".dialog").dialog({ autoOpen: false, modal: true, width: 900 });
    //This is needed to enable click events on buttons in dialog
    dlg.parent().appendTo($("form:first"));

    $('.openDialog').click(function () {
        $(".dialog").dialog('open');
        return false;
    });

    $('.closeDialog').click(function () {
        $(".dialog").dialog('close');
        return false;
    });
});
////////////////////////////////////////////
// Validation
////////////////////////////////////////////
$(document).ready(function () {
    highlight();

    $('.xForm input:submit').bind('click', highlight);
    $('.xForm input').blur(highlight);
    $('.xForm textarea').blur(highlight);
});

function highlight() {
    //For each errorMessage, find the first previous input field
    $("span.xformvalidator:hidden").each(function () {
        $(this).prevAll("input:first,textarea:first").removeClass("inputError");
    });

    $("span.xformvalidator:visible").each(function () {
        $(this).prevAll("input:first,textarea:first").addClass("inputError");
    });
}
////////////////////////////////////////////
// Revenue/nav control
////////////////////////////////////////////
$(document).ready(function () {
    $(".blogDivider:last").remove();

    $(".nav.click").click(function () {
        $(".revenueTab").hide();
        $(".navTab").show();
    });


    $(".revenue.click").click(function () {
        $(".revenueTab").show();
        $(".navTab").hide();
    });

    $(".navTab").hide();
});
////////////////////////////////////////////
// License agreement
////////////////////////////////////////////
$(document).ready(function () {
    $(".licenseAgree input").click(function () {
        var checked = $(this).is(":checked");
        var button = $(".licenseButton input");
        
        if (checked) {
            button.removeAttr('disabled');
        }
        else {
            button.attr('disabled', 'disabled');
        }
    });
});
////////////////////////////////////////////
// FlexSlider
////////////////////////////////////////////
$(document).ready(function () {
    $('.flexslider').flexslider({ controlsContainer: ".sliderContainer", animation: "slide", randomize: true });
});
