
function sendWindowForm( divForm, _form ){
	divResp = 'emailResponse'+divForm;
	
		//var _last = $('#' + _form + ' button.submitButton');
		
		//_last.disabled = true;
		
		//
		//alert(_form.attr('id'))
		//alert(_form.serialize())
		
		//return false;
		if($('#'+divResp).length < 1){
			$('#'+_form).append('<div id="'+divResp+'" class="emailResponse"><div id="emailResponseMsg">Enviando...</div></div>');
		}
		_form = $('#'+_form);
		//$('#emailResponseMsg').show().update('Enviando...').addClass('emailResponseEnviando');
		$.ajax({
					  url: 'http://www.masaia.com.br/_Request/',
					  data: _form.serialize(),
					  dataType: 'json',
					  cache: false,
					  type: 'POST',
					  complete: function(resposta) {
						var res = jQuery.parseJSON(resposta.responseText)
					  	if(1){//resposta.responseText.isJSON()){
							if(res.status == 'ok'){
								$('#emailResponseMsg').html(res.mensagem)
									.removeClass('emailResponseErro')
									.removeClass('emailResponseEnviando')
									.addClass('emailResponseEnviada');
								
								if(res.mensagem){
									//$(_form).scrollIntoView();
									$('#emailResponseMsg').show();
									if(pageTracker) pageTracker._trackEvent("Formulário","Enviar",divForm,1);
								}else{
									$('#emailResponseMsg').remove();
								}
								//$(_form).reset();
								if(res.script)
									eval(res.script);
							}else{
								$('#emailResponseMsg')
									.html(res.mensagem)
									.removeClass('emailResponseEnviando')
									.addClass('emailResponseErro');
								//$(_form).scrollIntoView();
								$('#emailResponseMsg').show();
								if(pageTracker) pageTracker._trackEvent("Formulário","Enviar",divForm,0);
							}
						}else{
							$('#emailResponseMsg')
								.html('Não foi possível executar esta função neste momento. Tente novamente, por favor ou envie e-mail para <a href="contato@mazaya.com.br">contato@mazaya.com.br</a>.')
								.removeClass('emailResponseEnviando')
								.addClass('emailResponseErro');
							//$(_form).scrollIntoView();
							$('#emailResponseMsg').show();
							if(pageTracker) pageTracker._trackEvent("Formulário","Enviar",divForm,0);
						}
					  }
			});
		
	return false;
}

var $ = jQuery;
$(document).ready(function(){
	
			
			
			$('#fileInputArquivo').uploadify({
				'uploader'  : 'http://www.masaia.com.br/_shared/_swf/uploadify.swf',
				'script'    : 'http://www.masaia.com.br/_Request/enviarArquivo',
				'cancelImg' : 'http://www.masaia.com.br/_shared/_images/cancel.png',
				'buttonText': 'Anexar arquivos',	
				'auto'      : true,
				onComplete: function (a, b ,c, d, e) {
					//alert(a+'\n'+b+'\n'+c+'\n'+d+'\n'+e);
					var res = jQuery.parseJSON(d);
					if(res.mensagem != 'undefined') $('#listaArquivos').after(res.mensagem)
				}
			});
			$('#fileInputCurriculo').uploadify({
				'uploader'  : 'http://www.masaia.com.br/_shared/_swf/uploadify.swf',
				'script'    : 'http://www.masaia.com.br/_Request/enviarArquivo',
				'cancelImg' : 'http://www.masaia.com.br/_shared/_images/cancel.png',
				'buttonImg'	: 'http://www.masaia.com.br/_imagens/anexar-curriculum.png',
				'auto'      : true,
				onComplete: function (a, b ,c, d, e) {
					//alert(a+'\n'+b+'\n'+c+'\n'+d+'\n'+e);
					var res = jQuery.parseJSON(d);
					if(res.mensagem != 'undefined') $('#fileInputCurriculo').after(res.mensagem)
				}
			});
		
			$('#slider').nivoSlider({
					directionNavHide:false, //Only show on hover
					pauseTime:10000,
			});
			
			
			$(function(){
			 $(".tool-tip").tipTip({maxWidth: "150px", edgeOffset: 10});
			});
			
			$('.viewport').mouseenter(function(e) {
				//$(this).children('a').children('img').animate({ height: '105', left: '0', top: '0', width: '130'}, 100);
				$(this).children('a').children('span').fadeIn(200);
			}).mouseleave(function(e) {
				//$(this).children('a').children('img').animate({ height: '121', left: '-20', top: '-20', width: '150'}, 100);
				$(this).children('a').children('span').fadeOut(200);
			});
						
			$('#container-4').tabs({ fxFade: true, fxSpeed: 'fast' });
			
			$('#mycarousel').jcarousel();
			
			
			$("input").focus(function() {
				if (this.value == this.defaultValue){  
						this.value = '';  
					}  
				if(this.value != this.defaultValue){  
						this.select();  
					}  
			});
			
			$("input").blur(function() {
				if (this.value == ''	){  
					this.value = (this.defaultValue ? this.defaultValue : '');  
				} 
			});
			
			$(".portItem").click(function(event){
											event.preventDefault();
											$.ajax({url : this, context : event.target,
																				   success: function(data) {
																						$('#case').html(data);
																						$('#mycarousel_port').jcarousel();
																					  }});
								});
			
			
});

$(document).ready(function(){
  $("#content-slider").slider({
    animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });
});

function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
}

