// Carrega Imagens

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function carrega() {
	MM_preloadImages('images/port2_consultorio.jpg','images/port3_moura.jpg','images/port4_nutripaulos.jpg','images/port5_kfo.jpg');	
}


// Twitter Ápice

(function($) {
	/*
		jquery.twitter.js v1.5
		Last updated: 08 July 2009

		Created by Damien du Toit
		http://coda.co.za/blog/2008/10/26/jquery-plugin-for-twitter

		Licensed under a Creative Commons Attribution-Non-Commercial 3.0 Unported License
		http://creativecommons.org/licenses/by-nc/3.0/
	*/

	$.fn.getTwitter = function(options) {

		$.fn.getTwitter.defaults = {
			userName: "apiceinternet",
			numTweets: 5,
			loaderText: "Loading tweets...",
			slideIn: true,
			slideDuration: 750,
			showHeading: true,
			headingText: "Latest Tweets",
			showProfileLink: true,
			showTimestamp: true
		};

		var o = $.extend({}, $.fn.getTwitter.defaults, options);

		return this.each(function() {
			var c = $(this);

			// hide container element, remove alternative content, and add class
			c.hide().empty().addClass("twitted");


			// add twitter list to container element
			var twitterListHTML = "<ul id=\"twitter_update_list\"><li></li></ul>";
			c.append(twitterListHTML);

			var tl = $("#twitter_update_list");

			// hide twitter list
			tl.hide();

			// add preLoader to container element
			var preLoaderHTML = $("<p class=\"preLoader\">"+o.loaderText+"</p>");
			c.append(preLoaderHTML);

			// add Twitter profile link to container element
			if (o.showProfileLink) {
				var profileLinkHTML = "<p class=\"profileLink\"><a href=\"http://twitter.com/"+o.userName+"\" target='_blank'>Siga-nos no twitter!</a></p>";
				c.append(profileLinkHTML);
			}

			// show container element
			c.show();

			$.getScript("http://twitter.com/javascripts/blogger.js");
			$.getScript("http://twitter.com/statuses/user_timeline/"+o.userName+".json?callback=twitterCallback2&count="+o.numTweets, function() {
				// remove preLoader from container element
				$(preLoaderHTML).remove();

				// remove timestamp and move to title of list item
				if (!o.showTimestamp) {
					tl.find("li").each(function() {
						var timestampHTML = $(this).children("a");
						var timestamp = timestampHTML.html();
						timestampHTML.remove();
						$(this).attr("title", timestamp);
					});
				}

				// show twitter list
				if (o.slideIn) {
					// a fix for the jQuery slide effect
					// Hat-tip: http://blog.pengoworks.com/index.cfm/2009/4/21/Fixing-jQuerys-slideDown-effect-ie-Jumpy-Animation
					var tlHeight = tl.data("originalHeight");

					// get the original height
					if (!tlHeight) {
						tlHeight = tl.show().height();
						tl.data("originalHeight", tlHeight);
						tl.hide().css({height: 0});
					}

					tl.show().animate({height: tlHeight}, o.slideDuration);
				}
				else {
					tl.show();
				}

				// add unique class to first list item
				tl.find("li:first").addClass("firstTweet");

				// add unique class to last list item
				tl.find("li:last").addClass("lastTweet");
			});
		});
	};
})(jQuery);


$(document).ready(function() {
	carrega();
	$("#twitter").getTwitter({
		userName: "apiceinternet",
		numTweets: 3,
		loaderText: "Carregando tweets...",
		slideIn: true,
		slideDuration: 750,
		showHeading: true,
		headingText: "Ultimas do Twitter",
		showProfileLink: true,
		showTimestamp: true
	});
	var Intervalo = setInterval("slidein()", "4000");
});

