$(document).ready(function() { $('#content').hide(); $.address.init(function(event) { $('.link').address(); }).change(function(event) { var value = $.address.state().replace(/^\/$/, '') + event.value; if(value.indexOf("?") != -1) { var hrefArr = value.split('/'); var id = hrefArr[hrefArr.length-1]; var toLoad = '/' + id + ' #content'; $('#content').slideUp('slow', function() { $('#content').load(toLoad,'', function() { $('a.portfolio').addClass('selected').focus(); $('#content').delay(200).slideDown('slow'); }) }); } $('.link').each(function() { var href = $(this).attr('href'); if(value == '/') { $('a.index').addClass('selected').focus(); var toLoad = 'index.php #content'; $('#content').load(toLoad,'', function() { $('#content').delay(200).slideDown('slow'); }); } if(value == '/contact_succes.php') { $('a.contact').addClass('selected').focus(); var toLoad = 'contact_succes.php #content'; $('#content').load(toLoad,'', function() { $('#content').delay(200).slideDown('slow'); }); } if(value == '/404.php') { var toLoad = '404.php #content'; $('#content').load(toLoad,'', function() { $('#content').delay(200).slideDown('slow'); }); } if (href == value) { var a = {}; a['/index.php'] = "Hoofdpagina"; a['/overmij.php'] = "Over mij"; a['/ervaring.php'] = "Ervaring"; a['/portfolio.php'] = "Portfolio"; a['/portfolio.php?p=1'] = "Portfolio | Aelbertsberg & Elswout"; a['/portfolio.php?p=2'] = "Portfolio | Artistieke Interlyceale 2010"; a['/portfolio.php?p=3'] = "Portfolio | Kennemer Hockey"; a['/portfolio.php?p=4'] = "Portfolio | Kennemer Lyceum: inschrijfformulier"; a['/portfolio.php?p=7'] = "Portfolio | Helemaal voor jezelf"; a['/portfolio.php?p=5'] = "Portfolio | Vol Vertrouwen"; a['/portfolio.php?p=6'] = "Portfolio | Wijkraad Binnenstad Haarlem"; a['/portfolio.php?p=8'] = "Portfolio | Kennemer Lyceum: MR-verkiezingen"; a['/portfolio.php?p=9'] = "Portfolio | Kennemer Lyceum"; a['/portfolio.php?p=10'] = "Portfolio | Sport Interlyceale 2010"; a['/contact.php'] = "Contact"; $.each(a, function(key, value) { if(href == key) { if(key.indexOf("?") != -1) { $('a.portfolio').addClass('selected'); } else { $('a.' + key).addClass('selected'); } document.title = 'Tim van der Meij | ' + value; } }); $(this).addClass('selected').focus(); var toLoad = $(this).attr('href') +' #content'; $('#content').slideUp('slow', function() { $('#content').load(toLoad,'', function() { $('#content').delay(200).slideDown('slow'); }) }); } else { $(this).removeClass('selected'); } }); }); });