/*
Interactive Image slideshow with text description
By Christian Carlessi Salvads (cocolinks@c.net.gt). Keep this notice
intact.
Visit http://www.dynamicdrive.com for script
*/
/* kquinn: this script has been considerably modified */


/* global variables */
g_fPlayMode = 0;
g_iimg = -1;
g_imax = 0;
g_ImageTable = new Array(); /* this is the original array. Another smaller array (smallArray) is randomly selected from its contents. */
g_img_dir = '/graphics/slideshow-players/mini-slideshow-250w/images/';


function illuminate(thisLight) {

    // turn the lights off
    var lights = new Array();
    lights[1] = getobject("light_01");
    lights[2] = getobject("light_02");
    lights[3] = getobject("light_03");
    lights[4] = getobject("light_04");
    lights[5] = getobject("light_05");
    lights[6] = getobject("light_06");
    lights[7] = getobject("light_07");

    for( n=1;n<lights.length;n++ ) {
	if( thisLight == n ) {
	    // turn on one light
	    //	    var onlight = document.getElementById(thisLight);
	    //      onlight.src = g_img_dir + 'sustainability-slideshow_11.jpg'
	    
	    lights[n].src = g_img_dir + 'on.jpg'
		} else {
		    lights[n].src = g_img_dir + 'off.jpg';
		}
    }
return false;
}

/* slideshow functions */
function ChangeImage(fFwd)
{
if (fFwd)
{
   if (++g_iimg==g_imax){
         g_iimg=0;
   }
}
else
{
   if (g_iimg==0){
      g_iimg=g_imax;
   }
   g_iimg--;
   
}
Update();
}

function getobject(obj){
if (document.getElementById)
return document.getElementById(obj)
else if (document.all)
return document.all[obj]
}

function Update(){

//  g_imax = 7;

  // need to call modifyimage to apply transition filter for IE
  illuminate(g_iimg+1);
  modifyimage("_Ath_Slide_Container",g_iimg);
  getobject("_Ath_FileName").innerHTML = smallArray[g_iimg][2];

  // added this to create hyperlink
//  getobject("_Ath_Href").href = smallArray[g_iimg][1];
}


function Play()
{
  g_fPlayMode = !g_fPlayMode;
  if (g_fPlayMode)
  {  // play mode
    getobject("btnPlay").alt = "Pause Slideshow";
    getobject("btnPlay").src = g_img_dir + 'pause.jpg';

    Next();

  } else {    // stop mode
  getobject("btnPlay").alt = "Play Slideshow";
  getobject("btnPlay").src = g_img_dir + 'play.jpg';
  }
}
function OnImgLoad() {
  if (g_fPlayMode)
  g_to = window.setTimeout("Tick()", g_dwTimeOutSec*1000);
}
function Tick() {
  if (g_fPlayMode)
  Next();
}
function Prev() {
  ChangeImage(false);
}
function Next() {
  ChangeImage(true);
}
function showSlide(number) {

    // stop the show
    Stop();

    // change the current image in the slideshow
    g_iimg = number-1;

    // show one slide
    modifyimage("_Ath_Slide_Container",number-1);

    // show appropriate description
    getobject("_Ath_FileName").innerHTML = smallArray[number-1][2];    
    
    // turn on light which corresponds to it
    illuminate(number);
    return false;
}
function Stop() {

    if( typeof(g_to) != "undefined" ) {
	// clearTimeOut for Tick or the slide change will get erratic after stopping and starting show
	clearTimeout(g_to)
    }
    // change play mode
    g_fPlayMode = false;

    // direct the user
    getobject("btnPlay").alt = "Play Slideshow";

    // change the image to play button
    getobject("btnPlay").src = g_img_dir + 'play.jpg';
}
    
    


////configure below variables/////////////////////////////


