/*
    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_size	= 0;
// desired height and width of images, only takes affect if above is one
var img_width	= 728;
var img_height	= 90;

// time between refreshs of ad locations, to disable refreshs set to 0. In milliseconds, 1000 = 1 second
var refresh_time = 10000;
// maximum amount of refreshs, good to set if a user may be on a page for a long period of time.
var refresh_max = 30;

// 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_banners = 0;


// ignore/skip this line 
var banners = 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
banners[0] = new banner('ItsJustLunch', 'http://x.azjmp.com/2Dy0n?sub=valentines', 'img src='http://images-cdn.azoogleads.com/ssa/6625_banners/267752.gif', '30/04/2019');
banners[1] = new banner('SignatureSingles', 'http://www.mb01.com/lnk.asp?o=1820&c=27122&a=25446', 'http://www.mb01.com/getimage.asp?m=1905&o=1820&i=27122.dat', '10/04/2019');
banners[2] = new banner('Mate1', 'http://www.mb01.com/lnk.asp?o=1482&c=21231&a=25446', 'http://www.mb01.com/getimage.asp?m=1006&o=1482&i=21231.dat', '10/04/2019');
banners[3] = new banner('ChristianMingle', 'http://www.mb01.com/lnk.asp?o=1123&c=15032&a=25446', 'http://www.mb01.com/getimage.asp?m=943&o=1123&i=15032.dat', '10/04/2019');
banners[4] = new banner('BBWPersonals', 'http://www.mb01.com/lnk.asp?o=1765&c=26445&a=25446', 'http://www.mb01.com/getimage.asp?m=943&o=1765&i=26445.dat', '10/04/2019');
banners[5] = new banner('SinglesNet', 'http://www.mb01.com/lnk.asp?o=1761&c=26340&a=25446', 'http://www.mb01.com/getimage.asp?m=1833&o=1761&i=26340.dat', '10/04/2019');
banners[6] = new banner('Matchmaker', 'http://www.pntrs.com/t/4-16922-19980-17861', 'http://www.pntrs.com/b/4-16922-19980-17861', '10/04/2019');
banners[7] = new banner('FindingSingles', 'http://gnspf.com/click/?s=56294&c=96447', 'http://gnspf.com/images/3617-96447-728x90.jpg?s=56294', '10/04/2019');
banners[8] = new banner('MetroDate', 'http://www.tkqlhce.com/click-3249772-10285197', 'http://www.mb01.com/getimage.asp?m=1905&o=1820&i=27122.dat', '10/04/2019');
banners[9] = new banner('EliteMate', 'http://www.lynxtrack.com/afclick.php?o=2512&b=mfzdrdmr&p=32710&l=1&c=57646', 'http://www.imglt.com/i/lt/2512/em_728x90copy.jpg', '10/04/2019');
banners[10] = new banner('Date.com', 'http://launch.roirocket.com/z/19996/CD27865/', 'http://launch.roirocket.com/42/27865/19996/', '10/04/2019');
banners[11] = new banner('LDSRomances', 'http://www.LDSRomances.com/i/af18023560-pr', 'http://images.LDSRomances.com/lds/fbanner3.gif', '10/04/2019');
banners[12] = new banner('SeekingMarriage', 'http://www.lynxtrack.com/afclick.php?o=6038&b=81h6mhm1&p=32710&l=1&c=43256', 'http://www.imglt.com/i/lt/6038/Copy-of-SeekingMarriage-728.jpg', '10/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 banner(name, url, image, date)
{
	this.name	= name;
	this.url	= url;
	this.image	= image;
	this.date	= date;
	this.active = 1;
}

function show_banners()
{
	var html = '<div id="adLocation-' + location_counter + '"></div>';
	document.write(html);
	display_banners(location_counter);
	location_counter++;
}

function display_banners(location)
{
	if(location == '' || !location || location < 0)
	{
		// no location given
		return;
	}
	
	var am	= banners.length;
	
	if((am == used) && duplicate_banners == 0) {
		// all banners have been used
		return;
	}

	var rand	= Math.floor(Math.random()*am);	
	var bn 		= banners[rand];
	
	var image_size 	= (force_size == 1) ? ' width="' + img_width + '" height="' + img_height + '"' : '';
	var html 		= '<a href="' + bn.url + '" title="' + bn.name + '" target="_blank"><img border="0" src="' + bn.image + '"' + image_size + ' alt="' + bn.name+ '" /></a>';
	
	var now		= new Date(); 
	
	var input	= bn.date;
	input		= input.split('/', 3);
	var end_date	= new Date();
	end_date		= end_date.setFullYear(parseFloat(input[2]), parseFloat(input[1]), parseFloat(input[0]));
	
	if((now < end_date) && bn.active == 1) 
	{
		var location_element = document.getElementById('adLocation-' + location);
		
		if(location_element == null)
		{
			// ad location doesn't exist
			alert('spyka Webmaster banner rotator\nError: adLocation doesn\'t exist!');
		}
		else
		{
			location_element.innerHTML = html;
			
			if(duplicate_banners == 0)
			{
				bn.active = 0;
				used++;
			}
		}
	}
	else
	{
		display_banners(location);
	}
}

function refresh_banners()
{
	if((refresh_counter == refresh_max) || refresh_time < 1)
	{
		clearInterval(banner_refresh);  
	}
	used = 0;
	for(i = 0; i < banners.length; i++)
	{
		banners[i].active = 1;
	}
	for(i = 1; i < location_counter; i++)
	{
		display_banners(i);
	}
	refresh_counter++;
}
var banner_refresh = window.setInterval(refresh_banners, refresh_time);