$(document).ready(function () {   
     
	$("#email_newsletter").focus(function() {
		$(this).attr("value", "");
	});
	
	$("#submit_newsletter").live("click", function() { 
			if ($("#email_newsletter").val().length > 0) {
		         $.post(  
		             "../view.php",  
		             {submit_newsletter: "true",
					  email_newsletter: $("#email_newsletter").val()},  
		             function(){
					 	$("#newsletter_submit_msg").remove(); 
		                $("#submit_newsletter").parent().prepend('<p style="font-weight: bold" id="newsletter_submit_msg">Thank you!</p>'); 
						$("#email_newsletter").attr("value", "Your email"); 
		             },  
		             "html");  
			}
		return false;
	});  
	
	$("#pages a").live("click", function(e) {
		
		var $this = $(this);
		var url = $this.attr("href");
		
		$("#leftContent_holder > *").fadeOut(400, function() {
			$("#leftContent").load(url+" #leftContent > *", function() {
				$("#leftContent_holder > *").hide().fadeIn(400);
			});
		})
		
		
		return false;
	});
	   
	   
    //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   
    $('.ajax').live("click", function () {   
			 
			someObject.run = false;
			  
	        //grab the full url    
	        var hash = this.rel;
			   
	        //remove the # value   
	        hash = hash.replace(/^.*#/, '');   
			
			oldHash = parseInt(hash);
	           
	        //for back button   
  
	        //run the ajax   
			//getPage();
			
			if (jQuery.browser.safari) {
				$.history.load(hash);				  
			} else {
	        	$.history.load(hash);  
			}
			
			$("#leftContent .image_container").fadeOut(300, function(){
				$("#leftContent").load(hash+" #leftContent > *", function() {
					$("#leftContent .image_container").hide().fadeIn(300);
				}); 
			});
			
			someObject.run = true;
       
	   		//alert(hash)
        //cancel the anchor tag behaviour   
        return false;   
    }); 
	
	function pageload(hash) {   
	
			var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
			if (is_chrome || jQuery.browser.safari) {
				
			    if (hash) {
					someObject.getPage();
				}
			} else {
			    if (hash) {
					someObject.getPage();
				}
			}
		
	}   
	            
});  

var someObject = ({
	run: true,
	getPage:function() {
		var data = '' + document.location.hash.replace(/^.*#/, '');
		if (this.run) {
			$("#leftContent .image_container").fadeOut(300, function(){
				$("#leftContent").load(data + " #leftContent > *", function(){
					$("#leftContent .image_container").hide().fadeIn(300);
				});
			});
		}
	}
}); 
       
  

		

   
   /* $.ajax({   
        url: "view.php",     
        type: "GET",           
        data: data,           
        success: function (html) {     
           
            //hide the progress bar   
            $('#loading').hide();      
               
            //add the content retrieved from ajax and put it in the #content div   
            $('#leftcontent').html(html);   
               
            //display the body with fadeIn transition   
            $('#content').fadeIn('slow');          
        }          
    });   */
