// JavaScript Document
var SITE = "http://"+window.location.host;//"http://www.twiser.com.br";
//alert(SITE)
function clear_form_elements(ele) {
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}

		function natal(){	
			//alert('teste');
			$(document).ready(function(){
				$('.natal2').html('');			
			});
		};
		
$.easing.custom = function (x, t, b, c, d) {
	var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}

$(document).ready(function(){

	$("#tooltip_cont").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
	$("#tooltip_marketing").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
	$("#tooltip_consultoria").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
		$("#tooltip_share").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
		$("#tooltip_com").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
		$("#tooltip_midias").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
		
        $("#tooltip_port").tooltip({
		effect: 'slide',
		offset: [0, 55],
		position: 'bottom center',
		relative: true
		
		});
		
		$(".tool_news2").tooltip({ position: "bottom left", opacity: 0.7});
	
	
	$('.menu li').hover(function(){
		$(this).removeClass('menu_int');
		$(this).addClass('menu_intH');
	},function(){
		$(this).removeClass('menu_intH');
		$(this).addClass('menu_int');
	});
	
	$(".menu li a").each(function() { 
		if(this.href == window.location){
			$(this).parent().removeClass('menu_int');
			$(this).parent().addClass('menu_intH1');
		}
	});
	
	$('#browsable').scrollable({
		circular: true,
		easing: 'custom',
		speed: 800		
		}).navigator().autoscroll({interval: 3000});
	
	$("#indi_tip").tooltip({
		tipClass: 'tool_news3',
		offset: [0, -10],
		position: 'bottom center',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});	
	$("#cont_tip").tooltip({
		tipClass: 'tool_news',
		offset: [0, 10],
		position: 'bottom center',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});
	$("#cont_tip1").tooltip({
		tipClass: 'tool_news1',
		offset: [15, 40],
		position: 'bottom center',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});
	$('.btn_close').click(function(){
		$('.tool_news').css('display','none');
		
	});
	$('.btn_close1').click(function(){
		$('.tool_news1').css('display','none');
	});
	$('.btn_close2').click(function(){
		$('.tool_news3').css('display','none');
		clear_form_elements('#Findique')
		//$('#Findique').reset();
	});
	$('#cont_tip').click(function(){
		$('.tool_news').css('display','block');
	});		
	$('#cont_tip1').click(function(){
		$('.tool_news1').css('display','block');
	});		
	$('#indi_tip').click(function(){
		$('.tool_news3').css('display','block');
	});		
	
	



	$("#chained").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({
	interval: 3000		
});



    $('.contPortiCaixa a, .boxPortfolioImgLupa a').live('click',function(event){
        $.ajax({
            type: "get",
            data: "acao=anterior&id="+this.rev,
            url: SITE + "/ajax.php",
            dataType: 'html',
            success: function(valor){
                $('#up').html(valor);
                $('#up').show();
                return true;
            }
        });
        event.preventDefault(event);
        return false;
    });	
    $('.boxPortfolioImg a').live('click',function(event){
        $.ajax({
            type: "get",
            data: "acao=anterior&id="+this.rev,
            url: SITE + "/ajax.php",
            dataType: 'html',
            success: function(valor){
                $('#up').html(valor);
                $('#up').show();
                return true;
            }
        });
        event.preventDefault(event);
        return false;
    });	
	////////////////////////////////////////////////////////////
	//							Indique						  //
	////////////////////////////////////////////////////////////
	$('#Findique').submit(function(event){
    
    
            var dados = $('#Findique').serialize();
            $('#formulario-contato .bt-submit').val('Enviando...');
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=indique&" + dados,
                url: SITE + "/proc_foot.php",
                dataType: "html",
                success: function(valor){
                    // Preenche a tabela com os dados
					$('#campo_email_indique').html(valor);
					clear_form_elements('#Findique');
                    return true;
					
                }
            });
        return false;
		clear_form_elements('#Findique')
    });
	
	$('#feedback').submit(function(event){
    
    
            var dados = $('#feedback').serialize();
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=feedback&" + dados,
                url: SITE + "/proc_foot.php",
                dataType: "html",
                success: function(valor){
                    // Preenche a tabela com os dados
					$('#retornoF').html(valor);
                    return true;
					
                }
            });
        return false;
    });
	////////////////////////////////////////////////////////////
	//					  	 Contato     					  //
	////////////////////////////////////////////////////////////
	$('#Fcontato').submit(function(event){
    
    
            var dados = $('#Fcontato').serialize();
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=contato&" + dados,
                url: SITE + "/proc_foot.php",
                dataType: "html",
                success: function(valor){
                    // Preenche a tabela com os dados
					$('#contato_site').html(valor);
					clear_form_elements('#Fcontato');
                    return true;
                }
            });
        
        
        return false;
        
    });
	////////////////////////////////////////////////////////////
	//						Newsletter						  //
	////////////////////////////////////////////////////////////
	$('#Fcontato2').submit(function(event){
    
    
            var dados = $('#Fcontato2').serialize();
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=contato2&" + dados,
                url: SITE + "/proc_foot.php",
                dataType: "html",
                success: function(valor){
                    // Preenche a tabela com os dados
					$('#contato_site2').html(valor);
					clear_form_elements('#Fcontato2');
                    return true;
                }
            });
        
        
        return false;
        
    });
	////////////////////////////////////////////////////////////
	//					Fim	Newsletter						  //
	////////////////////////////////////////////////////////////
	var triggers = $(".overlay").overlay({
	
		// some mask tweaks suitable for modal dialogs
		mask: {
			color: '#000',
			opacity: 0.8
		},	
		closeOnClick: true
	});
	
	$('.contPortiCaixa a').click(function(){
		window.location = this.href;
	});
	
	 $('#feedback').feedback();
	 
	 
});
