var counter = 1; 
var imagePath = 'images/homepage/';
var slideDuration = 9000; //time in milliseconds
var transitionDuration = 1500; //time in milliseconds
var numberOfSlides = 5; //number of slides in folder
var numberOfYIPSlides = 23; //number of slides in folder
var linksArray = new Array();
var imagesArray = new Array();
var i=0;
var randomnumber=Math.floor(Math.random()*(numberOfYIPSlides-1)) + 1
var YIPcounter = randomnumber

linksArray[1] = "Inside%20SAISD/News/District%20Highlights/MonthlyHighlights.asp?theMonth=5&theYear=2007#1303"; //Michelle Ruiz
linksArray[2] = "Inside%20SAISD/News/News%20Releases/PressRelease.asp?PRID=1293"; //Girls Gymnastics
linksArray[3] = "Inside%20SAISD/News/District%20Highlights/MonthlyHighlights.asp?theMonth=5&theYear=2007#1304"; //Lamar Great Barrier Reef
linksArray[4] = "Inside%20SAISD/News/News%20Releases/PressRelease.asp?PRID=1292"; //Brian Ball
linksArray[5] = "Inside%20SAISD/News/News%20Releases/PressRelease.asp?PRID=1291"; //Chris Sloan HEB Award

imagesArray[1] = "MichelleRuiz4thPlaceStatePoleVault.jpg" //Michelle Ruiz
imagesArray[2] = "GirlsGymnasticsStateChamps2007.jpg" //Girls Gymnastics
imagesArray[3] = "LamarGreatBarrierReef.jpg" //Lamar Great Barrier Reef
imagesArray[4] = "BrianBall2.jpg" //Brian Ball
imagesArray[5] = "ChrisSloanHEBExcellenceAward2.jpg" //Chris Sloan HEB Award

function runYIP(containerID, imageID) {
	var imageFile = imagePath + "YIP/image" + YIPcounter + ".jpg";
	blendimage(containerID, imageID, imageFile, transitionDuration);
	t=setTimeout("runYIP('" + containerID + "', '" + imageID + "')", slideDuration);
	backcounter=YIPcounter-1
	if (backcounter == 0) backcounter = numberOfYIPSlides;
	YIPcounter++;
	if (YIPcounter > numberOfYIPSlides) YIPcounter = 1;
}

function runSlideShow(containerID, imageID) {
	var imageFile = imagePath + "rotate/" + imagesArray[counter];
	blendimage(containerID, imageID, imageFile, transitionDuration);
	t=setTimeout("runSlideShow('" + containerID + "', '" + imageID + "')", slideDuration);
	changeLink(imageID, counter);
	backcounter=counter-1
	if (backcounter == 0) backcounter = numberOfSlides;
	counter++;
	if (counter > numberOfSlides) counter = 1;
}
function nextSlide(containerID, imageID) {
	if (document.getElementById(imageID).style.opacity == 0.99 ){
	clearTimeout(t)
	var imageFile = imagePath + "YIP/image" + YIPcounter + ".jpg";
	blendimage(containerID, imageID, imageFile, transitionDuration);
	t=setTimeout("runYIP('" + containerID + "', '" + imageID + "')", slideDuration);
	//changeLink(imageID, counter);
	backcounter=YIPcounter-1
	if (backcounter == 0) backcounter = numberOfYIPSlides;
	YIPcounter++;
	if (YIPcounter > numberOfYIPSlides) YIPcounter = 1;
	}
}

function previousSlide(containerID, imageID) {
	if (document.getElementById(imageID).style.opacity == 0.99 ){
	clearTimeout(t)
	var imageFile = imagePath + "YIP/image" + backcounter + ".jpg";
	blendimage(containerID, imageID, imageFile, transitionDuration);
	t=setTimeout("runYIP('" + containerID + "', '" + imageID + "')", slideDuration);
	//changeLink(imageID, backcounter);
	backcounter=backcounter-1
	if (backcounter == 0) backcounter = numberOfYIPSlides;
	YIPcounter=YIPcounter-1;
	if (YIPcounter == 0) YIPcounter = numberOfYIPSlides;
	}
}

