			//<![CDATA[
$(document).ready(function() {
    // language flags
    $('.lang-content').addClass('js').find('li').addClass('js');

    // reset text in all input fields
    $('input[type=text], textarea').reSetValue();

    // lang overlay
    $('.lang-head').click(function() {
      toggleXtra($(this));
      return false;
    });
        
    // search overlay
    $('.search-head').click(function() {
      toggleXtra($(this));
      return false;
    });

    // tooltip
    $('.tooltip').tooltip();		      
    
    // hide lang-head and search-head on click outside the element    
    $(document).click(function(event) {
        var t = $(event.target);
        if (!t.parent().hasClass('lang-head') && !t.parent().hasClass('search-head') && !t.parents().hasClass('overlay')) {
            $('.overlay').hide();
        }
    });

    // tip-friend modal function
    $('div.lightboxme').hide();
    $('a.lightboxme').click(function() {
        var t = $(this).attr('rel');
        $('div.' + t).lightbox_me({
            centered: true,
            overlayCSS: { background: '#333', opacity: .5 },
            overlaySpeed: 300,
            lightboxSpeed: "normal"
        });
        return false;
    });

    $('a[rel=tipfriend]').click(function() {
        $('.lb_overlay, div.lightboxme').fadeOut(500);
        $('div.tipfriend').lightbox_me({
            centered: true,
            overlayCSS: { background: '#333', opacity: .5 },
            overlaySpeed: 300,
            lightboxSpeed: "normal"
        });
        return false;
    });

  });

  function toggleXtra(ref) {
    /* vars */
    var all = $('.overlay');
    var pre = all.prev();
    var el = ref.next();
    /* toggle class */
    pre.removeClass('active');
    $(ref).addClass('active');
    if (el.is(':visible')) {
      all.hide();
    } else if (el.is(':hidden')) {
      all.hide();
      el.show();
    }
    return false;
  }

				//]]>
        
        

