// genereal js
          
$(function(){

			 $(".navlink a").bind("click",function (event) {
			 $(".navlink a").removeClass('nhovered');
			      //event.preventDefault(); 
            var newclass = ($(this).parents().attr("id"));
            var cleanclass =  newclass.replace("navrow_pages","");
            var nav = 'navrow_pages';
           if($(this).parents().attr("id")==nav+'_about-tlc'){ 
           $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
           var ora='#contenuto2';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);      
        $("#contenuto2").fadeIn(1000);   
         }else if($(this).parents().attr("id")==nav+'_teams-coaches'){
                              $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
                  var ora='#contenuto3';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);   
        $("#contenuto3").fadeIn(1000);   
         }else if($(this).parents().attr("id")==nav+'_in-the-community'){
                             $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
                  var ora='#contenuto8';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);  
        $("#contenuto8").fadeIn(1000);   
         }else if($(this).parents().attr("id")==nav+'_recognition'){
                               $(".navlink a").removeClass('hovered');
           $('#navrow #navrow_pages_recognition a').addClass('nhovered');
         }else if($(this).parents().attr("id")==nav+'_eventcal'){
                               $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
                  var ora='#contenuto1';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);  
        $("#contenuto1").fadeIn(1000);   
                  }else if($(this).parents().attr("id")==nav+'_blog'){
                                      $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
                  var ora='#contenuto7';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);  
        $("#contenuto7").fadeIn(1000);   
         }else if($(this).parents().attr("id")==nav+'_portfolio'){ 
                              $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
           //event.preventDefault();
           //event.stopPropagation();
	        // window.open(this.href, '_blank');   
         }else{
         
                            $(".navlink a").removeClass('hovered');
           $(this).addClass('hovered');
        var ora='#contenuto0';
       $("#contenuto:first-child").children().not(ora).fadeOut(500);  
        $("#contenuto0").fadeIn(1000);    
         }  
         if($(this).parents().attr("id")=='navrow_home') {
             $("#adv1,#adv2,#adv3,#adv4,#adv5,#adv").show();
                    event.preventDefault();
           event.stopPropagation();
                      $("body").removeClass();      
            $("body").addClass("t_home mod_home public") ;    
         }else{
            $("#adv1,#adv2,#adv3,#adv4,#adv5,#adv").hide();
            $("body").removeClass();      
            $("body").addClass("mod_pages sub"+cleanclass+"") ; 
            }   

});

});
    

$(function(){
   $('#logolove').click(function(){

    var ora='#contenuto0';
    $("#contenuto:first-child").children().not(ora).fadeOut(500);  
    $("#contenuto0").fadeIn(1000);  
    $("body").removeClass();      
    $("body").addClass("t_home mod_home public") ;    
  });
});


$(function(){
        $("#staffpr li").bind("mouseenter",function (event) {
            var identita = $(this).attr("id");
            $('<div id="sideimg2"><img src="images/'+identita+'side.png"></div>').appendTo(".staff_box");
            var li =  $(this);
            var offset = li.offset();
            $('#sideimg2 img').css('marginTop', parseInt(offset.top/6)+"px");
            /*alert(parseInt(offset.top/10));*/
            $("#sideimg2").stop(true, true).show();
});  
        $("#staffpr li").bind("mouseleave",function (event) {
            $("#sideimg2").stop(true, true).hide();
            $("#sideimg2 img").remove();
            $("#sideimg2").remove();
            
}); 
});



$(function(){
      $("a #close ").bind("click",function (event){
              if($(this).hasClass('up')){
                $("#navrow").fadeOut('slow');
                $(this).removeClass("up");
                $(this).addClass("down");
                }
              else{
                $("#navrow").fadeIn('slow');
                $(this).removeClass("down");
                $(this).addClass("up");
              }
              });
      });

//Servizi e Lavori

    $(function(){
      $(".cat a").bind("click",function (event){
           event.preventDefault();
           event.stopPropagation();
      var nuovaclasse = $(this).attr("class");
     //alert(nuovaclasse);
      $(".serviziul > li").hide("fast");
      $("#"+nuovaclasse).show("slow");
              });
      });
      
//Social icon

     $(function(){
     $(".social").bind("mouseover",function(event){
     $(".social img").show();
     });
     });
          $(function(){
     $(".social").bind("mouseleave",function(event){
     $(".social img").hide();
     });
     });      

 //Event calendar
 
 $(function () {
	$('.date_has_event').each(function () {
		// options
		var distance = 10;
		var time = 250;
		var hideDelay = 500;

		var hideDelayTimer = null;

		// tracker
		var beingShown = false;
		var shown = false;

		var trigger = $(this);
		var popup = $('.events ul', this).css('opacity', 0);

		// set the mouseover and mouseout on both element
		$([trigger.get(0), popup.get(0)]).mouseover(function () {
			// stops the hide event if we move from the trigger to the popup element
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// don't trigger the animation again if we're being shown, or already visible
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;

				// reset position of popup box
				popup.css({
					bottom: 20,
					left: -76,
					display: 'block' // brings the popup back in to view
				})

				// (we're using chaining on the popup) now animate it's opacity and position
				.animate({
					bottom: '+=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					// once the animation is complete, set the tracker variables
					beingShown = false;
					shown = true;
				});
			}
		}).mouseout(function () {
			// reset the timer if we get fired again - avoids double animations
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// store the timer so that it can be cleared in the mouseover if required
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				popup.animate({
					bottom: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					// once the animate is complete, set the tracker variables
					shown = false;
					// hide the popup entirely after the effect (opacity alone doesn't do the job)
					popup.css('display', 'none');
				});
			}, hideDelay);
		});
	});
});
  $(function () {
$(".calcont a").click(function() {
      
        /* grabs URL from HREF attribute then adds an  */
  /* ID from the DIV I want to grab data from    */
  var myUrl = $(this).attr("href") + " .calendar-event";
  	var creazione = $(this).attr("id");
  $("#calecont").load(myUrl);

  return false;
});
});    

  $(function () {
$(".date_has_event").click(function() {
     event.preventDefault();  
        /* grabs URL from HREF attribute then adds an  */
  /* ID from the DIV I want to grab data from    */
  var myUrl = $(this).attr("href") + " .calendar-event";
  	var creazione = $(this).attr("id");
  $("#calecont").load(myUrl);
  return false;
});
});   

/*Staff fading*/
$(function () { 
$("#btm-staff ol li a").click(function(event){ 
    event.preventDefault(); 
    var myUrl = $(this).attr("href");
    $(".staff_box").load(myUrl);
});
});