function changeLink(imageID, counter) {
	if (linksArray[counter] == "") {
		document.getElementById("slideshowLink").removeAttribute("href");
		document.getElementById(imageID).style.cursor = "default";}
	else {
		document.getElementById("slideshowLink").href = linksArray[counter];
		document.getElementById(imageID).style.cursor = "pointer";}
}

function blendimage(containerID, imageID, imageFile, transitionDuration) {
	document.getElementById(containerID).style.backgroundImage = "url(" + document.getElementById(imageID).src + ")"; //sets the current foreground image to the background
	document.getElementById(containerID).style.backgroundRepeat = "no-repeat"; //sets the current foreground image to the background
	changeOpac(1, imageID); //makes the foreground image transparent
	f=setTimeout("fade('" + containerID + "', '" + imageID + "', '" + imageFile + "', '" + transitionDuration + "')", 0); //waits split second before proceeding to prevent a flicker in some browsers
}

function fade(containerID, imageID, imageFile, transitionDuration) {
	var speed = Math.round(transitionDuration / 100);
	var timer = 0;
	document.getElementById(imageID).src = imageFile; //sets source of foreground image to next image
	//fades in foreground image
	for(i = 0; i <= 99; i++) {
		o=setTimeout("changeOpac(" + i + ",'" + imageID + "')",(timer * speed));
		timer++;
	}
}

function changeOpac(opacity, imageID) {
	var object = document.getElementById(imageID).style; 
	object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function toggle(inlineLinkId, extendedTextId)
{

    var target = document.getElementById(extendedTextId);
    var parent = document.getElementById(inlineLinkId);

    if ((target == null) || (parent == null)) return;

    if (target.style.display == 'none')
    {
        target.style.display = 'inline';
        parent.style.display = 'none';
    }
    else
    {
		target.style.display = 'none';
        parent.style.display = 'inline';
    }
}



//Suckerfish Drop Down Menu Script
sfHover = function() {
	var sfEls = document.getElementById("navBar").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//Suckerfish Drop Down Menu Script for Jump Menu
//sfHover2 = function() {
//	var sfEls2 = document.getElementById("jumpMenu").getElementsByTagName("LI");
//	for (var i=0; i<sfEls2.length; i++) {
//		sfEls2[i].onmouseover=function() {
//			this.className+=" sfhover";
//		}
//		sfEls2[i].onmouseout=function() {
//			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//		}
//	}
//}
//if (window.attachEvent) window.attachEvent("onload", sfHover2);


//Embed XStandard Active X Code

function embedXstandard()
{
	document.write('<object type="application/x-xstandard" id="editor1" width="580" height="420">')
    document.write('<param name="Styles" value="http://www.saisd.org/XStandard/styles.xml" />')
    document.write('<param name="PreviewXSLT" value="" />')
    document.write('<param name="ScreenReaderXSLT" value="" />')
    document.write('<param name="Localization" value="" />')
    document.write('<param name="Toolbar" value="undo,hyperlink,underline,strong,em,sup,sub,numbering,bullets,blockquote,undo-blockquote,layout-table,wysiwyg,source" />')
    document.write('<param name="ShowStyles" value="yes" />')
    document.write('<param name="ShowToolbar" value="yes" />')
    document.write('<param name="ClassImageFloatLeft" value="left" />')
    document.write('<param name="ClassImageFloatRight" value="right" />')
    document.write('<param name="Options" value="0" />')
    document.write('<param name="IndentOutput" value="no"/>')
    document.write('<param name="Debug" value="no"/>')
    document.write('<param name="BackgroundColor" value="" />')
    document.write('<param name="BorderColor" value="black" />')
    document.write('<param name="Base" value="http://soap.xstandard.com/library/" />')
    document.write('<param name="LatestVersion" value="1.5.0.0"/>')
    document.write('<param name="Lang" value="en"/>')
    document.write('<param name="Value" value=""/>')
    document.write('<div class="message">If you do not see the editor here, there are two possible reasons. (1) You have not yet installed XStandard to your computer. (2) You are using a browser that does not support ActiveX or Mozilla/Firefox plug-ins.</div>')
    document.write('</object>')
}


//Form Focus Function

window.onload = focusForm;
function focusForm(){
   if(document.getElementById("username")){
	  if(document.getElementById("username").value == ""){
	      document.getElementById("username").focus();
	  }
	  else {
	      document.getElementById("password").focus();
	  }
   } 
}

//Toggles display of extended text areas

