﻿
//Global variables
var thisAd = 0;	//this counter is used to keep track of the current position in the array so that the 'Previous' and 'Next' links can be used
var rotateImage = true;
var timer;


function init()
{

//An array of random numbers is created. 
//Each individual number is used to join the correct values from the adImages, quote and adURL arrays 
//(e.g: map the 3rd URL to the 3rd graphic)
getRandomArr();
//alert(' Random arr= '  + randomNumArr);
rotate();
}


// **************************adImages, quote & adURL ARRAYS MUST REMAIN PROPERLY ORDERED AND BE THE SAME LENGTH FOR FUNCTIONS TO WORK

// COLLEGE AD GRAPHICS
adImages = new Array(
//WAOL/ANGEL
//"WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif","WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif","WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif",
//South Seattle
"SSCC_DoNotMissBus2.gif","SSCC_GoGreen2.gif",
//Peninsula
"PCC_Anytime.jpg","PCC_Business.jpg","PCC_Chem1.jpg","PCC_CRJ.jpg","PCC_Too_busy.jpg"
//Clover Park
, "CloverPark_hospitality_S09.gif", "CloverPark_dental_S09.gif", "CloverPark_medical_S09.gif", "CloverPark_payroll_S09.gif", "CloverPark_spanish_S09.gif"
//WAOL/ANGEL
//,"WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif","WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif","WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif"
//North Seattle
,"NSCC_ACCT.gif", "NSCC_ATEC.gif", "NSCC_ENGL.gif"
//Grays Harbor
,"GHC_AA.gif","GHC_accounting.gif","GHC_childcare.gif","GHC_science.gif","GHC_SOC270.gif"
//WAOL/ANGEL
//, "WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif"
//Spokane CC
,"spokane_accounting_W08.gif","spokane_business_W08.gif","spokane_classes_W08.gif","spokane_comp_W08.gif","spokane_legal_W08.gif"
//Whatcom CC
,"wcc_onlinenursing.jpg", "wcc_onlinepta.GIF", "wcc_onlinemedassist.jpg"
//YVCC
, "YVCC_wine.gif"
//SPSCC
, "SPSCC_1.jpg", "SPSCC_2.jpg", "SPSCC_3.jpg", "SPSCC_4.jpg", "SPSCC_7.jpg"
//WAOL/ANGEL
//"WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL1.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif", "WAOL-ANGEL2.gif","WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif", "WAOL-ANGEL3.gif","WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif", "WAOL-ANGEL4.gif"
//Edmonds
, "ED-MGMT-107.jpg", "ED-EMERG-100.jpg", "ED-ENGR-231.jpg", "ED-CLART-205.jpg", "ED-ENVS-101.jpg"
//LakeWashington
, "lkwash_edu.gif", "lkwash_multimedia.gif"
//Renton
, "renton_medicalcoding.GIF"
//Shoreline
, "scc_summer01.jpg", "scc_summer02.jpg", "scc_summer03.jpg", "scc_summer04.jpg", "scc_summer05.jpg"
);

// ALT TAGS FOR COLLEGE GRAPHIC IMAGES
quote = new Array(
//South Seattle
"", "",
//Peninisula
"", "", "", "", ""
//Clover Park
,"","","","",""
//North Seattle
, "", "", ""
//Grays Harbor
, "", "", "", "", ""
//Spokane CC
,"","","","",""
//Whatcom CC
, "", ""
//YVCC
, ""
//SPSCC
, "", "", "", "", ""
//Edmonds
, "", "", "", "", ""
//LakeWashington
, "", ""
//Renton
, ""
//Shoreline
, "", "", "", "", ""
);