// slide bg
$(function(){
	$('#bnt_agencia').mouseover(function() {
		$('#menu').css("background-position","0px -50px");
	});
	$('#bnt_solucoes').mouseover(function() {
		$('#menu').css("background-position","0px -100px");
	});
	$('#bnt_orcamento').mouseover(function() {
		$('#menu').css("background-position","0px -150px");
	});
	$('#bnt_trabalhos').mouseover(function() {
		$('#menu').css("background-position","0px -200px");
	});
	$('#bnt_contato').mouseover(function() {
		$('#menu').css("background-position","0px -250px");
	});
	$('#menu').mouseout(function() {
		$('#menu').css("background-position","0px 0px");
	});
							  
	$('.prev').click(function() {		
		bg = $(this).parent().css("background-image");
		bg = bg.split("/");
		ultimo = bg.length - 1;
		bg = bg[ultimo].split(".jpg");
		
		var fundos = new Array();
		fundos[0] = "port7_sorri";
		fundos[1] = "port6_brazildeconcreto";
		fundos[2] = "port1_apoio";
		fundos[3] = "port2_consultorio";
		fundos[4] = "port3_moura";
		
		if (bg[0] == fundos[0]) {
			$(this).parent().css("background","url(images/" + fundos[4] + ".jpg)");	
		}
		if (bg[0] == fundos[1]) {
			$(this).parent().css("background","url(images/" + fundos[0] + ".jpg)");	
		}
		if (bg[0] == fundos[2]) {
			$(this).parent().css("background","url(images/" + fundos[1] + ".jpg)");	
		}
		if (bg[0] == fundos[3]) {
			$(this).parent().css("background","url(images/" + fundos[2] + ".jpg)");	
		}
		if (bg[0] == fundos[4]) {
			$(this).parent().css("background","url(images/" + fundos[3] + ".jpg)");	
		}
	});

	$('.next').click(function() {		
		bg = $(this).parent().css("background-image");
		bg = bg.split("/");
		ultimo = bg.length - 1;
		bg = bg[ultimo].split(".jpg");
		
		var fundos = new Array();
		fundos[0] = "port7_sorri";
		fundos[1] = "port6_brazildeconcreto";
		fundos[2] = "port1_apoio";
		fundos[3] = "port2_consultorio";
		fundos[4] = "port3_moura";
		
		if (bg[0] == fundos[0]) {
			$(this).parent().css("background","url(images/" + fundos[1] + ".jpg)");
		}
		if (bg[0] == fundos[1]) {
			$(this).parent().css("background","url(images/" + fundos[2] + ".jpg)");	
		}
		if (bg[0] == fundos[2]) {
			$(this).parent().css("background","url(images/" + fundos[3] + ".jpg)");	
		}
		if (bg[0] == fundos[3]) {
			$(this).parent().css("background","url(images/" + fundos[4] + ".jpg)");	
		}
		if (bg[0] == fundos[4]) {
			$(this).parent().css("background","url(images/" + fundos[0] + ".jpg)");	
		}
	});
});

function slidein(){
    bg = $('.dircli').css("background-image");
	bg = bg.split("/");
	ultimo = bg.length - 1;
	bg = bg[ultimo].split(".jpg");
	
	var fundos = new Array();
	fundos[0] = "port7_sorri";
	fundos[1] = "port6_brazildeconcreto";
	fundos[2] = "port1_apoio";
	fundos[3] = "port2_consultorio";
	fundos[4] = "port3_moura";
	
	if (bg[0] == fundos[0]) {
		$('.dircli').css("background","url(images/" + fundos[1] + ".jpg)");
	}
	if (bg[0] == fundos[1]) {
		$('.dircli').css("background","url(images/" + fundos[2] + ".jpg)");	
	}
	if (bg[0] == fundos[2]) {
		$('.dircli').css("background","url(images/" + fundos[3] + ".jpg)");	
	}
	if (bg[0] == fundos[3]) {
		$('.dircli').css("background","url(images/" + fundos[4] + ".jpg)");	
	}
	if (bg[0] == fundos[4]) {
		$('.dircli').css("background","url(images/" + fundos[0] + ".jpg)");	
	}
}
