Cufon.replace('h1,h2,h3,h4,h5,h6,#tagline,#footer'); //CV 20.8.10 - moved out of jq function (should be standalone)

$(function() {
    //CV 20.8.10 and updated 27.8.10 after bug report on non-homepages.
    if ($.browser.msie && $.browser.version < 7) {
        prefix = '';
        // fill in with domain/path details - dev vs live different dir levels
        if (window.location.hostname == 'dev.digitalhosting.org.uk') prefix = '/londonpetshow';

        var a = new Array('8','4','5','7','10'); // name components of images
        var rand1 = Math.floor(Math.random() * a.length);
        var img1 = a[rand1]; // or it'll cause error on last image after splice shortens array
        
        a.splice(rand1, 1); // ensures two different images by removing removing first pick
        var rand2 = Math.floor(Math.random() * a.length);
        var img2 = a[rand2]; // just consistency
        
        var rand_img1 = '<img id="rand1" src="' + prefix + '/resources/frontend/images/a' + img1 + '.png" alt="" />';
        var rand_img2 = '<img id="rand2" src="' + prefix + '/resources/frontend/images/a' + img2 + '.png" alt="" />';
        // console.log(rand1);
        // console.log(a[rand1]);

        $('#animalsTop').html(rand_img1);
        $('#animals').html(rand_img2);
        
        if ($.isFunction($.fn.supersleight)) {
            $('#logo, #buytickets, #bus, #hamster').supersleight({shim: prefix + '/resources/frontend/_img/x.gif'});
            
            // we need image to load first so we can get width height for supersleight
            // shim parameter passed to account for prefix difference
            // split in two due to diffferent load times
            $('#animalsTop img').load(function() { 
                $('#animalsTop').supersleight({shim: prefix + '/resources/frontend/_img/x.gif'});
            });
            $('#animals img').load(function() {
                $('#animals').supersleight({shim: prefix + '/resources/frontend/_img/x.gif'});
            });
        }
    } else {
        $('#animalsTop').cycle({
            fx: 'fade',
            speed: 300,
            //next:   '#animalsTop',
            timeout: 5000
        });
    
        $('#animals').cycle({
            fx: 'fade',
            speed:  300,
            //next:   '#animals',
            timeout: 5000
        });
    }
    //these have been hidden in CSS initially to prevent all images showing on load before js kicks in
    $('#animalsTop, #animals, #rotator').show();
    // end CV
    
    $('#rotator').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '110px' }); 
    $('#rotator').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '110px' }); 
    $("#bus").animate({left: "-420px"}, 4000);
    //$('#animals').innerfade({ speed: 'slow', timeout: 8000, type: 'sequence', containerheight: '325px' }); 
    $('#animals1Top').innerfade({ speed: 'slow', timeout: 8000, type: 'sequence', containerheight: '325px' }); 
    
    $('.rmv-dft-val').click(function() {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });

    $('.rmv-dft-val').blur(function() {
        if (this.value == '') {
            this.value = this.defaultValue;
        }
    });
});
