var currentPage=$("title").text();

if(currentPage=='Xyn Xu - London art direction, digital design & development / Freelancer'){
	currentPage='Home';
}




$('#nav').load('nav.html?'+ Math.random()*99999,function(response, status, xhr) {
	//alert("hello");
	$('#nav').fadeIn(2000);
	$('#nav a').filter(function(){
		var text=$(this).text();
		//alert(text);
		return text==currentPage;
	}).addClass('current');
	init();
});	
/*
$('nav').load('nav.html?'+ Math.random()*99999,function(response, status, xhr) {
	//alert("hello");
	$('nav').fadeIn(2000);
	$('nav a').filter(function(){
		var text=$(this).text();
		//alert(text);
		return text==currentPage;
	}).addClass('current');
	init();
});*/

//var currentPage=$('.content h1').text();



function init(){

var starty=$('#backToTop').offset().top;

        $('#backToTop').hide();
        
        if ( $.browser.msie ){
            $(window).scroll(function () {    
                var scrolly=$('body').scrollTop();            
                if(scrolly){
                    $('#backToTop:hidden').fadeIn('slow');
                }
                if(scrolly>starty){
                    $('#backToTop').css("position","absolute");
              	    $('#backToTop').css("top",scrolly+20);
                }else{
                    $('#backToTop').css("position","relative");
                    $('#backToTop').css("top",10);
                    if(!scrolly){
                        $('#backToTop:visible').fadeOut('slow');
                    }
                }
            });
        
        
        }else{

        
        $(window).scroll(function () { 
            var scrolly=$('body').scrollTop();
            //$('#backToTop:visible').stop();
            //$('#backToTop:visible').hide();
            $('#backToTop:hidden').fadeIn('slow');

            if(scrolly>starty){
                var offset=scrolly-starty+20;
                $('#backToTop').css("position","fixed");
                $('#backToTop').css("top",10);
            }else{
                $('#backToTop').css("position","relative");
                if(!scrolly){
                    //$('#backToTop:hidden').stop();
                    //$('#backToTop:hidden').show();
                    $('#backToTop:visible').fadeOut('slow');
                }
            }
        });
        
        };
}
