$url = 'http://akademiamatematyki.pl/';

$(document).ready(function(){
	
	$('ul#menuMain').superfish({
			hoverClass:  'sfHover',
			pathClass:   'current',
			delay:       200,                             // one second delay on mouseout 
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
            speed:       'fast',                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: false         
	}); 
	
	$('ul#menuMain li').hover(
		function() {
			$(this).children('a').addClass('activeLnk');
		},
		function() {
			$(this).children('a').removeClass('activeLnk');
		}
	);
	
	$('.ofertaBox li a:first-child').click(function() {
		$('.ofertaBox li a:first-child').removeClass('activeTab');
		$(this).addClass('activeTab');
		$(this).parent().parent().parent('.ofertaBox').children().children('div.ofertaTekst').fadeOut();
		$(this).parent().parent().children('div.ofertaTekst').fadeIn();
		var tab = $(this).parent().parent().children('div.ofertaTekst').attr('id');
		var href = '';		
		$('#offer_more').attr('href',href);
		
	});
	
});

 var emailReplaceArray = [

    ['(at)', '@'],

    ['(dot)', '.']

  ];

  ( function(elm, evnt, func) {
    if (elm.addEventListener) {
      elm.addEventListener(evnt, func, false);
    }
    else if (elm.attachEvent) {
      elm.attachEvent('on' + evnt, function() {
        func.call(elm, event);
      } );
    }
  } ) (window, 'load', function(e) {

    var replTab = emailReplaceArray;
    for (var i = 0; i < replTab.length; i++) {
      var s = escape(replTab[i][0].replace(/\s/g, ''));
      replTab[i][0] = s.replace(/%u/g, '\\u').replace(/%/g, '\\x');
    }
    var getEmail = function(s) {
      s = s.replace(/\s/g, '');
      for (var i = 0; i < replTab.length; i++) {
        s = s.replace(new RegExp(replTab[i][0], 'ig'), replTab[i][1]);
      }
      return s;
    };
    var as = document.getElementsByTagName('a');
    var html = document.getElementsByTagName('html')[0];
    var text = html.textContent != undefined ? 'textContent' : 'innerText';
    for (var i = 0; i < as.length; i++) {
      if (! as[i].className.match(/(^|\s)adres_email($|\s)/)) continue;
      var email = getEmail(as[i][text]);
      as[i].setAttribute('href', 'mailto:' + email);
      as[i][text] = email;
    }
    emailReplaceArray = undefined;
  } );
