$(document).ready(function(){
		
		
		
		// remove link background images since we're re-doing the hover interaction below 
		// (doing it this way retains the CSS default hover states for non-javascript-enabled browsers)
		// we also want to only remove the image on non-selected nav items, so this is a bit more complicated
		$(".nav").children("li").each(function() {
			var current = "nav current-" + ($(this).attr("class"));
			var parentClass = $(".nav").attr("class");
			if (parentClass != current) {
				$(this).children("a").css({backgroundImage:"none"});
			}
		});	


		// create events for each nav item
		attachNavEvents(".nav", "home");
		attachNavEvents(".nav", "fundo");
		attachNavEvents(".nav", "projects");
		attachNavEvents(".nav", "subscribers");
		attachNavEvents(".nav", "news");
		attachNavEvents(".nav", "downloads");
		attachNavEvents(".nav", "links");
		attachNavEvents(".nav", "newsletter");
		
		function attachNavEvents(parent, myClass) {
			$(parent + " ." + myClass).mouseover(function() {
				$(this).append('<div class="nav-' + myClass + '"></div>');
				$("div.nav-" + myClass).css({display:"none"}).fadeIn(200);
			}).mouseout(function() {
				$("div.nav-" + myClass).fadeOut(200, function() {
					$(this).remove();
				});
			}).mousedown(function() {
				$("div.nav-" + myClass).attr("class", "nav-" + myClass + "-click");
			}).mouseup(function() {
				$("div.nav-" + myClass + "-click").attr("class", "nav-" + myClass);
			});
		}

	
	/* LINKS ON THE RIGHT SIDE */
	$("#kwick_1").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
	
	$("#kwick_2").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
	
	$("#kwick_3").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
	
	$("#kwick_4").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
	
	$("#kwick_5").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
	
	$("#kwick_6").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});


	  $(".actual-projects").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});


 $(".destaques-container").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
 
 
 $(".destaques-container2").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
 
 
 $(".destaques-container-central").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});
  $(".destaques-container-last").click(function(event) {
	  event.preventDefault();
	  var str = $(this).find("a").attr("href");
	  if(str.length > 0){
	  window.location = $(this).find("a").attr("href");
	  }
	});

});
