/// EVENTS
var initloop = true;
var eltSlideShow;
var eltCaptions;
var eltAds0;
var eltContent;
var eltPlaceHolder;
//var eltTest99;
var maxdivs = 7;
var is = new Is();

var intLeftAlley = 600
var imgHeight = 400
var slideShowTop = '265px;'
var captionTopLine = imgHeight+265 + 'px;'
var adToggle=0;

//User defined variables - change these variables to alter the behaviour of the script
var ImageFolder = "/Images/Ads/"; //Folder name containing the images
var ImageFileNames = new Array('Capstone1L.jpg', 'SportsSpectrumL.jpg'); //List of images to use
var ImageURLs = new Array('http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html', 'http://www.iplus.zetnet.co.uk/', 'http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html', 'http://www.iplus.zetnet.co.uk/'); //List of hyperlinks associated with the list of images
var DefaultURL = 'http://www.hspn.net/default.asp'; //Default hyperlink for the Banner Ad
var DisplayInterval = 8; //Number of seconds to wait before the next image is displayed
var TargetFrame = ""; //Name of the frame to open the hyperlink into
//Internal variables (do not change these unless you know what you are doing)

// Defaults: --------
var ctrlMainLooping = 1;
var offsetMainSlideShow = 0;
var MainSlideshowImageNum = 0
var startMainSlideshowImageNum = 0;
var selectedCaptionNum = 0;
var refreshMainSlideShowImage = true;
// ------------------

var IsValidBrowser = false;
var BannerAdCode = 0;
var ciInitIndex = 0;
var Adcounter = 0;
var maxAds = 1;
var maxMainSlideshowImageNum = 40;
var startAd = 0;

//var oLayer = eval('eltAds0');
var oSlideShow = eval('eltSlideShow');
//var oCaptions = eval('eltCaptions');

DisplayInterval = DisplayInterval * 1000;
//var NumberOfImages = ImageFileNames.length;
var NumberOfImagesa = 39;
var CountofDivs = 27;

//Add a trailing forward slash to the ImageFolder variable if it does not already have one
if (ImageFolder.substr(ImageFolder.length - 1, ImageFolder.length) != "/" && ImageFolder != "") { ImageFolder += "/";}
if (TargetFrame == '')
{
	var FramesObject = null;
}	
else
{
	var FramesObject = eval('parent.' + TargetFrame);
}


function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // --- BROWSER VERSION ---
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major >= 4))
		
    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = (this.ie && (this.major == 4))

    this.opera = (agt.indexOf("opera") != -1)
     
    this.nav4up = this.nav && (this.major >= 4)
    this.nav5up = this.nav4up && (navigator.userAgent.indexOf("Firefox")!=-1)

    this.ie4up  = this.ie  && (this.major >= 4)
}
function init_vars()
	{
		eltSlideShow = getElt("Slideshow");
		eltPlaceHolder = getElt("placeHolder");
//		eltAds0 = getElt("AdBanner1");
//		eltCaptions = getElt("MainCaptions");
//		eltContent = getElt("Content");
		//eltWaitBox = getElt("WaitBox");
		//showContent();
	}

function getElt () 
{
 if (is.nav5up) {
    var currentLayer = document.getElementById([getElt.arguments[0]]);
    return currentLayer;
  } 
  else if (is.ie4up ) {
    var elt = eval('document.all.' + getElt.arguments[getElt.arguments.length-1]);
    return(elt);
  }
  else if (is.nav4up) {
	//showit(document.layers[0]);
    var currentLayer = document.layers[getElt.arguments[0]];

    for (var i=1; i<getElt.arguments.length && currentLayer; i++)
    {   currentLayer = currentLayer.document.layers[getElt.arguments[i]];
    }
    return currentLayer;
    }
}

function clearWait() {
	document.all.WaitBox.style.display = 'none';
  document.all.Content.style.visibility = 'visible';
}
function showContent()  {
	var oLayer = eval('eltContent');

	if (is.nav5up)
		{
		oLayer.style.visibility = "visible";
		}
	else if (is.nav4up)
		{
		oLayer.visibility = "visible";
		document.layers[0].visibility = "hidden";
		}
	else
		{
		oLayer.style.visibility = "visible";
		}
}
function showMe(d) {
	var oLayer = eval('eltAds' + d);
	if (is.nav4up)
		{
		oLayer.visibility = "visible";
		}
	else
		{
		oLayer.style.visibility = "visible";
		}
}
var aSlideShow = new Array;
aSlideShow[0]='<img src="http://www.hspn.net/images/EastCoast/PhotoGallery/BoysV5A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[1]='<img src="http://www.hspn.net/images/EastCoast/PhotoGallery/18UGirlsWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[2]='<img src="http://www.hspn.net/images/EastCoast/Marketing/VinesFloor.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[3]='<img src="http://www.hspn.net/images/EastCoast/PhotoGallery/SlamDunkLEAD.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[4]='<img src="http://www.hspn.net/images/Investment/PrayerCircleInv.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[5]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/CoachesPickupGameLead.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[6]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/CoachesPickupGame3.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[7]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/15UGirlsWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[8]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/12UBoysWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[9]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/15UBoysWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[10]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/18UBoysWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[11]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/AdultsWinners.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[12]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/Luncheon3.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[13]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/Luncheon.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[14]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/Luncheon2.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[15]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV3A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[16]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV3A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[17]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV3A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[18]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV3A3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[19]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV2A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[20]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV2A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[21]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV1A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[22]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsV1A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[23]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsJV1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[24]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsJV2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[25]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/GirlsJV3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[26]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV5A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[27]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV5A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[28]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV5A3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[29]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV4A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[30]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV4A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[31]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV4A3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[32]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV3A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[33]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV3A2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[34]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV3A3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[35]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV2A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[36]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/Boys_V_2A_2nd_CHENWhite 2717.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[37]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysV1A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[38]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysVA2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[39]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysVA3rd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[40]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/BoysJV3A1st.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';
aSlideShow[41]='<img src="http://www.hspn.net/Images/EastCoast/PhotoGallery/Boys_JV_3A_2nd.jpg" width="' + intLeftAlley + '" height="' + imgHeight + '" align="left" hspace="2">';

