function FlashInstalled() {
        result = false;
        if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
        {
                result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
        }
        else if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
        {
                // IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
                eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)     result = true; xObj = null;     } catch (e)     {}');
        }
        return result;
}

function FlashWrite(url,width,height)
{
        document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
        document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
        document.write('  WIDTH=' + width + ' HEIGHT=' + height + '>');
        document.write(' <PARAM NAME=movie VALUE="' + url + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>  ');
        document.write(' <EMBED src="' + url + '" quality=high bgcolor=#FFFFFF  ');
        document.write(' swLiveConnect=FALSE WIDTH=' + width + ' HEIGHT=' + height);
        document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
        document.write(' </EMBED></OBJECT>');
}


//------------------------------------------------------------------------------------------------------------------------

var imgAr = new Array();
	imgAr[0] = new Array("chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif");
	imgAr[1] = new Array("michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif",
						 "chips.gif");
	imgAr[2] = new Array("freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif");
	imgAr[3] = new Array("remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg");
	imgAr[4] = new Array("northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif");
	imgAr[5] = new Array("burchlandmfg.gif",
						 "captainjack.gif",
						 "iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg");
	imgAr[6] = new Array("captainjack.gif",
						 "iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif");
	imgAr[7] = new Array("iowamall.gif",
						 "chips.gif",
						 "michaelsharpcpa.gif",
						 "freese_notis_banner_ad.jpg",
						 "remaxopportunities.gif",
						 "northwest_bank.jpg",
						 "burchlandmfg.gif",
						 "captainjack.gif");

var destAr = new Array();
	destAr[0] = new Array("http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com");
	destAr[1] = new Array("http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com");
	destAr[2] = new Array("http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com");
	destAr[3] = new Array("http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net");
	destAr[4] = new Array("http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html");
	destAr[5] = new Array("http://www.burchlandmfg.com",
						  "http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com");	
	destAr[6] = new Array("http://www.captainjack.com",
						  "http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com");
	destAr[7] = new Array("http://www.iowamall.com",
						  "http://www.chipsrestaurant.com",
						  "http://www.michaelsharpcpa.com",
						  "http://adsl.weather.net",
						  "http://www.homesinankeny.com/bin/web/real_estate/AR116000/HOME_SEARCH/Ankeny/1185395800.html",
						  "http://www.bank-northwest.com",
						  "http://www.burchlandmfg.com",
						  "http://www.captainjack.com");
	
//------------------------------------------------------------------------------------------------------------------------

// preload all advertisers images
if (document.images) {
	var rImg = new Array();
	for (var i=0; i<imgAr.length; i++) {
    rImg[i] = new Array();
    for (var j=0; j<imgAr[i].length; j++) {
      rImg[i][j] = new Image(); 
		  rImg[i][j].src = "images/banner_ads/" + imgAr[i][j];
    	// NOTE: the path to the images!
    	// change it as needed, or include path in imgAr items and remove it here.    
    }
  }
}  
    
// called onload, sets up image objects for rotation
function initImgRotation() {
  // arguments: image name, rotation speed, matching array number
  new rotateImgObj('ad0',7000,0);
  new rotateImgObj('ad1',7000,1);
  new rotateImgObj('ad2',7000,2);
  // add as many as you like
  
  // starts rotation for all defined image objects
  for (var i=0; i<rotateImgObj.ar.length; i++) {
     rotateImgObj.ar[i].timer = setTimeout(rotateImgObj.ar[i].obj + ".rotate()",3000);  
  }
}

// variables for link sub-window
var subWinWd = 700;	// width of sub-window
var subWinHt = 350;	// height of sub-window
// list of common chrome elements: "menubar,location,toolbar,status,scrollbars,resizable"
var subWinChrome = "menubar,location,toolbar,status,scrollbars,resizable";
// for centering sub-window on screen
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var subWinTop = Math.round((screenHeight-subWinHt)/3);
var subWinLeft = Math.round((screenWidth-subWinWd)/2);

var subWin;
// called onclick of images
function doImgClick(n) {
	if (document.images && rotateImgObj.ar[n]) {
    var img = rotateImgObj.ar[n];
    if (destAr[img.num][img.ctr]) {
  		if (destAr[img.num][img.ctr].indexOf('javascript:')!=-1) eval(destAr[img.num][img.ctr]);
  		else {
  			if (subWin && !subWin.closed) subWin.focus();
  			subWin = window.open(destAr[img.num][img.ctr],"subWin", subWinChrome+",height="+subWinHt+",width="+subWinWd+",top="+subWinTop+",left="+subWinLeft);
  		}
    }
	}
}

// automatically closes sub-window when document unloads
function closeWin() {	if (subWin && !subWin.closed) subWin.close(); }
window.onunload = closeWin;

rotateImgObj.ar = new Array(); // holds all rotating image objects defined
// constructor for rotating image objects
// arguments: image name, speed of rotation, array element number (starts at zero)
function rotateImgObj(nm,s,num) {
  this.speed = s; this.num = num; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm];
  this.obj = nm + "object"; eval(this.obj + "=this");
  rotateImgObj.ar[rotateImgObj.ar.length] = this;
}

rotateImgObj.prototype.rotate = rotateImg;
// controls rotation
function rotateImg() {
  clearTimeout(this.timer); 
  if (this.ctr < rImg[this.num].length-1) this.ctr++;
  else this.ctr = 0;
  this.imgObj.src = rImg[this.num][this.ctr].src;
  this.timer = setTimeout(this.obj + ".rotate()",this.speed);
}

// for stopping/starting onmouseover/out
function stopRotation(n) {	
  if (rotateImgObj.ar[n])
    clearTimeout(rotateImgObj.ar[n].timer); 
}

function restartRotation(n) {
  if (rotateImgObj.ar[n])
    rotateImgObj.ar[n].timer = setTimeout(rotateImgObj.ar[n].obj + ".rotate()",300);
}

// write first images to page from array
function firstimages(adnumber) {
return('<a href="javascript: doImgClick('+ adnumber +')" onmouseover="stopRotation('+ adnumber +')" onmouseout="restartRotation('+ adnumber +')" onfocus="this.blur()"><img src="images/banner_ads/'+ (imgAr[adnumber][0]) +'" alt="Click For Details" name="ad'+ adnumber +'" width="150" height="150" border="0" id="ad'+ adnumber +'0"></a>');
}

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) {
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight +',resizable=1,scrollbars=yes,menubar=no,status=no');
}

