//Document Ready Main Function 
$(document).ready(function(){
	//Tooltips for Top Menu
	$("#startseite").append("<em></em>");
	$("#dienstleistungen").append("<em style=\"margin-left:28px;\"></em>");
	$("#schritte").append("<em style=\"margin-left:14px;\"></em>");
	$("#kontakt").append("<em></em>");
	$(".menu2 a").hover(function() {
		$(this).find("em").animate({opacity: "show", top: "-40"}, "slow");
		var hoverText = $(this).attr("title");
	    $(this).find("em").text(hoverText);
	}, function() {
		$(this).find("em").animate({opacity: "hide", top: "-50"}, "fast");
	});   
	//Slider for Social Network Feed
	$(".btn-slide").click(function(){
		$("#panel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	//Twitter aufrufen
    $('#twitter').twitter('80GradNord');  
});
//Bottomslider for Customer Reviews
$(function() {
	$('#kunden').tabs({ fx: [{opacity:'toggle', duration:'slow'},{opacity:'toggle', duration:'fast'}] }).tabs('rotate', 4000);
});


//JQuery Twitter Feed
(function($){
	$.fn.twitter = function(username,options){
		if (username){
			var defaultSettings = {
				count:'1'
			}
			var settings = $.extend(defaultSettings, options);
			var url = "http://twitter.com/status/user_timeline/"+username+".json?count="+settings.count+"&include_rts=true&callback=?";
			var holder = this;
			$.getJSON(url, function(data){
							$.each(data, function(i, item) {
								holder.append("<p style=\"font-size:32px; color:#c8dcea;\"><a href=\"http://www.twitter.com/80GradNord/\" target=\"_blank\">"+item.text.makeLinks()+"</a></p>");
								});
			});
		}else{
			console.debug("Der Username fehlt, Vollidiot!");
		}
		String.prototype.makeLinks = function() {
			return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(str) {
				return str.link(str);
			});
		}; 
	return this;
	};	
})(jQuery);


