/**********************************************************************************/
/*                                                                                */
/*  Function Name:  change_photo()                                                */
/*  Description:                                                                  */
/*  Parameters                                                                    */
/*  Input:                                                                        */
/*  Output:         string                                                        */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           05 March 2011                                                 */
/*                                                                                */
/**********************************************************************************/


/*

$('#photoset').keydown(function(event) {
 
    if  (document.getElementById('photoset'))
    {
        var photoset  = document.getElementById('photoset');
        var nextphoto = photoset.photonext.value;
        var prevphoto = photoset.photoprev.value;
        
        if (event.keyCode == '39') 
        {
            //  next photo
            $('div#content_2').load(nextphoto + ' div#content_3');
        }
 
        else if (event.keyCode == '37') 
        {
            //  previous photo
            $('div#content_2').load(prevphoto + ' div#content_3');
        }
 
    }

});

*/

function navigate_photosetphoto(evt)	{

  evt = (evt) ? evt : ((event) ? event : null);

  if  ((evt) && (document.getElementById('photoset')))	{

    var photoset  = document.getElementById('photoset');
    var nextphoto = photoset.photonext.value;
    var prevphoto = photoset.photoprev.value;
	
    var thingPressed  = "";
		
    var elem = (evt.target) ? evt.target : evt.srcElement;
		
    thingPressed  = (evt.charCode) ? evt.charCode : evt.keyCode;

		if  (thingPressed == "39")	{
      //  next photo
      //  ajax_fetch_url(nextphoto, 'photosetphoto');

      $('div#content_2').load(nextphoto + ' div#content_3');
			
    } else if (thingPressed == "37")	{
			//  previous photo
      //  ajax_fetch_url(prevphoto, 'photosetphoto');

      $('div#content_2').load(prevphoto + ' div#content_3');
    
    }
  
  }

  return false;

}

function initKeyDetect()	{
  attachEventListener(document, "keydown", function (evt) { navigate_photosetphoto(evt); }, false);
  return true;
}


addLoadListener(initKeyDetect);



