// Make a shortcut.
var $$ = jQuery;

// The ready handler.
$$(function()
{
    // Replace all hr elements with an hr div.
    var $hrclone = $$("<div>").addClass("hr-clone").html("<!-- -->");
    $$("hr").replaceWith($hrclone);

		// Insert custom bullet points for page items.
		$$("li.page_item").each(function()
		{
			var $e = $$(this);
			$e.html("&raquo; " + $e.html());
		});	

    // Get the title.
    var title = $$("#title").val().toLowerCase();

    // Now find the span that has that text.
    $$('#option-' + title).addClass("selected");

		// Make the entire div activate the link.
		$$("#options .text div").click(function()
		{
			location.href = $$(this).find('a').attr('href');
		});
		
		// Add hover support (needed for IE6).
		$$("#options .text div:not(.selected)").hover(function()
		{
			$$(this).toggleClass("selected");
		}, 
		function()
		{
			$$(this).toggleClass("selected");
		});

    // Enable collapsible content.
    
    // First collapse them all
    $$('div.collapsible > div').hide();

    var $collapsible = $$('div.collapsible');

    $collapsible.each(function()
    {      
       var $element = $$(this);
             
       $element.children("h3").css("cursor", "pointer").click(function()
       {
           $element.children("div").slideToggle();
           $$.scrollTo($element, 1000);
       });
    });

    // Take the top margin off any h4 elements that are the first on in their div.
    //jQuery("div.collapsible > div h4:first-child").addClass("no-top-margin");  

	// Rollover.
	$$("img.rollover").hover(
		function() 
		{ 
			var img = $$(this);
			var src = img.attr("src");			
			img.attr("src", src.replace("_u.", "_o."));
		},
		function() 
		{ 
			var img = $$(this);
			var src = img.attr("src");
			img.attr("src", src.replace("_o.", "_u."));
		}
	);

});



