$(document).ready(function(){
	$.ajax({url: '/content.php', type: 'GET', success: content_success_handler});
	window.$loader_empty = $('#empty');
	window.$loader_carros = $('#carros');
	window.img_loaded = [];
	window.processing = 0;
	window.images = [
		{elm: '#topo-cont h1', type: 'background', src: '/static/images/logo_topo.gif', aling: 'center center no-repeat'},
		{elm: '#topo-cont li', type: 'background', src: '/static/images/menu-separador.gif', aling: 'left top no-repeat'},
		{elm: '#topo-cont p', type: 'background', src: '/static/images/telefone_topo.gif', aling: 'center center no-repeat'},
		{elm: '#topo-cont div', type: 'background', src: '/static/images/redes_pb.gif', aling: 'left top no-repeat'},
		{elm: '#menu-quemsomos a', type: 'background', src: '/static/images/menu-quem_somos.gif', aling: 'left top no-repeat'},
		{elm: '#menu-clientes a', type: 'background', src: '/static/images/menu-clientes.gif', aling: 'left top no-repeat'},
		{elm: '#menu-trabalhos a', type: 'background', src: '/static/images/menu-trabalhamos.gif', aling: 'left top no-repeat'},
		{elm: '#menu-blog a', type: 'background', src: '/static/images/menu-blog.gif', aling: 'left top no-repeat'},
		{elm: '#menu-talentos a', type: 'background', src: '/static/images/menu-talentos_redirect.gif', aling: 'left top no-repeat'},
		{elm: '#menu-contato a', type: 'background', src: '/static/images/menu-contato.gif', aling: 'left top no-repeat'},
		{elm: '#arte', type: 'background', src: '/static/images/set1_arte.gif', aling: 'center bottom no-repeat'},
		{elm: '#logo', type: 'background', src: '/static/images/logo_set1.png', aling: 'center center no-repeat'},
		{elm: '#artby', type: 'background', src: '/static/images/art_by.png', aling: 'center center no-repeat'},
		{elm: '#frase1', type: 'background', src: '/static/images/frase1.gif', aling: 'center center no-repeat'},
		{elm: '#frase2', type: 'background', src: '/static/images/frase2.gif', aling: 'center center no-repeat'},
		{elm: '#vermelho1, #vermelho2, #vermelho3, #vermelho4', type: 'background', src: '/static/images/tarja_vermelha.gif', aling: 'center center no-repeat'},
		{elm: '#pontilhado1, #pontilhado2, #pontilhado3', type: 'background', src: '/static/images/pontilhado.gif', aling: 'center center no-repeat'},
		{elm: '#barco', type: 'background', src: '/static/images/barco.png', aling: 'center center no-repeat'},
		{elm: '#mar1', type: 'background', src: '/static/images/mar.png', aling: 'center center no-repeat'},
		{elm: '#mar2', type: 'background', src: '/static/images/mar.png', aling: 'center center repeat'},
		{elm: '#nuvem1, #nuvem2', type: 'background', src: '/static/images/nuvem.png', aling: 'center center no-repeat'},
		{elm: '#cinza1, #set4, #quad_cinza', type: 'background', src: '/static/images/cinza.png', aling: 'center center repeat'},
		{elm: '#balao1', type: 'background', src: '/static/images/balao_redirect.png', aling: 'center center no-repeat'},
		{elm: '#balao2', type: 'background', src: '/static/images/balao_coruja.png', aling: 'center center no-repeat'},
		{elm: '#balao3', type: 'background', src: '/static/images/balao_coracao.png', aling: 'center center no-repeat'},
		{elm: '#balao4', type: 'background', src: '/static/images/balao_publicidade.png', aling: 'center center no-repeat'},
		{elm: '#balao5', type: 'background', src: '/static/images/balao_interferencia.png', aling: 'center center no-repeat'},
		{elm: '#forma-branca', type: 'background', src: '/static/images/forma-branca.gif', aling: 'center center no-repeat'},
		{elm: '#aviao', type: 'background', src: '/static/images/aviao.png', aling: 'center center no-repeat'},
		{elm: '#set2', type: 'background', src: '/static/images/nos_somos_bg.jpg', aling: 'top left no-repeat'},
		{elm: '#tarjas_fundo', type: 'background', src: '/static/images/tarja_branca_fundo.png', aling: 'center center no-repeat'},
		{elm: '#txts_nos_somos', type: 'background', src: '/static/images/textos_nos_somos.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_promocoes', type: 'background', src: '/static/images/nos_somos_promocoes.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_programas', type: 'background', src: '/static/images/nos_somos_programas.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_gerenciamento', type: 'background', src: '/static/images/nos_somos_gerenciamento.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_conversao', type: 'background', src: '/static/images/nos_somos_conversao.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_campanhas', type: 'background', src: '/static/images/nos_somos_campanhas.png', aling: 'center center no-repeat'},
		{elm: '#nos_somos_negocios', type: 'background', src: '/static/images/nos_somos_negocios.png', aling: 'center center no-repeat'},
		{elm: '#bg_arte', type: 'background', src: '/static/images/fundo-arte.gif', aling: 'center top repeat-y'},
		{elm: '#tarja_branca1, #tarja_branca2', type: 'background', src: '/static/images/branco.gif', aling: 'center top repeat-y'},
		{elm: '#peixes1, #peixes3', type: 'background', src: '/static/images/peixes1.png', aling: 'center center no-repeat'},
		{elm: '#peixes2, #peixes4', type: 'background', src: '/static/images/peixes2.png', aling: 'center center no-repeat'},
		{elm: '#ideas', type: 'background', src: '/static/images/full_digital_ideas.png', aling: 'center center no-repeat'},
		{elm: '#rtfolio', type: 'background', src: '/static/images/txt_portfolio.png', aling: 'right center no-repeat'},
		{elm: '#o', type: 'background', src: '/static/images/txt_portfolio.png', aling: 'right center no-repeat'},
		{elm: '#p', type: 'background', src: '/static/images/txt_portfolio.png', aling: 'left center no-repeat'},
		{elm: '#mao', type: 'background', src: '/static/images/mao.png', aling: 'left center no-repeat'},
		{elm: '#portfolio_txt', type: 'background', src: '/static/images/portfolio_txt.png', aling: 'left center no-repeat'},
		{elm: '#arte_contato', type: 'background', src: '/static/images/arte_contato.png', aling: 'center center no-repeat'},
		{elm: '#entre_em_contato', type: 'background', src: '/static/images/entre_em_contato.png', aling: 'center center no-repeat'},
		{elm: '#form_contato', type: 'background', src: '/static/images/form.png', aling: 'center center no-repeat'},
		{elm: '#redes', type: 'background', src: '/static/images/redes.png', aling: 'center center no-repeat'},
		{elm: '#fotos1, #fotos2', type: 'background', src: '/static/images/fotos.jpg', aling: 'left center repeat'},
		{elm: '#triangulo_cinza', type: 'background', src: '/static/images/triangulo_cinza.png', aling: 'center center repeat'},
		{elm: '#video', type: 'background', src: '/static/images/bg_video.gif', aling: 'center center repeat'},
		{elm: '#form_erro', type: 'background', src: '/static/images/msg_erro.png', aling: 'center center repeat'},
		{elm: '#form_sucesso', type: 'background', src: '/static/images/msg_sucesso.png', aling: 'center center repeat'},
		{elm: '#logos img:eq(0)', type: 'image', src: '/static/images/logo_cliente_01.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(1)', type: 'image', src: '/static/images/logo_cliente_02.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(2)', type: 'image', src: '/static/images/logo_cliente_03.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(3)', type: 'image', src: '/static/images/logo_cliente_04.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(4)', type: 'image', src: '/static/images/logo_cliente_05.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(5)', type: 'image', src: '/static/images/logo_cliente_06.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(6)', type: 'image', src: '/static/images/logo_cliente_07.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(7)', type: 'image', src: '/static/images/logo_cliente_08.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(8)', type: 'image', src: '/static/images/logo_cliente_09.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(9)', type: 'image', src: '/static/images/logo_cliente_10.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(10)', type: 'image', src: '/static/images/logo_cliente_11.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(11)', type: 'image', src: '/static/images/logo_cliente_12.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(12)', type: 'image', src: '/static/images/logo_cliente_13.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(13)', type: 'image', src: '/static/images/logo_cliente_14.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(14)', type: 'image', src: '/static/images/logo_cliente_15.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(15)', type: 'image', src: '/static/images/logo_cliente_16.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(16)', type: 'image', src: '/static/images/logo_cliente_17.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(17)', type: 'image', src: '/static/images/logo_cliente_18.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(18)', type: 'image', src: '/static/images/logo_cliente_19.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(19)', type: 'image', src: '/static/images/logo_cliente_20.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(20)', type: 'image', src: '/static/images/logo_cliente_21.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(21)', type: 'image', src: '/static/images/logo_cliente_22.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(22)', type: 'image', src: '/static/images/logo_cliente_23.gif', aling: 'center center repeat'},
		{elm: '#logos img:eq(23)', type: 'image', src: '/static/images/logo_cliente_24.gif', aling: 'center center repeat'},
		{src: '/static/images/logo_cliente_over_01.gif'},
		{src: '/static/images/logo_cliente_over_02.gif'},
		{src: '/static/images/logo_cliente_over_03.gif'},
		{src: '/static/images/logo_cliente_over_04.gif'},
		{src: '/static/images/logo_cliente_over_05.gif'},
		{src: '/static/images/logo_cliente_over_06.gif'},
		{src: '/static/images/logo_cliente_over_07.gif'},
		{src: '/static/images/logo_cliente_over_08.gif'},
		{src: '/static/images/logo_cliente_over_09.gif'},
		{src: '/static/images/logo_cliente_over_10.gif'},
		{src: '/static/images/logo_cliente_over_11.gif'},
		{src: '/static/images/logo_cliente_over_12.gif'},
		{src: '/static/images/logo_cliente_over_13.gif'},
		{src: '/static/images/logo_cliente_over_14.gif'},
		{src: '/static/images/logo_cliente_over_15.gif'},
		{src: '/static/images/logo_cliente_over_16.gif'},
		{src: '/static/images/logo_cliente_over_17.gif'},
		{src: '/static/images/logo_cliente_over_18.gif'},
		{src: '/static/images/logo_cliente_over_19.gif'},
		{src: '/static/images/logo_cliente_over_20.gif'},
		{src: '/static/images/logo_cliente_over_21.gif'},
		{src: '/static/images/logo_cliente_over_22.gif'},
		{src: '/static/images/logo_cliente_over_23.gif'},
		{src: '/static/images/logo_cliente_over_24.gif'}
	];
	window.test = 0;
	for (var img, i = 0; i < window.images.length; i++) {
		window.images[i];
		img = new Image();
		img.index = i;
		img.onload = image_load_handler;
		img.src = window.images[i].src;
	} delete i; delete img;
});

