this.tooltip = function()
{	
    /*
   * Tooltip script 
   * powered by jQuery (http://www.jquery.com)
   * 
   * written by Alen Grakalic (http://cssglobe.com)
   * 
   * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
   *
   */
  
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;
		
				
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(
	  function(e)
	  {											  
  		this.t = this.title;
  		this.title = "";									  
  		$("body").append("<div id='tooltip'>"+ this.t +"</div>");
		
		
  		$("#tooltip")
  			.css("top", (e.pageY - yOffset) + "px")
  			.css("left",(e.pageX + xOffset) + "px")
  			.fadeIn("fast");		
    },   
  	function() 
  	{
  		this.title = this.t;		
  		$("#tooltip").remove();
    }
  );	
    
  
    
	$("a.tooltip").mousemove(
  	function(e)
  	{
  		$("#tooltip")
  			.css("top", (e.pageY - yOffset) + "px")
  			.css("left",(e.pageX + xOffset) + "px");
  	}
  );
  
};


function setup_mashup_slideshow()
{
  // slide show stuff
	
  var s_index = Math.floor(Math.random() * 9) * 3; 

	$('#slideshow1').cycle({
    fx:    'fade',  
    pause:   0, 
    timeout: 2000,
    speed:   1000,
    random:  0,
    startingSlide: s_index
    //fxFn: transitionChooser
  }); 
  

	if (window.location == "http://wpa2.aud.ucla.edu/info/"
	   || window.location == "http://wpa2.aud.ucla.edu/info/index.php")
	{
	    $('#slideshow1').css("display", "none");    	    
	    $('#citylab-logo').css("display", "inline");
	}
	else
	{
      $('#slideshow1').css("display", "block");
  }
}

function resource_gallery_hide_all()
{
  for (var id =1; id <= 12; id++)
  {
    $('#resource-content-container #r-' + id).css("display", "none");        
  }
}
function resources_gallery_show_all()
{
   for (var id =1; id <= 12; id++)
  {
    $('#resource-content-container #r-' + id).css("display", "block");        
  } 
  return false;
}

function resources_gallery_unfold_id(id_param)
{
    for (var id =1; id <= 12; id++)
  {
    if ($('#resource-content-container #r-' + id).css("display") == "block")
    {
      $('#resource-content-container #r-' + id).slideUp(1000);        
    }
  }
  $('#resource-content-container #r-' + id_param).slideDown(1000);   
}

function resources_gallery_show_id(id_param)
{
    // scroll body to top
    //$('body').scrollTo(0,0);
    $('body').scrollTo(0,500, {onAfter:resources_gallery_unfold_id(id_param)});

    return false;
}



function setup_resources_gallery()
{
   // clear all
   resource_gallery_hide_all();
   
   $('#resource-icon-1').click(function(){ return resources_gallery_show_id(1); });
   $('#resource-icon-2').click(function(){ return resources_gallery_show_id(2); });
   $('#resource-icon-3').click(function(){ return resources_gallery_show_id(3); });
   $('#resource-icon-4').click(function(){ return resources_gallery_show_id(4); });
   $('#resource-icon-5').click(function(){return  resources_gallery_show_id(5); });
   $('#resource-icon-6').click(function(){ return resources_gallery_show_id(6); });
   $('#resource-icon-7').click(function(){ return resources_gallery_show_id(7); });
   $('#resource-icon-8').click(function(){ return resources_gallery_show_id(8); });
   $('#resource-icon-9').click(function(){ return resources_gallery_show_id(9); });
   $('#resource-icon-10').click(function(){ return resources_gallery_show_id(10); });
   $('#resource-icon-11').click(function(){ return resources_gallery_show_id(11); });
   $('#resource-icon-12').click(function(){ return resources_gallery_show_id(12); });
   
   // show all link
   $('#resource-show-all').click(
     function() 
     {
       $('body').scrollTo(0,500);
       resources_gallery_show_all();
       return false;
     }
  );
}



$(document).ready(function()
{
  setup_mashup_slideshow();    
  setup_resources_gallery();
  // init the tooltip script
  tooltip();
});
