    $(function() {
        $('#gallery a').lightBox();
        $('#gallery2 a').lightBox();
    });


var headline_count;
var headline_interval;
var headline_interval2;
var old_headline = 0;
var current_headline=0;

$(document).ready(function(){

	// $("#wrap a").fancybox();

  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top','5px');
  
  headline_interval = setInterval(headline_rotate,6000); //time in milliseconds
  headline_interval2 = setInterval(blinking,2000); //time in milliseconds
  
	
		   $("#gallery").find("img").each(function(i) {
                $(this).css("opacity","0.6");
            });
            
		   $("#gallery img ").hover(function() {
                $(this).animate({opacity: "1"}, "fast");
            }, 
            function() {
                $(this).animate({opacity: "0.6"}, "fast");
            });
            
      		   $("#gallery2 ul li").find("img").each(function(i) {
                $(this).css("opacity","0.8");
            });
            
		   $("#gallery2 ul li img ").hover(function() {
                $(this).animate({opacity: "1"}, "fast");
            }, 
            function() {
                $(this).animate({opacity: "0.8"}, "fast");
            });      

	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});
	
  
  
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; //remainder will always equal old_headline until it reaches headline_count - at which point it becomes zero. clock arithmetic
  $("div.headline:eq(" + old_headline + ")").animate({top: -45},"slow", function() {
    $(this).css('top','40px');
    });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
  old_headline = current_headline;
}


function blinking() {
	$("#alert").animate({opacity: "1"}, "slow");
	$("#alert").animate({opacity: "0.4"}, "slow");
}