//JavaScript Banner Ad Rotator version 2.1 - last modified 16 November 2000
//Obtained from http://www.brettb.com/js_banner_ad_rotator.asp
//Email comments or suggestions using the form at http://www.brettb.com/Contact.asp
//If you want a version of this script that will open links in a new browser window
//then please visit http://www.winnershtriangle.com/w/Products.JavaScriptBannerAdRotator.asp


function InitializeSlideshow() 
{
	//Determine the browser name and version
	//The script will only work on Netscape 3+ and Internet Explorer 4+
	var BrowserType = navigator.appName;	
	var BrowserVersion = parseInt(navigator.appVersion);

	if (BrowserType == "Netscape" && (BrowserVersion >= 3)) 
	{
		IsValidBrowser = true;
		//alert(IsValidBrowser);
	}

	if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) 
	{
		IsValidBrowser = true;
	}
	if (IsValidBrowser) 
	{
		document.TimerObject = setTimeout("ChangeImage('',maxMainSlideshowImageNum,startMainSlideshowImageNum, refreshMainSlideShowImage)", 0);
//    document.TimerObject = setTimeout("ChangeImagea('',maxAds, startAd)", 0);

	}
}

function ChangeImage(preF, maxImageNum, startImageNum, refresh)
{
	//setMainSlideshow();
	
	if (IsValidBrowser)
		{
			// ----------- call to change slide show image ----
			//alert(MainSlideshowImageNum+','+ctrlMainLooping+','+imageWithinSlideShowPanelCounter+','+selectedCaptionNum);
			showFlash(MainSlideshowImageNum , selectedCaptionNum, refreshMainSlideShowImage);
			//selectedCaptionNum++;
			MainSlideshowImageNum++;			
			 if (MainSlideshowImageNum > maxMainSlideshowImageNum)	
				{
					MainSlideshowImageNum = 0;
					//selectedCaptionNum = 0;
				}
			if (adToggle > 0)
				{
				//document.TimerObject = setTimeout("ChangeImagea('',maxAds, startAd)", 0);
				//adToggle = 0;
				}
			else
				{
				adToggle = 1;
				}
			document.TimerObject = setTimeout("ChangeImage('', maxMainSlideshowImageNum, startMainSlideshowImageNum)", DisplayInterval);
		}
}

function ChangeImagea(preF, maxI, initIndex) {

	if (IsValidBrowser)
	 {
		Adcounter = Adcounter + 1;
		if (Adcounter > maxI)
		{
			Adcounter = initIndex;
		}
		showAda(Adcounter);
	}
}

function showAda(d)
{
//oLayer = eval('eltAds0');
if (IsValidBrowser)
{
//		oLayer.innerHTML = adsF[d];
//		oLayer.style.visibility = "visible";
}
}

function showFlash(d,o,refresh)
{

	//alert(d +','+o+','+refresh);
	//document.getElementById("MainCaptions").style.visibility="hidden";
	//document.getElementById("MainCaptions").style.backgroundColor="transparent";
	//document.getElementById("MainCaptions").style.left="5px";
	//document.getElementById("MainCaptions").style.top="485px";
	//document.getElementById("MainCaptions").style.width="280px";
	//document.getElementById("MainCaptions").style.position="absolute";

	document.getElementById("Slideshow").style.visibility="hidden";
	document.getElementById("Slideshow").style.backgroundColor="transparent";
	document.getElementById("Slideshow").style.left="20px";
	document.getElementById("Slideshow").style.top= "110px";
	document.getElementById("Slideshow").style.width="600px";
	document.getElementById("Slideshow").style.position="absolute";


	oSlideShow = eval('eltSlideShow');
	//oCaptions = eval('eltCaptions');

	if (IsValidBrowser)
	{
		//setMainSlideshow();
		//oCaptions.style.visibility = "visible";
		//oCaptions.innerHTML = '<p>Photo<br><br>is<br><br>Loading.....</p>';

		if (refresh)
		{
			//oSlideShow.innerHTML = '<p>Photo<br><br>is<br><br>Loading.....</p>';
			oSlideShow.style.visibility = "visible";
			oSlideShow.innerHTML = aSlideShow[d];
			oSlideShow.style.visibility = "visible";
		}
		//oCaptions.style.visibility = "visible";
		//oCaptions.innerHTML = aCaptions[o];
    //document.getElementById("MainCaptions").style.visibility="visible";
	}
}


function setMainSlideshow() {
 if (MainSlideshowImageNum = maxMainSlideshowImageNum)	
	{
		MainSlideshowImageNum = 0;
		//selectedCaptionNum = 0;
	}
}
function setSlideShowDefaults(val)
{
	ctrlMainLooping = val;
	ctrlMainPanelLooping =0;
	offsetMainSlideShow = 0;
	imageWithinSlideShowPanelCounter =0;
	MainSlideshowImageNum = 40+(6*(val-1));
	startMainSlideshowImageNum = MainSlideshowImageNum;
	selectedCaptionNum = 6*(val-1);
	refreshMainSlideShowImage = true;

}
