
$(document).ready(function() {
	$('#revealDivZone').hide();
	$('#revealDivField').hide();
	$("#chooseZone").click(function () {
		slideElement('revealDivZone'); 
	});
	
	$("#chooseField").click(function () {
		slideElement('revealDivField'); 
	});
	
            // Navigation
        	$("ul#nav li.parent_li").hover(function() {
        		$(this).find("ul.subnav").slideDown('fast').show(); 
        		$(this).addClass("subhover"); 		 
                $(this).hover(function() {  
                }, function(){  
                    $(this).find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
        			$(this).removeClass("subhover"); //On hover out, remove class "subhover"  
                 });  
           
                 //Following events are applied to the trigger (Hover events for the trigger)  
                 }).hover(function() {  
                     $(this).addClass("subhover"); //On hover over, add class "subhover"  
                 }, function(){  //On Hover Out  
                     $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
             });  
        	 
        	 $("ul#nav li.parent_li ul.subnav li.parent_li").hover(function() {
        		$(this).find("ul.subnav_2").slideDown('fast').show(); 
        		$(this).addClass("subhover"); 		 
                $(this).hover(function() {  
                }, function(){  
                    $(this).find("ul.subnav_2").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
        			$(this).removeClass("subhover"); //On hover out, remove class "subhover"  
                 });  
           
                 //Following events are applied to the trigger (Hover events for the trigger)  
                 }).hover(function() {  
                     $(this).addClass("subhover"); //On hover over, add class "subhover"  
                 }, function(){  //On Hover Out  
                     $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
             }); 
            
            
            
            
            
});

function slideElement(ElementId) {
    if (document.getElementById(ElementId).style.display == "block") {
        $('#' + ElementId).slideUp(600);
    }
    else {
        $('#' + ElementId).slideDown(600);
    }
}

		//SEARCH BOX FUNCTIONS
			//====================
			function updateSubCategoryDropDownForSearch() {
				//Clean the select options in the current sub category Drop down
				$('#subcategory dt a').html('');
				$('#subcategory dd ul').html('');
				//Add the standard "By Sub Category" element
				$('#subcategory dt a').append('<span id="0">תת קטגוריה</span>');
				//Iterate on the mainCategoriesCollection Array
				var i;
				for (i = 0; i < mainCategoriesCollection.length; i++) {
				//If the fatherId suits the selected id,
				if (mainCategoriesCollection[i].FatherId == $('#category dt a .classvalue').html()) {
					//Add the element to the sub category list
					var syntax = "<li><a href='#'>"+mainCategoriesCollection[i].Name+"<span class='classvalue'>"+mainCategoriesCollection[i].Id+"</span></a></li>";
					//var syntax = "<li><a value=" + mainCategoriesCollection[i].Id + "><span>"+ mainCategoriesCollection[i].Name+ "</span>" + "</a></li>";
					$('#subcategory dd ul').append(syntax);
					}
				}
				$("#subcategory dd ul li a").click(function() {
				//alert("Thanks for visiting!");
                var text = $(this).html();
                $("#subcategory dt a span").html(text);
                $("#subcategory dd ul").hide();
                //$("#result").html("Selected value is: " + getSelectedValue("category"));
				$("#result2").html("Selected value is: " + getSelectedValue("subcategory"));
				});
			}
			
			function getSelectedValue(id) {
                return $("#" + id).find("dt a span.classvalue").html();
            }