//configure the below images and description to your own. 
/* elements: [0] is the image filepath, [2] is the title/hyperlink shown, [1] is the URL to link to. */
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Safe-School-Recognition--5..jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Safe-School-Recognition-.jpg","<div class=\"desc_header\">School Building Day</div>Members of the Foshay Learning Center school community joined to highlight the voters. and LAUSD's significant investment in the safety of its school campuses through the bond funded $7.6 Modernization & Repair Program.  At LAUSD's Foshay Learning Center alone, more than $6 million has been invested in fire alarm upgrades, and various safety and technology upgrades, all of which directly benefit the safety of students. This is representative of the more than $1 billion in similar projects District-wide which make our school campuses safer places for students and community alike. Although these upgrades are not as visible as other school building modernizations, they are among the most critical for the safety and well-being of students.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Historic-Schools-Day-4.28.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Historic-Schools-Day-4.2.jpg","<div class=\"desc_header\">Historic Schools Day</div>Historic Schools Day, Tuesday, April 28, Chief Facilities Executive Guy Mehula recognized the coalition that ensures Valley Region High School #5 reflects the historical integrity of the neighborhood architecture. The coalition includes the project architect, community based organizations, local residents and officials from the City of San Fernando. Thanks to the coalition.s efforts, the students and community of San Fernando will receive a school building that pays tribute to the past while helping make possible a better future.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Healthy-Schools-Colfax.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Healthy-Schools-Colfax.jpg","<div class=\"desc_header\">Healthy Schools Day</div>LAUSD Kicked off Healthy Schools Day on Monday, April 27 at Colfax Elementary School, where Board Member Tamar Galatzan recognized Colfax Elementary School's outstanding efforts to create and maintain a healthy school environment at the schools weekly assembly.  Galatzan also presented a $5,000 check to the school to support its thriving school garden.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Healthy-School---University.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Healthy-School---Univers.jpg","<div class=\"desc_header\">Healthy Schools Day</div>The Healthy Schools Day celebration continued at University High where School Board Member Marlene Canter, Chief Facilities Executive Guy Mehula, Director of Food Services Dennis Barrett and University High School Principal Eric Davidson toured the school's newly modernized cafeteria.  Thanks to new mobile serving lines and equipment which ensure the hot foods stay hot and cold foods stay cold, the University High School cafeteria is now serving as many as three hundred more lunches a day and in less time.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Community-Day-4.30.09-056.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Community-Day-4.30.09-05.jpg","<div class=\"desc_header\">Schools as Centers of Community Day</div>Members of the Washington Irving Middle School community and special guests came together for the unveiling of the \"Fun Fence\" that students created to decorate the construction site of Central Los Angeles High School #13. Working with the \"I See My River\" project, the students created art inspired by the Los Angeles River.  The \"Fun Fence\" celebration provides students and the community an opportunity to celebrate their new school and new center of community.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Senior-Citizens-Day-4.29.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Senior-Citizens-Day-4.29.jpg","<div class=\"desc_header\">Senior Citizens in Schools Day</div>Board Member M&oacute;nica Garc&iacute;a celebrated Senior Citizens in Schools Day on Wednesday, April 29 by recognizing senior citizens from across the District who have participated in and been committed to LAUSD's school building program and to the students of their various communities.");
g_ImageTable[g_imax++] = new Array ("/graphics/slideshow-players/mini-slideshow-250w/images/Community-Day-4.30.09-007.jpg","/graphics/slideshow-players/mini-slideshow-250w/images/lg-Community-Day-4.30.09-00.jpg","<div class=\"desc_header\">Schools as Centers of Community Day</div>Members of the Washington Irving Middle School community and special guests came together for the unveiling of the \"Fun Fence\" that students created to decorate the construction site of Central Los Angeles High School #13. Working with the \"I See My River\" project, the students created art inspired by the Los Angeles River. The \"Fun Fence\" celebration provides students and the community an opportunity to celebrate their new school and new center of community.");

// Kevin Quinn
// March 3, 2004
// set g_imax to the number of  elements of the array for viewing in slideshow


function inArray(value,thisArray) {
   for( i=0;i<thisArray.length;i++ ) {
      if( thisArray[i] === value ) {
         return 1;
      }
   }
return 0;
}

smallArray = new Array();
var z = 0;
var nextnum = null;
g_imax = 7;

while( smallArray.length < g_imax) {
    z++;    
    nextnum = Math.floor(Math.random() * g_ImageTable.length)
	// the break number was increased to 50 so that you always wind up with a full array (small array with g_imax elements)
    if (z > 50) break;
    
    if(!inArray(g_ImageTable[nextnum],smallArray)) { 
       smallArray.push(g_ImageTable[nextnum]);
    }
}

/* debug */
/* 
for( n = 0;n<smallArray.length;n++ ) {
     document.write( smallArray[n][0] + ": " + n + "<BR>" );
}
*/

//extend the above list as desired
g_dwTimeOutSec=5

////End configuration/////////////////////////////

if (document.getElementById||document.all)
window.onload=Play



// begin transitions JavaScript

//Preload images ("yes" or "no"):
var preloadimg="no"// otherwise pageload will take too long

//Set optional link target to be added to all images with a link:
var optlinktarget="_self"

//Set image border width
var imgborderwidth=0

//Optionally, change 1.0 and 0.7 below to affect Wipe gradient size and duration in seconds in IE5.5+:
//var filterstring="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=1.0)"
var filterstring="progid:DXImageTransform.Microsoft.Fade(Overlap=1)"

///////No need to edit beyond here/////

if (preloadimg=="yes"){
for (x=0; x<smallArray.length; x++){
var myimage=new Image()
myimage.src=smallArray[x][0]
}
}

function returnimgcode(theimg){
var imghtml=""
if (theimg[1]!="")
imghtml='<a style="cursor:hand;cursor:pointer;"'
imghtml+=' onmouseover = "window.status = \'Click image to open larger image.\'"'
imghtml+=' onclick = "openWindow(\'' + theimg[1] + '\')" target="'+optlinktarget+'">'
imghtml+='<img onload = "OnImgLoad()" width = "248" height="168" src="'+theimg[0]+'" border="'+imgborderwidth+'">'


if (theimg[1]!="")
imghtml+='</a>'
return imghtml
}

/* in order to use transitions there must be 3 phases and they must be in order. */
/*
1. Apply the filter
2. Change the image or other element to be changed
3. Play the transition filter
*/
function modifyimage(loadarea, imgindex){
if (document.getElementById){
var imgobj=document.getElementById(loadarea)
if (imgobj.filters && window.createPopup){
imgobj.style.filter=filterstring
imgobj.filters[0].Apply()
}
imgobj.innerHTML=returnimgcode(smallArray[imgindex])
if (imgobj.filters && window.createPopup)
imgobj.filters[0].Play()
return false
}
}

function openWindow(urlString) {
popupWin=window.open(urlString,'remote','width=800,height=600,top=50,left=100,resizable=yes')
}



