   hidePageContent = false;

  //if url hasn't hash, redirect    
  if ($.address.path()=="/"){     
    var addUrl = $.address.baseURL().replace('http://'+document.domain, ''); 
    if(addUrl==''){addUrl = '/index.html';}   
    window.location = 'http://'+document.domain+'/#'+addUrl;  
  }   
  else{      
    hidePageContent = true;   
  }
  
  // if url has hash, get content  
  $(document).ready(function() {  
    var href = $.address.value();
    href = href.substring(1,href.length).replace('.html', '');  

    if(href=="index" || href==""){      
      $.get('ajax-response.php?addres='+href, '', function(data){  
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".ajaxWraperContener").html(responseObj.tplContent);    
        mainPageInit();   
      });                       
    }
    else if(href=="menu"){  
      $(".ajaxWraperContener").animate({opacity: 0}, 1); 
      $.get('ajax-response.php?addres='+href, '', function(data){    
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".ajaxWraperContener").html(responseObj.tplContent);                  
        menuPageInitSub();        
        window.setTimeout('menuPageInitMain()',1000);
      }); 
    }                     
    else if(href=="blog/"){
      window.location = 'http://vizaz.pl/blog/';
    }  
    else{     
      $(".ajaxWraperContener").animate({opacity: 0}, 1);   
      $.get('ajax-response.php?addres='+href+'&res=menuContener', '', function(data){   
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".ajaxWraperContener").html(responseObj.tplContent);    
        $(".ajaxContener").animate({opacity: 0}, 1);                  
        menuPageInitSub();
                         
        window.setTimeout('animateAfter(".main .mainMenu .menuItemActive")',1500);
        if($(".ajaxContener").find('.subMenuPortfolio').length>0){
          window.setTimeout('animateAfter(".main .ajaxContener")',2000);
          portfolioPageInit();
        }
        else{
          window.setTimeout('animateAfter(".main .ajaxContener")',2000);
        }      
        subPageBackButtonInit();         
      });                      
    }
  });    

function portfolioPageInit(){
  $(".main .subMenuPortfolio ul li a").click(function(){    
    $(".main .subMenuPortfolio ul li a").removeClass('active');
    $(this).addClass('active');
    
    clickedLink = $(this);
       
    $(".mainContent").animate({opacity: 0}, 500, function(){
      var href = clickedLink.attr('href').replace('http://'+document.domain, '');       
      $.address.value(href);               
      href = href.replace('.html', '');   
      
      $.get('ajax-response.php?addres='+href+'&res=onlyPhotos', '', function(data){     
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".mainContent").html(responseObj.tplContent);    
        $(".mainContent").animate({opacity: 1}, 1000);     
        portfolioGallertInit(); 
      });
    });
    
    return false;
  }); 
  
  portfolioGallertInit();                                         
}

function portfolioGallertInit(){               
  $('.portfolioPhotoList ul li a').click(function(){
    var href = $(this).attr('href');
    $('.portfolioPhotoDetails img').attr('src', href);
    return false;
  });     
    
  if($(".main .portfolioPhotoList ul li").length>4){    
    var activePage = 0;  
    $('.portfolioPhotoList ul').addClass('orginalList').hide();
    $('.portfolioPhotoList').append('<ul class="displayList"></ul>');
    $('.portfolioPhotoList').append('<span class="prevButton"><</span>').append('<span class="nextButton">></span>');
    
    $('.portfolioPhotoList ul li').animate({opacity: 0}, 1)  
    
    portfolioPagination(activePage);
  }     
}
function portfolioPagination(page_index){ 
  $(".portfolioPhotoList .displayList").empty();
        
  var max_elem = Math.min((page_index+1) * 5, $('.portfolioPhotoList .orginalList li').length);
  
  if(page_index==0){
    $('.portfolioPhotoList .prevButton').unbind('click').hide();  
  }
  else{           
    $('.portfolioPhotoList .prevButton').unbind('click').show().click(function(){       
      portfolioPagination(page_index-1); 
    })    
  }
  
  if(max_elem>=$('.portfolioPhotoList .orginalList li').length){
    $('.portfolioPhotoList .nextButton').unbind('click').hide();  
  }
  else{           
    $('.portfolioPhotoList .nextButton').unbind('click').show().click(function(){       
      portfolioPagination(page_index+1); 
    })    
  }
                 
	for(var i=page_index*5;i<max_elem;i++){
    $(".portfolioPhotoList .displayList").append($('.portfolioPhotoList .orginalList li:eq('+i+')').clone(true, true));
  }                                                             
  
  $(".portfolioPhotoList .displayList li").each(function(index) { 
    window.setTimeout('animateAfter(".portfolioPhotoList .displayList li:eq('+index+')")',500*index);
  });

  return false;
}

