﻿
//     Detect IE6

    browserDetect.init();
    
    if ((browserDetect.browser == "Explorer")&&(browserDetect.version == "6")){
           imageExtension =  'gif';
    }
    else {
       imageExtension  = 'png';
    }


// Setup Roatation

/**	topBannerAdvert 
	(2 lists of adverts)
	
	Richard Pearce, Mar 2007
	Adapted for 2 lists of banners, July 07.
	
	**/


function retrieveComputedStyle(element, styleProperty){
/**	retrieveComputedStyle
	cross-browser function to return the style of an element
	**/
	var computedStyle = null;
	if (typeof element.currentStyle != "undefined"){
		computedStyle = element.currentStyle;
	}else{
		computedStyle = document.defaultView.getComputedStyle(element, null);
	}
	return computedStyle[styleProperty];
}

var topBanner = {
	addEvent: function(elm, evType, fn, useCapture) {
	// addEvent cross-browser event handling for IE5+, NS6 and Mozilla
	// By Scott Andrew
		if (elm.addEventListener) {
			elm.addEventListener(evType, fn, useCapture); 
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	},
	
	init: function(){
		topBanner.rotateAd1();
		topBanner.rotateAd2();
		
		return true;
	},
	
	addItemAd1: function(imgSrc, imgAlt, linkUrl, tgt){
		var newIndex = topBanner.bannerAd1.length;
		topBanner.bannerAd1[newIndex] = [imgSrc, imgAlt, linkUrl, tgt];
	},
	
	addItemAd2: function(imgSrc, imgAlt, linkUrl, tgt){
		var newIndex = topBanner.bannerAd2.length;
		topBanner.bannerAd2[newIndex] = [imgSrc, imgAlt, linkUrl, tgt];
	},
	
	rotateAd1: function(){
		if(topBanner.bannerAd1.length > 0){
			var b = document.getElementById("topBannerAd1Img");
			var a = document.getElementById("topBannerAd1Link");
			if (b==null||a==null){
				return true;
			}
			
			b.src = topBanner.bannerAd1[topBanner.currentBannerAd1][0];
			b.alt = topBanner.bannerAd1[topBanner.currentBannerAd1][1];
			b.title = topBanner.bannerAd1[topBanner.currentBannerAd1][1];

			if (topBanner.bannerAd1[topBanner.currentBannerAd1][2]!="") {
				a.href = topBanner.bannerAd1[topBanner.currentBannerAd1][2];
				a.target = topBanner.bannerAd1[topBanner.currentBannerAd1][3];
			}else{
				a.removeAttribute("href");
				a.removeAttribute("target");
			}
			
			if(topBanner.currentBannerAd1==topBanner.bannerAd1.length-1){
				topBanner.currentBannerAd1 = 0;
			}else{
				topBanner.currentBannerAd1++;
			}
			
			if(topBanner.bannerAd1.length > 1){
				b.timeout = setTimeout("topBanner.rotateAd1()",topBanner.rotateDelay);
			}
		}
	},
	
	rotateAd2: function(){
		if(topBanner.bannerAd2.length > 0){
			var b = document.getElementById("topBannerAd2Img");
			var a = document.getElementById("topBannerAd2Link");
			if (b==null||a==null){
				return true;
			}
			
			b.src = topBanner.bannerAd2[topBanner.currentBannerAd2][0];
			b.alt = topBanner.bannerAd2[topBanner.currentBannerAd2][1];
			b.title = topBanner.bannerAd2[topBanner.currentBannerAd2][1];
			if(topBanner.bannerAd2[topBanner.currentBannerAd2][2]!="") {
				a.href = topBanner.bannerAd2[topBanner.currentBannerAd2][2];
				a.target = topBanner.bannerAd2[topBanner.currentBannerAd2][3];
			}else{
				a.removeAttribute("href");
				a.removeAttribute("target");
			}
			
			if(topBanner.currentBannerAd2==topBanner.bannerAd2.length-1){
				topBanner.currentBannerAd2 = 0;
			}else{
				topBanner.currentBannerAd2++;
			}
			if(topBanner.bannerAd2.length > 0){
				b.timeout = setTimeout("topBanner.rotateAd2()",topBanner.rotateDelay);
			}
		}
	},
	
	bannerAd1: [],
	bannerAd2: [],
	currentBannerAd1: 0,
	currentBannerAd2: 0,
	rotateDelay: 8000
}

