window.onload = initBannerLink;

var adImages = new Array("http://www.siliconvalleypower.com/img/home_promo_fridge.jpg",
//"http://www.siliconvalleypower.com/img/main_promo_scoudown.jpg",//
"http://www.siliconvalleypower.com/img/hp_scou_032410.jpg",
"http://www.siliconvalleypower.com/img/hp_4reasons10.jpg",
"http://www.siliconvalleypower.com/img/hp_obpscary2.jpg",
"http://www.siliconvalleypower.com/img/hp_energyaudit_hsprg.jpg",
"http://www.siliconvalleypower.com/img/home_promo_eia.jpg",
"http://www.siliconvalleypower.com/img/home_promo_rapgfatherson.jpg",
"http://www.siliconvalleypower.com/img/home_promo_sesm3.jpg",
"http://www.siliconvalleypower.com/img/home_promo_scholarship08.jpg",
"http://www.siliconvalleypower.com/img/home_promo_nspfuture3.jpg",
"http://www.siliconvalleypower.com/img/home_promo_scgpembrace.jpg");
var adURL = new Array("HD70&URL=http://www.siliconvalleypower.com/res/?sub=rebatesfridge",
//"HD88&URL=https://www.siliconvalleypower.com/SCUO/Login.aspx",//
"HD88&URL=https://www.siliconvalleypower.com/SCUO/Login.aspx",
"HD110&URL=http://www.siliconvalleypower.com/res/articles/?sub=recyclefridge",
"HD111&URL=https://www.siliconvalleypower.com/SCUO/SignUp_Step1.aspx",
"HD112&URL=http://www.siliconvalleypower.com/res/?sub=resaudit",
"HD29&URL=http://www.siliconvalleypower.com/bus/?doc=eia",
"HD77&URL=http://www.siliconvalleypower.com/res/?sub=assist",
"HD66&URL=http://www.siliconvalleypower.com/bus/?sub=busrebates",
"HD30&URL=http://www.siliconvalleypower.com/info/?sub=scholarship",
"HD84&URL=http://www.siliconvalleypower.com/res/?sub=neighborhoodsolar",
"HD79&URL=http://www.siliconvalleypower.com/res/?sub=green");
var thisAd = 0;

function rotate() {
	thisAd++;
	if (thisAd == adImages.length) {
		thisAd = 0;
	}
	document.getElementById("adBanner").src = adImages[thisAd];

	setTimeout("rotate()", 5 * 2000);
}

function newLocation() {
	document.location.href = "http://www.siliconvalleypower.com/promoredirect.asp?promoad=" + adURL[thisAd];
	return false;
}

function initBannerLink() {
	if (document.getElementById("adBanner").parentNode.tagName == "A") {
		document.getElementById("adBanner").parentNode.onclick = newLocation;
	}
	
	rotate();
}

						