// Cross site FRONT-END functions
// Author: Yanay Zohar

var jungoapp = {

  'lang' : 'en',
  'phrases': {}    // will be filled dynamically
  
};


$(document).ready( function(){

    
    // prevent no firebug support errors when calling console.log in code:
    if(typeof console === "undefined") {  
    console = { log: function() { } };
    }
    
    // update language used, if set by url:
    if( $(document).getUrlParam("lang") )  
      jungoapp.lang =  $(document).getUrlParam("lang");    

   
    $("ul.sf-menu").supersubs({ 
        minWidth:    16,   // minimum width of sub-menus in em units 
        maxWidth:    62,   // maximum width of sub-menus in em units 
        extraWidth:  1,    // extra width can ensure lines don't sometimes turn over 
                           // due to slight rounding differences and font-family 
        speed:       0,
        delay:       0                           
    }).superfish();  // call supersubs first, then superfish, so that subs are 
                     // not display:none when measuring. Call before initialising 
                     // containing tabs for same reason. 
   
    
    //activate "accordion" navs: slides the element with class "menu_body" when paragraph with class "menu_head" is clicked
    $("#acco-set p.acco-title").click(function()
    {
        $("#context-bar-content").css("border-bottom", "1px solid white"); // while expanding seperate from surroding text 
        $(this).next("div.acco-content").slideToggle(300).siblings("div.acco-content").slideUp("slow");
    });
    
    
    $("#context-bar").bind("mouseover",function(){
        
        $("#context-bar").css("background-color","#F2F2F2");
        $("#context-bar-content").css("background-color","#F2F2F2");
        $("#context-expanding").css("background-color","#F2F2F2");
        
        $(".acco-title").addClass("with-down-arrow-dark");
        
        $("#context-fix-corner").show();
    });
    
    $("#context-bar").bind("mouseleave",function(){
        
        $("#acco-set div.acco-content").hide("fast");
        
        $("#context-bar").css("background-color","transparent");
        $("#context-bar-content").css("background-color","transparent").css("border-bottom", "none");
        $("#context-expanding").css("background-color","transparent");
        
        $(".acco-title").removeClass("with-down-arrow-dark");
        $(".acco-title").removeClass("with-down-arrow-blue").css('font-weight','normal');
        
        $("#context-fix-corner").hide();
        
    });
    
    
    $(".acco-title").bind("mouseover",function(){
    
      $(".acco-title").removeClass("with-down-arrow-blue").css('font-weight','normal');
      $(this).addClass("with-down-arrow-blue").css('font-weight','bold');
    });
    
    $('#current-lang-display').bind("mouseover",function(){
          $('#language-select').removeClass('hide');
    });
    
    $('#language-select').bind("mouseleave",function(){
          $('#language-select').addClass('hide');
    });
    
    
    // if php injected language code, use it:
    if( $('#lang-for-js').html() )
        jungoapp.lang = $('#lang-for-js').html();
    
    jungoapp.phrases = JSON.parse( $('#phrases-for-js').html() );  // will make lang-depdendant phrases availalbe in JS code.

    $('.minip').corner();    
    $('.minip2').corner();
    $('.docnote').corner();
    $('.mini-wide').corner();
	
	
	    
    JTracker();  // track current page
    
    
    // some pages have dynamic place holder for next events:
          /*
          // implement only after new jungo.com server:
          // update in HTP-DEF: IN <PROMO_EVENTS> : <div id='optional-events-teaser' style='display:none;'></div>
          // and remove static texts
          $('#optional-events-teaser').load( get_scripts_path()+'st/events.php?teaser_text=1');
          if( $('#optional-events-teaser').html() )
          {
            $('#optional-events-teaser').show();
          } 
          */   
    
 
});


function fill_search_src(){
    
  $("#fr").val( location.href );
  
}

 
