     var numberOfPhotos;


    // Opens a window with the selected url using the server name selected in the form
    function openPhotoViewer(albumOwnerType, albumOwnerId, selectedImageId, showEditButtons) {
        url = '/image-gallery-web/AlbumPhotosDisplay.action' + '?albumOwnerType=' + albumOwnerType + '&albumOwnerId=' + albumOwnerId +
              '&selectedImageId=' + selectedImageId + '&showEditButtons=' + showEditButtons;
        windowId = 'Imageviewer';
        window.open(url, windowId, 'height=520,width=680,top=50,left=50,scrollbars=yes,status=yes,resizeable=yes');
        return true;
    }
    function startSession(albumOwnerType, albumOwnerId, nextAction) {
        url = '/image-gallery-web/secure/StartSession.action' + '?albumOwnerType=' + albumOwnerType + '&albumOwnerId=' + albumOwnerId +
              '&nextAction=' + nextAction;
        windowId = 'Imageviewer';
        window.open(url, windowId, 'height=520,width=680,top=50,left=50,scrollbars=yes,status=yes,resizeable=yes');
        return true;
    }

    function setFullImage(newPhoto, imgHeight, imgWidth, caption) {
        //change the image
       //ajaxGetter(''+newPhoto,'mainPhoto');
        this.document.fullimage.src = "/image-gallery-web/temp-image.gif";
        this.document.fullimage.width = imgWidth;
        this.document.fullimage.height = imgHeight;
        this.document.fullimage.src = newPhoto;
        this.document.getElementById('photocaption').innerHTML = caption;
        return true;
}


    numberOfPhotosInAlbum = new Array();
    photoAlbumURL =  new Array();
    photoAlbumURLWidth =  new Array();
    photoAlbumURLHeight =  new Array();
     photoAlbumCaption =  new Array();

    var slideshowCounter = 1;

    function counter(){
       setFullImage(photoAlbumURL[slideshowCounter], photoAlbumURLHeight[slideshowCounter], photoAlbumURLWidth[slideshowCounter],photoAlbumCaption[slideshowCounter]);
       slideshowCounter = slideshowCounter +1;
       if(numberOfPhotosInAlbum.length == slideshowCounter){
         slideshowCounter =0;
       }
    }

    var startSlideShowInt;

    function startSlideShow(){
        if (numberOfPhotosInAlbum.length == 0) {
            return;
        }
      slideshowCounter =0;
      counter();
      startSlideShowInt = setInterval('counter()', 5000);
      $('start').style.display = 'none';
      $('pause').style.display = 'block';
    }

    function stopSlideshowFromNav(){
        clearInterval(startSlideShowInt);

    }

    function stopSlideShow(){
      clearInterval(startSlideShowInt);
    $('pause').style.display = 'none';
    $('start').style.display = 'block'; 

    }

    var my_glider;
    var my_glider2;

    function nextPhotos() {
        my_glider.next();

    }
    function previousPhotos() {
        my_glider.previous();
    }
    function pageLoad() {
        my_glider = new Glider('my-glider', {duration:0.5});
        //loadslider();
    }

    function pageLoad2() {
      my_glider2 = new Glider2('my-glider2', {duration:0.5});
      loadslider();
    }
    function loadslider(){
      var startGlide = setInterval('my_glider2.next()', 3000);
    }


function setFullImageProperties(url, height, width) {
      alert("In Image props");
      var newImage = new
       document.getElementById('fullimage').src = ''+url;
       document.fullimage.imageheight = height;
       document.fullimage.imagewidth = width;
     return true;
}

    function setUploadAlbumMode(mode) {
        document.getElementById('uploadAlbumMode').value=mode;
        return ajaxPostFunction(document.mainform, document.mainform.action,'maincontent');

    }

    // function to submit the file upload form and show a div
    function submitUploadForm(form,divName) {
        var hiddenDiv = document.getElementById(divName);
        if (hiddenDiv != null) {
            hiddenDiv.style.display = 'block';
        }

        form.submit();
        return true;
    }

    // function to disable the enter key in form fields; prevents the form being submitted which breaks out
    // of the lightbox
    function stopEnterKey(e) {
        var keynum;
        var keychar;
        var numcheck;

        if (window.event) // IE
        {
            keynum = e.keyCode;
        }
        else if (e.which) // Netscape/Firefox/Opera
        {
            keynum = e.which;
        }
//        alert("keynum=" + keynum);
        if (keynum == 13) {
//            alert('enter key');
            return false;
        }

        return true;
    }



var ajaxLoader = "<div align='center'><br /><br /><img id='loader_gif' src='/image-gallery-web/images/waiting.gif' alt='loading...'/></div>";

/* NEW JAVASCRIPT GET AJAX FUNCTION TO USE */
function ajaxGetter(url,content) {
//    alert('content=' + content + ' url=' + url + ' galleryId=' + document.getElementById("galleryId"));

    document.getElementById(content).innerHTML = ajaxLoader;
    new Ajax.Updater(''+content+'',url,
    {
        method:'get',
        evalScripts: true
    });

//    alert('finished: ' + document.getElementById(content).innerHTML);
    return false;
}
////////////////////////////////////////////////////

//
//
//
//function ajaxPostFunction(form, forwardPage, content){
//
//    alert(form);
//
//
//    var params = "";
//    for (var i=0; i < form.elements.length; i++) {
//        if(i > 0){
//            params += "&";
//        }
//
//        if(form.elements[i].type == "submit") {
//          // do nothing
//      }
//      else if(form.elements[i].type == "checkbox"){
//          if(form.elements[i].checked) {
//              params += (form.elements[i].name + "=" + form.elements[i].value);
//          }
//      }
//      else{
//          params += (form.elements[i].name + "=" + form.elements[i].value);
//      }
//       alert(params);
//  }
//    alert(forwardPage);
//    alert(content);
//
//  new Ajax.Updater(content, forwardPage,
//
//  {
//      method:'post',
//      parameters:params,
//      evalScripts: true,
//
//      onCreate: function(){
//        document.getElementById(content).innerHTML = loader;
//      },
//      onComplete: function(){
//        //$('loaderDiv').hide();
//     }
//
//  });
//
//  return false;
//}
//


function ajaxPostFunction(form, forwardPage, content){
    var params = "";
    for (var i=0; i < form.elements.length; i++) {
        if(i > 0){
            params += "&";
        }

        if(form.elements[i].type == "submit") {
          // do nothing
      }
      else if(form.elements[i].type == "checkbox"){
          if(form.elements[i].checked) {
              params += (form.elements[i].name + "=" + form.elements[i].value);
          }
      }
      else{
          params += (form.elements[i].name + "=" + form.elements[i].value);
      }
  }


  new Ajax.Updater(''+content,forwardPage,
  {
      method:'post',
      parameters:params,
      evalScripts: true,

      onCreate: function(){
        $(''+content).innerHTML=ajaxLoader;
      },
      onComplete: function(){
        //$('loaderDiv').hide();
     }

  });

  return false;
}

// Opens the google authentication window     
 function googleLauncher(url) {
//      alert('opening google window :  ' + url);
      windowId = 'GoogleAuthenticator';
      newWindow = window.open(url, windowId, 'height=520,width=680,top=50,left=50,scrollbars=yes,status=yes,resizeable=yes');
      newWindow.focus();
      return true;

  }