$(document).ready(function(){
    InitGall();
    AddExitMsg();
    HackSignup();
});

var showSlide = 0;
function InitGall()
{
    $('.photo-list li:first').show();
    $('.photo-list .cycle a').click(function(event){
        event.preventDefault();
        var numSlides = $('.photo-list li').length;
        var PrevNext = $(this).attr('rel');
        if(PrevNext == "Prev")
        {
            if(showSlide > 0)
            {
                showSlide--;
            }
            else
            {
                showSlide = numSlides - 1;
            }
        }
        else if(PrevNext == "Next")
        {
            if(showSlide < numSlides - 1)
            {
                showSlide++;
            }
            else
            {
                showSlide = 0;
            }
        }
        $('.photo-list li').hide();
        $('.photo-list li:eq('+showSlide+')').show();
    });
}

// JavaScript External Link Exit Message
function exitMsg(){
     var answer = confirm("You are now leaving the Congressman Jim Sensenbrenner website. Thank you for visiting. Neither my office nor the U.S. House of Representatives is responsible for the content of the non-House site you are about to access.")

if (!answer)
return false;

return true;
//end of Exit Message
}


// Check whether links are external:
// (Only works with elements that have href):
$.extend($.expr[':'],{
    external: function(a,i,m) {
        if(!a.href) {return false;}
        if(a.hostname.search(/house\.gov/gi)!=-1) {return false;}
        if(a.hostname.search(/gop\.gov/gi)!=-1) {return false;}
        return a.hostname && a.hostname !== window.location.hostname;
    }
});

/* --- Add Exit Message ---*/
function AddExitMsg()
{
    $('a:external').click(function(){
        return(exitMsg());
    });
}

function HackSignup()
{
    $('.formAddress select[id*=AddressState] + label').html('<span style="color:red;">*</span> Zip');
}