function afterload () {
	window.anim_itens = [
		{elm: $('#arte'), props: [
			{"height": {ini: $('#arte').height(), fin: 853, start: 0, end: 884, calc: calc.linear}}
		]},
		{elm: $('#logo'), props: [
			{
				"margin-left": {ini: $('#logo').margin().left, fin: -700, start: 0, end: 437, calc: calc.linear},
				"top": {ini: $('#logo').position().top, fin: 197, start: 0, end: 437, calc: calc.linear}
			}
		]},
		{elm: $('#artby'), props: [
			{
				"margin-left": {ini: $('#artby').margin().left, fin: 570, start: 0, end: 437, calc: calc.linear},
				"top": {ini: $('#artby').position().top, fin: 227, start: 0, end: 437, calc: calc.linear}
			}
		]},
		{elm: $('#frase1'), props: [
			{
				"margin-left": {ini: $('#frase1').margin().left, fin: -315, start: 0, end: 760, calc: calc.linear},
				"top": {ini: $('#frase1').position().top, fin: 468, start: 0, end: 760, calc: calc.linear}
			}
		]},
		{elm: $('#frase2'), props: [
			{
				"margin-left": {ini: $('#frase2').margin().left, fin: -138, start: 0, end: 760, calc: calc.linear},
				"top": {ini: $('#frase2').position().top, fin: 605, start: 0, end: 760, calc: calc.linear}
			}
		]},
		{elm: $('#barco'), props: [
			{"margin-left": {ini: $('#barco').margin().left, fin: -177, start: 0, end: 882, calc: calc.linear}},
		]},
		{elm: $('#vermelho1'), props: [
			{"top": {ini: $('#vermelho1').position().top, fin: -1450, start: 0, end: 779, calc: calc.linear}}
		]},
		{elm: $('#vermelho2'), props: [
			{
				"top": {ini: $('#vermelho2').position().top, fin: -123, start: 0, end: 2044, calc: calc.linear},
				"margin-left": {ini: $('#vermelho2').margin().left, fin: -2506, start: 0, end: 2044, calc: calc.linear}
			}
		]},
		{elm: $('#pontilhado1'), props: [
			{
				"top": {ini: $('#pontilhado1').position().top, fin: 459, start: 0, end: 2322, calc: calc.linear},
				"margin-left": {ini: $('#pontilhado1').margin().left, fin: -2468, start: 0, end: 2322, calc: calc.linear}
			}
		]},
		{elm: $('#pontilhado2'), props: [
			{
				"top": {ini: $('#pontilhado2').position().top, fin: 459, start: 0, end: 2322, calc: calc.linear},
				"margin-left": {ini: $('#pontilhado2').margin().left, fin: -548, start: 0, end: 2322, calc: calc.linear}
			}
		]},
		{elm: $('#pontilhado3'), props: [
			{
				"top": {ini: $('#pontilhado3').position().top, fin: 2412, start: 0, end: 2322, calc: calc.linear},
				"margin-left": {ini: $('#pontilhado3').margin().left, fin: -548, start: 0, end: 2322, calc: calc.linear}
			}
		]},
		{elm: $('#vermelho3'), props: [
			{
				"top": {ini: $('#vermelho3').position().top, fin: -1741, start: 0, end: 784, calc: calc.linear},
				"margin-left": {ini: $('#vermelho3').margin().left, fin: -162, start: 0, end: 784, calc: calc.linear}
			}
		]},
		{elm: $('#vermelho4'), props: [
			{
				"top": {ini: $('#vermelho4').position().top, fin: 1190, start: 922, end: 1858, calc: calc.linear},
				"margin-left": {ini: $('#vermelho4').margin().left, fin: -2248, start: 922, end: 1858, calc: calc.linear}
			}
		]},
		{elm: $('#balao1'), props: [
			{"top": {ini: $('#balao1').position().top, fin: 784, start: 0, end: 1600, calc: calc.linear}}
		]},
		{elm: $('#balao2'), props: [
			{"top": {ini: $('#balao2').position().top, fin: 850, start: 0, end: 1936, calc: calc.linear}}
		]},
		{elm: $('#balao3'), props: [
			{"top": {ini: $('#balao3').position().top, fin: 1130, start: 0, end: 1936, calc: calc.linear}}
		]},
		{elm: $('#balao4'), props: [
			{"top": {ini: $('#balao4').position().top, fin: 901, start: 0, end: 1936, calc: calc.linear}}
		]},
		{elm: $('#balao5'), props: [
			{"top": {ini: $('#balao5').position().top, fin: 1144, start: 0, end: 1936, calc: calc.linear}}
		]},
		{elm: $('#aviao'), props: [
			{"margin-left": {ini: $('#aviao').margin().left, fin: 495, start: 509, end: 1800, calc: calc.linear}}
		]},
		{elm: $('#tarjas_fundo'), props: [
			{"top": {ini: $('#tarjas_fundo').position().top, fin: -180, start: 735, end: 2818, calc: calc.linear}}
		]},
		{elm: $('#txts_nos_somos'), props: [
			{"top": {ini: $('#txts_nos_somos').position().top, fin: 114, start: 735, end: 2818, calc: calc.linear}}
		]},
		{elm: $('#nos_somos_promocoes'), props: [
			{
				"top": {ini: $('#nos_somos_promocoes').position().top, fin: 559, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_promocoes').margin().left, fin: -494, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#nos_somos_programas'), props: [
			{
				"top": {ini: $('#nos_somos_programas').position().top, fin: 611, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_programas').margin().left, fin: -498, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#nos_somos_gerenciamento'), props: [
			{
				"top": {ini: $('#nos_somos_gerenciamento').position().top, fin: 664, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_gerenciamento').margin().left, fin: -582, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#nos_somos_conversao'), props: [
			{
				"top": {ini: $('#nos_somos_conversao').position().top, fin: 716, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_conversao').margin().left, fin: -612, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#nos_somos_campanhas'), props: [
			{
				"top": {ini: $('#nos_somos_campanhas').position().top, fin: 768, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_campanhas').margin().left, fin: -495, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#nos_somos_negocios'), props: [
			{
				"top": {ini: $('#nos_somos_negocios').position().top, fin: 820, start: 735, end: 2818, calc: calc.linear},
				"margin-left": {ini: $('#nos_somos_negocios').margin().left, fin: -457, start: 735, end: 2818, calc: calc.linear}
			}
		]},
		{elm: $('#bg_arte'), props: [
			{"top": {ini: $('#bg_arte').position().top, fin: 0, start: 1618, end: 5000, calc: calc.linear}}
		]},
		{elm: $('#peixes1'), props: [
			{"margin-left": {ini: $('#peixes1').margin().left, fin: -1270, start: 1618, end: 5000, calc: calc.linear}}
		]},
		{elm: $('#peixes2'), props: [
			{"margin-left": {ini: $('#peixes2').margin().left, fin: -1270, start: 1618, end: 5000, calc: calc.linear}}
		]},
		{elm: $('#peixes3'), props: [
			{"margin-left": {ini: $('#peixes3').margin().left, fin: -1270, start: 2700, end: 3700, calc: calc.linear}},
			{"top": {ini: $('#peixes3').position().top, fin: 1035, start: 3000, end: 3450, calc: calc.linear}}
		]},
		{elm: $('#peixes4'), props: [
			{"margin-left": {ini: $('#peixes4').margin().left, fin: -1270, start: 2700, end: 3700, calc: calc.linear}},
			{"top": {ini: $('#peixes4').position().top, fin: 843, start: 3000, end: 3450, calc: calc.linear}}
		]},
		{elm: $('#p'), props: [
			{"margin-left": {ini: $('#p').margin().left, fin: -485, start: 2882, end: 3428, calc: calc.linear}}
		]},
		{elm: $('#rtfolio'), props: [
			{"top": {ini: $('#rtfolio').position().top, fin: 72, start: 3282, end: 3428, calc: calc.linear}}
		]},
		{elm: $('#o'), props: [
			{"top": {ini: $('#o').position().top, fin: 72, start: 3482, end: 3782, calc: calc.linear}}
		]},
		{elm: $('#mao'), props: [
			{"top": {ini: $('#mao').position().top, fin: -165, start: 3482, end: 4082, calc: calc.mao}}
		]},
		{elm: $('#fotos1'), props: [
			{"margin-left": {ini: $('#fotos1').margin().left, fin: -1920, start: 4519, end: 6861, calc: calc.linear}}
		]},
		{elm: $('#fotos2'), props: [
			{"margin-left": {ini: $('#fotos2').margin().left, fin: -960, start: 4519, end: 6861, calc: calc.linear}}
		]}
	];
	
	window.$window = $(window);
	window.$window.bind('scroll', window_scroll_handler);
	$('#topo a').bind('click', menu_click_handler);
	$('form').bind('submit', form_submit_handler);
	
	window.$form_contato = $('#form_contato');
	window.$form_sucesso = $('#form_sucesso');
	window.$form_erro = $('#form_erro');
	
	$('#logos img').hover(logos_mouseover_handler, logos_mouseout_handler);

	window.$video_iframe = $('#video iframe');
	$('#video img').bind('click', video_click_handler);
	
	if (window.location.hash.length > 0) {
		$(window).scrollTop(parseInt(window.location.hash.replace(/[^0-9]/g, ''), 10));
	}
	
	$('<a target="_blank" href="http://www.awwwards.com/web-design-awards/redirect"></a>').prependTo('body')
		.css({
			background: 'url(http://www.manufacturedessai.it/images/award_day_black.png)',
			display: 'block',
			width: 69,
			height: 105,
			position: 'fixed',
			right: 0,
			top: 50,
			"z-index": 1000
		});
}

function window_scroll_handler () {
	var elm, props, i, j, l;
	var st = window.$window.scrollTop();
	for (i = 0; i < window.anim_itens.length; i++) {
		elm = window.anim_itens[i].elm;
		for (j = 0; j < window.anim_itens[i].props.length; j++) {
			props = window.anim_itens[i].props[j];
			for (l in props) {
				if (st <= props[l].start) {
					elm.css(l, props[l].ini);
				} else if (st >= props[l].end) {
					elm.css(l, props[l].fin);
				} else {
					elm.css(l, props[l].calc(props[l].ini, props[l].fin, parseFloat(elm.css(l).replace(/[^0-9.\-]/, '')), props[l].start, props[l].end, st));
				}
			}
		}
	}
}

calc = {
	linear: function (ini, fin, now, start, end, st) {
		return ((fin-ini)*(((st-start))/(end-start)))+ini;
	},
	mao: function (ini, fin, now, start, end, st) {
		return  (150*((((st-start)/(end-start))<=0.5) ? ((st-start)/(end-start)) : 1-((st-start)/(end-start)))*2)+ini;
	}
};

function menu_click_handler (event) {
	if ($(this).attr('href').match(/^#[0-9]+/)) {
		event.preventDefault();
		var dst = parseInt($(this).attr('href').replace('#', ''),10);
		var t = (dst-window.$window.scrollTop())*2;
		$.scrollTo(dst, (t < 0 ? -t : t));
	}
}

function form_submit_handler (event) {
	event.preventDefault();
	var $this = $(this);
	$this.find('button').fadeOut(500, function(){
		$(this).remove('');
		$('<span></span>').appendTo($this).fadeIn(500, function () {
			$.ajax({
				url: '/contato.php',
				data: $this.serialize(),
				context: $this,
				dataType: 'json',
				type: 'POST',
				success: function (data) {
					var $this = this;
					$this.find('span').fadeOut(500, function(){
						$(this).remove();
						$('<button type="submit"></button>').appendTo($this).fadeIn(500);
					});
					if (data.ok) {
						form_show_ok();
					} else {
						form_show_error();
					}
				},
				error: function () {
					var $this = this;
					$this.find('span').fadeOut(500, function(){
						$(this).remove();
						$('<button type="submit"></button>').appendTo($this).fadeIn(500);
					});
					form_show_error();
				}
			});
		});
	});
}

function form_show_error () {
	window.$form_contato.fadeOut(500, function(){
		window.$form_erro.fadeIn(500, function(){
			setTimeout('(function(){window.$form_erro.fadeOut(500, function(){window.$form_contato.fadeIn(500);});})();', 2000);
		});
	});
}

function form_show_ok () {
	window.$form_contato.fadeOut(500, function(){
		window.$form_sucesso.fadeIn(500, function(){
			setTimeout('(function(){window.$form_sucesso.fadeOut(500, function(){window.$form_contato.fadeIn(500);});})();', 2000);
		});
	});
}

function logos_mouseover_handler (event) {
	var $this = $(this);
	console.log($this);
	$this.attr('src', $this.attr('src').replace(/logo_cliente_([0-9]+?).gif/, 'logo_cliente_over_$1.gif'));
}

function logos_mouseout_handler (event) {
	var $this = $(this);
	$this.attr('src', $this.attr('src').replace(/logo_cliente_over_([0-9]+?).gif/, 'logo_cliente_$1.gif'));
}

function content_success_handler (data) {
	window.$content = $(data);
	window.$content.find('#arte').css({"height": 1093});
	window.$content.find('#logo').css({"margin-left": -227, "top": 97});
	window.$content.find('#artby').css({"margin-left": 75, "top": 127});
	window.$content.find('#frase1').css({"margin-left": -737, "top": 368});
	window.$content.find('#frase2').css({"margin-left": 114, "top": 505});
	window.$content.find('#barco').css({"margin-left": -675});
	window.$content.find('#vermelho1').css({"top": -743});
	window.$content.find('#vermelho2').css({"margin-left": -1484, "top": 899});
	window.$content.find('#pontilhado1').css({"margin-left": -4790, "top": -1863});
	window.$content.find('#pontilhado2').css({"margin-left": -2870, "top": -1863});
	window.$content.find('#pontilhado3').css({"margin-left": -2870, "top": 90});
	window.$content.find('#vermelho3').css({"margin-left": 622, "top": -957});
	window.$content.find('#vermelho4').css({"margin-left": -1312, "top": 2126});
	window.$content.find('#balao1').css({"top": 1363});
	window.$content.find('#balao2').css({"top": 1150});
	window.$content.find('#balao3').css({"top": 1498});
	window.$content.find('#balao4').css({"top": 1442});
	window.$content.find('#balao5').css({"top": 1685});
	window.$content.find('#aviao').css({"margin-left": -250});
	window.$content.find('#tarjas_fundo').css({"top": -294});
	window.$content.find('#txts_nos_somos').css({"top": 0});
	window.$content.find('#nos_somos_promocoes').css({"margin-left": -431, "top": 445});
	window.$content.find('#nos_somos_programas').css({"margin-left": -276, "top": 498});
	window.$content.find('#nos_somos_gerenciamento').css({"margin-left": -120, "top": 550});
	window.$content.find('#nos_somos_conversao').css({"margin-left": 3, "top": 602});
	window.$content.find('#nos_somos_campanhas').css({"margin-left": -97, "top": 654});
	window.$content.find('#nos_somos_negocios').css({"margin-left": -249, "top": 706});
	window.$content.find('#bg_arte').css({"top": -950});
	window.$content.find('#peixes1').css({"margin-left": 960});
	window.$content.find('#peixes2').css({"margin-left": 960});
	window.$content.find('#peixes3').css({"margin-left": 960, "top": 823});
	window.$content.find('#peixes4').css({"margin-left": 960, "top": 1077});
	window.$content.find('#p').css({"margin-left": -992});
	window.$content.find('#rtfolio').css({"top": -78});
	window.$content.find('#o').css({"top": -78});
	window.$content.find('#mao').css({"top": -165});
	window.$content.find('#fotos1').css({"margin-left": -960});
	window.$content.find('#fotos2').css({"margin-left": -1920});
	for (var i = 0; i < window.img_loaded.length; i++) {
		attachImage(window.img_loaded[i]);
	}
	window.processing++;
	loader_step();
}

function image_load_handler (event) {
	var obj = window.images[this.index];
	if (typeof window.$content != 'undefined') {
		attachImage(obj);
	} else {
		window.img_loaded[window.img_loaded.length] = obj;
	}
	window.processing++;
	loader_step();
}

function attachImage (obj) {
	var elm;
	if (typeof obj.elm != 'undefined') {
		elm = window.$content.find(obj.elm);
		if (obj.type == 'background') {
			elm.css('background', 'url(' + obj.src + ') ' + (typeof obj.aling != 'undefined' ? obj.aling : ''));
		} else if (obj.type == 'image') {
			elm.attr('src', obj.src);
		}
	}
}

function _loader () {
	if (window.processing == window.images.length+1) {
		$('#loader').fadeOut(700, function(){
			$(this).remove();
			var div = $('<div></div>').css({width: '100%', height: 10000, position: 'absolute', "z-index": 99999, "background": '#ffffff', top: 0, left: 0}).prependTo('body');
			$('body').prepend(window.$content.children());
			afterload();
			div.fadeOut(700);
		});
	}
}

function loader_step () {
	var itotal = window.images.length+1;
	var p = window.processing/itotal;
	window.$loader_empty.stop().animate({width: 423*(1-p)}, 500);
	window.$loader_carros.stop().animate({"margin-left": 430*p}, {duration: 500, complete: _loader});
}

function video_click_handler (event) {
	var id = $(this).attr('src').replace(/.*?vi\/(.+?)\/2.jpg/, '$1');
	var iframe = window.$video_iframe.attr('src').replace(/(.*?\/embed\/).+?(\?rel.*)/, '$1' + id + '$2');
	window.$video_iframe.attr('src', iframe);
}
