/*
 * Speech bubble script
 *
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Cvitković with help from Ivan Nikolić
 * 
 */

$('h1').hover(function(e){show_baloon("I usually respond if you call me like this.", "talk", 2000, e)});
$('h2').hover(function(e){show_baloon("Sorry, it has to be perfect.", "smile", 2000, e)});
$('#social_left').hover(function(e){show_baloon("Are you gonna be my stalker on Twitter?", "left", 1200, e)});
$('#social_right').hover(function(e){show_baloon("Send me love or hate mails. Don't even think about spam.", "right", 1200, e)});
$('#face').hover(function(e){show_baloon("U can't touch this, that's my head, stop! Hammer time...", "angry", 2000, e)});

var exit = "Noooo... Don't leave me alone...";
var intro = "Hello my dear visitor! I'm Alen and don't try to touch my head.";
var to;var checker;function show_baloon(tl,face,time,e){if(e.type=='mouseenter'){clearTimeout(to);if($('#baloon').length==0){$("#content").append("<div id='baloon'><p>"+tl+"</p></div>")}else{$('#baloon').find('p').html(tl)}$("#baloon").css("top",-74+"px").css("left",506+"px").fadeIn("fast");$("#face").removeClass().toggleClass(face,true)}else if(e.type=='mouseleave'){to=setTimeout(function(){$("#baloon").fadeOut(200,function(){$(this).remove()});$("#face").removeClass().toggleClass("normal",true)},time)}}$("body").hover(function(e){if(e.pageY<20&&checker==true){if($('#baloon').length==0){$("#content").append("<div id='baloon'><p>"+exit+"</p></div>")}else{$('#baloon').find('p').html(exit)}$("#baloon").css("top",-74+"px").css("left",506+"px").fadeIn("fast");$("#face").removeClass().toggleClass("sad",true)}clearTimeout(to);to=setTimeout(function(){$("#baloon").fadeOut(200,function(){$(this).remove()});$("#face").removeClass().toggleClass("normal",true)},5000)});$(document).ready(function(){$("#content").append("<div id='baloon'><p>"+intro+"</p></div>");$("#baloon").css("top",-74+"px").css("left",506+"px").fadeIn("slow");$("#face").removeClass().toggleClass("smile",true);clearTimeout(to);to=setTimeout(function(){$("#baloon").fadeOut(50,function(){$(this).remove()});$("#face").removeClass().toggleClass("normal",true)},5000);setTimeout(function(){checker=true},3000)});
