/*************************** 
 * Styling Republic
 * Javascript Initialisation
 * 19-01-2009 - i-Aspect B.V.
 * rutger@i-aspect.com
 *
 */ 


$(document).ready(function () {

   // detect link to subpage
   var host = window.location.host;
	var URI = location.href.replace(/#.*/,'');//local url without hash
   var currentlocation = URI.split('/').pop();

   if(currentlocation && $.inArray('#',window.location.href.split('/').pop())){
      document.location.replace('http://'+host+'/#'+currentlocation);
      return;
   }

	var a_uris = [];
	var $navigationitems = $('#navigatie a');
	var nrOfItems=$navigationitems.size();

	$navigationitems.each(function(list){
      a_uris.push(this.href);      

      var s_url = this.href + '/ajax';

      // Change url to anchor
      this.href = '#' + this.href.split('/').pop();
      
      if(list>0){      

         jQuery.ajaxQueue({
            url: s_url,
            success: function(html){ 
               $("#scrollContainer").append(html);
               if(list==nrOfItems-1){
                  $.getScript("js/coda-slider.js");
                  $.getScript("js/photobook.js");
                  $.getScript("js/projectgallery.js");
               }

            }
         });
      }         

	});
	
});


