<!--
// Originally by Rachel Scanlon (I think)
// Updated 1/13/11 by Jeremy Klemm
// 
// Usage:
// call chooseAdFrom(array); to randomly pick an ad from the ad numbers in your array
//
// Example: chooseAdFrom(['0','1']);
// Result: Will choose randomly from ads 0 and 1 and display the chosen ad as the output 
// 


/* number of ads we need to store data for */
totalImages = 11;

/* number of properties for each image */
imageProperties = 4;


 var image = new Array(totalImages);

   for (x=0; x<=(totalImages - 1); x++){
      image[x]=new Array(imageProperties);
   }



/* define image urls */

if (document.images)
 {
	/* 
	
	array items:
			0 - the CSS style for the specific ad
			1 - largeAd or smallAd, depending on the size of the ad
			2 - alt text
			3 - hyperlink URL.
	
	*/
	

	// New customer
	image[0][0]="bbs";
	image[0][1]="largeAd";
	image[0][2]="Boka dig nu p&aring; h&ouml;stens kurser! &ndash; Spara 20 %";
	image[0][3]="/sommar";

	// Proj. Mgmt
	image[1][0]="specialOffer1";
	image[1][1]="largeAd";
	image[1][2]="Spara upp till 40 % per kurs";
	image[1][3]="/contact/secmpltr.htm?wt.svl=företagskort_advert";

	// Management / "New Manager"
	image[2][0]="mgmt";
	image[2][1]="smallAd";
	image[2][2]="Ledarskapspaketet &ndash; Din v&auml;g till ett effektivt ledarskap!";
	image[2][3]="/chef/?wt.svl=edarskapspaketet_advert";

	// New Courses
	image[3][0]="newCourses";
	image[3][1]="smallAd";
	image[3][2]="Nya kurser &ndash; ISO-certifiering, SQL Server 2012, Bygga iPhone appar, ... och mycket mer";
	image[3][3]="/general/newcourses.asp?wt.svl=nya_kurser_advert";

	// OTES
	image[4][0]="otes";
	image[4][1]="smallAd";
	image[4][2]="F&ouml;retagsintern utbildning &ndash; Kostnadseffektiv och skr&auml;ddarsydd utbildning p&aring; plats hos er";
	image[4][3]="/onsites/index.htm?wt.svl=företagsintern_utbildning_advert";
	

	// New Customer 2
	image[5][0]="newCustomer";
	image[5][1]="smallAd";
	image[5][2]="Just nu erbjuder vi 5000 kr rabatt till nya kunder";
	image[5][3]="/nykund/?wt.svl=nykund_advert";
	
	// Proj. Mgmt 2
	image[6][0]="specialOffer";
	image[6][1]="largeAd";
	image[6][2]="Specialerbjudande &ndash; Spara upp till 50 % per kurs med Tv&aring;- eller Trekl&ouml;ver";
	image[6][3]="/klover";


        // EastCoast
	image[7][0]="eastcoast";
	image[7][1]="smallAd";
	image[7][2]="Fler kurstillf&auml;llen med AnyWare &ndash; Delta p&aring; livekurser i England utan att resa";
	image[7][3]="/utomlands?wt.svl=eastcoast_advert";


        // resources
	image[8][0]="resources";
	image[8][1]="smallAd";
	image[8][2]="Ladda ner utan kostnad &ndash; Artiklar online inom IT och Management";
	image[8][3]="http://resources.learningtree.se/overview.aspx?wt.svl=artiklar_online_advert";
	

        // Tasters
	image[9][0]="tasters";
	image[9][1]="smallAd";
	image[9][2]="Kostnadsfri 2-timmarskurs: Smakprov på kurs inom ITIL &amp; projektledning";
	image[9][3]="http://www2.learningtree.se/promos/smakprov.aspx";


        // AnyWare
	image[10][0]="anyware";
	image[10][1]="smallAd";
	image[10][2]="LIVE, online utbildning: Uppt&auml;ck &ouml;ver 165 praktiska kurser tillg&auml;ngliga &ouml;verallt";
	image[10][3]="/anyware?wt.svl=anyware_advert";
 }    





/* no need to edit past this point */












 
function get_random(maxNum) {
  if (Math.random && Math.round) {
    var ranNum= Math.round(Math.random()*(maxNum-1));
    ranNum+=1;
  }  else  {
	today=new Date();
	hours=today.getHours();
	mins=today.getMinutes();
	secn=today.getSeconds();
	if (hours==19)
		hours=18;
	var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
  }
  return ranNum;
}

/* pass in an array of options to choose from, and this will randomly return one */
function chooseAdFrom(imgOptions) {
		var choose_one= get_random(imgOptions.length);  
		choose_one--;
		chosen = imgOptions[choose_one];
		document.write('<a href="'+image[chosen][3]+'" class="'+image[chosen][0]+' ' +image[chosen][1]+'" title="' + image[chosen][2] + '"></a>');
}


/* show one image */
function showAd(img) {
		document.write('<a href="'+image[img][3]+'" class="'+image[img][0]+' ' +image[img][1]+'" title="' + image[img][2] + '"></a>');
}

//-->
