jQuery(document).ready(function() {
	jQuery.noConflict();
	jQuery('.form').submit(function() {
		
		var url = jQuery(this).attr("action");
		var campos = jQuery(this).serialize();
		var processa = campos;
		jQuery('#loader').show();
		jQuery.post(url, processa, function(retorno) {
				jQuery('#response-msg').html(retorno);
				jQuery('#loader').hide();
		});
		return false;
	});
	iniciar();
	jQuery.history.init(function (hash) {
		if (hash)
		{
			if (hash == '/')
			{
				jQuery('#bg').animate({left: "0px"}, "slow");
				jQuery('#bois').animate({left: "-400px"}, "slow");
			}
			else
			{
				jQuery('#bg').animate({left: "-800px"}, "slow");
				jQuery('#bois').animate({left: "-1200px"}, "slow");	
			}
			carrega(hash);
		}
	});

	
});
function loadHistory(hash) {
	if (hash)
	{
		if (hash == '/flip/')
			window.location.href = 'http://bahiaembrio.com.br/flip/';
			
		jQuery.history.load(hash);
	}
	return true;
}

function carrega(url)
{
	jQuery("#content").html('<p align="center" style="margin-top: 300px;"><img src="wp-content/themes/bahiaembrio/images/ajax-loader.gif" /></p>');
	jQuery.get("wp-content/themes/bahiaembrio/ajax.php", { url: url }, function(data) {
				
		jQuery("#content").html(data);

		jQuery('.form').submit(function() {
		
		var url = jQuery(this).attr("action");
		var campos = jQuery(this).serialize();
		var processa = campos;
		jQuery('#loader').show();
		jQuery.post(url, processa, function(retorno) {
				jQuery('#mailReturn').html(retorno);
				jQuery('#loader').hide();
		});
		return false;
	});
		
		Cufon.replace('h1'); // Works without a selector engine
		Cufon.replace('h2'); // Works without a selector engine
		Cufon.replace('#sub1'); // Requires a selector engine for IE 6-7, see above
		
		flowplayer("a.myPlayer", "http://releases.flowplayer.org/swf/flowplayer-3.2.7.swf", {
			// this is the player configuration. You'll learn on upcoming demos.
			plugins:  {
				controls:  {
					volume: false		
				}
			}
		});
			
	});
}