//LINKS FOR COLLEGE ADS
adURL = new Array(
//South Seattle
"http://online.southseattle.edu",
"http://online.southseattle.edu",
//Peninisula 
"http://www.pencol.edu/academics/eLearning/default.asp",
"http://www.pencol.edu/academics/eLearning/default.asp",
"http://www.pencol.edu/academics/eLearning/default.asp",
"http://www.pencol.edu/academics/eLearning/default.asp",
"http://www.pencol.edu/academics/eLearning/default.asp"
//Clover Park
, "http://www.cptc.edu/wrl.asp?t=wrl&iDRN=1008&iCRN=2010",
"http://www.cptc.edu/wrl.asp?t=wrl&iDRN=1008&iCRN=2010",
"http://www.cptc.edu/wrl.asp?t=wrl&iDRN=1008&iCRN=2010",
"http://www.cptc.edu/wrl.asp?t=wrl&iDRN=1008&iCRN=2010",
"http://www.cptc.edu/wrl.asp?t=wrl&iDRN=1008&iCRN=2010"
//North Seattle
,"http://www.virtualcollege.org/",
"http://www.virtualcollege.org/",
"http://www.virtualcollege.org/"
//Grays Harbor
,"http://ghc.ctc.edu/distance/index.htm",
"http://ghc.ctc.edu/distance/index.htm",
"http://ghc.ctc.edu/distance/index.htm",
"http://ghc.ctc.edu/distance/index.htm",
"http://ghc.ctc.edu/distance/index.htm"
//Spokane CC
,"http://www.scc.spokane.edu/?dl",
"http://www.scc.spokane.edu/?dl",
"http://www.scc.spokane.edu/?dl",
"http://www.scc.spokane.edu/?dl",
"http://www.scc.spokane.edu/?dl"
//Whatcom CC
,"http://www.whatcom.ctc.edu/nursing",
"http://www.whatcom.ctc.edu/pta",
"http://www.whatcom.ctc.edu/medicalassisting"
//YVCC
, "http://www.yvcc.edu/wine"
//SPSCC
,"","","","",""
//Edmonds
, " http://schedule.edcc.edu/search.php?classID=14954591&count=137&time=online&quarter=1",
"http://schedule.edcc.edu/search.php?classID=14954682&count=137&time=online&quarter=1",
"http://schedule.edcc.edu/search.php?classID=14954684&count=137&time=online&quarter=1",
"http://schedule.edcc.edu/search.php?classID=14954669&count=137&time=online&quarter=1",
"http://schedule.edcc.edu/search.php?classID=14954765&count=137&time=online&quarter=1"
//LakeWashington
, " http://lwtchost.ctc.edu/dept/distancelearning/",
"http://lwtchost.ctc.edu/dept/distancelearning/"
//Renton
, " http://www.rtc.edu/Programs/TrainingPrograms/MedicalOfficeCoder/" 
//Shoreline
, " http://www.shoreline.edu/elearning/",
" http://www.shoreline.edu/elearning/",
" http://www.shoreline.edu/elearning/",
" http://www.shoreline.edu/elearning/",
" http://www.shoreline.edu/elearning/"
);

var imgCt = adImages.length;

function randomizeNumArr(){ //randomize the array
	return (Math.round(Math.random())-0.5);
}

function randomNumGenerator(){//return random number
	randomNum = Math.floor((Math.random() * imgCt))
	return randomNum; 
}

function getRandomArr(){ //build an array of numbers
	randomNumArr = new Array();
	var i;
	var x;
	for(i=0;i<imgCt;i++){
		randomNumArr[i] =  i;
	}
	randomNumArr.sort(randomizeNumArr);
}



function rotate()
{
	window.clearTimeout(timer);//clear previous timer
	if (rotateImage)
	{
		if (document.images) 
		{
		    var cycleImg = document.getElementById('cycle');
		    if (cycleImg)
		    {
			    thisAd ++;
			    if (thisAd == imgCt)
			    {
				    thisAd = 0;
			    }
			    //alert(thisAd + ' Random arr= '  +randomNumArr[thisAd]);
			    cycleImg.src = 'http://www.waol.org/imgs/Adds/' + adImages[randomNumArr[thisAd]];
			    //document.getElementById('cycle').src = '/imgs/Adds/' + adImages[randomNumArr[thisAd]];
			    //document.getElementById('cycle').alt = quote[randomNumArr[thisAd]];	//alt text when user mouses over image
			    //window.defaultStatus = quote[randomNum];   //text will display on status bar
				
			    // This sets the interval to which the images and quotes are rotated. 1000 equals 1 second
			    timer = window.setTimeout('rotate()', 7000);
				 
			}
		}
	}
}

function rotateLink() { 
	URL = adURL[randomNumArr[thisAd]];  
	window.open(URL,'','','');
	//window.location.href = "http://" + adURL[thisAd]; 
 }

function movePrev(){
	rotateImage = false;
	window.clearTimeout(timer);//clear previous timer
	if (document.images && thisAd > 0){
		thisAd --;
		if (thisAd == 0){
			thisAd = imgCt-1;
		}
		document.getElementById('cycle').src = 'http://www.waol.org/imgs/Adds/' + adImages[randomNumArr[thisAd]];
		//document.getElementById('cycle').src = '<%=this.ResolveUrl("~/imgs/Adds/")%>' + adImages[randomNumArr[thisAd]];
		//document.getElementById('cycle').alt = quote[randomNumArr[thisAd]];	
		rotateImage = true;
		timer = window.setTimeout("rotate()", 15000);
	}
}

function moveNext() {
	rotateImage = false;	
	window.clearTimeout(timer);
	if (document.images && thisAd > 0){
		thisAd ++;
		if (thisAd == imgCt){
			thisAd = 1;
		}
	    document.getElementById('cycle').src = 'http://www.waol.org/imgs/Adds/' + adImages[randomNumArr[thisAd]];
		//document.getElementById('cycle').src = '<%=this.ResolveUrl("~/imgs/Adds/")%>' + adImages[randomNumArr[thisAd]];
		//document.getElementById('cycle').alt = quote[randomNumArr[thisAd]];
		rotateImage = true;	
		timer = window.setTimeout('rotate()', 15000);
	}
}

function stopRot() { //stop ad rotation
	rotateImage = false;
	window.clearTimeout(timer);
}

function resumeRot() { //resume ad rotation
	rotateImage = true;
	timer = window.setTimeout("rotate()", 7000);
}



init();