
function updateImgInfo(img, info, press) {
    var parameters = '?press=' + press + '&img=' + escape(img) + '&info=' + escape(info);

    $('#debugg22').load('/press_releases/updateImgInfo.ajcall.php' + parameters);
}



function keyWasPressed(e, keycode){
    if(e) var unicode=e.keyCode? e.keyCode : e.charCode;
    
    if(keycode){
        if(unicode==keycode){
            return(true);
        }else{
            return(false);
        }
    }else{
        return(unicode);
    }
}





function slidePage(opt){

	if(opt=="right" && pageNow<pageTotal){
		pageNow ++;
		$("#inner_gallery_list").show().animate({marginLeft: -((pageNow-1)*pageSize)},"slow");
	}
	if(opt=="left" && pageNow>1){
		pageNow --;
		$("#inner_gallery_list").show().animate({marginLeft: -((pageNow-1)*pageSize)},"slow");
	}

	if(pageNow==pageTotal)
		$("#rightScrollArrow").attr("class", "inactiveBtn");
	else
		$("#rightScrollArrow").attr("class", "");

	if(pageNow==1)
		$("#leftScrollArrow").attr("class", "inactiveBtn");
	else
		$("#leftScrollArrow").attr("class", "");
	
	$("#pagingInfo").text('page ' + (pageNow) + ' of ' + pageTotal);
	
}





































var delay  = 8000;      //Time between slides
var transition = 500;   //Transition time
var selected = 0;
var pauseOnClickArrow = true;
var pause = false;

var galleryWidth = "";
var galleryHeight = "";

var total_photos = "";
var total_photoinfo = "";



function jzSlideshowINIT(){
    galleryWidth = $("#jzgallery").css("width").replace("px", "");
    galleryHeight = $("#jzgallery").css("height").replace("px", "");
    
    total_photos = $("#gallery").children("li").length;
    total_photoinfo = $("#photoinfo").children("li").length;
    
    $("#jzgallery #gallery").css("width", galleryWidth*total_photos+100);           //Defines innerElement width
    //alert(galleryWidth);
    $("#jzgallery #photoinfo").css("height", galleryHeight*total_photoinfo);    //Defines innerElement height
    
    $("#jzgallery #gallery li img").css("width", galleryWidth + "px");
    $("#jzgallery #photoinfo li").css("height", galleryHeight + "px");
}

function jzSlideshow(opt, sel, act){        //options: play, stop, previous, next

    last_selected = selected;

     if(sel!=null) selected = sel; //Forces selected photo
    
    switch (opt){
        case 'play':
            if(pause==false) {
                selected++;
                if(selected>=total_photos) selected=0; //loops photos - return to first photo
                setTimeout("jzSlideshow('play', "+selected+");" , delay);
            }
            break;
        
        case 'pause':
            pause=true;
            break;
        case 'prev':
            if(pauseOnClickArrow) pause=true;
	    selected--;
            break;
        case 'next':
            if(pauseOnClickArrow) pause=true;
	    selected++;
            break;
        default:
            pause=true;
    }
    
    if(selected>=0 && selected<total_photos && (opt!='play' || pause==false)){
        //$("#gallery_debug").text("||selected:" + selected + " ||option: " + opt + " ||pause: " + pause);
        $("#gallery").animate({ left: galleryWidth*(-selected) }, transition, function() {});
        $("#photoinfo").animate({ top: galleryHeight*(-selected) }, transition, function() {});
        $("#photoButton_" + last_selected).css("color","gray");
        $("#photoButton_" + selected).css("color","#6699CC");
    }else{
        selected = last_selected;
    }
    
    if(pause){
                $('#btn-play').css("display", "inline");
        $('#btn-pause').css("display", "none");
    }else{
                $('#btn-pause').css("display", "inline");
        $('#btn-play').css("display", "none");

    }

}





$(document).ready(function() {

    $('#btn-pause').click(function () {

        jzSlideshow('pause');
    });

    $('#btn-play').click(function () {
        pause=false;
        jzSlideshow('play');
    });
    
    $('#btn-next').click(function () {
        jzSlideshow('next');
    });	

    $('#btn-prev').click(function () {
        jzSlideshow('prev');
    });	
    
    jzSlideshowINIT();
    jzSlideshow('play', -1); // Starts slideshow

});