function mainPageInit(){

	// init resize bkg
	$(".backgroundImgResize").fullBg();

  // main page text animation         
  $(".mainPageContener span, .mainPageContener a").animate({opacity: 0}, 1);  
  window.setTimeout('animateAfter(".mainPageContener span.name")',500);
  window.setTimeout('animateAfter(".mainPageContener span.artist")',1000);
  window.setTimeout('animateAfter(".mainPageContener a", "0.6")',1500);

	// main page hover button
  $(".mainPageContener a").hover(
    function () {
      $(this).stop(true, true).animate({opacity: 1}, 500);
    }, 
    function () {
      $(this).stop(true, true).animate({opacity: 0.6}, 500);
    }
  );
  
	// main page click button
  $(".mainPageContener a").click(function(){  
    var href = $(this).attr('href').replace('http://'+document.domain, '');       
    $.address.value(href);  

    href = href.replace('.html', '');   
    $(".ajaxWraperContener").animate({opacity: 0}, 500, function(){         
      $.get('ajax-response.php?addres='+href, '', function(data){       
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".ajaxWraperContener").html(responseObj.tplContent);     
        menuPageInitSub();        
        window.setTimeout('menuPageInitMain()',1000);
      });                    
    });
    return false;
  });
}



function menuPageInitSub(){   
    $(".sub .text a.name, .sub .text a.artist, .main .mainMenu .menuItem").css('opacity', 0);   	                             
    $(".ajaxWraperContener").animate({opacity: 1}, 1, function(){      
      window.setTimeout('animateAfter(".sub .text a.name")',500);   
      window.setTimeout('animateAfter(".sub .text a.artist")',1000); 
      
      $(".sub .text a.name, .sub .text a.artist").click(function(){        
      
        var href = $(this).attr('href').replace('http://'+document.domain, '');       
        $.address.value(href);
        href = href.replace('.html', ''); 
        
        $(".ajaxWraperContener").stop(true, true).animate({opacity: 0}, 500, function(data){                     
          $.get('ajax-response.php?addres='+href, '', function(data){          
            var responseObj = $.evalJSON(data); 
            document.title = responseObj.metaTag.title;
            $(".ajaxWraperContener").html(responseObj.tplContent);
               
          $(".ajaxWraperContener").stop(true, true).animate({opacity: 1}, 1,  function(data){
            mainPageInit();   
          });
               
          }); 
        });
        
        return false;
      }); 
    
    });                         
}

function menuPageInitMain(){    	   
      $(".main .mainMenu .menuItem").animate({opacity: 0}, 1);   	                             
      window.setTimeout('animateAfter(".main .mainMenu .menuItemPortfolio")',500);  
      window.setTimeout('animateAfter(".main .mainMenu .menuItemAbout")',1000);      
      window.setTimeout('animateAfter(".main .mainMenu .menuItemBackstage")',1500);  
      window.setTimeout('animateAfter(".main .mainMenu .menuItemContact")',2000);   
      window.setTimeout('animateAfter(".sub .text span.nam")',2500); 
      
    // main page hover button
    $(".main .mainMenu .menuItem a").hover(          
      function () {                                
        if($(this).hasClass('active')) return false;    
        $(this).stop(true, true).animate({opacity: 1}, 500); 
      },                                                  
      function () {                                       
        $(this).stop(true, true).animate({opacity: 0.3}, 500);     
      }                                                           
    );

  	// main page click button
    $(".main .mainMenu .menuItem a.ajax").click(function(){ 
        
      if($(this).parent().hasClass('menuItemBackstage')){         
        window.location = 'http://vizaz.pl/blog/';
      }  
        
      clickedLink = $(this);
      // set class
      $(".main .mainMenu .menuItem a").addClass('noActive');
      $(this).removeClass('noActive');
      $(this).addClass('active');
                                                     
      $(this).unbind('click').click(function(){return false;}); 

      // animate             
      $(this).parent().animate({top: '40px'}, 500);  
      $(".ajaxContener").animate({opacity: 0}, 1);  
      $(".main .mainMenu .menuItem a.noActive").animate({opacity: 0}, 500,function(){                
                  
        $(".main .mainMenu .menuItem a.noActive").hide();        
        
        var href = clickedLink.attr('href').replace('http://'+document.domain, '');       
        $.address.value(href);
        href = href.replace('.html', ''); 
        
       // href = href.substring(1,href.length).replace('.html', '');   
        $.get('ajax-response.php?addres='+href, '', function(data){          
          var responseObj = $.evalJSON(data); 
          document.title = responseObj.metaTag.title;
          $(".ajaxContener").html(responseObj.tplContent);    
          $(".ajaxContener").animate({opacity: 1}, 1000);
          portfolioPageInit();                           
          subPageBackButtonInit();         
        }); 

      });
      return false;
    });    
}


function subPageBackButtonInit(){
  $(".main .backButtonArea a").click(function(){
    
    var href = $(this).attr('href').replace('http://'+document.domain, '');       
    $.address.value(href);
    href = href.replace('.html', '');  
    
    $(".main").animate({opacity: 0}, 1000, function(){    
      $.get('ajax-response.php?addres='+href+'&add=back', '', function(data){           
        var responseObj = $.evalJSON(data); 
        document.title = responseObj.metaTag.title;
        $(".main").html(responseObj.tplContent);  
        $(".main").animate({opacity: 1}, 1);          
        menuPageInitMain();   
      });
    });
    
    return false;
  });   
}   

 	
function animateAfter(string, opacity){
 if (opacity == null){
   opacity = 1;
 }
                
  $(string).animate({opacity: opacity}, 1000);               
}            

