﻿
$(document).ready(function(){

    $("#div_weddingEnquiry dd > *[readonly!='readonly']").focus(function(){
        $(this).parent('dd').addClass('dd_active');
    });
    
    $('#div_weddingEnquiry dd > *').blur(function(){
        $(this).parent('dd').removeClass('dd_active');
    });
    
    $("#div_weddingEnquiry input[readonly]").each(function(){
        $(this).parent('dd').addClass('dd_disabled');
    });
    
    // Show disabled buttons clearly
    $('.button_submit[disabled=disabled]').addClass('disabled');
    
    // Feedback Page
    $('.a_button[disabled=disabled]').addClass('disabled');
    
    // Hide errors all nice
    $('#h4_info span').click(function(){ $(this).parent().fadeOut(); });
    
    // Sort out feedback form scale labels
    $('.inp_scl').each(function(){
        // First one needs shifting to the other side
        $('input:first', this).before("<label for=\"q" + $(this).prev('h5').children('em').text().substr(1) + "_0\" class=\"label_scl\">" + $('label:first', this).html() + "</label>");
        // Make sure the last one doesn't get removed
        $('label:last', this).addClass("label_scl");
        // Clear the rest
         $('label:not(.label_scl)', this).remove();
    });
    
    // Project Page - Hide the extra panels to start
    $('#divProjectContentWide > div:not(:first)').hide();
    
    // Show correct panel if hash tag present
    if (window.location.hash != "") {
        $('#divProjectContentWide > div').hide();
        switch(window.location.hash) {
            case "#free_resources":
                $('#content-1').show();
                break;
            case "#paper_resources":
                $('#content-2').show();
                break;
            default:
                $('#divProjectContentWide > div:first').show();
        }
    }
    
    // Deal with clicks
    $('a.projectChangeContent').click(function(){
        $('#divProjectContentWide > div').hide();
        switch($(this).attr("data-id")) {
            case "content-1":
                $('#content-1').show();
                break;
            case "content-2":
                $('#content-2').show();
                break;
            default:
                $('#divProjectContentWide > div:first').show();
        }
    });
    
});
