﻿$(document).ready(function() {

    $("#BtnSearchItems").click(function() {
        setTimeout("SendSearch()", 500);
    });
    $(".SearchFreeText").focus(function() {
        if ($(this).val() == "חיפוש מוצרים") $(this).val("");
    });
    $(".SearchFreeText").blur(function() {
        if ($(this).val() == "") $(this).val("חיפוש מוצרים");
    });

    $("#catalog2").fancybox({ 'overlayShow': true });
    $("#acontact").fancybox({ 'overlayShow': true });
    $("#acontact").click(function() {
    });
    $("#alogin").fancybox({ 'overlayShow': true });

    //    $("#aCatalogs").hover(
    //    function() { $(".catalocLinks").show(); },
    //    function() { $(".catalocLinks").hide(); }
    //    )
    //    $(".catalocLinks, .catalocLink a").hover(
    //    function() { $(".catalocLinks").show(); },
    //    function() { $(".catalocLinks").show(); }
    //    )
    $("#nav-one").hover(
				function() {
				    $("ul", this).slideDown();
				    $("ul li", this).hover(function() { $(".catalocLinks").show(); });
				},
				function() { $("ul", this).slideUp(); }
			);
    if (document.all) {
        $("#nav-one").hoverClass("sfHover");
    }

    $('.SearchFreeText').keypress(function(e) {
        if (parseInt(e.which) == 13) {
            SendSearch();
            return false;
        }
    });
});


$.fn.hoverClass = function(c) {
    return this.each(function() {
        $(this).hover(
					function() { $(this).addClass(c); },
					function() { $(this).removeClass(c); }
				);
    });
};

function SendSearch() {
    var FreeText = $(".SearchFreeText").val() != "חיפוש מוצרים" ? $(".SearchFreeText").val() : "";
    window.location = "searchResults.aspx?Key=" + FreeText;
}
function IsNumeric(input) { var RE = /^-{0,1}\d*\.{0,1}\d+$/; return (RE.test(input)); }

function GoToCategories(id) {
    window.location = "ShowProducts.aspx?ParentID=" + id + "&CategoryID=" + id;
}

//var obj = $("#divID"); var halfsc = $(window).height() / 2; var halfh = $(obj).height() / 2; var halfscrn = screen.width / 2; var halfobj = $(obj).width() / 2; var goRight = halfscrn - halfobj; var goBottom = halfsc - halfh; $(obj).css({ marginLeft: goRight }).css({ marginTop: goBottom });

/*
* DEFAULT OPTIONS
*
options: {
template:"yourMenuVoiceTemplate",--> the url that returns the menu voices via ajax. the data passed in the request is the "menu" attribute value as "menuId"
additionalData:"",								--> if you need additional data to pass to the ajax call
menuSelector:".menuContainer",		--> the css class for the menu container
menuWidth:150,										--> min menu width
openOnRight:false,								--> if the menu has to open on the right insted of bottom
iconPath:"ico/",									--> the path for the icons on the left of the menu voice
hasImages:true,									--> if the menuvoices have an icon (a space on the left is added for the icon)
fadeInTime:100,									--> time in milliseconds to fade in the menu once you roll over the root voice
fadeOutTime:200,									--> time in milliseconds to fade out the menu once you close the menu
menuTop:0,												--> top space from the menu voice caller
menuLeft:0,											--> left space from the menu voice caller
submenuTop:0,										--> top space from the submenu voice caller
submenuLeft:4,										--> left space from the submenu voice caller
opacity:1,												--> opacity of the menu
shadow:false,										--> if the menu has a shadow
shadowColor:"black",							--> the color of the shadow
shadowOpacity:.2,								--> the opacity of the shadow
openOnClick:true,								--> if the menu has to be opened by a click event (otherwise is opened by a hover event)
closeOnMouseOut:false,						--> if the menu has to be cloesed on mouse out
closeAfter:500,									--> time in millisecond to whait befor closing menu once you mouse out
minZindex:"auto", 								--> if set to "auto" the zIndex is automatically evaluate, otherwise it start from your settings ("auto" or int)
hoverInted:0, 										--> if you use jquery.hoverinted.js set this to time in milliseconds to delay the hover event (0= false)
onContextualMenu:function(o,e){} --> a function invoked once you call a contextual menu; it pass o (the menu you clicked on) and e (the event)
},
*/

$(function() {
    

    $(".vertMenu").buildMenu(
    {
        //template: "menuVoices.html",
        menuWidth: 133,
        openOnRight: true,
        menuSelector: ".menuContainer",
        iconPath: "ico/",
        hasImages: false,
        fadeInTime: 200,
        fadeOutTime: 200,
        adjustLeft: 0,
        adjustTop: 0,
        opacity: .95,
        openOnClick: false,
        minZindex: 200,
        shadow: false,
        hoverIntent: 130,
        submenuHoverIntent: 130,
        closeOnMouseOut: true
    });
});

function recallcMenu(el) {
    if (!el) el = $.mbMenu.lastContextMenuEl;
    var cmenu = +$(el).attr("cmenu");
    $(cmenu).remove();
}



function showMessage(msg) {
    var msgBox = $("<div>").addClass("msgBox");
    $("body").append(msgBox);
    msgBox.append(msg);
    setTimeout(function() { msgBox.fadeOut(500, function() { msgBox.remove(); }) }, 3000)
}
