$(document).ready(function() {

    // Plug holes in CSS Cross browser selectors to save using additional classes in markup		 
    $('#sNavigation li:last-child,ul.inline li:last-child').addClass("last"); // adds class of last to last element
    $('ul#rsList li:first-child').addClass("first"); // adds class of first to first element

    // Add closing quote to blockquotes
    //$("#contentMain blockquote cite").after("<img src=\"images/quote-close.gif\" alt=\"\" class=\"blockquoteClose\" /> ");

    // Add hover state to tooltips
    $("a.info").hover(
		function() {
		    $(this).addClass("hover");
		},
		function() {
		    $(this).removeClass("hover");
		}
	);

    // Form Field Focussing
    $('input[type=text],textarea').focus(function() {
        $(this).addClass("focusField");
    }).blur(function() {
        $(this).removeClass("focusField");
    });

    $("#sField").focus(function() {
        $(this).val("");
    });


    /* This puts caption box around images...
    $(document).find("img.imgLeft").each(function() {
        $(this).after("<div class='imgBox left'><div class='container'><img alt='" + $(this).attr("alt") + "' src='" + $(this).attr("src") + "' title='" + $(this).attr("title") + "'/><p>" + $(this).attr("title") + "</p>" + "</div></div>");
        $(this).remove();
    });
    $(document).find("img.imgRight").each(function() {
        $(this).after("<div class='imgBox right'><div class='container'><img alt='" + $(this).attr("alt") + "' src='" + $(this).attr("src") + "' title='" + $(this).attr("title") + "'/><p>" + $(this).attr("title") + "</p>" + "</div></div>");
        $(this).remove();
    });*/

    jQuery('.eventMenuSub').hide();
    jQuery('.eventMenuSub').slideDown("slow");

    jQuery('.collapseSelectGroup h3').click(function() {
        $(this).parent().toggleClass("collapseSelectGroupClosed");
    });
    jQuery('.ratesGroup h3').click(function() {
        $(this).parent().toggleClass("ratesGroupClosed");
    });

    // Gallery thumbnail previews
    jQuery('li.galleryThumbnail a').click(function() {
        var img = jQuery('img:first', this);
        var li = jQuery(this).parents('li:first');
        
        jQuery('li.galleryThumbnail').removeClass('eventsGalleryActive')
        li.addClass('eventsGalleryActive')
        var curHref = img.attr('src').substring(6);
        var val = curHref.lastIndexOf('/');
        if (val > 0) curHref = curHref.substring(0, val);
        
        jQuery('#mainimg').attr('src', curHref).attr('alt', img.attr('alt'));
        jQuery('#mainheading').text(img.attr('title'))
        jQuery('#maindesc').html(jQuery('.longdesc', li).html())
        
        return false;
    });
});