/* FadeIn Script */
$(document).ready(function(){
		
		$(".community-bw").fadeTo("fast", 0.0);
		
		$(".community-bw").hover(function(){
		
		$(this).fadeTo("fast", 1.0);
		
		},function(){
		
		$(this).fadeTo("fast", 0.0);

		});
		
		
});


$(document).ready(function() {
		$(".topMenuAction").click( function() {
			if ($("#openCloseIdentifier").is(":hidden")) {
				$("#slider").animate({ 
					marginLeft: "300px"
					}, 500 );
				$("#topMenuImage").html('<img src="images/style/social-close.png" alt="social-open" width="61" height="194" />');
				$("#openCloseIdentifier").show();
			} else {
				$("#slider").animate({ 
					marginLeft: "0px"
					}, 500 );
				$("#topMenuImage").html('<img src="images/style/social-open.png" alt="social-close" width="61" height="194" />');
				$("#openCloseIdentifier").hide();
			}
		});  
	});

/* Smoothy Scrolling */
$(function() {
    $('a.special-scroll').bind('click',function(event){
        var $anchor = $(this);
        
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 3500);
        event.preventDefault();
    });
});


$(document).ready(function() {
    $('#about-speech-bubble').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 5000,
		speed: 0,
	});
});


$(function () {
  $('ul#community-list li.selectable').each(function () {
    // options
    var distance = 10;
    var time = 500;
    var hideDelay = 200;

    var hideDelayTimer = 10;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('.tooltip-selector', this);
    var popup = $('.tooltip', 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({
          top: -90,
          left: -55,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + 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({
          top: '-=' + 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);
    });
  });
})

$(document).ready(function() {

    //if submit button is clicked
    $('#send-button').click(function () {

        //Get the data from all the fields
        var name = $('input[name=name]');
        var email = $('input[name=email]');
        var phone = $('input[name=phone]');
        var comment = $('textarea[name=comment]');


        //organize the data properly
        var data = 'name=' + name.val() + '&email=' + email.val() + '&phone=' + phone.val() + '&comment='  + encodeURIComponent(comment.val());

        //show the loading sign
        $('.loader').delay(10).fadeIn('slow').delay(3000).fadeOut('slow');

        //start the ajax
        $.ajax({
            //this is the php file that processes the data and send mail
            url: "process.php",

            //GET method is used
            type: "GET",

            //pass the data
            data: data,

            //Do not cache the page
            cache: false,

            //success
            success: function (html) {
                //if process.php returned 1/true (send mail success)
                if (html==1) {
                    //hide the form
                    //show the success message
                    $('#send-button').delay(4000).fadeTo(0.7);

                //if process.php returned 0/false (send mail failed)
                } else alert('Sorry, unexpected error. Please try again later.');
            }
        });

        //cancel the submit button default behaviours
        return false;
    });
});

$(document).ready(function() {
			$("#activityFeed").soSoSocial();
		});
		
$(document).ready(function(){				
		$('#activityFeed ul').tinyscrollbar();
	});

