/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

	--------------------------------------------------------------------
	
	Simple banner rotator. Version: 1.2.0
	Download, support, contact: http://www.spyka.net 
	(c) Copyright 2009 spyka Web Group
*/

/* 
	For full documentation:  http://www.spyka.net/docs/simple-banner-rotator
	For support:			 http://www.spyka.net/forums
*/

//								EDIT FROM HERE
///////////////////////////////////////////////////////////////////////////////////
//         						Program options
 

// if 1 (one), all images will be resized to img_width and img_height, else images will display their correct size
var force_sizec	= 0;
// desired height and width of images, only takes affect if above is one
var img_widthc	= 190;
var img_heightc	= 300;

// time between refreshs of ad locations, to disable refreshs set to 0. In milliseconds, 1000 = 1 second
var refresh_timec = 0;
// maximum amount of refreshs, good to set if a user may be on a page for a long period of time.
var refresh_maxc = 10;

// if you do not want the same banners to display on the same page then set this to 0, else set it to 1.
// this option is only used if you have put the show_banners() javascript code more than once into a page
var duplicate_banners3 = 0;


// ignore/skip this line 
var banners3 = new Array();

// banner list syntax: banners[x] = new banner(website_name, website_url, banner_url, show_until_date);  DATE FORMAT: dd/mm/yyyy
// be sure to increase x by 1 for each banner added!
// to make sure a banner is always rotating, just set the date far into the future, i.e. year 3000
banners3[0] = new vertbanner('vb1', 'http://www.polsonpropane.com', 'http://www.valleyjournal.net/ads/PolsonPropane_VB.jpg', '30/04/2019');
banners3[1] = new vertbanner('vb2', 'http://www.valleyjournal.net', 'http://www.valleyjournal.net/ads/house_vert_free.jpg', '30/04/2019');
banners3[2] = new vertbanner('vb3', 'http://www.polsonpropane.com', 'http://www.valleyjournal.net/ads/PolsonPropane_VB.jpg', '30/04/2019');
banners3[3] = new vertbanner('vb4', 'http://www.valleyjournal.net', 'http://www.valleyjournal.net/ads/house_vert_free.jpg', '30/04/2019');
//         				There is no need to edit below here
var used = 0;
var first_pass = 0;
var location_counter = 1;
var refresh_counter = 1;

function vertbanner(name, url, image, date)
{
	this.name	= name;
	this.url	= url;
	this.image	= image;
	this.date	= date;
	this.active = 1;
}

function show_vertbanner()
{
	var html = '<div id="adLocationc-' + location_counter + '"></div>';
	document.write(html);
	display_banners3(location_counter);
	location_counter++;
}

function display_banners3(locationc)
{
	if(locationc == '' || !locationc || locationc < 0)
	{
		// no location given
		return;
	}
	
	var amc	= banners3.length;
	
	if((amc == used) && duplicate_banners3 == 0) {
		// all banners have been used
		return;
	}

	var rand	= Math.floor(Math.random()*amc);	
	var bn 		= banners3[rand];
	
	var image_sizec 	= (force_sizec == 1) ? ' width="' + img_widthc + '" height="' + img_heightc + '"' : '';
	var html 		= '<a href="' + bn.url + '" title="' + bn.name + '" target="_blank"><img border="0" src="' + bn.image + '"' + image_sizec + ' alt="' + bn.name+ '" /></a>';
	
	var nowc		= new Date(); 
	
	var inputc	= bn.date;
	inputc		= inputc.split('/', 3);
	var end_datec	= new Date();
	end_datec		= end_datec.setFullYear(parseFloat(inputc[2]), parseFloat(inputc[1]), parseFloat(inputc[0]));
	
	if((nowc < end_datec) && bn.active == 1) 
	{
		var location_elementc = document.getElementById('adLocationc-' + locationc);
		
		if(location_elementc == null)
		{
			// ad location doesn't exist
			alert('Banner rotator\nError: adLocationc doesn\'t exist!');
		}
		else
		{
			location_elementc.innerHTML = html;
			
			if(duplicate_banners3 == 0)
			{
				bn.active = 0;
				used++;
			}
		}
	}
	else
	{
		display_banners3(locationc);
	}
}

function refresh_banners3()
{
	if((refresh_counter == refresh_maxc) || refresh_timec < 1)
	{
		clearInterval(banner_refreshc);  
	}
	used = 0;
	for(i = 0; i < banners3.length; i++)
	{
		banners3[i].active = 1;
	}
	for(i = 1; i < location_counter; i++)
	{
		display_banners3(i);
	}
	refresh_counter++;
}
var banner_refreshc = window.setInterval(refresh_banners3, refresh_timec);