$().ready(function(){
	$("div.download .rightContent .fl p").addClass("bigP");
	$("div.team .rightContent p").addClass("bigP");
	$("div.progettiCaseStudies .rightContent p").addClass("bigP");
	
	var navbar = $("#mynavbar").data("article");
	$("#mynavbar li[data-article='"+navbar+"']").addClass("active");
	//news accordion
	if($('.newsWidget').length){
		$('.newsWidget article h3,.newsWidget article p').css({display:'none'})
		$('.newsWidget time').stop(true,true).toggle(
				function(){
					$(this).next('.newsWidget article h3').slideDown().next().slideDown();
				},
				function(){
					$(this).next('.newsWidget article h3').slideUp().next().slideUp();
				}
			)
		}
	if($('#allegaCV').length){
		$("#allegaCV").fileinput({
			buttonText: "ALLEGA CV"
		});
	}

	if($('.newsScroll').length){
		$('.newsScroll').marquee({
			speed : 1,
			draggable : true,
			clsDrag : 'onDrag',
			enableCookie : false,
			enableScroll : true,
			stepScroll : 1,
			enableAnimateScroll : true,
			animateScrollDuration : 550,
			animateScrollEasing : 'linear'
		});
	}
	//case studies menu
	if($('.caseStudiesWidget').length){
	//with active class you can show the submenu
	$('.secondaryLevel:not(ul.active)').css({display:'none'})
	$('.caseStudiesWidget ul li a').stop(true,true).click(
			function(){
				if($(this).next().is(':hidden')){
						$(this).next().slideDown();
					}
				else $(this).next().slideUp();	
			}
		)
	}
	if($('#photogalleryWrapper').length){
		var imageScroller = $('#photogalleryWrapper').smoothDivScroll({
				autoScroll: "onstart" , 
				autoScrollDirection: "backandforth", 
				autoScrollStep: 1, 
				autoScrollInterval: 20	
			});
		$('#photogalleryWrapper .item').click(function(){
			var currProject = $(this);
			var currHtml = currProject.html();
			var currImageId = $(currHtml).find('img').attr('id');
			$('#photogalleryWrapper .item').fadeOut(function(){
					$('.scrollingHotSpotLeft,.scrollingHotSpotRight').css({display:'none'});
					$('#currItem').html(currHtml).fadeIn().find('.description').fadeIn(function(){
							Reflection.add(document.getElementById(currImageId), { height: 1/4, opacity: 2/3 });
							$('#currItem').animate({
								width:780
								},
								1000)
						});
					
				})
				
			})
		$('#currItem').click(function(){
				$('.scrollingHotSpotLeft,.scrollingHotSpotRight').css({display:'block'});
				$(this).stop(true,true).fadeOut(function(){
						$('#currItem').css({width:0})
					}).html('');
				$('#photogalleryWrapper .item').fadeIn();	
		})
	}
});

$(function(){
	$("#argument").change(function () {
		if ($("#argument").val() == "Richiesta accesso area riservata")
			$("#myPassword").fadeIn();
		else
			$("#myPassword").hide();
	});
	if ($("#argument").val() == "Richiesta accesso area riservata")
		$("#myPassword").fadeIn();
	else
		$("#myPassword").hide();
})
