$(document).ready(function() {
	$("#enviaForm").click(function(){
		$(this).hide("slow");
		// load the contact form using ajax
		$.post("fale.php", {nome: $("#name").val(), email: $("#email").val(), msg: $("#message").val()}, function(data){
			alert(data);
			if(data == "Obrigado pelo contato! Seu e-mail foi enviado com sucesso!"){
				$("#contatoForm").hide("slow");
				$("#name").val("");
				$("#email").val("");
				$("#message").val("");
			}
			$("#enviaForm").show("slow");
		});
	});
	
	$("#faleConoscoInfo").click(function(){
		$("#contatoForm").slideToggle("slow");
	});
	
	$('#promos').cycle({ 
	     fx:     'fade', 
		 speed:   500, 
		 timeout: 9000, 
		 pause:   1 
	});
	
	$("#fecharBannerMaior, #fecharTextoBannerMaior, #fecharTextoBannerMaior2").click(function(){
		$("#bannerMaior").slideUp();
	});

        $("#eadIMG").click(function(){
            $("#bannerMaior").slideDown();
        })

	$("#bannerLink").click(function(){
		$("#textoBannerMaior").fadeIn("slow");
		$("#bannerMaior").fadeOut("slow");
	});
	
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.webs.com/jQuery.ScrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	var target = $('#content').get(0);//the scrolled div
	
	/**
	 * restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 */
	target.scrollLeft = target.scrollTop = 0;
	
	//scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: target, //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1500
	});
	
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: In the former version of the demo, I called $('#navigation').localScroll()
	 * Now I want to also affect the >> and << links, so I'll use $.localScroll() instead
	 */
	$.localScroll({
		target: target, //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
	
	fixedMenuId = 'fixeddiv';   
  
	var fixedMenu =
	{   
	    hasInner: typeof(window.innerWidth) == 'number',   
	    hasElement: document.documentElement != null  
	       && document.documentElement.clientWidth,   
	  
	    menu: document.getElementById   
	        ? document.getElementById(fixedMenuId)   
	        : document.all   
	          ? document.all[fixedMenuId]   
	          : document.layers[fixedMenuId]   
	};   
	  
	fixedMenu.computeShifts = function()   
	{   
	    fixedMenu.shiftX = fixedMenu.hasInner   
	        ? pageXOffset   
	        : fixedMenu.hasElement   
	          ? document.documentElement.scrollLeft   
	          : document.body.scrollLeft;   
	    if (fixedMenu.targetLeft > 0)   
	        fixedMenu.shiftX += fixedMenu.targetLeft;   
	    else  
	    {   
	        fixedMenu.shiftX +=    
	            (fixedMenu.hasElement   
	              ? document.documentElement.clientWidth   
	              : fixedMenu.hasInner   
	                ? window.innerWidth - 20   
	                : document.body.clientWidth)   
	            - fixedMenu.targetRight   
	            - fixedMenu.menu.offsetWidth;   
	    }   
	  
	    fixedMenu.shiftY = fixedMenu.hasInner   
	        ? pageYOffset   
	        : fixedMenu.hasElement   
	          ? document.documentElement.scrollTop   
	          : document.body.scrollTop;   
	    if (fixedMenu.targetTop > 0)   
	        fixedMenu.shiftY += fixedMenu.targetTop;   
	    else  
	    {   
	        fixedMenu.shiftY +=    
	            (fixedMenu.hasElement   
	            ? document.documentElement.clientHeight   
	            : fixedMenu.hasInner   
	              ? window.innerHeight - 20   
	              : document.body.clientHeight)   
	            - fixedMenu.targetBottom   
	            - fixedMenu.menu.offsetHeight;   
	    }   
	};   
	  
	fixedMenu.moveMenu = function()   
	{   
	    fixedMenu.computeShifts();   
	  
	    if (fixedMenu.currentX != fixedMenu.shiftX   
	        || fixedMenu.currentY != fixedMenu.shiftY)   
	    {   
	        fixedMenu.currentX = fixedMenu.shiftX;   
	        fixedMenu.currentY = fixedMenu.shiftY;   
	  
	        if (document.layers)   
	        {   
	            fixedMenu.menu.left = fixedMenu.currentX;   
	            fixedMenu.menu.top = fixedMenu.currentY;   
	        }   
	        else  
	        {   
	            fixedMenu.menu.style.left = fixedMenu.currentX + 'px';
	            fixedMenu.menu.style.top = fixedMenu.currentY + 'px';
	        }   
	    }   
	  
	    fixedMenu.menu.style.right = '';   
	    fixedMenu.menu.style.bottom = '';   
	};   
	  
	fixedMenu.floatMenu = function()   
	{   
	    fixedMenu.moveMenu();   
	    setTimeout('fixedMenu.floatMenu()', 20);   
	};   
	  
	// addEvent designed by Aaron Moore   
	fixedMenu.addEvent = function(element, listener, handler)   
	{   
	    if(typeof element[listener] != 'function' ||    
	       typeof element[listener + '_num'] == 'undefined')   
	    {   
	        element[listener + '_num'] = 0;   
	        if (typeof element[listener] == 'function')   
	        {   
	            element[listener + 0] = element[listener];   
	            element[listener + '_num']++;   
	        }   
	        element[listener] = function(e)   
	        {   
	            var r = true;   
	            e = (e) ? e : window.event;   
	            for(var i = 0; i < element[listener + '_num']; i++)   
	                if(element[listener + i](e) === false)   
	                    r = false;   
	            return r;   
	        }   
	    }   
	  
	    //if handler is not already stored, assign it   
	    for(var i = 0; i < element[listener + '_num']; i++)   
	        if(element[listener + i] == handler)   
	            return;   
	    element[listener + element[listener + '_num']] = handler;   
	    element[listener + '_num']++;   
	};   
	  
	fixedMenu.supportsFixed = function()   
	{   
	    var testDiv = document.createElement("div");   
	    testDiv.id = "testingPositionFixed";   
	    testDiv.style.position = "fixed";   
	    testDiv.style.top = "0px";   
	    testDiv.style.right = "0px";   
	    document.body.appendChild(testDiv);   
	    var offset = 1;   
	    if (typeof testDiv.offsetTop == "number"  
	        && testDiv.offsetTop != null    
	        && testDiv.offsetTop != "undefined")   
	    {   
	        offset = parseInt(testDiv.offsetTop);   
	    }   
	    if (offset == 0)   
	    {   
	        return true;   
	    }   
	  
	    return false;   
	};   
	  
	fixedMenu.init = function()   
	{   
	    if (fixedMenu.supportsFixed())   
	        fixedMenu.menu.style.position = "fixed";   
	    else  
	    {   
	        var ob =    
	            document.layers    
	            ? fixedMenu.menu    
	            : fixedMenu.menu.style;   
	  
	        fixedMenu.targetLeft = parseInt(ob.left);   
	        fixedMenu.targetTop = parseInt(ob.top);   
	        fixedMenu.targetRight = parseInt(ob.right);   
	        fixedMenu.targetBottom = parseInt(ob.bottom);   
	  
	        if (document.layers)   
	        {   
	            menu.left = 0;   
	            menu.top = 0;   
	        }   
	        fixedMenu.addEvent(window, 'onscroll', fixedMenu.moveMenu);   
	        fixedMenu.floatMenu();   
	    }   
	};   
  
	fixedMenu.init();

  

});

function clearForm(form) {
$(':input', form).each(function() {
  var type = this.type;
  var tag = this.tagName.toLowerCase(); // normalize case
  if (type == 'text' || type == 'password' || tag == 'textarea')
    this.value = "";
  else if (type == 'checkbox' || type == 'radio')
    this.checked = false;
  else if (tag == 'select')
    this.selectedIndex = -1;
});
};

