$(document).ready(function(){

//------------------------------------//
// Forms
//------------------------------------//

    //cleare the default text when the user clicks the input field
    $('.txtEmailAddress').click(function(){
        $(this).val("");
        $('#emailTickler').fadeOut();
    });

//------------------------------------//

//------------------------------------//
// Header Slideshow
//------------------------------------//
    if ($('#photoHolder').size() != 0) {
        $('#photoHolder').cycle({speed:  2500});    
    }
//------------------------------------//

//------------------------------------//
// Content Slideshow
//------------------------------------//
    if ($('#photoGallery').size() != 0) {

        $('#photoGallery').cycle({ 
            prev:   '#prev', 
            next:   '#next', 
            speed:  3000
        });
    }

//------------------------------------//
// Catch And Kill
//------------------------------------//
    $("a.fb").fancybox();
    $("#catch-kill-holder a:nth-child(4n)").addClass("last");
//------------------------------------//


//------------------------------------//
// Random Sub Page Photo
//------------------------------------//
    /*Settings*/
    //var thePath = "/TwoRivers/Images/SubPageHeaderPhotos/" // localhost
    var thePath = "/Images/SubPageHeaderPhotos/" //Dev and Prod

    var loadRandomPhoto = function(theFile){
         $.ajax({
            type: "GET",
            //url: "/TwoRivers/XML/" + theFile, // localhost
            url: "/XML/" + theFile, // dev and prod
            dataType: "xml",
            success: function(xml) {    
                //get elements      
                var images = $("image", xml)
                                
                //create a random number within the range of our image count
                var now=new Date();
                var num=((now.getSeconds()) % images.length);
                
                //grab all the data we need.
                var imageUrl = thePath + images.eq(num).attr('url')
                var imageTitle = images.eq(num).attr('title')
                
                //set up the photo
                $("img.randomPhoto").attr({
                    src: imageUrl,
                    alt: imageTitle                    
                }).fadeIn("normal")
            }
        });
    };
    
    // build the proper file name based on the 
    // title attribut of the random photo image element
    var theFile = $('img.randomPhoto').attr("title")+".xml";
    
    loadRandomPhoto(theFile);

//------------------------------------//

//------------------------------------//
// Form Tickler
//------------------------------------//
    // Basically, we need to help the user know where to go once they click
    // #linkFooterSignup link.
    $('#linkFooterSignup').click(function(){
    
        $('#emailTickler').fadeIn();       
        
    });
//------------------------------------//


});






