$(document).ready(function(){
	/**
	 * Fancybox tooltips
	 */
	$("a.lightview").fancybox({
		titleShow: false
	});
	
	/**
	 * expand/collapse dropdown menu
	 */
	$(".menu li:has(ul)").hover(
		function(){$(this).addClass("hover").find("ul").stop(true, true).show()},//slideDown()},
		function(){$(this).removeClass("hover").find("ul").hide();}//slideUp("fast")}
	);
	
	/**
	 * Carousel of our clients
	 */
	$(".caruselclients").jCarouselLite({
		btnNext: '.next',
		btnPrev: '.prev',
		visible: 1,
		scroll: 1, 
		auto: 4500,
		speed: 500
	});
	
	
	/**
	 * Clear on focus using label-positioning
	 */
	$('#form-ob .form-text, .user-login #user-login-form .form-text')
	.each(function(){
		if ( $(this).val() != '' ) $(this).prev().css('top', '-9999px');
	})
	.focus(function(){
		clean($(this));
	})
	.find('label').click(function(){
		clean($(this).next());
	});
	
	
	/**
	 * Expand/collapse project bar
	 */
	$("#new_projects p").click(
		function(){
			$("#new_projects p").toggle();
			$("#new_projects ul").toggle();
		}
	);
	
	
	
});

/**
 * Visual hidding labels
 */
function clean(i) {
	l = i.prev();
	if ( !i.extended ) {
	i.blur(function(){
	if ( i.val() == '' ) l.css('top', '');
	})
	i.extended = true;
	}
	l.css('top', '-9999px')
}
