
function sendWindowForm( divForm, _form ){
	divResp = 'emailResponse'+divForm;
	
		//if($('#'+divResp).length < 1){
			//$('#'+_form).append('<div id="'+divResp+'" class="emailResponse"><div id="emailResponseMsg">Enviando...</div></div>');
		//}
		_form = $('#'+_form);
		$.ajax({
					  url: 'http://www.energiaitajai.com.br/_Request/',
					  data: _form.serialize(),
					  dataType: 'json',
					  cache: false,
					  type: 'POST',
					  complete: function(resposta) {
						  try
							{
								res = jQuery.parseJSON( resposta.responseText );
								
								if(res.status == 'ok'){
									
									if(res.mensagem){
										$("body").append('<div id="dialog">'+res.mensagem+'</div>');
										$("#dialog").dialog({
													modal: true,
													buttons: {
														Ok: function() {
															$(this).dialog('destroy');
															$("#dialog").remove();
														}
													}
												});
									}else{
										$("body").append('<div id="dialog">'+res.erro+'</div>');
										$("#dialog").dialog({
													modal: true,
													buttons: {
														Ok: function() {
															$(this).dialog('destroy');
															$("#dialog").remove();
														}
													}
												});
									}
									if(res.script)
										eval(res.script);
								}else{
										$("body").append('<div id="dialog">'+res.mensagem+'</div>');
										$("#dialog").dialog({
													modal: true,
													buttons: {
														Ok: function() {
															$(this).dialog('destroy');
															$("#dialog").remove();
														}
													}
												});
								}
							}
							catch(e)
							{
							  $("body").append('<div id="dialog">'+resposta.responseText+'</div>');
							  $("#dialog").dialog({
										  modal: true,
										  buttons: {
											  Ok: function() {
												  $(this).dialog('destroy');
												  $("#dialog").remove();
											  }
										  }
									  });
							}
					  }
			});
		
	return false;
}

$(document).ready(function() {
			$("a.imgZoom").fancybox({
				'type'				: 'image',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Imagem: ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			$("a.ajaxZoom").fancybox({
				'type'				: 'ajax'
			});
			
			$("ul.youtube").ytplaylist({addThumbs:true, playerHeight: 365, autoPlay: false, holderId: 'ytvideo', thumbSize: 'large'});

			$('input:text').setMask();
			
			$(".catPlus").click(function(){
										 $(this).next('ul').slideToggle(300);
										 });
			
			
			$(".boxUn a").click(function(){
										 event.preventDefault();
										 $(this).parent().toggleClass('ativo');
										 });
			
			$("a[href="+window.location+"]").parent().parent().show()
			$("a[href="+window.location+"]").addClass('current');
			$("a[href="+window.location+"]").next().next().toggle();
			
			
			$( "#tabs" ).tabs();
			
			$("#cadastreseForm").validate();
			$("#formularioForm").validate({
				rules: { 
						senha: { 
							required: false, 
							minlength: 5 
						}, 
						confirmacao: { 
							required: false, 
							minlength: 5, 
							equalTo: "#senha" 
						}, 
//						email: { 
//							required: true, 
//							email: true, 
//							remote: "emails.php" 
//						},
						nome: {
						  required: "#pessoaFisica:checked"
						},
						cpf: {
						  required: "#pessoaFisica:checked"
						},
						rg: {
						  required: "#pessoaFisica:checked"
						},
						razao_social: {
						  required: "#pessoaJuridica:checked"
						},
						cnpj: {
						  required: "#pessoaJuridica:checked"
						}
					}, 
				messages: {
					cpf: "Este campo &eacute; obrigat&oacute;rio.",
					telefone: "Este campo &eacute; obrigat&oacute;rio.",
					endereco: "Este campo &eacute; obrigat&oacute;rio.",
					numero: "Este campo &eacute; obrigat&oacute;rio.",
					remote: "Please fix this field.",
					email: "Este e-mail n&atilde;o &eacute; v&aacute;lido.",
					url: "Please enter a valid URL.",
					date: "Please enter a valid date.",
					dateISO: "Please enter a valid date (ISO).",
					dateDE: "Bitte geben Sie ein gültiges Datum ein.",
					number: "Please enter a valid number.",
					numberDE: "Bitte geben Sie eine Nummer ein.",
					digits: "Please enter only digits",
					creditcard: "Please enter a valid credit card number.",
					equalTo: "Digite igual ao campo Senha.",
					accept: "Please enter a value with a valid extension."
				}
			});
			$('#spotBannerInner').nivoSlider({
				effect: 'fade',
				animSpeed:300,
				controlNav: false,// Slide transition speed
				pauseTime:7000, // How long each slide will show
				captionOpacity:1,
				directionNav: false
			});
			$('#banner').nivoSlider({
				animSpeed:500, // Slide transition speed
				pauseTime:6000, // How long each slide will show
				captionOpacity:1 // Universal caption opacity
			});
			$('#bannerSec').nivoSlider({
				effect: 'sliceDown',
				animSpeed:300,
				controlNav: false,// Slide transition speed
				pauseTime:3000, // How long each slide will show
				captionOpacity:1,
				directionNav: false
			});
			$('#spotMenu').nivoSlider({
				effect: 'sliceDown',
				animSpeed:300,
				controlNav: false,// Slide transition speed
				pauseTime:3000, // How long each slide will show
				captionOpacity:1,
				directionNav: false
			});
			$('#acontece').nivoSlider({
				effect: 'fade',
				animSpeed:300,
				pauseTime:10000, // How long each slide will show
				captionOpacity:0.8,
				controlNavThumbs:true,
				controlNavThumbsFromRel:true,
				directionNav: false
			});
			
	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	}
)


