/**
 * @package     Modules
 * @subpackage  Gallery
 * @copyright	Copyright (C) 2005 - 2010 Yannis - Pastis Glaros, Pramnos Hosting
 * @author      Yannis - Pastis Glaros <mrpc@pramnoshosting.gr>
 */

var $x1, $y1, $x2, $y2, $w, $h;


$(document).ready(function() {
    hash = window.location.hash;
    if (hash != ''){
        hash = hash.substr(1);

        window.location = 'index.php?pageid='+moduleid+'&'+hash;
    }

});

function showimage(timage,album){
   
    $.ajax({
        url: "ajax.php",
        type: "GET",
        data: "pageid="+moduleid+"&action=getimage&img=" + timage + "&album=" + album,
        dataType: "json",
        cache: false,
        beforeSend: function(object){
            $('#IFid1').attr("src", "modules/gallery/images/progress_bar.gif");
            $('#morephotos').html('Loading...');
            $('#photocomments').empty();
            $('#customfooter').empty();
        },
        success: function(pingdata){
            //IFid1
            window.location.hash = 'image='+pingdata.cnum+'&album='+ pingdata.album;
            $('#morephotos').empty();
            $('#IFid1').attr("src", pingdata.href);
            $('span.image_title').html(pingdata.image_title);
            $('#image_desc').html(pingdata.image_desc);
            $('#photonum').html(pingdata.cnum);
            $('#timepassed').html(pingdata.timepassed);
            //alert();
            $('title').attr('title', pingdata.pagetitle);
            
            nextimage = pingdata.nextimage;
            previmage = pingdata.previmage;
            $('#totalnum').html(pingdata.totalimages);
            $('#customfooter').html(pingdata.customfooter);
            $('#morephotos').html(pingdata.morephotos);
            $('#fullsizelink').html(pingdata.fullsizelink);
            $('#photocomments').html(pingdata.comments);
            if (analyticsenabled != 'no'){
                pageTracker._trackPageview(pingdata.href);
            }
        }
    })
}


$(document).keydown(function(e){
    if (e.keyCode == 37) {
       showimage(previmage,album);
       return false;
    }
    if (e.keyCode == 39) {
       showimage(nextimage,album);
       return false;
    }
});




function selectChange(img, selection)
{
    document.getElementById('tagX1').value = selection.x1;
    document.getElementById('tagX2').value = selection.x2;
    document.getElementById('tagY1').value = selection.y1;
    document.getElementById('tagY2').value = selection.y2;



}



