function gotoURL(url){
	document.location = url;
}

function moveCSS(){

	$('.menuButton').click(function(event){
	
	
		//load loading image
		$("#content").children().fadeOut(200);
		
	
		event.preventDefault();
		
		var id = $(this).attr("id");
		var url = $(this).attr('href');
		var leftWidth;
		//var animationCompleted = false;
		var moveDirection = "down";
		var upArray = new Array("chisiamoMenu","prodottiMenu","ispirazioniMenu","storiaMenu","teamMenu","illuminazioneMenu","regaliMenu","showroomMenu","realizzazioniMenu");
		
		for(i=0;i<upArray.length;i++){
			if(id == upArray[i]){
				moveDirection = "up";
			}
		}
						
		if(moveDirection == "up"){ //move up
			if($("#menu").height() < 25){ //if it's to move
				$("#menu").animate({"paddingBottom": "21px"},300,function () {
					if(id != "" && $("#left").width() > 630){//clicked da current section HOME
						leftWidth = "630px";
						$("#left").animate({"width": leftWidth},500);
						$("#right").animate({"marginLeft": leftWidth},500,function () {
							gotoURL(url);
						});
					}
					else{
						gotoURL(url);
					}
				});
			}
			else{
				if(id != "" && $("#left").width() > 630){//clicked da current section HOME
					leftWidth = "630px";
					$("#left").animate({"width": leftWidth},500);
					$("#right").animate({"marginLeft": leftWidth},500,function () {
						gotoURL(url);
					});
				}
				else{
					gotoURL(url);
				}
			}
		}
		else{ //move down
			if($("#menu").height() > 25){ //if it's to move
				$("#localNavigation").animate({"height": "0px","paddingTop": "0px"},300,function() {
					if(id != "" && $("#left").width() > 630){//clicked da current section HOME
						leftWidth = "630px";
						$("#left").animate({"width": leftWidth},500);
						$("#right").animate({"marginLeft": leftWidth},500,function () {
							gotoURL(url);
						});
					}
					else{
						gotoURL(url);
					}
				});
			}
			else{
				if(id != "" && $("#left").width() > 630){//clicked da current section HOME
					leftWidth = "630px";
					$("#left").animate({"width": leftWidth},500);
					$("#right").animate({"marginLeft": leftWidth},500,function () {
						gotoURL(url);
					});
				}
				else{
					gotoURL(url);
				}
			}
		}
		
	});
}

function moveHome(){
	
	$("#left").css({"width": "630px"});
	$("#right").css({"marginLeft": "630px"});

	$("#right").animate({"marginLeft": "658px"},500);
	$("#left").animate({"width": "658px"},500);	
}
