﻿// load script once the page is done loading //-->
$(document).ready(function () {

    //HIDE STORE REQUEST
    //TOGGLE STORE REQUEST
    $(".msg_head").click(function () {
        if ($('.storeRequestBottom').hasClass('open')) {
            $('.storeRequestBottom').find('img').fadeOut();
            $('.storeRequestBottom').removeClass('open');
        } else {
            $('.storeRequestBottom').find('img').fadeIn();
            $('.storeRequestBottom').addClass('open');
        }
        $(".msg_body").slideToggle(600);
    });

    if (!$(".storeRequestBottom").hasClass('open')) {
        $(".storeRequestForm").hover(function () {
            $(".msg_head p strong").css("text-decoration", "underline");
        }, function () {
            $(".msg_head p strong").css("text-decoration", "none");
        });
    }


    //MAIN NAVIGATION ----------------------------
    //CENTER NAV
    $('.subNav').each(function () {
        moveLeft = ($(this).outerWidth() - $(this).parent('li').outerWidth()) / -2
        $(this).css({ left: moveLeft + 'px' });
    });


    //REMOVE COLUMN DIVS IF NOT CONTENT
    if ($.trim($("#leftColumnInner").html()) == "") {
        $("#leftColumnInner").remove();
    }

    if ($.trim($("#rightColumnInner").html()) == "") {
        $("#rightColumnInner").remove();
    }



    //RECIPE COLLAPSE/EXPAND
    $('.sf_listItemBody').show();



    //LOREM FINDER
    //DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME
    $('.content *').each(function () {
        if ($(this).html().substring(0, 5) == "Lorem" || $(this).html().substring(0, 6) == '"Lorem') {
            $(this).addClass("missing").css({ color: '#ff0000' });
        }
    });


});

//INLINE INPUT TEXT FOCUS FUNCTIONS
function focusText(textbox, text) {
    var control = document.getElementById(textbox);
    if (control.value == text)
        control.value = '';
}

function blurText(textbox, text) {
    var control = document.getElementById(textbox);
    if (control.value == '')
        control.value = text;
}

 function validateDefault(source, args) {
    //field and message need to be set via codebehind
    if (document.getElementById(source.field).value == source.message)
        args.IsValid = false;
    else
        args.IsValid = true;
}
