﻿/*============================================================= RADIO & CHECK BOX*/
$(document).ready(function(){
	$('#de').focus(function(){
		$(this).calendario({ 
			target:'#de'
		});
	});
	$('#ate').focus(function(){
		$(this).calendario({ 
			target:'#ate'
		});
	});
});
/*===============================================================================*/



/*============================================================= RADIO & CHECK BOX*/
$(document).ready( function(){ 
	$(".cb-enable").click(function(){
		var parent = $(this).parents('.switch');
		$('.cb-disable',parent).removeClass('selected');
		$(this).addClass('selected');
		$('.checkbox',parent).attr('checked', true);
	});
	$(".cb-disable").click(function(){
		var parent = $(this).parents('.switch');
		$('.cb-enable',parent).removeClass('selected');
		$(this).addClass('selected');
		$('.checkbox',parent).attr('checked', false);
	});
});
/*===============================================================================*/



/*============================================== RADIO & CHECK BOX PERSONALIZADOS*/
$(document).ready(function() { 
	$(".radio, .checkbox").hide();		
	$("#form_orcamento input, #form_contato input").each(function(i){
		if($(this).is(':checked')) {
				$(this).siblings('label').addClass("ativo");
		}
	});
	// Radios estilizados
	$(".list_radio label").click(function() {
			$(this).parent().siblings().children("label").removeClass("ativo");
			$(this).addClass("ativo");
			$(this).siblings('input[type=radio]').attr("checked", "checked"); 
	});			
	// Checkboxs estilizados
	$(".list_check label").toggle(
		function() {
			$(this).siblings('input[type=checkbox]').attr("checked", "checked"); 
			$(this).addClass("ativo");
		},		function() {
			$(this).siblings('input[type=checkbox]').attr("checked", ""); 
			$(this).removeClass("ativo");
	});				
});	
/*===============================================================================*/



/*========================================================================= BOTÕES*/
$(document).ready(function() {
  $('.btns').append('<span class="hover"></span>').each(function () {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function () {
			$span.stop().fadeTo(600, 1);
		}, function () {
	$span.stop().fadeTo(600, 0);
		});
	});
});
/*===============================================================================*/



/*================================================================= CLIENTES HOME*/
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 994;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  $('#slidesContainer').css('overflow', 'hidden');
  slides
    .wrapAll('<div id="slideInner"></div>')
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
  $('#slideInner').css('width', slideWidth * numberOfSlides);
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Mover pra esquerda.</span>')
    .append('<span class="control" id="rightControl">Mover pra direita.</span>');
	manageControls(currentPosition);

  $('.control')
    .bind('click', function(){
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    manageControls(currentPosition);
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });
  function manageControls(position){
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
});
/*===============================================================================*/



/*======================================================== BLOQUEAR BOTÃO DIREITO*/
/*function click() {
  if (event.button==2||event.button==3) {
  oncontextmenu='return false';}
}
  document.onmousedown=click
  document.oncontextmenu = new Function("return false;")*/
/*===============================================================================*/



/*======================================================================== Banner*/
//jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
//    if ((t/=d) < (1/2.75)) {
//        return c*(7.5625*t*t) + b;
//    } else if (t < (2/2.75)) {
//        return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
//    } else if (t < (2.5/2.75)) {
//        return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
//    } else {
//        return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
//    }
//};
//$(document).ready(function() {
//	if ($('#banner')[0] != null) {
//		$('#banner_content').cycle({ 
//			fx:     'scrollRight', 
//			timeout: 5000,
//			easing: 'easeInOutBack'
//			//pager: '#banner_pager'
//		 });
//	}
//});
/*===============================================================================*/



