
// Shake buttons
id_move = 0;
k = 2;
kActive = 2;

function startShakeObject(obj)
{
if(id_move != 0)
stopShakeObject();

idShaking = obj;
x = parseInt(idShaking.style.left);
y = parseInt(idShaking.style.top);

id_move = setInterval("shakeObject()", 50);
}

function shakeObject()
{
idShaking.style.left = x + (k*2*Math.random() - k - 1);
idShaking.style.top = y + (k*2*Math.random() - k - 1);
}

function stopShakeObject()
{
clearInterval(id_move);
id_move = 0;
idShaking.left = x;
idShaking.style.top = y;
}

function shakeActiveObject()
{
document.all[activeID].style.left = xActive + (kActive*(2*Math.random() - 1) - 1);
document.all[activeID].style.top = yActive + (kActive*(2*Math.random() - 1) - 1);
}

// Photo gallery
var ngallery;

function MoveToPhoto(id, g)
{
document.images['fullphoto'+g].src = "../photos/" + id + ".jpg";
}
function HidePhoto(g)
{
document.images['fullphoto'+g].src = ""; 
document.all['photoenlarge'+g].style.display = "none";
document.all['photogallery'+g].style.display = "block";
}
function EnlargePhoto(id, g)
{
document.all['photogallery'+g].style.display = "none";
document.all['photoenlarge'+g].style.display = "block";
document.images['fullphoto'+g].src = "../photos/" + id + ".jpg";
}
function NextPhoto(g)
{
src = document.images['fullphoto'+g].src; 
start = src.indexOf("photos/") + 7;
l = src.indexOf(".jpg") - start;
id = parseInt(src.substr(start, l));
i = indexFind(id,g);
if(i == -1)
return;
if(i < photoArray[g].length - 1)
MoveToPhoto(photoArray[g][i+1],g);
}
function PrevPhoto(g)
{
src = document.images['fullphoto'+g].src
start = src.indexOf("photos/",g) + 7
l = src.indexOf(".jpg") - start
id = parseInt(src.substr(start, l))
i = indexFind(id,g);
if(i == -1)		
return;
if(i > 0)
MoveToPhoto(photoArray[g][i-1],g);
}
function SavePhoto(g)
{
src = document.images['fullphoto'+g].src; 
start = src.indexOf("photos/") + 7;
l = src.indexOf(".jpg") - start;
id = parseInt(src.substr(start, l));
i = indexFind(id,g);
if(i == -1)
return;
myWin=open("download.php?photo=" + id, "photoWindow", "width=500,height=400");
}
function indexFind(value,g)
{
var i;
for(i=0; i<photoArray[g].length; i++) 
if(photoArray[g][i] == value)
return i;
return -1;
}
photoArray = new Array();