﻿$j(function () {

    //$j('li.mainMenu').hover(
    //function () { $j(this).addClass('hover') },
    //function () { $j(this).removeClass('hover') });

   

    $j("li.mainMenu").hoverIntent({
        over: function () { $j(this).addClass('hover') }, // function = onMouseOver callback (REQUIRED)    
        timeout: 250, // number = milliseconds delay before onMouseOut    
        out: function () { $j(this).removeClass('hover') } // function = onMouseOut callback (REQUIRED)    
    });
    
    $j('#SearchText').hint();
   
})





/* INPUT FIELD HINT TEXT FROM TITLE */
/* Called from document ready above */
$j.fn.hint = function () {

    return this.each(function () {
        // get jQuery version of 'this'
        var t = $j(this);
        // get it once since it won't change
        var title = t.attr('title');

        // only apply logic if the element has the attribute
        if (title) {
            // on blur, set value to title attr if text is blank
            t.blur(function () {
                if (t.val() == '' || t.val() == title) {
                    t.val(title);
                    t.addClass('blur');
                }
            });
            // on focus, set value to blank if current value 
            // matches title attr
            t.focus(function () {
                if (t.val() == title) {
                    t.val('');
                    t.removeClass('blur');
                }
            });

            // clear the pre-defined text when form is submitted
            t.parents('form:first').submit(function () {
                if (t.val() == title) {
                    t.val('');
                    t.removeClass('blur');
                }
            });

            // now change all inputs to title
            t.blur();
        }
    });
}


/* CLEAR HINT TEXT - USUALLY CALLED BEFORE SUBMIT */
$j.fn.clearHintText = function () {
    return this.each(function () {
        // get jQuery version of 'this'
        var t = $j(this);

        t.find("input, textarea").each(function () {
            $this = $j(this);
            if (($this.val() == $this.attr('title')) && $this.hasClass('blur')) $this.val('');
        });
    });
}

function clearHintText(container) {
    $j("input, textarea", container).each(function () {
        $this = $j(this);
        if (($this.val() == $this.attr('title')) && $this.hasClass('blur')) $this.val('');
    });
}



