$(document).ready(function(){
	if ($('body#studios').length > 0) {
		$('h2').each(function() {
	    string = $(this).text();
	    filename = string.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,'');
	    $(this).html('<img src="/public/images/text-image/white/'+filename+'.gif" alt="'+string+'"/>');
	  });
	}
	$('#level1 a').each(function() {
	  string = $(this).text();
	  filename = string.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,'');
	  $(this).addClass(filename);
	});
	if ($('body#homepage').length > 0) {
		$("#gallery").randomize("img");
		$('#gallery').animate({ opacity: 1 },3000);
		$('.loading').animate({ opacity: 0 },3000);
		$('#gallery').css("width",760);
		$('#gallery img').css("width",760);
	}
	$('#gallery').cycle({
		fx:     'fade', 
		speed:  3500,
		pause: 1
	});
});
(function($) {

$.fn.randomize = function(childElem) {
  return this.each(function() {
      var $this = $(this);
      var elems = $this.children(childElem);

      elems.sort(function() { return (Math.round(Math.random())-0.5); });  

      $this.remove(childElem);  

      for(var i=0; i < elems.length; i++)
        $this.append(elems[i]);      

  });    
}
})(jQuery);

