/// <reference path="../jquery/jquery-1.3.2-vsdoc2.js"/>

// ----------------------------------------------------------------------------------
// Class ISSFImage
// ---------------------------------------------------------------------------------- 
function ISSFImage(path, text) {
    this.path = path;
    this.text = text;
    this.author = "";
    this.existLarge = "false";
}
function ISSFImage(path, text, author) {
    this.path = path;
    this.text = text;
    this.author = author;
    this.existLarge = "false";
}
ISSFImage.prototype.setPath = function(value) {
    this.path = value;
}
ISSFImage.prototype.setText = function(value) {
    this.text = value;
}
ISSFImage.prototype.setAuthor = function(value) {
    this.author = value;
}
ISSFImage.prototype.setExistLarge = function(value) {
    this.existLarge = value;
}
ISSFImage.prototype.getPath = function() {
    return this.path;
}
ISSFImage.prototype.getText = function() {
    return this.text;
}
ISSFImage.prototype.getAuthor = function() {
    return this.author;
}
ISSFImage.prototype.getExistLarge = function() {
    return this.existLarge;
}

// ----------------------------------------------------------------------------------
// Class HomeGallery
// ---------------------------------------------------------------------------------- 
function HomeGallery(images) {
    this.currPicture = 0;
    this.rotatorId = 0;
    this.autoPlay = true;
    this.images = images;
}
function fullScreen(theURL, autoPlay) {
    
    // Bildwiedergabe stoppen falls ein Bild angeklickt wird.
    if (homeGallery.autoPlay == true) {
        playPause();
    }
    window.open(theURL, '', 'fullscreen=yes, scrollbars=yes');
}
HomeGallery.prototype.selectImage = function(value) {
    document.getElementById("homegallerytext").firstChild.innerHTML = this.images[value].getText();

    var authorHtmlTag = document.getElementById("homegalleryauthor");
    if (authorHtmlTag != null) {
        authorHtmlTag.innerHTML = this.images[value].getAuthor();
    }


    var existLarge = this.images[value].getExistLarge().toLowerCase();

    if (existLarge == "true") {
        jQuery("#homegallerystage").empty();        
        jQuery("#homegallerystage").append(
            "<a href=\"javascript:void(0);\" onClick=\"fullScreen('image.htm?image=" + this.images[value].getPath() + "');\">" +
                "<img src=\"" + this.images[value].getPath() + "\" id=\"homegalleryimage\" alt=\"\" />" +
            "</a>" +
            // Fullscreen Image
            "<div class=\"photoplayer_fullscreenicon\">" +
                "<a href=\"javascript:void(0);\" onClick=\"fullScreen('image.htm?image=" + this.images[value].getPath() + "');\">" +
                    "<img src=\"/App_Themes/issftheme/Images/photoplayer/fullscreenicon.png\" alt=\"\" />" +
                "</a>" +
            "</div>");

    } else {
        jQuery("#homegallerystage").empty();
        jQuery("#homegallerystage").append(
            "<img src=\"" + this.images[value].getPath() + "\" id=\"homegalleryimage\" alt=\"\" />");

    }
}

HomeGallery.prototype.previousImage = function() {
    if (this.currPicture > 0) {
        this.currPicture--;
    } else {
        this.currPicture = this.images.length - 1;
    }
    this.selectImage(this.currPicture);
}

HomeGallery.prototype.nextImage = function() {
    this.currPicture++;
    if (this.currPicture >= this.images.length) {
        this.currPicture = 0;
    }
    this.selectImage(this.currPicture);
}

HomeGallery.prototype.loadImage = function(value) {
    if (value >= 0 && value < this.images.length) {
        this.currPicture = value;
        this.selectImage(this.currPicture);
    }
}

HomeGallery.prototype.rotator = function() {
    this.nextImage();
}

HomeGallery.prototype.startRotator = function(myfunction) {
    this.rotatorId = window.setInterval(myfunction, 3000);

}
HomeGallery.prototype.stopRotator = function() {
    window.clearInterval(this.rotatorId);
}





/* 
Using MooTools to fade between two images

Fading between two images is actually a fairly simple task with MooTools. 
The first thing you need to do is setup up two DIV tags that are absolutely 
positioned over one another inside another DIV tag that uses default placement. 
Then you place your image tags inside each of the absolutely positioned DIV tags. 
Each of the DIV tags needs to have an id attribute so they can be referenced 
in your javascript code.

This gives you two DIV tags that will stack on top of one another but the DIV they 
are inside of will flow with the page. One of the DIV tags starts with an opacity 
of zero and the other with an opacity of one

First you decide which DIV tag will become Transparent and which one will be visible. 
Next there are two lines of code to check for an active animation and stop any animations 
that are already running, before we start some new animations. The last two lines 
create an animation attached to each DIV, going from the current opacity to the specified 
Opacity, and sets the animation object to the DIV tags .fx member. See the full code 
below or check out the example.

<script type=”text/javascript” src=”/js/mootools-release-1.11.js” language=”javascript”></script>
<script language=”javascript”>
function show(whichOne){
if(whichOne == 1){
tDiv = “div1″;
vDiv = “div2″;
}else{
tDiv = “div2″;
vDiv = “div1″;
}
if($(tDiv).fx){$(tDiv).fx.stop();}
if($(vDiv).fx){$(vDiv).fx.stop();}
$(tDiv).fx = $(tDiv).effect(’opacity’, {duration: 2000}).start(0);
$(vDiv).fx = $(vDiv).effect(’opacity’, {duration: 2000}).start(1);	
}
</script>
<div style=”background-color:#aaaaaa; border: 1px solid #444; cursor: pointer;” onclick=”show(1);”>Show 1</div>
<div style=”background-color:#aaaaaa; border: 1px solid #444; cursor: pointer;” onclick=”show(2);”>Show 2</div>
<div style=”height:112px;”>
<div id=”div1″ style=”position:absolute; opacity: 0;”><img id=”image1″ src=”http://www.sweetvision.com/wordpress/wp-content/uploads/2008/03/image1.jpg” /></div>
<div id=”div2″ style=”position:absolute; opacity: 1;”><img id=”image2″ src=”http://www.sweetvision.com/wordpress/wp-content/uploads/2008/03/image2.jpg” /></div>
</div>
*/