function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


var tab = new Array();
$(document).ready(function(){	
	
	$("#news").easySlider({
		prevId: 		'prevBtn',
		prevText: 		'',
		nextId: 		'nextBtn',	
		nextText: 		'',
		controlsShow:	true,
		speed: 			1000,
		auto:			true,
		pause:			2000,
		continuous:		true
	});
	
	$('.tab').hover(function(){
		var obj = $(this).parent();
		var id = $(this).parent().attr('id');
		$('.tab').parent().css({zIndex:'100'});
		obj.css({zIndex:'99999999999999'});			
		if(tab[id] == true){
			if(id != 'contactus') obj.css({zIndex:'100'});
			else obj.css({zIndex:'90'});
			obj.animate({left:'-376px'},425);
			tab[id] = false;
		}else{
			obj.animate({left:'0'},425);
			tab[id] = true;
		}
	});
	
	$('.faq').click(function(){
		$('.faq .fullanswer').slideUp(300);
		$('.faq .showfullanswer').css({display:'inline'});
		$('.fullanswer',this).css({display:'none'});
		$('.fullanswer',this).parent().find('.fullanswer').slideDown(300);
	});

	var nextcal = true;
	$('.gotocal span').html('שבוע הבא ›');
	$('.gotocal span').click(function(){
		if(nextcal == true){
			$(this).html('‹ השבוע');
			nextcal = false;
		}else{
			$(this).html('שבוע הבא ›');
			nextcal = true;
		}
		$('.cal.current').slideUp(300,function(){
			$(this).removeClass('current');
		});
		
		$('.cal.hidden').slideDown(300,function(){
			$('.cal').addClass('hidden');
			$(this).removeClass('hidden');
			$(this).addClass('current');
		});
	});

	$('#calid').mouseover(function(){
		$('li',this).addClass('open');
	});
	
	$('#calid').mouseout(function(){
		$('li',this).removeClass('open');
	});
	
	$('.storebtn').mouseover(function(){
		$('.storebtn h2').css({backgroundColor:'#3d3d3f'});
		$('h2',this).css({backgroundColor:'#e3001b'});
	});
	
});

