$(document).ready(function(){
	$("ul#menu li p").hide();
	$("div#performare").hide();
	$("div#formazione").hide();
	
	var b=$(".boxMenu");
	b.hide();
	jQuery("ul#menu li a img").hover(
		function(){
			this.src = this.src.replace("Off","On");
		},
		function(){
			this.src = this.src.replace("On","Off");
		}
	);
	
	$('ul#menu > li.more > a').click(function(e){
		e.preventDefault();
		var d=$(this).get(0).href.split("#")[1];
		var f=$("#"+d);
		
		f.siblings('div').hide();
		$(this).parent().addClass('mouseclick');
		
    	if(f.is(":visible")){
			f.hide();
			$(this).parent().removeClass('mouseclick');
		}else{
			f.slideDown('1500');
		}
  	}).mouseover(function(e) {
		e.preventDefault();
		$(this).parent().addClass("mouseover");
	}).mouseout(function(e) {
		e.preventDefault();
		$(this).parent().removeClass("mouseover");
	});
	$("#anagrafica").fancybox({
		'width'				: 420,
		'height'			: 210,
		'padding'			: 0,
		'centerOnScroll'	: true,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	$(".info").fancybox({
		'width'				: 590,
		'height'			: 400,
		'padding'			: 0,
		'centerOnScroll'	: true,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	$(".login").fancybox({
		'width'				: 305,
		'height'			: 280,
		'padding'			: 0,
		'centerOnScroll'	: true,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'onClosed'			: function() {
	    	self.location.reload()
		}
	});
	$('input[type="text"],input[type="select"]').focus(function() {
        if (this.value == this.defaultValue){this.value = '';}
        if(this.value != this.defaultValue){this.select();}
    });
	$('input[type="text"],input[type="select"]').blur(function() {
        if(this.value == '') {this.value = this.defaultValue;}
    });
	$("#logout").live('click', function(e){
		e.preventDefault();
		$.ajax({
			type: "POST",
			url: "/logout.php",
			success: self.location.reload()
		});
	}); 
	Cufon(['ul#utility > li a'], {fontFamily: 'HelveticaNeue Medium',textShadow: '0px 1px white',hover: {color: '#000000',textShadow: '0px 1px white'}});
	Cufon(['span.medium'], {fontFamily: 'HelveticaNeue Medium',textShadow: '0px 1px white',hover: {color: '#000000',textShadow: '0px 1px white'}});
	Cufon(['span.light'], {fontFamily: 'HelveticaNeue Light',textShadow: '0px 1px white'});
});
function popUp(url,name,width,height){
 	if (document.all){
    	var x = window.screenLeft;
      	var y = window.screenTop;
      	var w = window.document.body.offsetWidth;
      	var h = window.document.body.offsetHeight;
 	} else {
   		var x = window.screenX;
   		var y = window.screenY;
   		var w = window.outerWidth;
   		var h = window.outerHeight;
 	}
 	var cntx = x + Math.round((w - width) / 2);
 	var cnty = y + Math.round((h - height) / 2);
 	var aa = window.open (url, name, 'resizable=yes,scrollbars=yes,left=' + cntx + ',top=' + cnty + ',width=' + width + ',height=' + height);
}
