function AZSwoop(link, params)
{
	this.spans = {};

	this.setCookie = function(name, value, expireDays)
	{
		var date = new Date();
		date.setTime(date.getTime() + expireDays * 24 * 60 * 60 * 1000);
		document.cookie = name +'='+ value + '; expires='+ date.toGMTString() +'; path=/';
	}

	this.getCookie = function(searchName)
	{
		var aCookies = document.cookie.split(';');
		var aTemp = '';
		var name = '';
		var value = '';

		for (var i = 0; i < aCookies.length; i++)
		{
			aTemp = aCookies[i].split('=');
			name = aTemp[0].replace(/^\s+|\s+$/g, '');

			if (name == searchName)
			{
				if (aTemp.length > 1)
					value = unescape(aTemp[1].replace(/^\s+|\s+$/g, ''));
				return value;
			}
		}
		return '';
	}

	this.swoopInit = function(bExpand, bForceMarker)
	{
		var oBlock = document.getElementById(this.block);
		var oSpan = this.spans;
		if (typeof(oBlock) == 'undefined' || typeof(oSpan) == 'undefined')
			return;
		if (typeof(oSpan.swoopPid) == 'undefined')
			oSpan.swoopPid = 0;
		if (oSpan.swoopPid != 0 && !bForceMarker)
			return;
		oSpan.swoopPid = Math.round(Math.random() * 1000 + 1);
		setTimeout('window.AZSwoopi.swoop('+ bExpand +', '+ oSpan.swoopPid +');', 20);
	}

	this.swoop = function(bExpand, iPid)
	{
		var oBlock = document.getElementById(this.block);
		var oSpan = this.spans;
		if (typeof(oBlock) == 'undefined' || typeof(oSpan) == 'undefined' || iPid != oSpan.swoopPid)
			return;
		var bStop = true;
		if (bExpand)
		{
			if (parseInt(oBlock.style.height) + 5 < oSpan.swoopMaxHeight)
			{
				oBlock.style.height = (parseInt(oBlock.style.height) + 5) +'px';
				bStop = false;
			}
			else
				oBlock.style.height = oSpan.swoopMaxHeight +'px';
		}
		else
		{
			if (parseInt(oBlock.style.height) - 5 > oSpan.swoopMinHeight)
			{
				oBlock.style.height = (parseInt(oBlock.style.height) - 5) +'px';
				bStop = false;
			}
			else
				oBlock.style.height = oSpan.swoopMinHeight +'px';
		}
		if (this.params.shift)
		{
			var body = document.getElementsByTagName('body')[0];
			body.style.paddingTop = oBlock.style.height;
			body.style.backgroundPosition = 'center '+ oBlock.style.height;
		}
		if (bStop)
		{
			oSpan.swoopPid = 0;
			return;
		}
		setTimeout('window.AZSwoopi.swoop('+ bExpand +', '+ iPid +');', 20);
	}

	params = params || {};
	params.shift = params.shift || 0;
	params.auto_show = params.auto_show || 4;
	params.bns_set = params.bns_set || 1;

	this.params = params;
	this.block = 'az_swoop';
	switch (params.bns_set)
	{
		case 2: /* slots */
		this.urls = new Array(
			{'url': 'http://azartcash.com/bns/swoop/21.gif', 'color': '#1f001e'},
			{'url': 'http://azartcash.com/bns/swoop/22.gif', 'color': '#0d1702'}
		);
		break;
		case 3: /* new year */
		this.urls = new Array(
			{'url': 'http://azartcash.com/bns/swoop/31.gif', 'color': '#00212a'},
			{'url': 'http://azartcash.com/bns/swoop/32.gif', 'color': '#4a0000'}
		);
		break;
		case 4: /* classic slots */
		this.urls = new Array(
			{'url': 'http://azartcash.com/bns/swoop/41.gif', 'color': '#1d082b'},
			{'url': 'http://azartcash.com/bns/swoop/42.gif', 'color': '#ff8a00'},
			{'url': 'http://azartcash.com/bns/swoop/43.gif', 'color': '#000056'},
			{'url': 'http://azartcash.com/bns/swoop/44.gif', 'color': '#2b0000'},
			{'url': 'http://azartcash.com/bns/swoop/45.gif', 'color': '#122a02'},
			{'url': 'http://azartcash.com/bns/swoop/46.gif', 'color': '#080128'}
		);
		break;

		case 1: /* roulette */
		default:
		this.urls = new Array(
			{'url': 'http://azartcash.com/bns/swoop/11.gif', 'color': '#042527'},
			{'url': 'http://azartcash.com/bns/swoop/12.gif', 'color': '#330c21'},
			{'url': 'http://azartcash.com/bns/swoop/13.gif', 'color': '#314a59', 'bg': 'url(http://azartcash.com/bns/swoop/13_bg.gif) center center repeat'},
			{'url': 'http://azartcash.com/bns/swoop/14.gif', 'color': '#071602'},
			{'url': 'http://azartcash.com/bns/swoop/15.gif', 'color': '#5b0008'}
		);
	}
	var height = 100;
	var width = 800;
	var i = this.getCookie('last_swoop');
	if (i != '')
	{
		i++;
		if (i >= this.urls.length)
			i = 0;
	}
	else
		i = Math.floor(Math.random() * this.urls.length);
	this.setCookie('last_swoop', i, 3);
	var url = this.urls[i].url;
	var color = this.urls[i].color;
	var bg = this.urls[i].bg || '';
	this.spans = {};
	this.spans.swoopMinHeight = 25;
	this.spans.swoopMaxHeight = height;

	var body = document.getElementsByTagName('body')[0];
	body.style.width = '100%';
	body.style.margin = 0;
	body.style.paddingTop = this.spans.swoopMinHeight + 'px';
	body.style.backgroundPosition = 'center '+ this.spans.swoopMinHeight + 'px';

	document.write('<a href="'+ link +'" target="_blank" style="padding: 0px; margin: 0px; border: 0px; display: block; height: '+ this.spans.swoopMinHeight +'px; width: 100%; overflow: hidden; position: fixed; _position: absolute; top: 0; left: 0; z-index: 100500; text-align: center; background-color: '+ color + (bg != '' ? '; background: '+ bg : '') +'" onmouseover="window.AZSwoopi.swoopInit(1, 1)" onmouseout="window.AZSwoopi.swoopInit(0, 1)" id="'+ this.block +'"><img src="'+ url +'" height="'+ height +'" width="'+ width +'" style="padding: 0px; margin: 0px; border: 0px"></a>');
	var i = this.getCookie('count_swoop') || 0;
	if (i < this.params.auto_show)
	{
		window.setTimeout('window.AZSwoopi.swoopInit(1, 0)', 20);
		window.setTimeout('window.AZSwoopi.swoopInit(0, 0)', 5000);
	}
	this.setCookie('count_swoop', ++i, 3);
}