/*========================================================= VALIDAÇÃO FORMULÁRIOS*/
/*======================================== CADASTRO VAGAS*/
function validaTrabalhe(){
	if ($('#nome').val() == "" || $('#nome').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>nome</strong>.</p>');
		return false;
	}
	if ($('#email').val() == "" || $('#email').val().length < 4 || $('#email').val().indexOf("@") < 1 ){
		Sexy.error('<h1>Por Favor,</h1><p>Informe seu <strong>e-mail</strong> corretamente.</p>');
		return false;
	}
	if ($('#idade').val() == "" || $('#idade').val().length < 4){
		Sexy.error('<h1>Por Favor,</h1><p>Informe sua <strong>idade</strong>.</p>');
		return false;
	}
	if ($('#bairro').val() == "" || $('#bairro').val().length < 4){
		Sexy.error('<h1>Por Favor,</h1><p>Informe seu <strong>bairro</strong>.</p>');
		return false;
	}
	if ($('#telefone').val() == "" || $('#telefone').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>telefone</strong>.</p>');
		return false;
	}
	if ($('#curso').val() == "" || $('#curso').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Qual sua <strong>faculdade ou curso</strong>?</p>');
		return false;
	}
	if ($('#contratacao').val() == "" || $('#contratacao').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Qual forma de <strong>contratação</strong>?</p>');
		return false;
	}
	if ($('#interesse').val() == "" || $('#interesse').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Qual a sua <strong>área de interesse</strong>?</p>');
		return false;
	}
	if ($('#conclusao').val() == "" || $('#conclusao').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Qual a <strong>conclusão</strong> do seu curso?</p>');
		return false;
	}
}
/*=======================================================*/

/*====================================== ORÇAMENTO ONLINE*/
function validaOrcamento(){
	if ($('#nome').val() == "" || $('#nome').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>nome</strong>.</p>');
		return false;
	}
	if ($('#empresa').val() == "" || $('#empresa').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Digite qual <strong>empresa</strong> você trabalha.</p>');
		return false;
	}
	if ($('#email').val() == "" || $('#email').val().length < 4 || $('#email').val().indexOf("@") < 1 ){
		Sexy.error('<h1>Por Favor,</h1><p>Informe seu <strong>e-mail</strong> corretamente.</p>');
		return false;
	}
	if ($('#telefone').val() == "" || $('#telefone').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>telefone</strong>.</p>');
		return false;
	}
	if ($('#indicado').val() == "" || $('#indicado').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Foi <strong>indicado</strong> por quem?</p>');
		return false;
	}
	if ($('#assunto').val() == "" || $('#assunto').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha o <strong>assunto</strong> da mensagem.</p>');
		return false;
	}
	if ($('#mensagem').val() == "" || $('#mensagem').val().length < 4){
		Sexy.error('<h1>Por Favor,</h1><p>Digite sua <strong>mensagem</strong>.</p>');
		return false;
	}
}
/*=======================================================*/

/*=============================================== CONTATO*/
function validaContato(){
	if ($('#nome').val() == "" || $('#nome').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>nome</strong>.</p>');
		return false;
	}
	if ($('#empresa').val() == "" || $('#empresa').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Digite qual <strong>empresa</strong> você trabalha.</p>');
		return false;
	}
	if ($('#email').val() == "" || $('#email').val().length < 4 || $('#email').val().indexOf("@") < 1){
		Sexy.error('<h1>Por Favor,</h1><p>Informe seu <strong>e-mail</strong> corretamente.</p>');
		return false;
	}
	if ($('#telefone').val() == "" || $('#telefone').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha seu <strong>telefone</strong>.</p>');
		return false;
	}
	if ($('#assunto').val() == "" || $('#assunto').val() == ""){
		Sexy.error('<h1>Por Favor,</h1><p>Preencha o <strong>assunto</strong> da mensagem.</p>');
		return false;
	}
	if ($('#mensagem').val() == "" || $('#mensagem').val().length < 4){
		Sexy.error('<h1>Por Favor,</h1><p>Digite sua <strong>mensagem</strong>.</p>');
		return false;
	}
}
/*=======================================================*/

/*======================================= NEWSLETTER HOME*/
function validaNewsletter(){
	if ($('#email').val() == "" || $('#email').val().length < 4 || $('#email').val().indexOf("@") < 1 ){
		Sexy.error('<h1>Por Favor,</h1><p>Informe seu <strong>e-mail</strong> corretamente.</p>');
		return false;
	}else{
		email = $('#email').val();
		$.post('controller/newsletterController.php', {email:email}, function (data) {
			Sexy.alert('<div class="enviado">Enviado com sucesso</div>');
		});
		return false;
	}
}
/*===============================================================================*/



/*======================================================================= OVERLAY*/
$(function() {
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$("a[rel]").overlay({
		mask: '#fff',
		effect: 'apple',

		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
			$('.galleria-thumbnails').width(600);
	  	},
	  	onLoad: function () {
			 $('.galleria-thumbnails').width(600);
		}
    });
});
/*===============================================================================*/



/*======================================================================= OVERLAY*/
$(document).ready(function() {
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$("a[rel]").overlay({
		mask: '#fff',
		effect: 'apple',

		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
	  }
    });
});
