var bannerList = ["",
      		"/assets/sponsorImages/midasResources.gif",
		"/assets/sponsorImages/c4L.gif",
                "/assets/sponsorImages/eFoodsStat.gif",
		"/assets/sponsorImages/berkeyWaterFilters.gif",
		"/assets/sponsorImages/pureBulk.gif",
                "/assets/sponsorImages/mySolarBackUp.gif",
                "/assets/sponsorImages/healthyWorldStore.gif",
                "/assets/sponsorImages/foodInsurance.gif",
		"/assets/sponsorImages/directive21.gif",
		"/assets/sponsorImages/ecoloblue.gif",
                "/assets/sponsorImages/readyReserve.gif",
                "/assets/sponsorImages/airAqua.gif",
                "/assets/sponsorImages/freezeDryGuy.gif",
		"/assets/sponsorImages/makeHerbalMedicines.gif",
		"/assets/sponsorImages/indigoRising.gif",
		"/assets/sponsorImages/readyMadeResources.gif",
		"/assets/sponsorImages/newVitality.gif",
		"/assets/sponsorImages/startPage.gif",
		"/assets/sponsorImages/patriotFood.gif" ,
		"/assets/sponsorImages/utopiaSilver.gif",
		"/assets/sponsorImages/heartBody.gif",
		"/assets/sponsorImages/dailyPaul.gif",
		"/assets/sponsorImages/taxHelpOnline.gif",
		"/assets/sponsorImages/frontSight.gif",
		"/assets/sponsorImages/gardenCan.gif",
		"/assets/sponsorImages/healthTruthRevealed.gif",
                "/assets/sponsorImages/calbenPureSoap.gif",
                "/assets/sponsorImages/survivalSeedBank.gif",
                "/assets/sponsorImages/getTheTea.gif",
                "/assets/sponsorImages/organicaSeed.gif",
                "/assets/sponsorImages/rippleCreek.gif",
		"/assets/sponsorImages/ofTheField.gif",
		"/assets/sponsorImages/hempUSA.gif",
		"/assets/sponsorImages/valleyViewEmus.gif",
		"/assets/sponsorImages/rCharge.gif",
                "/assets/sponsorImages/nutrimedical.gif",
                "/assets/sponsorImages/bytestyle.gif"
                ];

var bannerUrlList = ["", 
		"http://www.gcnlive.com/ccount/click.php?id=53",
		"http://www.campaignforliberty.com/",
		"http://www.gcnlive.com/ccount/click.php?id=7",
		"http://www.gcnlive.com/ccount/click.php?id=8",
		"http://www.gcnlive.com/ccount/click.php?id=55",
		"http://www.gcnlive.com/ccount/click.php?id=9",
		"http://www.gcnlive.com/ccount/click.php?id=11",
		"http://www.gcnlive.com/ccount/click.php?id=58",
		"http://www.gcnlive.com/ccount/click.php?id=34",
		"http://www.gcnlive.com/ccount/click.php?id=13",
		"http://www.gcnlive.com/ccount/click.php?id=51",
		"http://www.gcnlive.com/ccount/click.php?id=14",
		"http://www.gcnlive.com/ccount/click.php?id=15",
		"http://www.gcnlive.com/ccount/click.php?id=16",
		"http://www.gcnlive.com/ccount/click.php?id=57",
		"http://www.gcnlive.com/ccount/click.php?id=46",
		"http://www.gcnlive.com/ccount/click.php?id=48",
		"http://www.gcnlive.com/ccount/click.php?id=18",
		"http://www.gcnlive.com/ccount/click.php?id=50",
		"http://www.gcnlive.com/ccount/click.php?id=19",
		"http://www.gcnlive.com/ccount/click.php?id=20",
		"http://www.dailypaul.com/",
		"http://www.gcnlive.com/ccount/click.php?id=23",
		"http://www.gcnlive.com/ccount/click.php?id=24",
		"http://www.gcnlive.com/ccount/click.php?id=25",
		"http://www.gcnlive.com/ccount/click.php?id=26",
		"http://www.gcnlive.com/ccount/click.php?id=27",
		"http://www.gcnlive.com/ccount/click.php?id=28",
		"http://www.gcnlive.com/ccount/click.php?id=29",
		"http://www.gcnlive.com/ccount/click.php?id=30",
		"http://www.gcnlive.com/ccount/click.php?id=54",
		"http://www.gcnlive.com/ccount/click.php?id=31",
		"http://www.gcnlive.com/ccount/click.php?id=32",
		"http://www.gcnlive.com/ccount/click.php?id=52",
		"http://www.gcnlive.com/ccount/click.php?id=33",
		"http://www.gcnlive.com/ccount/click.php?id=35",
      		"http://bytestyle.tv/" 
      		];
                    
