// All this code would go in your .js file	

var adArrayStatic=new Array();

                        

                        adArrayStatic[0] = ["http://naturetravelspecialists.com", "../ads/Australia_90.gif", "_blank"];

                        adArrayStatic[1] = ["http://www.birdinginnh.com", "../ads/New_Hamp_90.jpg", "_blank"];

                        

                        function DisplayStaticAds(){

                                    for(var i = 0; i < adArrayStatic.length; ++i){

                                                document.write('<tr><td><a href=\"' + adArrayStatic[i][0] + '\" target=\"' + adArrayStatic[i][2] + '\"><img src=\"' + adArrayStatic[i][1] + '\" border=0></a></td></tr>');

                                    }

                        }

		var adArray=new Array();
		var adRoot = ''; // If the incldue will be used in more than one direcotry, this may be necessary to set this on page load
		var adDisplayTimeInSeconds = 10;  // How long before we display the next ad, in seconds.
		
		// web-url, image-src, target
		adArray[0]=["http://www.NewfoundlandLabrador.com", "../ads/Newfoundv2_400.jpg", "_blank"];
		adArray[1]=["http://www.celestron.com/skyscout/new/index.php?utm_source=Audubon&utm_medium=Banner&utm_campaign=SkyScout", "../ads/celestron.jpg", "_blank"];
		adArray[2]=["http://www.arizonaguide.com", "../ads/arizona_400.jpg", "_blank"];
		adArray[3]=["http://www.peru.info", "../ads/peru_400.jpg", "_blank"];
		adArray[4]=["http://ad.doubleclick.net/clk;123585954;18341929;s", "../ads/pentax.jpg", "_blank"];
		
		
		function DisplayAd(){
			// generate random num within scope
			var addNumber = Math.floor(Math.random()*adArray.length);
			var objHref = document.getElementById('RotatingAdLink');
			var objImg = document.getElementById('RotatingAdImage');
		
			
			// If the page has not fully loaded, these values will not exist, so 
			// we need to check for their existence before we move forward.
			if(objHref && objImg){
				// alert('We are going to try and display ad #' + addNumber + '\nURL: ' + adArray[addNumber][0] + '\nIMG: ' + adArray[addNumber][1]);
				if(objHref.style){
					objHref.style.display = 'none'; // If the brower suports it, make sure the image and the link never mismatch
				}
				
				// Set the ad properties
				objHref.href = adArray[addNumber][0];
				objHref.target = adArray[addNumber][2];
				objImg.src = adRoot + adArray[addNumber][1];
				
				if(objHref.style){
					objHref.style.display = 'inline';
				}
	
				return true; // An ad was displayed
			}
			
			return false; // We did not display an ad
		}
			
			
			
		function RotateAds(){
			var refreshDelay = adDisplayTimeInSeconds * 1000;
			var didWeDisplayAnAd = DisplayAd();
			if(didWeDisplayAnAd == false){
				refreshDelay = 100; // And ad did not display, the page is probably still loading, wait 1/10 of a second, and try again.
			}
				
			window.setTimeout('RotateAds()', refreshDelay); // Display the next ad in a few seconds
		}
			
			
		// End copy of code to .js file