﻿// -------------- autofill
function autoFill(id,v,colbefore,colafter){$(id).css({color:colbefore}).attr({value:v}).focus(function(){if($(this).val()==v){$(this).val("").css({color:colafter});}}).blur(function(){if($(this).val()==""){$(this).css({color:colbefore}).val(v);}});}
// -------------- headers
jQuery(function(){jQuery("#lateral .cliente").hover(function(){jQuery(this).animate({marginLeft:"20px"},250);},function(){jQuery(this).stop().animate({marginLeft:"0px"},250);});jQuery("#lateral .sub-cliente").hover(function(){jQuery(this).animate({marginLeft:"40px"},250);},function(){jQuery(this).stop().animate({marginLeft:"20px"},250);});jQuery(".ferramentas ul li").hover(function(){jQuery(this).animate({marginTop:"-4px"},250);},function(){jQuery(this).animate({marginTop:"0px"},250);});jQuery("#lateral h3 ").hover(function(){jQuery(this).animate({marginLeft:"10px"},250);},function(){jQuery(this).animate({marginLeft:"0px"},250);});});
// -------------- ready
$(document).ready(function(){
$(document).pngFix();
// -------------- flash
var myFile=document.location.toString();
if(myFile.match("empresa")||myFile.match("equipe")||myFile.match("contato")||myFile.match("clientes")||myFile.match("releases")){var int="../"}else{var int=""}
$('#logo-fla').flash({src: int+'logo.swf',wmode: 'transparent',width: 280,height: 319},{menu:false,version: '9.0.24'});
$('#menu').flash({src: int+'menu.swf',wmode: 'transparent',width: 702,height: 60},{version: '9.0.24'});
$('#slogan').flash({src: int+'slogan.swf',wmode: 'transparent',width: 720,height: 302},{version: '9.0.24'});
// -------------- busca
autoFill($("#search"),"digite sua busca","#FCC4C4","#FFF");autoFill($(".searchi"),"faça sua busca por releases","#2E6173","#B70604");
// -------------- clientes
$(".cliente_img").fadeTo("slow", 0.5);
$(".cliente_img").hover(function(){
$(this).fadeTo("slow", 1.0);
},function(){
$(this).fadeTo("slow", 0.5);
});
// -------------- ferramentas
$('a#print').click(function() {
	window.print();
	return false;
});
$("#ico-indica").colorbox({iframe:true,width:530,height:400,opacity:0.60,close:'fechar'});
// -------------- Reset Font Size
var originalFontSize = $('#texto').css('font-size');
  $(".resetFont").click(function(){
  $('#texto').css('font-size', originalFontSize);
});
// -------------- Increase Font Size
$("#increaseFont").click(function(){
  var currentFontSize = $('#texto').css('font-size');
  var currentFontSizeNum = parseFloat(currentFontSize, 10);
  var newFontSize = currentFontSizeNum*1.2;
  $('#texto').css('font-size', newFontSize);
  return false;
});
// -------------- Decrease Font Size
$("#decreaseFont").click(function(){
  var currentFontSize = $('#texto').css('font-size');
  var currentFontSizeNum = parseFloat(currentFontSize, 10);
  var newFontSize = currentFontSizeNum*0.8;
  $('#texto').css('font-size', newFontSize);
  return false;
});
// -------------- icons
$(".fadeThis").hover(function(){
$(this).fadeTo("slow", 0.5);
},function(){
$(this).fadeTo("slow", 1.0);
});
// -------------- slide
$('.backtotop').click(function(){
	$.scrollTo(0, 'slow', {} );
	return false;
});
// -------------- contato
$('#submit').click(function () {
	var hasError = false;
	var namec = $("#namec").val();
	var emailc = $("#emailc").val();
	var fonec = $("#fonec").val();
	var commentc = $("#commentc").val();
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	
	if(namec == '') {
	$("#namec").addClass('hightlight');
	$('#namec').attr('title','Inclua seu nome');
	hasError = true;
	} else {$("#namec").removeClass('hightlight');
	$('#namec').removeAttr('title');}
	if(fonec == '') {
	$("#fonec").addClass('hightlight');
	$("#fonec").attr('title','Inclua seu telefone');
	hasError = true;
	} else {$("#fonec").removeClass('hightlight');
	$('#fonec').removeAttr('title');}
	if(commentc == '') {
	$("#commentc").addClass('hightlight');
	$("#commentc").attr('title','Faltou a sua mensagem');
	hasError = true;
	} else {$("#commentc").removeClass('hightlight');
	$('#commentc').removeAttr('title');}
	if(!emailReg.test(emailc) || emailc == '') {
	$("#emailc").addClass('hightlight');
	$("#emailc").attr('title','Coloque corretamente seu e-mail');
	hasError = true;
	} else {$("#emailc").removeClass('hightlight');
	$('#emailc').removeAttr('title');}
						   
	if(hasError == false) {
	var data = $('#formc').serialize();
	$('.text,#submit').attr('disabled','true');	
	$('.loading').show();	
	$.ajax({
		url: "process.asp",			
		type: "POST",
		data: data,		
		cache: false,
		success: function (html) {			
			if (html=="Mensagem Enviada") {					
				$('#box-form').slideUp('slow');
				setTimeout(function(){$('#form-ok').fadeIn('slow');},200);
				$('#form-erro').hide();
			} else {
			$('.text,.submit').removeAttr("disabled")
			$('#box-form').slideUp('slow');
			setTimeout(function(){$('#form-erro').fadeIn('slow');},200);
			$('.loading').hide();}
		}		
	});}	
	return false;
});	
$('#form-again').click(function () {
	$('#form-erro').slideUp('slow');
	setTimeout(function(){$('#box-form').slideDown('slow');},1000);
	return false;
});


});