$(document).ready(function(){
var hash = window.location.hash.substr(2);

	comienzo();
	if(google) hash=google;
	
	var href = $('#header li a').each(function(){
		var href = $(this).attr('href');
		href=href.substr(2);
		
		if(hash==href){
			var toLoad = hash+'.php #contenido';
			$('#contenido').load(toLoad,comienzo)
			$('body').removeClass();
			$('body').addClass(hash);
		}											
	})

	
	
	$('#programas a').click(function(){
				var toLoad= 'programas.php #contenido';
				$('#contenido').fadeTo('slow',0.1,loadcontent);
				
				function  loadcontent(){
					$('#contenido').load(toLoad,showContent);
					$('body').removeClass();
				}
				function showContent(){
						$('#contenido').fadeTo('slow',1);
						$('body').addClass('programas');
						comienzo();
				}
	});					
	$('#home a').click(function(){
				var toLoad= 'index.php #contenido';
				$('#contenido').fadeTo('slow',0.1,loadcontent);
				
				function  loadcontent(){
					$('#contenido').load(toLoad,showContent);
					$('body').removeClass();
				}
				function showContent(){
						$('#contenido').fadeTo('slow',1);
						$('body').addClass('index');
						comienzo();
				}
				
	});		
	
	$('#portfolio a').click(function(){
				var toLoad= 'portfolio.php #contenido';
				$('#contenido').fadeTo('slow',0.1,loadcontent);
				
				function  loadcontent(){
					$('#contenido').load(toLoad,showContent);
					$('body').removeClass();
				}
				function showContent(){
						$('#contenido').fadeTo('slow',1);
						$('body').addClass('portfolio');
						comienzo();
				}
				
	});
	$('#contacto a').click(function(){
				var toLoad= 'contacto.php #contenido';
				$('#contenido').fadeTo('slow',0.1,loadcontent);
				
				function  loadcontent(){
					$('#contenido').load(toLoad,showContent);
					$('body').removeClass();
				}
				function showContent(){
						$('#contenido').fadeTo('slow',1);
						$('body').addClass('contacto');
						comienzo();
				}
				
	});	
	function comienzo(){
	$('.rounded').corners();

	$(".tooltip").tooltip({ 
 	track: true, 
    delay: 0, 
    showURL: false, 
    opacity: 1, 
    fixPNG: true, 
    showBody: " - ", 
    extraClass: "pretty fancy"
        
	});
	
		//AJAX FORM
var opciones = { 
    beforeSubmit: validateFields, 
    success: showResponse, 
	clearForm: true    
		
    
}; 
$('#form').ajaxForm(opciones); 

function showResponse(responseText, statusText){  
        
		
		 $('#load').css("display", "none");
		$('#status').html(responseText);
		}
	};
	


});	
