// DHgallery v 1.0 -> Copyright (c) 2006 Dhstudio.eu <http://www.dhstudio.eu/>

//DHgallery Variables

var images = new Array();
var comments = new Array();
var showthis=0;
var galleryID="gallery";
var galleryINFO="imageinfo";
var gallery_counter="gallery_counter";
var pressbutton=0;



function initImage(imageId)
{
        image = document.getElementById(imageId);
        setOpacity(image, 0);
        fadeIn(imageId,0);
        pressbutton=1;
}
function fadeIn(objId,opacity)
{

if (document.getElementById)
        {
        obj = document.getElementById(objId);
        if (opacity <= 100)
                {
                setOpacity(obj, opacity);
                opacity += 10;
                window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
                }
        }
}

function setOpacity(obj, opacity)
{
        opacity = (opacity == 100)?99.999:opacity;   
        obj.style.filter = "alpha(opacity:"+opacity+")";   // IE/Win
        obj.style.KHTMLOpacity = opacity/100;   // Safari<1.2, Konqueror
        obj.style.MozOpacity = opacity/100;   // Older Mozilla and Firefox
        obj.style.opacity = opacity/100;   // Safari 1.2, newer Firefox and Mozilla, CSS3
}

function dhgallery ()
{
// Get Pics -> images array
for ( var i=1;i<arguments.length;i+=2)
{
        if ( i == 1 ) 
        {
                var sortelements=0;
        }
images[sortelements]=arguments[i];
sortelements++;
};
// Get Comments -> comments array
for ( var i=2;i<arguments.length;i+=2)
{
        if ( i == 2 ) 
                {
                var sortelements=0;
                }

comments[sortelements]=arguments[i];
sortelements++;
};

function refresh_counter()
        {
                var gallerycounter = document.getElementById(gallery_counter);
                gallerycounter.innerHTML=showthis+1 + "/" + images.length ;
                changeinfo = document.getElementById(galleryINFO);
                changeinfo.innerHTML=comments[showthis];
		big_image.innerHTML="<a href=http://vnproperty.eu/"+images[showthis]+" target='_blank'>Big Image</a>";
                initImage(galleryID)
                setTimeout("pressbutton=0",2000);
        }

//Check First Argument

if ( arguments[0] == "dhgallery" )
        {
        refresh_counter();
        }

if (arguments[0] == "next" )
{
        if ( ( showthis < images.length-1) && ( pressbutton == 0 ) )
                {
                document.getElementById(galleryID).src = images[++showthis];
		changeinfo = document.getElementById(galleryINFO);
                changeinfo.innerHTML=comments[showthis];
		big_image.innerHTML="<a href=http://vnproperty.eu/"+images[showthis]+" target='_blank'>Big Image</a>";
                refresh_counter();
                }
}

if (arguments[0] == "back" )
{
        if ( ( showthis > 0 ) && ( pressbutton == 0 ) )
                {
                document.getElementById(galleryID).src = images[--showthis];
                changeinfo = document.getElementById(galleryINFO);
                changeinfo.innerHTML=comments[showthis];
                refresh_counter();
                }
}


if (arguments[0] == "begin" )
{
	if ( ( showthis > 0 ) && ( pressbutton == 0 ) )
		{
		showthis=0;
		document.getElementById(galleryID).src = images[showthis];
		changeinfo = document.getElementById(galleryINFO);
		changeinfo.innerHTML=comments[showthis];
		refresh_counter();
		}
}


if (arguments[0] == "end" )
{
	if ( ( showthis > -1 ) && ( pressbutton == 0 ) )
		{
		showthis=(images.length-1);
		document.getElementById(galleryID).src = images[showthis];
		changeinfo = document.getElementById(galleryINFO);
		changeinfo.innerHTML=comments[showthis];
		refresh_counter();
		}
}



// End Dhgallery
}
