    var img1 = new Image;
    img1.src = "images/blockloading.gif";                  
    var img2 = new Image;
    img2.src = "images/carthover.png";                  
    var img3 = new Image;
    img3.src = "images/coghover.png";         
    
    var current = 1;            
    $(document).ready(function()
    { 
        $(".button").button();
        $(".buttonset").buttonset();
        $('.validate').validate();
        
        $('#autosubmit').submit();
        $('#autoclick').click();
        
        $('.scrollingimages').cycle({ 
            height: '125px',
            width: '208px',
            fx: 'uncover', 
            delay: -1000 
        });
        
        $(".scrollingimages").hover(function() 
        {
            $(this).pause();
        },
        function() 
        {
            $(this).resume();
        });
        
        $('.niceform input[type="text"], .niceform textarea').addClass('textinput');
        $('.niceform input[type="submit"]').button();              
        
          // Striping generic child elements                
        $(".striped > *:even:not(tbody):not(.nostripe), .striped > tbody > *:even:not(.nostripe)").addClass("stripe1");
        $(".stripe1 + *").addClass("stripe2");
        $(".stripe1, .stripe2").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
        
        $(".llmenu").lavaLamp({ fx: "easeOutBack", speed: 1500, returnDelay: 1500}) ;
        
        $("#sidemenu li").hover(function() 
        {
            $(this).children('ul:hidden:not(:animated)').slideDown("medium");
        },
        function() 
        {
            //$(this).children('ul:visible:not(:animated)').slideUp("slow");
        });
        
        $("#sidemenu").hover(function() 
        {
            clearTimeout(hTimeout);
        },
        function() 
        {
            hTimeout = setTimeout(function(){closesidemenu();}, 2000);
        });
        
        function closesidemenu()
        {
            $("#sidemenu li ul:not(.locked)").slideUp("slow");
        }
        
        $("li a").each(function (index, domElement) {
            // If link matches full URL or if it matches partial URL mark it as selected. Is this a hack? Perhaps - but it very easily highlights live menu items - a one-liner rather than a one-pager.
            if (domElement.href == window.location.href || domElement.href == window.location.pathname + window.location.search) 
            {
                $(this).addClass("selected").parentsUntil("#sidemenu", "ul").slideDown("medium").addClass("locked");                
            }
        });
        
        $("a.newwindow").click(function()
        {
           window.open(this.href);
           return false; 
        });
        
        // Allow hrefs with the class 'ajax' and a rel attribute set with a selector to load via ajax into that selector.
        $('.ajax').unbind('click').click
        (
            function(e)
            {
                if ($(this).attr("href") == "") return false;
                var $locationhint = $(this).attr('rel');
                if (!$locationhint) $locationhint = "this";
                $location = false;
                if ($locationhint == "this") $location = $(this);
                if ($locationhint == "child") $location = $(this).children(0);
                if ($locationhint == "parent") $location = $(this).parent();
                if  (!$location) $location = $($locationhint);
                $location.html ("<img src='images/blockloading.gif' />");
                $location.load("ajax.php?r=" + $(this).attr("href"), "", $location.addClass("dommodified"));
                e.preventDefault();
            }
        ); 
        
        // Allow hrefs with the class 'ajax' and a rel attribute set with a selector to load via ajax into that selector.
        $('.ajaxconfirm').unbind('click').click
        (
            function(e)
            {
                $prompt = $(this).attr('title');
                if (!$prompt) $prompt = "Are you sure you wish to perform this action?";
                if (!confirm($prompt)) 
                {
                    e.stopPropagation(); 
                    e.preventDefault();
                    return false; 
                }
                else
                {
                    var $locationhint = $(this).attr('rel');
                    if (!$locationhint) $locationhint = "this";
                    $location = false;
                    if ($locationhint == "this") $location = $(this);
                    if ($locationhint == "child") $location = $(this).children(0);
                    if ($locationhint == "parent") $location = $(this).parent();
                    if  (!$location) $location = $($locationhint);
                    $location.html ("<img src='images/blockloading.gif' />");
                    $($location).load("ajax.php?r=" + $(this).attr("href"), "", $location.addClass("dommodified"));
                    e.preventDefault();
                }                       
            }
        );
        
        $('.autoclick').click();               
        
        $('.hidethis').click(function()
        {
            $(this).hide();
            return false;
        });                

        $('.hideparent').click(function()
        {
            $(this).parent().hide();
            return false;
        });

        $("a.fb, a[href$='.jpg'], a[href$='.gif'], a[href$='.png']").fancybox //.inner a:has('img'):not(#gallerycontainer a):not(#gallerynav a)
        ({
            'zoomSpeedIn': 600,
            'zoomSpeedOut': 300,
            'overlayShow': true,
            'hideOnContentClick': false,
            'cyclic': true,
            'imageScale': true
        });
        
        // Do all fbc separately so they dont group into a gallery.
        $("a.fbc").each(function(){
        $(this).attr("href", $(this).attr("href").replace("index.php", "ajax.php"));
        $(this).fancybox 
        ({
            'zoomSpeedIn': 600,
            'zoomSpeedOut': 300,
            'overlayShow': false,
            'hideOnContentClick': true,
            'cyclic': false,
            'imageScale': true,
            'showNavArrows': 	false
        });});
        
        // Do all fbp separately so they dont group into a gallery, bigger cos this is a page.
        $("a.fbp").each(function(){
        $(this).attr("href", $(this).attr("href").replace("index.php", "ajax.php")); // Load ajax page into fb
        $(this).fancybox 
        ({
            'zoomSpeedIn': 600,
            'zoomSpeedOut': 300,
            'overlayShow': true,
            'width': 990,
            'frameWidth': 990,
            'height': 800,
            'frameHeight': 800,
            'titleShow': false,
            'type': 'iframe',
            'autoDimensions': true,
            'hideOnContentClick': false,
            'showCloseButton': true,
            'cyclic': false,
            'imageScale': true,                    
            'showNavArrows': 	false
        });});          
            
        setTimeout(function(){hideads();}, 1500);
        setTimeout(function(){hideads();}, 3000);
        setTimeout(function(){hideads();}, 6000);
        setTimeout(function(){hideads();}, 12000);                
        setTimeout(function(){hideads();}, 16000);                
        setTimeout(function(){hideads();}, 24000);                
    });
    
    function hideads()
    {
        $(".gsc-adBlock").hide();
    }
    
