// PARA COLOCAR A IMAGEM NO FUNDO NA POSICAO CERTA

var bg_im;
var mw = 1306;
var mh = 875;
var ratio = mw/mh;

function updateSize()
{
	if (typeof bg_im == "undefined")
		bg_im = document.getElementById("bg_container");
	var size = getWinsize();
	if (size.h > (size.w / ratio))
	{
		bg_im.style.width = Math.ceil(size.h*ratio) + "px"
		margin = "0 0 0 "+ Math.round((size.w-(size.h*ratio))/2) +"px";
		bg_im.style.margin = margin;	
	}
	else
	{
			bg_im.style.width ="100%";
			bg_im.style.margin = "0";	
	}
}

function getWinsize()
{
	var _obj = new Object();
	if( typeof( window.innerWidth ) == "number" ) 
	{
	//Non-IE
		_obj.w = window.innerWidth;
		_obj.h = window.innerHeight;
	}         
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
    //IE 6+ in 'standards compliant mode'
		_obj.w = document.documentElement.clientWidth;
		_obj.h = document.documentElement.clientHeight;        
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
    //IE 4 compatible
        _obj.w = document.body.clientWidth;
        _obj.h = document.body.clientHeight;
	}
	return _obj;
}


// JavaScript Document

var myGlobalHandlers = {
	onCreate: function(){
		Element.show('loader');
	},
	onComplete: function() {
		Element.hide('loader');
	}
};

// Funções para o formulário de contato
  function enviarContato() {
  	var mensagem = '';
  	if ($('name').value.length == 0) mensagem += "- Name:\n";
  	if ($('email').value.length == 0) mensagem += "- E-mail:\n";
  	if ($('email').value.indexOf('@') == -1) mensagem += "- E-mail inválido:\n";
  	if ($('phone').value.length == 0) mensagem += "- Phone:\n";
		if ($('mensagem').value.length == 0) mensagem += "- Message:\n";

	if (mensagem) alert("Campos de preenchimento obrigatório:\n"+mensagem)
	else
	{
		//var param = Form.serialize('form_contato');
		var param = $H({
					   name:$('name').value,
					   email:$('email').value,
					   phone:$('phone').value,
					   mensagem:$('mensagem').value
					   }).toQueryString();
		oAjax = new Ajax.Request('contact_send.php',{parameters:param,onComplete:mostracontato})
	}
  }

  function mostracontato(r) {
  	alert(r.responseText);
		window.location = 'index.php';
  }
//-----------------------------------------------------------------------------------------

MostrarSecao = function(id) {
	FecharSecao();
	new Effect.Appear('secao_'+id);
}

// AJAX
CarregaAjax = function(id) {
 pars = "id="+id;
 new Ajax(id,{update: $('testimony_cont'),evalScripts:true,data:pars}).request();
}



