var Custom = {

	InitMenu: function() {
		$("#MenuSide").find("LI").each(function() {
			this.onclick = function() {
				var oUL = $(this).find(".open-menu:first");
				if (oUL.find("LI").length > 0 && ($(this).children("A:first").get(0).href == ''))
				{
					$(this).children("A:first").get(0).href = "#";
					
				var sDisplay = oUL.css("display");
				if (sDisplay == "block") {
					var oEl = window.addEventListener ? arguments[0].target : event.srcElement;
					if ($(oEl).parents(".open-menu").length == 0)
						oUL.slideUp();
				} else {
					var shref = $(this).children("A:first").get(0).href.replace(location.href,"").replace(location.href.replace(/\#/gi,""),"");
					var bResult = !((shref == "" || shref == "#") && !$(document.body).hasClass("Keam_ShowMarkers") && oUL.find("LI").length==0);
					if (bResult)
						oUL.slideDown();
				}
				}
			}
		}).find("LI.selected").each(function() {
			$(this).parent().css("display","block");
		});
	},

	InitCubes: function() {
		$("#Qubes").find(".octava").each(function(iIndex) {
			$(this).addClass("c"+(iIndex+1));
			if ($(this).attr("data-media") == "")
			{
				$(this).find("P").css("color","#708db9");
				$(this).find("P").find("A").css("color","#708db9");
			}
		});
	},

	SendContactForm: function() {

		var bErrors = false;
		$("#tblContact").find("INPUT").each(function() {
			if (this.value.replace(/\s/gi,"") == "")
			{
				if ($(document.body).hasClass("direction-rtl"))
				{
					alert("ישנם שדות חובה שלא מילאת");
				} else {
					alert("Please fill all required fields");
				}

				bErrors = true;
				return false;
				
			}
		});

		if (!bErrors)
		{
            $.ajax({
                type: "POST",
                url: "getXml.aspx",
                dataType: "xml",
                data: "obj=MailSender&sFunc=SendContactForm&" + $("#tblContact").serialize(),
                success: function(xml) {

					if ($(document.body).hasClass("direction-rtl"))
					{
						alert("הטופס נשלח בהצלחה, תודה על פנייתך");
					} else {
						alert("Form sent successfully");
					}

					location.href = location.href;
                }
            });

		}

	}

}


