// JavaScript Document

 $(document).ready(function () {  
	 
	 var temp_hash = "";	
     //Check if url hash value exists (for bookmark) 

     $.history.init(pageload); 

	
     //highlight the selected link  
     $( 'a[href="'+ document.location.hash+'"]').addClass('selected');
	 
       	
     //Seearch for link with REL set to ajax  
     $('a[rel="ajax"]').click(function () {  
 	 	
           
         //grab the full url  
         var hash = this.href;  
           
         //remove the # value  
         hash = hash.replace(/^.*#/, '');  
           
         //for back button  
         $.history.load(hash);     
           
         //clear the selected class and add the class class to the selected link  
         $('a[rel=ajax]').removeClass('selected');  
        $(this).addClass('selected');  
         
//		 alert( temp_hash+" "+hash );
/*		 if( temp_hash != hash )
		 	{*/
			temp_hash = hash;
	         //hide the content and show the progress bar  
    	     $('#catalog_mm').hide();  
        	$('#loading').show();  
           
    	     //run the ajax  
	         getPage();  
//			}
       
         //cancel the anchor tag behaviour  
         return false;  
     });   
 });  
       
  
 function pageload(hash) {  
     //if hash value exists, run the ajax  
	
     if (hash) getPage();      
 }  
           
 function getPage() {  
     
     //generate the parameter for the php script  
     var data = 's1=1&' + document.location.hash.replace(/^.*#/, '');  
		
     $.ajax({  
         url: 'http://www.djani.rs/catalog_response.php',    
         type: 'GET',          
         data: data,       
         cache: false,  
         success: function (html) { 
		 
		
              //hide the progress bar  
             $('#loading').hide();     
              
             //add the content retrieved from ajax and put it in the #content div  
             $('#catalog_mm').html(html);  
               
             //display the body with fadeIn transition  
             $('#catalog_mm').fadeIn('slow');         
         }         

     });  
	 
}  
