//  Tri Synergy, Inc. | ads.js
//  Kevin Scholl      | kscholl@comcast.net
//  Last Update       | 12 Nov 2005

// ----------------------------------------------------------------------
// GLOBAL VARIABLES
// ----------------------------------------------------------------------  

var ADS_BANNER     = new Array();
var ADS_BLOCK      = new Array();
var ADS_SKYSCRAPER = new Array();

var QUOTES         = new Array();

// ----------------------------------------------------------------------
// CREATE AD OBJECTS
// ----------------------------------------------------------------------

function adObj(adType,adURL,adPath,adWidth,adHeight) {

  this.type   = adType;
  this.url    = adURL;
  this.path   = adPath;
  this.width  = adWidth;
  this.height = adHeight;
  
  switch (adType) {
    case 1:
      ADS_BANNER[ADS_BANNER.length] = this;
      break;
    case 2:
      ADS_BLOCK[ADS_BLOCK.length] = this;
      break;
    case 3:
      ADS_SKYSCRAPER[ADS_SKYSCRAPER.length] = this;
      break;
    }    
  }

// ----------------------------------------------------------------------
// CREATE QUOTES OBJECTS
// ----------------------------------------------------------------------

function quoteObj(blurb) {

  this.snippet   = blurb;
	
	QUOTES[QUOTES.length] = this;
  }

// ----------------------------------------------------------------------
// DISPLAY RANDOM AD
// ----------------------------------------------------------------------

var adCheck = null;

function displayAd(adType) {

	var ad    = null;
  var theAd = null;
	switch (adType) {
	case 1:
		ad = (Math.floor(Math.random() * ADS_BANNER.length));
	  theAd = ADS_BANNER[ad];
		break;
	case 2:
		if (ad == null && adCheck == null) {
			ad = (Math.floor(Math.random() * ADS_BLOCK.length));
			adCheck = ad;
			theAd = ADS_BLOCK[ad];
			}
		else {
			ad = (Math.floor(Math.random() * ADS_BLOCK.length));
			while (ad == adCheck) {
				ad = (Math.floor(Math.random() * ADS_BLOCK.length));
				}
			theAd = ADS_BLOCK[ad];
			}
		break;
	case 3:
		ad = (Math.floor(Math.random() * ADS_SKYSCRAPER.length));
	  theAd = ADS_SKYSCRAPER[ad];
		break;
		}    

	if (theAd.url == "FLASH") {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + theAd.width + '" height="' + theAd.height + '">');
		document.write('<param name="movie" value="' + theAd.path + '" />');
		document.write('<param name="quality" value="high" />');
		document.write('<embed src="' + theAd.path + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + theAd.width + '" height="' + theAd.height + '"></embed>');
		document.write('</object>');
		}
	else {
		document.write('<a href="' + theAd.url + '"><img src="' + theAd.path + '" alt="Advertisement" border="0" width="' + theAd.width + '" height="' + theAd.height + '" /></a>');
		}
	}

// ----------------------------------------------------------------------
// DISPLAY RANDOM QUOTE
// ----------------------------------------------------------------------

function displayQuote() {

	var foo      = null;
  var theQuote = null;
	
	foo = (Math.floor(Math.random() * QUOTES.length));
	theQuote = QUOTES[foo];

	document.write('<p class="last"><img src="/images/quote_start.gif" alt="" width="16" height="12" border="0" />' + theQuote.snippet + '<img src="/images/quote_end.gif" alt="" width="16" height="12" border="0" /></p>');
	
  }
