﻿/***** GENERAL FUNCTIONS - START *****/
$(document).ready(function() {
   //set running news
   $("#marquee").marquee({yScroll: "bottom",showSpeed:1500,pauseSpeed:5000,scrollSpeed:15});

    //set click on search botton  
    $('.search_button').click(function() {
        searchContent();
    });
});
//select search controls by class, for press enter - trigger search
$(document).keypress(function(event) {
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if (keycode == '13') {
        if (event.target.className == "selector_search") {
            searchContent();
        }
        return false;
    }
});
function searchContent() {
    var val = $(ssv_txtSearch).val();
    if ($.trim(val) == "")
    {
        alert("! נא הזן ערך לחיפוש");
        $(ssv_txtSearch).focus();
    }
    else
        window.location.href = 'search_results.aspx?val=' + escape(val);
}            
/***** GENERAL FUNCTIONS - END *****/
/***** ACCORDION - START *****/
/*
DOCUMENT: includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 3/26/2009
UPDATED: 3/25/2010
DESCRIPTION: This is the JavaScript required to create the accordion style menu.  Requires jQuery library
NOTE: Because of a bug in jQuery with IE8 we had to add an IE stylesheet hack to get the system to work in all browsers. I hate hacks but had no choice :(.
*/
$(document).ready(function() {
	 
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.accordion_cat').click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.accordion_cat').removeClass('accordion_on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.accordion_sub_wrapper').slideUp('normal');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next().is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('accordion_on');
			  
			//OPEN THE SLIDE
			$(this).next().slideDown('normal');
		 } 
	 });
	/*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	//ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
	$('.accordion_cat').mouseover(function() {
		$(this).addClass('accordion_over');
	//ON MOUSEOUT REMOVE THE OVER CLASS
	}).mouseout(function() {
		$(this).removeClass('accordion_over');										
	});
	/*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	//CLOSES ALL S ON PAGE LOAD
	$('.accordion_sub_wrapper').hide();

});

/*** ACCORDION ADDITION : ***/
 //Hidden variables are created in category page :
       var currentCategoryColor = '#76844F';
         $(document).ready(function() {     
            //Open the accordion menu, by the parent category (if exists)
            if ($('#ctl00_cph1_hdn_cat_parent_id').val()) {
                var CatParentId = 'acrd_' + $('#ctl00_cph1_hdn_cat_parent_id').val();
              
                $('#' + CatParentId).addClass('accordion_on');
                $('#' + CatParentId).next().slideDown('normal');
                //if parent is link :
                $('#' + CatParentId).find('a').css('color', currentCategoryColor);
            }
         });      
            //Painting the current category (if exists)
            if ($('#ctl00_cph1_hdn_cat_id').val()) {
                var CatId = 'acrd_' + $('#ctl00_cph1_hdn_cat_id').val();
                $('#' + CatId).find('a').css('color', currentCategoryColor);
                
                if($('#' + CatId).attr("class") == "accordion_cat")
                {
                  document.getElementById(CatId).className = 'accordion_on';
                }  
            }
/***** ACCORDION - END *****/
/***** MARQUEE - START *****/
/*
 * Marquee jQuery Plug-in
 * Copyright 2009 Giva, Inc. (http://www.givainc.com/labs/)  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 * 	http://www.apache.org/licenses/LICENSE-2.0 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * Date: 2009-05-20
 * Rev:  1.0.01
 */
(function(A){A.marquee={version:"1.0.01"};A.fn.marquee=function(E){var F=typeof arguments[0]=="string"&&arguments[0];var D=F&&Array.prototype.slice.call(arguments,1)||arguments;var C=(this.length==0)?null:A.data(this[0],"marquee");if(C&&F&&this.length){if(F.toLowerCase()=="object"){return C}else{if(C[F]){var B;this.each(function(G){var H=A.data(this,"marquee")[F].apply(C,D);if(G==0&&H){if(!!H.jquery){B=A([]).add(H)}else{B=H;return false}}else{if(!!H&&!!H.jquery){B=B.add(H)}}});return B||this}else{return this}}}else{return this.each(function(){new A.Marquee(this,E)})}};A.Marquee=function(E,Q){Q=A.extend({},A.Marquee.defaults,Q);var O=this,M=A(E),F=M.find("> li"),H=-1,G=false,L=false,N=0;A.data(M[0],"marquee",O);this.pause=function(){G=true;P()};this.resume=function(){G=false;D()};this.update=function(){var R=F.length;F=M.find("> li");if(R<=1){D()}};function K(R){if(F.filter("."+Q.cssShowing).length>0){return false}var T=F.eq(R);if(A.isFunction(Q.beforeshow)){Q.beforeshow.apply(O,[M,T])}var S={top:(Q.yScroll=="top"?"-":"+")+T.outerHeight()+"px",left:0};M.data("marquee.showing",true);T.addClass(Q.cssShowing);T.css(S).animate({top:"0px"},Q.showSpeed,Q.fxEasingShow,function(){if(A.isFunction(Q.show)){Q.show.apply(O,[M,T])}M.data("marquee.showing",false);J(T)})}function J(S,R){if(L==true){return false}R=R||Q.pauseSpeed;if(C(S)){setTimeout(function(){if(L==true){return false}var V=S.outerWidth(),T=V*-1,U=parseInt(S.css("left"),10);S.animate({top:T+"px"},((V+U)*Q.scrollSpeed),Q.fxEasingScroll,function(){I(S)})},R)}else{if(F.length>1){setTimeout(function(){if(L==true){return false}S.animate({top:(Q.yScroll=="top"?"+":"-")+M.innerHeight()+"px"},Q.showSpeed,Q.fxEasingScroll);I(S)},R)}}}function I(R){if(A.isFunction(Q.aftershow)){Q.aftershow.apply(O,[M,R])}R.removeClass(Q.cssShowing);B()}function P(){L=true;if(M.data("marquee.showing")!=true){F.filter("."+Q.cssShowing).dequeue().stop()}}function D(){L=false;if(M.data("marquee.showing")!=true){J(F.filter("."+Q.cssShowing),1)}}if(Q.pauseOnHover){M.hover(function(){if(G){return false}P()},function(){if(G){return false}D()})}function C(R){return(R.outerWidth()>M.innerWidth())}function B(){H++;if(H>=F.length){if(!isNaN(Q.loop)&&Q.loop>0&&(++N>=Q.loop)){return false}H=0}K(H)}if(A.isFunction(Q.init)){Q.init.apply(O,[M,Q])}B()};A.Marquee.defaults={yScroll:"top",showSpeed:850,scrollSpeed:12,pauseSpeed:5000,pauseOnHover:true,loop:-1,fxEasingShow:"swing",fxEasingScroll:"linear",cssShowing:"marquee-showing",init:null,beforeshow:null,show:null,aftershow:null}})(jQuery);
/***** MARQUEE - END *****/
/***** GUID - START *****/
      function onPostBack()
      {
         var y = generateRandomSequence();
         var hdnGuid = document.getElementById("ctl00_hdnGuid");
         hdnGuid.value=y;
      }
      function generateRandomSequence() 
      { 
        var g = ""; 
        for(var i = 0; i < 32; i++) 
        g += Math.floor(Math.random() * 0xF).toString(0xF) 
        return g; 
      }
/***** GUID - END *****/
