/************************
Usman Bashir
http://creative-fuzon.com

core.js : The core code behind for all of the website.
http://usmanbashir.com

Version: 1.4.0.0

Start Date & Time: 29/10/2009 - 09:33:00 PM
Last Build Date & Time: 20/11/2009 - 04:21:00 AM
************************/

$(window).load(function() {
    var sQueryHash = window.location.hash;
    if ( sQueryHash !== "" ) { navigateToPage( sQueryHash ); }
    
    $('#nav a').click(function(e) { e.preventDefault(); navigateToPage( $(this).attr('href') ); });
    
    $('#download-vCard span').css( { display: 'block', opacity: 0, width: '999px' } ).parent().hover( function() {
            var e = $(this);
            e.css( { backgroundColor: '#ea872c', width: '24px' } ).animate( { width: '121px' }, 600, 'easeInOutExpo' );
            e.children('span').animate( { opacity: 1 }, 600, 'easeInExpo' );
        }, function() {
            var e = $(this);
            e.css( { backgroundColor: '#ea872c' } ).animate( { width: '24px' }, 600, 'easeOutExpo', function() { e.css( { backgroundColor: '#eeeeee' } ); } );
            e.children('span').animate( { opacity: 0 }, 600, 'easeOutExpo' );
        }
    );
});

function setPageTitle(sTitle) {
    var sPageTitle = 'Usman Bashir - Web & Software Develeoper';
    if ( sTitle !== undefined ) { document.title =  sPageTitle + ' -' + sTitle;} else { document.title = sPageTitle; }
}

function navigateToPage(sHref) {
    var oNavItem = $('#nav a[href=' + sHref + ']');
    
    $('#nav li').removeClass('current');
    oNavItem.parent().addClass('current');
    
    $('#content').scrollTo( sHref, { duration: 1000, onAfter: function() { window.location.hash = sHref; }, easing: 'easeInOutExpo' } );
    
    setPageTitle( sHref.toString().replace(/[\#\--]/g, ' ').replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); } ) );
}
