    $(function(){
      $('#scrollArea').jScrollPane();
      $('#scrollArea').jScrollPane({scrollbarWidth:13, scrollbarMargin:0});
    });
    
    function showPage(id){
      if(id=="index"){
          $.get('ajaxResponse.php?page='+id+'&time='+new Date().getTime(), '', function(data){
            $("#ajaxContent").html(data);
             reinitialiseJS();
          });
      }
      else{
        if($('#content').length){
          $.get('ajaxResponse.php?page='+id, '', function(data){
            $("#content").html(data);
            reinitialiseJS();
          });
        }
        else{ 
           $.get('ajaxResponse.php?page='+id+'&getAllContent=1&time='+ new Date().getTime(), '', function(data){
              $("#ajaxContent").html(data);
             reinitialiseJS();
          });
        }
      }
    }
    
    reinitialiseJS = function(){
      $('#scrollArea').jScrollPane();
      $('a.targetBlank').attr('target', '_blank');
      
      
      $('a.competition').click(function (){
        $.get('ajaxResponse.php?page=fragmenty&action=getCompetition', '', function(data){
          $("#content").html(data);
          reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      $('a.competitionNews').click(function (){
        $.get('ajaxResponse.php?page=aktualnosci&action=getCompetition', '', function(data){
          $("#content").html(data);
          reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      $('a.competitionNewsy').click(function (){
        $.get('ajaxResponse.php?page=newsy&action=getCompetition', '', function(data){
          $("#content").html(data);
          reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      
      // news link
      $('#sub ul.news li h3 a').click(function () { 
  
        $.get($(this).attr('href'), '', function(data){
            $("#content").html(data);
            reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      // fragment link
      $('#sub ul.book li a').click(function () { 
  
        $.get($(this).attr('href'), '', function(data){
            $("#content").html(data);
            reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      // pager link
      $('#sub .pageListRight ul li a').click(function () { 
  
        $.get($(this).attr('href'), '', function(data){
            $("#content").html(data);
            reinitialiseJS();
        });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      // back to main page
      $('a#mainPageLink').click(function () { 
  
          $.get('ajaxResponse.php?page=index&time='+new Date().getTime(), '', function(data){
            $("#ajaxContent").html(data);
             reinitialiseJS();
          });
        
        $(this).attr('href', 'javascript:void(0);');
      });
      
      // coment list
      $('a.addComment').click(function () { 
  
          $.get($(this).attr('href'), '', function(data){
            $("#content").html(data);
             reinitialiseJS();
          });
        
        $(this).attr('href', 'javascript:void(0);');
      });

		}
		
		function sendNewCommentNews(){
     var formNewComment = $("#iCommentText").val();
     var formNewCommentAuthor = $("#iCommentAutor").val();
     var formNewCommentParentId = $("#iCommentParentId").val();
     var urlFrom = $("#urlFrom").val();
      
      $.get('ajaxResponse.php?page=aktualnosci&action=addComment&author='+formNewCommentAuthor+'&comment='+formNewComment+'&id='+formNewCommentParentId+'&from='+urlFrom, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  } 
		function sendNewCommentNewsy(){
     var formNewComment = $("#iCommentText").val();
     var formNewCommentAuthor = $("#iCommentAutor").val();
     var formNewCommentParentId = $("#iCommentParentId").val();
     var urlFrom = $("#urlFrom").val();
      
      $.get('ajaxResponse.php?page=newsy&action=addComment&author='+formNewCommentAuthor+'&comment='+formNewComment+'&id='+formNewCommentParentId+'&from='+urlFrom, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  }  
  
		function sendNewCommentFragmenty(){
     var formNewComment = $("#iCommentText").val();
     var formNewCommentAuthor = $("#iCommentAutor").val();
     var formNewCommentParentId = $("#iCommentParentId").val();
     var urlFrom = $("#urlFrom").val();
      
      $.get('ajaxResponse.php?page=fragmenty&action=addComment&author='+formNewCommentAuthor+'&comment='+formNewComment+'&id='+formNewCommentParentId+'&from='+urlFrom, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  }  
  
		function sendNewCompetition(){
     var formAuthor = $("#iCompetitionAutor").val();
     var formEmail = $("#iCompetitionEmail").val();
     var answer = $(".iRadio:checked").val();
      
      $.get('ajaxResponse.php?page=fragmenty&action=addCompetitionResponse&author='+formAuthor+'&email='+formEmail+'&answer='+answer, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  }  
	function sendNewCompetitionNews(){
     var formAuthor = $("#iCompetitionAutor").val();
     var formEmail = $("#iCompetitionEmail").val();
     var answer = $(".iRadio:checked").val();
      
      $.get('ajaxResponse.php?page=aktualnosci&action=addCompetitionResponse&author='+formAuthor+'&email='+formEmail+'&answer='+answer, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  }  
  
	function sendNewCompetitionNewsy(){
     var formAuthor = $("#iCompetitionAutor").val();
     var formEmail = $("#iCompetitionEmail").val();
     var answer = $(".iRadio:checked").val();
      
      $.get('ajaxResponse.php?page=newsy&action=addCompetitionResponse&author='+formAuthor+'&email='+formEmail+'&answer='+answer, '', function(data){
        $("#content").html(data);
        reinitialiseJS();
      });
      
    return false;
  }  
  
  
  
  
