// MyCJ - Banner system
// © Copyright 2002 SharkSkills.com. All rights reserved.

var lastPaysiteName = 'Black Sex Planet';
var lastPaysiteURL = 'http://www.blacksexplanet.com/';
var lastPaysitePrice = '2.95$';
var sortbanners = true;

function bannerRandom (a, b) {
	if (Math.round(Math.random()) == 1){return 1;}
	else {return -1;}
}

function Banner (image, width, height, url, linktext, alttext) {
	this.image = image;
	this.width = width;
	this.height = height;
	this.url = url;
	this.linktext = linktext;
	this.alttext = alttext;
	this.showed = false;
}

function Paysite (name, price, url, image, width, height, description) {
	this.name = name;
	this.price = price;
	this.url = url;
	this.image = image;
	this.width = width;
	this.height = height;
	this.description = description;
	this.showed = false;
}

function getPaysiteRowsData (loops, showimage) {
	var written = 0;
	var out = '';
	for (i=0; i<paysiteslength; i++){
		var obj = paysites[i];
		if (obj.showed){continue;}
		written++;
		paysites[i].showed = true;
		out += '<tr>';
		if (showimage){
			out += '<td rowspan=2><a href="' + obj.url + '"><img src="' + obj.image + '" border=0 width=' + obj.width + ' height=' + obj.height + ' alt="' + obj.name + '" galleryimg="no"></a></td><td width=10></td>';
		}
		out += '<td valign=top height=25><div class="TextHeader"><a href="' + obj.url + '"><font size=+1><u>' + obj.name + '</u></font></a></div></td><td width=10></td><td valign=top height=25><b>';
		if (obj.price == '$0'){
			out += 'Try For Free';
		}
		else {
			out += 'Only ' + obj.price;
		}
		out += '</b></td></tr>';
		out += '<tr>';
		if (showimage){
			out += '<td></td>';
		}
		out += '<td colspan=3 valign=top height=75>' + obj.description + ' &#160;<a href="' + obj.url + '"><u><b>CLICK HERE!</b><u></a></td></tr>';
		if (loops != written){
			out += '<tr><td height=10></td></tr>';
		}
		lastPaysiteName = obj.name;
		lastPaysiteURL = obj.url;
		lastPaysitePrice = obj.price;
		if (loops == written){
			return out;
		}
	}
	return out;
}

function getPaysiteRows (loops) {
	document.write(getPaysiteRowsData(loops, true));
}

function getPaysiteTextRows (loops) {
	document.write(getPaysiteRowsData(loops, false));
}

/*
function getBanner (width, height, showtext) {
	for (i=0; i<bannerslength; i++){
		var obj = banners[i];
		if (obj.showed || width>0 && width!=obj.width || height>0 && height!=obj.height){continue;}
		banners[i].showed = true;
		var out = '<a href="' + obj.url + '" class="BannerText">';
		if (obj.alttext=='text'){
			obj.alttext=obj.linktext;
		}
		out += '<img src="' + obj.image + '" width=' + obj.width + ' height=' + obj.height + ' alt="' + obj.alttext + '" border=0 galleryimg="no">';
		if (showtext && obj.linktext!=''){
			out += '<br><b>' + obj.linktext + '</b>';
		}
		out += '</a>';
		document.write(out);
		return 1;
	}
}
*/

function getBanner (width, height, showtext) {
	document.write(getBannerData (width, height, showtext, bannerslength, banners));
}

function getBanner2 (width, height, showtext) {
	document.write(getBannerData (width, height, showtext, bannerslength, banners));
	//document.write(getBannerData (width, height, showtext, banners2length, banners2));
}

function getBannerData (width, height, showtext, arraylength, bannerarray) {
	for (i=0; i<arraylength; i++){
		var obj = bannerarray[i];
		if (obj.showed || width>0 && width!=obj.width || height>0 && height!=obj.height){continue;}
		bannerarray[i].showed = true;
		var out = '<a href="' + obj.url + '" class="BannerText">';
		if (obj.alttext=='text'){
			obj.alttext=obj.linktext;
		}
		out += '<img src="' + obj.image + '" width=' + obj.width + ' height=' + obj.height + ' alt="' + obj.alttext + '" border=0 galleryimg="no">';
		if (showtext && obj.linktext!=''){
			out += '<br><b>' + obj.linktext + '</b>';
		}
		out += '</a>';
		return out;
	}
}

function getOddBanner (width, height, showtext) {
	for (i=0; i<oddbannerslength; i++){
		var obj = oddbanners[i];
		if (obj.showed || width>0 && width!=obj.width || height>0 && height!=obj.height){continue;}
		oddbanners[i].showed = true;
		var out = '<a href="' + obj.url + '">';
		if (obj.alttext=='text'){
			obj.alttext=obj.linktext;
		}
		out += '<img src="' + obj.image + '" width=' + obj.width + ' height=' + obj.height + ' alt="' + obj.alttext + '" border=0 galleryimg="no">';
		if (showtext && obj.linktext!=''){
			out += '<br><b>' + obj.linktext + '</b>';
		}
		out += '</a>';
		document.write(out);
		return 1;
	}
}

function Dialer (image, width, height) {
	this.image = image;
	this.width = width;
	this.height = height;
	this.showed = false;
}

function getDialer (width, height) {
	for (i=0; i<dialerslength; i++){
		var obj = dialers[i];
		if (obj.showed || width>0 && width!=obj.width || height>0 && height!=obj.height){continue;}
		dialers[i].showed = true;
		document.write('<img src="' + obj.image + '" width=' + obj.width + ' height=' + obj.height + ' alt="" border=0 galleryimg="no">');
		return 1;
	}
}

