/*-------------------------------------------------
B U I L D I N G L I F E
Author:Fabio Ottaviani - Websolute
-------------------------------------------------*/


/*-------------------------------------------------
followMenu
-------------------------------------------------*/
function followMenu() {
	$menuH = $("#menu").outerHeight();
	$domH = $(window).height();
	$top = $(document).scrollTop();
	spost = Math.floor(6 + $top);
	$("#menu, #ribbon").stop().animate({top:spost},2000,"easeOutQuint");
}


/*-------------------------------------------------
hidden focus
-------------------------------------------------*/
$.fn.hiddenFocus = function() {
	return this.each(function() {
		var $this = $(this);
		$this.focus(function(){
			if ($this.val() == $this.attr("title")) {
				$this.val("");
			}
		}).blur(function(){
			if ($this.val() == "") {
				$this.val($this.attr("title"));
			}
		});
	});
}


/*-------------------------------------------------
scrollToTop
-------------------------------------------------*/
function scrollToTop(){
	alert ("ok");
}


/*-------------------------------------------------
INIT
-------------------------------------------------*/
$(function(){
	followMenu();
	$("#ribbon").height($("#menu").outerHeight());
	$("#searchform input.input").hiddenFocus();
	$(".gallery a").attr("rel","gal").fancybox({"titleShow":false});
	$("a[href$=.jpg],a[href$=.jpeg],a[href$=.png],a[href$=.gif]").fancybox({"titleShow":false});
});


/*-------------------------------------------------
WINDOW EVENTS
-------------------------------------------------*/
$(window).load(function(){followMenu();});
$(window).scroll(function(){followMenu();});
$(window).resize(function(){followMenu();});
