

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//<body onLoad="MM_preloadImages('image-1.jpg','imgs/image-2.jpg')">


$(document).ready(function () {
	    $.history.init(pageload);	
		$('a[href=' + window.location.hash + ']').addClass('selected');
		$('a[rel=ajax]').click(function () {
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
	 		$.history.load(hash);	
	 		$('a[rel=ajax]').removeClass('selected');
	 		$(this).addClass('selected');
	 		$('#content').hide();
	 		//$('#content').fadeOut();
	 		$('.loading').show();
			getPage();
			return false;
		});	
	});
	function pageload(hash) {
		if (hash) getPage();    
	}
	function getPage() {
		//var data = 'page=' + encodeURIComponent(document.location.hash);
		//var data = 'page=' + document.location.hash.replace(/^.*#/, '');
		if (document.location.hash=='') var data = 'page=' + encodeURIComponent('#pocetna');
		else var data = 'page=' + encodeURIComponent(document.location.hash);
		$.ajax({
			url: "strane.php",
			type: "GET",		
			data: data,		
			cache: false,
			success: function (html) {	
				//$('.loading').hide();
				$('.loading').fadeOut('slow');				
				$('#content').html(html);
				$('#content').fadeIn('slow');		
			}		
		});
	}
	
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}