var bannerListLivePlayer = ["",
      		"/assets/playerSponsors/midasResources.gif",
      		"/assets/playerSponsors/eFoods.gif"      		
                ];

var bannerUrlListLivePlayer = ["", 
      		"http://www.gcnlive.com/ccount/click.php?id=53",
		"http://www.gcnlive.com/ccount/click.php?id=43"
                    ];
                    
var bannerListOnDemand = ["",
      		"/assets/playerSponsors/midasResources.gif",
      		"/assets/playerSponsors/eFoods.gif"      		
                ];

var bannerUrlListOnDemand = ["", 
      		"http://www.gcnlive.com/ccount/click.php?id=53",
		"http://www.gcnlive.com/ccount/click.php?id=43"
                    ];


var numberOfBanners = bannerList.length-1;
var numberOfBannersLivePlayer = bannerListLivePlayer.length-1;
var numberOfBannersOnDemand = bannerListOnDemand.length-1;
var banners = Math.floor(Math.random()*numberOfBanners);
var bannersLivePlayer = Math.floor(Math.random()*numberOfBannersLivePlayer);
var bannersOnDemand = Math.floor(Math.random()*numberOfBannersOnDemand);
var allowCycle = true;
var allowCycleLivePlayer = true;
var allowCycleOnDemand = true;

function setAllowCycle(state, elem) {
  if(elem == "GCN") {
    allowCycle = state;
  } else if(elem == "LIVEPLAYER") {
    allowCycleLivePlayer = state;
  } else if(elem == "ONDEMAND") {
    allowCycleLivePlayer = state;
  } 
}

function cycle() {
  if(allowCycle) {
    if (++banners > numberOfBanners) {
      banners=1;
    }
	
	var banner1Obj = Obj("banner1");
    if (banner1Obj != null) {
      banner1Obj.src = rootURL + bannerList[banners];
    }
  }

  if(allowCycleLivePlayer) {
    if (++bannersLivePlayer > numberOfBannersLivePlayer) {
      bannersLivePlayer=1;
    }

	var bannerLPObj = Obj("bannerLivePlayer");
    if (bannerLPObj != null){
      bannerLPObj.src = rootURL + bannerListLivePlayer[bannersLivePlayer];
    }
  }

  if(allowCycleOnDemand) {
    if (++bannersOnDemand > numberOfBannersOnDemand) {
      bannersOnDemand=1;
    }

	var bannerODObj = Obj("bannerOnDemand");
    if (bannerODObj != null){
      bannerODObj.src = rootURL + bannerListOnDemand[bannersOnDemand];
    }
  }

  window.setTimeout('cycle();',3000);
}
 
function urlswitch(elem) {
  var returnUrl = "";
  
  if(elem == "GCN") {
    returnUrl = bannerUrlList[banners];
  } else if("LIVEPLAYER") {
    returnUrl = bannerUrlListLivePlayer[bannersLivePlayer];
  } else if("ONDEMAND") {
    returnUrl = bannerUrlListLivePlayer[bannersOnDemand];
  } 
  
  return returnUrl;
}

function onSponsorClick(elem) { 
  if(elem == "GCN") { 
    window.open(bannerUrlList[banners], "sponsor"); 
  } else if("LIVEPLAYER") { 
    window.open(bannerUrlListLivePlayer[bannersLivePlayer], "sponsor"); 
  } else if("ONDEMAND") { 
    window.open(bannerUrlListOnDemand[bannersDemand], "sponsor"); 
  } 
}

function Obj(objID) {
	if (document.getElementById && document.getElementById(objID)) {return document.getElementById(objID);}
	else if (document.all && document.all(objID)) {return document.all(objID);}
	else if (document.layers && document.layers[objID]) {return document.layers[objID];}
	else {return false;}
}
