   $(document).ready(function() {
   
      ////////////// setup objects to be invisible at page load
      ///*
      var hash = window.location.hash.substr(1);
      
        //setup images to be gone
      
      

        $("#header_name").fadeTo(1, 0.0);
        $("#left").fadeTo(1, 0.0);
        $("#nav").fadeTo(1, 0.0);
        $("#main_left").fadeTo(1, 0.0);
        $("#main_right").fadeTo(1, 0.0);
        $("#top_vid").fadeTo(1, 0.0);

        $("#top_buttons").animate({top:"-80"}, 1, "swing");
        showLoader();
        fadeheader();

        
        if(hash == "fadenav")
        {
          $("#nav li a").fadeTo(1, 0.5);    // fade all nav links to 0.5
          $("#nav li a").attr("id", "");    // none are current
        }

      //*/
      ///////////// end invisible objects

      // click 'hide video'
      $("#top_video a").click(function() {
         $("#top_video").animate({top:"-400"}, 1500, "swing"); // hide the vid box
         $("#top_vid").show(500);

      });

      // click 'show video'
      $("#top_vid a").click(function() {
         $("#top_vid").hide(300);
         $("#top_video").animate({top:"0"}, 1500, "swing");  // fly down the vid box
      
      });
      $("#nav li a").click(focusfadenav);
      

      
      //$("#nav li a").not("#nav li a:first").fadeTo(1, 0.5);
      //$("#nav li a:first").attr("id", "current");
      

      // set properties for top buttons
      $("#top_buttons a").attr("target", "_BLANK");



             var i = 1;

                // Dialog
                  for(i = 1; i <= 3; i++)
                  {
                    $('#dialog' + i).dialog({
                      autoOpen: false,
                      resizable: false,
	                  width: 450
				    });
				  }



				// Dialog Link - open the corresponding dialog, depending which link was clicked
			  	  $('#right_body a').click(function(){
                      var info = $(this).attr("class");
			  		  $('#' + info).dialog('open');
					  return false;
				  });


				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); },
					function() { $(this).removeClass('ui-state-hover'); }
				);



   });

    function fadeheader() {
      $("#header_name, #nav").fadeTo(1000, 1.0);
      $("#main_left").fadeTo(1000, 1.0);
      $("#left").fadeTo(1000, 1.0);
      $("#main_right").fadeTo(1000, 1.0, fadetop);
      
    }

    function fadetop() {
      $("#top_buttons").animate({top:"10"}, 2000, "swing", hideLoader);
    }

     ///////////////////////////////////////////////////////////////////
    // PERFORM ACTION WHEN CLICKING A LINK
    function focusfadenav() {
      // "this" is the link that was clicked
         $(this).attr("id", "current");
         $("#nav li a").not(this).attr("id", "");
         $(this).fadeTo(500, 1.0);
         $("#nav li a").not(this).fadeTo(500, 0.5);
         $('#main_left').fadeTo(500, 0.0).hide(1,loadContent);

         showLoader();
         // ajax code to load content from other page
        var toLoad = $(this).attr('href')+' #holder';
        
        //window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4);
        function loadContent() {
			$('#main_left').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#main_left').show(1).fadeTo(500, 1.0, hideLoader);
		}
		return false;
		// end code to load content

      }

      ///////////////////////////////////////////////////////
      // SHOW ANIMATION WHEN LOADING
      function hideLoader() {
			$('#load').fadeOut('normal');
			$("#top_vid").fadeTo(500, 1.0);
			
		}
		function showLoader() {
	    	$('#load').remove();
            $('#container').prepend('<span id="load">LOADING...</span>');
            $('#load').fadeIn('normal');
       }


