/* this is the for the slide show on the index page and imagepopup pages. */

var slideStatus = "playing";
$(document).ready(function(){
    //$("#slideControls").css("display","");
    $("#cyc img").css("cursor","pointer");
    $("#cyc").cycle({
        fx:'fade',
        timeout:4500,
        after:addLabel,
        before:remClass,
        next:'#next', 
        prev:'#previous'
    });
    
    var slides = $(".slide").length;
    if(slides>=2){
        $("#slideControls").css("visibility","");
    } else {
        $("#slideControls").css("visibility","");
        $("#previous, #pause, #next").css("visibility","hidden");
        $("body#imagePopup #cyc img").css("cursor","");
    }
    
    $("body#imagePopup #cyc img").click(function(){
        if(slides>=2){
            if(slideStatus=='playing'){
                $('#slideshowstatusfortwits').remove();
                $("#play").css("display","");
                $("#pause").css("display","none");
                slideStatus='paused';
                $('#cyc').cycle('pause');
                $('#slideShowContainer').after("<div id='slideshowstatusfortwits'>Your slide show is now paused.</div>");
                setTimeout(function(){
                    $('#slideshowstatusfortwits').fadeOut("slow",function(){
                        $('#slideshowstatusfortwits').remove();
                    });
                },1098);
            } else {
                $('#slideshowstatusfortwits').remove();
                $("#slideCopyText").css('display','none');
                $("#play").css("display","none");
                $("#pause").css("display","");
                slideStatus='playing';
                $('#cyc').cycle('resume');
                $('#slideShowContainer').after("<div id='slideshowstatusfortwits'>Your slide show is now playing.</div>");
                setTimeout(function(){
                    $('#slideshowstatusfortwits').fadeOut("slow",function(){
                        $('#slideshowstatusfortwits').remove();
                    });
                },1098);
            }
        }
    });
    $("#pause").click(function(){
        $("#play").css("display","");
        $("#pause").css("display","none");
        slideStatus='paused';
        $('#cyc').cycle('pause');
    });
    $("#play").click(function(){
        $("#slideCopyText").css('display','none');
        $("#play").css("display","none");
        $("#pause").css("display","");
        slideStatus='playing';
        $('#cyc').cycle('resume');
    });
    $("#slideShowContainer img").click(function(){
        //showInfoWindow(this.id+"_text");
        //$('#cyc').cycle('pause');
        //slideStatus='paused';
        var link = $("#slideShowContainer img.active").attr("longdesc");
        if(link!=undefined){
            window.location = link;
        } 
    });
    $("#moreInfo").click(function(){
        $("#slideCopyText").css('display','none');
        var activeText = $("#slideShowContainer img.active").attr("id");
        showInfoWindow(activeText+"_text");
        slideStatus='paused';
        $('#cyc').cycle('pause');
    });
    $(".closeInfoBox").click(function(){
        $("#slideCopyText").css('display','none');
        $('#cyc').cycle('resume');
    });
        
});
function addLabel(){
    $("#altLabel").html("<p>"+this.alt+"<\/p>");
    $(this).addClass("active");
}
function remClass(){
    $(".active").removeClass("active");
}
function showInfoWindow(id){
    $(".ssText").css("display","none");
    if(id!="undefined_text"){
        $("#"+id).toggle();
        $("#play").toggle();
        $("#pause").toggle();
        $("#slideCopyText").css('display','');
    }
}





/* replaced this code on the index page... 
<div id="flashSlideShow">
    <!--no flash.. will need to get a generic image for this.. ak-->
    <!-- %loop_getRandomImageForFlash% -->
    %html%
    <!-- %endloop_getRandomImageForFlash% -->
</div>
<script type="text/javascript">
    var swfObject = new SWFObject("/flashbanners/slideshowAK.swf","home","580","435","8","");
    swfObject.addParam("scale","noscale");
    swfObject.addParam("wmode","transparent");
    swfObject.addVariable('autoplay','true');
    swfObject.write("flashSlideShow");
</script>

<!-- <div id="slideCopyText" style="display:none;">
    <p id="slideShowSlide_0_text" style="display:none;" class="ssText">this is 194 panel lights are fun..<label class="closeInfoBox">Close Panel</label></p>
    <p id="slideShowSlide_1_text" style="display:none;" class="ssText">spaces are fun.. <label class="closeInfoBox">Close Panel</label></p>
    <p id="slideShowSlide_2_text" style="display:none;" class="ssText">how's about those bezels.. they're fun.. <label class="closeInfoBox">Close Panel</label></p>
    <p id="slideShowSlide_3_text" style="display:none;" class="ssText">some stubby ants here.. this is some really good stuff. <a href="#">Test link</a><label class="closeInfoBox">Close Panel</label></p>
    <p id="slideShowSlide_4_text" style="display:none;" class="ssText">spaces are fun.. <label class="closeInfoBox">Close Panel</label></p>
    <p id="slideShowSlide_5_text" style="display:none;" class="ssText">how's about those bezels.. they're fun.. <label class="closeInfoBox">Close Panel</label></p>
</div> -->

*/


