﻿/************************************************************************************************************
 * On Focus
 ***********************************************************************************************************/

$("#search").focus(function() {
    if ($(this).val() == "Search...")
        $(this).val("");
});

/************************************************************************************************************
 * On Blur
 ***********************************************************************************************************/

$("#search").blur(function() {
    if ($(this).val() == "")
        $(this).val("Search...");
});

/************************************************************************************************************
 * On Mouse Over
 ***********************************************************************************************************/
 
$("#menu li").mouseover(function() {
    $(this).addClass("active");
    $(this).children(".dropdown").show();
});

$("#menu li .content li").mouseover(function() {
    $(this).addClass("active");
    if ($(this).children(".sub-content").length > 0)
        $(this).children(".sub-content").show();
});

/************************************************************************************************************
 * On Mouse Leave
 ***********************************************************************************************************/

$("#menu li").mouseleave(function() {
    $(this).removeClass("active");
    $(this).children(".dropdown").hide();
});

$("#menu li .content li").mouseleave(function() {
    $(this).removeClass("active");
    if ($(this).children(".sub-content").length > 0)
        $(this).children(".sub-content").hide();
});

/************************************************************************************************************
 * On Key Press
 ***********************************************************************************************************/

$("#search").keypress(function(e) {  
    if (e.which == 13)
        doSearch();
});

/************************************************************************************************************
 * On Click
 ***********************************************************************************************************/

$("#search-image").click(function(e) {
    doSearch();
});

function doSearch()
{
    window.location = appPath + "search.aspx?q=" + ToUrlFormat($("#search").val());
}