if ( undefined != typeof $('.custom-select')  ) {
	$(".custom-select span").click(function(e) {
	 $(e.target).closest("dt").next('dd').toggle();
	    e.stopPropagation();
	});
	
	$("body").click(function() {
	    $('.custom-select dd').hide();
	});

}


if ( undefined != typeof section_rezultate ) {
	$("#marimi-picker span").click(function(e) {
	    $('#lista-alte-etape').toggle();
	    e.stopPropagation();
	});
	
	$("body").click(function() {
	    $('#lista-alte-etape').hide();
	});
}

if ( undefined != typeof section_meciuri_sezon_side ) {
	$(".etape-tabs dt").click(function(e) {
	    $('.etape-tabs dd.current, .etape-tabs dt.current').removeClass('current');
		$(this).addClass("current");
	    $(this).find('+ dd').addClass("current");
	});
}



//keep session alive
function KeepAlive() {
  var updateEvery = 30;//Seconds
  var img;
  var imgId = 'keepUpdated';
  var img_src_URL = 'files/keepalive.php?img=';
  var timer;
  var me = this;
  //create img element
    img = document.createElement('img');
    img.id = imgId;
    img.src = img_src_URL + '1';
    document.body.appendChild(img);

  this.updateImage = function() {
     img.src = img_src_URL + Math.floor(Math.random()*999);
     me.keepUpdated();
  }
  
  this.keepUpdated = function () {
     timer=setTimeout(function(){me.updateImage();},1000*updateEvery);
  };
  this.keepUpdated();
}


$(document).ready(function() {
//document.write = document.writeln = function(){};
  $ka = new KeepAlive();
});

