﻿
$(document).ready(function() {


    // MENU RELATED

    $('#menu ul.tabs li ul').addClass('nestedlist');
    $('#menu ul.tabs ul.dropdown ul').removeClass('nestedlist');
    $('#navigation').css('overflow', 'visible');
    $('.nestedlist').parent().addClass('parent_li');

    // SNIPPET RELATED

    var image_width = $('.image_and_caption').width();
    var image_width_plus_padding = image_width + 30;
    var text_width = 945 - image_width_plus_padding;
    $('.one_column .main .image_with_text .text').css('width', text_width);
    $('.slider .image_with_text .text').css('width', text_width);

    $('#body.two_column .right .content img').parent().addClass('image_align_center');

    // If in Edit Mode
    if ($('.cms_toolbar').hasClass('active_cms_toolbar')) {

        // Disabling a Hrefs in a snippet in edit mode
        $(".edit .content a").click(function(event) {
            event.preventDefault();
        });

        $(".signed_in_show_this").css('display', 'inline');
        $(".signed_in_hide_this").css('display', 'none');

    } else {
        //alert ("Toolbar Not Active!");
    }

    // IE 7 Z-INDEX BUG
    //$(function() {
    //if ($.browser.msie) {
    // $('div').each(function(i) {
    //  if ($(this).css('position') != 'absolute') $(this).css('zIndex', 1000 - (i * 10));
    //});
    // }
    // })

    //SNIPPETS

    // TESTIMONIAL SNIPPET

    $(".testimonial h2:empty").css('display', 'none');

    // CODE SNIPPET EXPAND / HIDE

    $('#code_snippet span.expand').text('Expand');
    $('#code_snippet span.hide').text('Hide');

    // CODE SNIPPET EXPAND
    $('#code_snippet span.expand').click(function() {
        $('.code_box').slideDown('slow', function() {
            $('#code_snippet span.expand').slideUp('fast', function() {
                $('#code_snippet span.hide').slideDown('fast');
            });
        });

    });

    // CODE SNIPPET HIDE
    $('#code_snippet span.hide').click(function() {
        $('.code_box').slideUp('slow', function() {
            $('#code_snippet span.hide').slideUp('fast', function() {
                $('#code_snippet span.expand').slideDown('fast');
            });
        });

    });

    //  search text
    $('.search_text').each(function() {

        //  remove inactive when focused
        $(this).focus(function() {
            $(this).removeClass('search_text_inactive');
            if ($(this).val() == 'Search') {
                $(this).val('');
            }
        });

        //  add inactive when blurred
        $(this).blur(function() {
            if ($(this).val() == '') {
                $(this).addClass('search_text_inactive');
                $(this).val('Search');
            }
        });

    });

});

