﻿/****************************************************************************************** 
Produces a Slide Show

This source code is the intellectual property of Genesis Software Corp. 
You are free to use this code provided this copyright notice appears.

Created by Genesis Software Corp. 
Copyright (c) 2009 Genesis Software Corp.
All Rights reserved

Employing this code without this copyright notice is a violation of US and International Copyright Laws.
******************************************************************************************/
function SlideShow(ss_url, host_element_id, px_height, px_width)
{
    this.homeURL=ss_url;
    this.target_element_id=host_element_id;
    this.cur_image=0;
    this.num_images=0;
    this.image_list=new Array();
    if(px_height != undefined)
        this.height_px=px_height;
    if(px_width != undefined)
        this.width_px=px_width;
    //Methods
    this.add=slide_show_add_image_set_object;    
    this.setListener=slide_show_setListener;
    this.evt_handler=slide_show_evt_handler;
    
}

/****************************************************************
Assume the objName will have a dot
****************************************************************/
function slide_show_setListener(nMilllisecs, slide_show_instance_name)
{
    return window.setInterval("slide_show_evt_handler('"+slide_show_instance_name+"')", nMilllisecs);
}

/****************************************************************
****************************************************************/
function slide_show_evt_handler(slide_show_instance_name)
{
    //You're a dirty little boy mr. plates
    var oSlideShow=eval(slide_show_instance_name);
    
    if(oSlideShow.num_images.length==0) return;
    if(oSlideShow.cur_image < oSlideShow.num_images-1)
        oSlideShow.cur_image++;
    else
        oSlideShow.cur_image=0;    
    var DisplayItem=oSlideShow.image_list[oSlideShow.cur_image];
    var imageDoc=DisplayItem.image;
    var click_url=DisplayItem.url;
    if(oSlideShow.homeURL.length > 0)
        {
        imageDoc=oSlideShow.homeURL+DisplayItem.image;
        click_url=oSlideShow.homeURL+DisplayItem.url;
        }
    var final_strng="<a href=\""+click_url+"\"><img src=\""+imageDoc+"\" border=\"0\"";
    if(oSlideShow.height_px != undefined)
        final_strng += " height=\"" + oSlideShow.height_px + "\"";
    if(oSlideShow.width_px != undefined)
        final_strng += " width=\"" + oSlideShow.width_px + "\"";
    final_strng += "></a>";
    document.getElementById(oSlideShow.target_element_id).innerHTML=final_strng;
}

/****************************************************************
****************************************************************/
function slide_show_add_image_set_object(image_file_name, image_click_url)
{
    var oSS=new SlideShowDisplayItem(image_file_name, image_click_url)
    this.image_list[this.num_images++]=oSS;
}


var slide_show_homeURL="";


/****************************************************************
****************************************************************/
function SlideShowDisplayItem(image_file_name, image_click_url)
{
    this.image=slide_show_homeURL+image_file_name;
    this.url=slide_show_homeURL+image_click_url;
}

/****************************************************************
Non Object oriented
var slide_show_cur_slide=-1;
var slide_show_num_slides=0;
var slide_show_image_list=new Array();


Cycle through the next image_list item and display to the given html element's
innerHTML.
function slide_show_next_element(html_elm_id)
{
    if(slide_show_image_list.length==0) return;
    if(slide_show_cur_slide < slide_show_num_slides)
        slide_show_cur_slide++;
    else
        slide_show_cur_slide=0;    
    var DisplayItem=slide_show_image_list[slide_show_cur_slide];
    var imageDoc=DisplayItem.image;
    var click_url=DisplayItem.url;
    document.getElementById(html_elm_id).innerHTML=("<a href=\""+click_url+"\"><img src=\""+imageDoc+"\" border=\"0\"></a>");
}
****************************************************************/

