﻿var zindex = 101;

var someArticleOpen = false;

$(document).ready(function() {



	



    /* main menu */
    $('.main-menu li.level-0')
        .mouseover(function() {
            //$('ul.level-1.hide-this').hide();
            zindex += 1;
            $(this).find('ul.level-1')
                .css({'z-index': zindex})
                .removeClass('hide-this').show(); //fadeIn(100);
        })
        .mouseout(function() {
            var o = $(this);
            o.find('ul.level-1').addClass('hide-this');
//            setTimeout(function() {
                o.find('ul.level-1.hide-this').hide(); //fadeOut(70);
//            }, 1);
        });
    $('.main-menu li.level-1')
        .mouseover(function() {
            $(this).find('ul.level-2').removeClass('hide-this').show(); //fadeIn(100);
        })
        .mouseout(function() {
            var o = $(this);
            o.find('ul.level-2').addClass('hide-this');
            setTimeout(function() {
                o.find('ul.level-2.hide-this').hide(); //fadeOut(70);
            }, 100);
        });
        
    /* newsletter */
    $('.newsletter-subscribe-text').focus(function() {
        if ($(this).attr('value') == 'מלא את כתובת הדוא"ל שלך') {
            $(this).removeClass('default-val');
            $(this).attr({value: ''});
        }
    });
        
    /* articles page */
    
    $('.tab-92 .articleRows').mouseover(function() {
        someArticleOpen = true;
        var o = $(this).find('.description');
        o.removeClass('hide-this');
        var delay = 500;
        if (someArticleOpen) delay = 500;
       setTimeout(function() {
            if (!(o.hasClass('hide-this'))) {
                o.slideDown(250);
            }
        }, delay);
    });
    $('.tab-92 .articleRows').mouseout(function() {
        var o = $(this).find('.description');
        o.addClass('hide-this');
        setTimeout(function() {
            someArticleOpen = false;
            o.filter('.hide-this').slideUp(250);
        }, 500);
    });
    
    
    /* faq */
    $('.faq .answer').hide();
    $('.faq .question a').click(function() {
        $(this).parent().parent().find('.answer').slideToggle();
    });
    $('.faq-expand-all').click(function() {
        if ($(this).hasClass('expanded')) {
            $(this).removeClass('expanded').html('הצג את התשובות לכל השאלות');
            $('.answer').hide();
        }
        else {
            $(this).addClass('expanded').html('סגור את התשובות לכל השאלות');
            $('.answer').show();
        }
    });

    /* graduate stories */
    $('.graduate-story .story').hide();
    $('.graduate-story .title a').click(function() {
        $(this).parent().parent().find('.story').slideToggle();
    });
    
    $('.zoom-link').click(function() {
        if ($('.wrapper').hasClass('big-font')) {
            $('.wrapper').removeClass('big-font');
            $('.zoom-link').html('הגדל אותיות');
        }
        else {
            $('.wrapper').addClass('big-font');
            $('.zoom-link').html('הקטן אותיות');
        }
    });
    
    /* opening panels (as in the homepage) */
    $('.open-panel h3')
        .css({cursor: 'pointer', color: '#6d1466'})
        .click(function() {
            $(this).parent().find('.open-panel-content').slideToggle();
        })
        .find('*').css({cursor: 'pointer', color: '#6d1466'});
    $('.open-panel-content').hide();
    
    var branchesHeight = parseInt($('.page').height()) - 650;
    if (branchesHeight > 90)
        $('.bg-rep').css({height: branchesHeight + 'px'});

    if ($(".breadcrumbs").html() != null)
    {
	if ($(".breadcrumbs a.trail:last").html() == "פרטי מאמר" || $(".breadcrumbs a.trail:last").html() == "הדמיה")
	{
		$(".breadcrumbs a.trail:last").html($(".content-typography h1:first").html());
	}
    }
    
   

});

//
 //קורסים וסדנאות
 //
function showCourseDetails(who){
	$who=".details_" + who;
	if($($who).css("display")=="none")
	{
		$($who).slideDown();
	}else{
		$($who).slideUp();
	}
}

function showCourseDates(who){
	$(".course").css("display","none") 
	$who=".type_"+who
	$($who).css("display","block")
	$.colorbox({width:"50%", inline:true, opacity:0.7,close:"סגור", href:"#Dates"} );
}



function removeCourseDates(who){
	$who=".type_"+who
	$("#Dates LI:not("+$who+")").remove(); 
	$.colorbox({width:"50%", inline:true, opacity:0.7,close:"סגור", href:"#Dates"} );

}










