function AdImage(img, desc, url, company, popup) {
    this._img = img;
    this._desc = desc;
    this._url = url;
    this._company = company;
    this._popup = popup;
}

AdImage.prototype._img;
AdImage.prototype._desc;
AdImage.prototype._url;
AdImage.prototype._company;
AdImage.prototype._popup;

AdImage.prototype.GetImage = function() { return this._img; }
AdImage.prototype.GetDescription = function() { return this._desc; }
AdImage.prototype.GetUrl = function() { return this._url; }
AdImage.prototype.GetCompany = function() { return this._company; }
AdImage.prototype.GetPopup = function() { return this._popup; }

var timera;
var timerb;
var gcount = 0;

var imagesA = new Array();
var imagesB = new Array();

var a = 0;
var b = 0;

function rotate() {
    if (gcount == 0) { 
    	getFirstImage(); gcount++; 
    }
        
    rotateA(); 
    rotateB(); 
}

function rotateA() {
    if (a < (imagesA.length - 1)) { a++; }
    else { a = 0; }
    setTimeout("changeGroupA('groupAimages')", timera);
}

function rotateB() {
    if (b < (imagesB.length - 1)) { b++ }
    else { b = 0; }
    setTimeout("changeGroupB('groupBimages')", timerb);
}

function changeGroupA(id) {
    var ia = document.getElementById(id);
    var la = document.getElementById('divgroupAimages');
    var img = imagesA[a];
    
    ia.src = img.GetImage();
    ia.setAttribute('alt', img.GetDescription());
    
    if (img.GetUrl() == "") { 
    	// la.href = "#";
    	la.style.cursor = "";
    	la.onclick = "";
    }
    else {
	    if (img.GetPopup().toLowerCase() == "yes") {
	    	la.style.cursor = "hand"; 
	    	la.onclick = function () { showPopup(img.GetCompany(), img.GetUrl()) };
	    }
	    else {
   	    	la.style.cursor = "hand";
	    	la.onclick = function() { showWindow(img.GetUrl()) };
	    } 
	}
    
    rotateA();
}

function changeGroupB(id) {
    var lb = document.getElementById('divgroupBimages');
    var ib = document.getElementById(id);
    var img = imagesB[b];
    
    ib.src = img.GetImage();
    ib.setAttribute('alt', img.GetDescription());
    
    if (img.GetUrl() == "") {
    	lb.style.cursor = ""; 
    	lb.onclick = "";
    }
    else {
    	if (img.GetPopup().toLowerCase() == "yes") {
    		lb.style.cursor = "hand";
    		lb.onclick = function () { showPopup(img.GetCompany(), img.GetUrl()) };
    	}
	    else {
       		lb.style.cursor = "hand";
	    	lb.onclick = function() { showWindow(img.GetUrl()) };
    	} 
    }
    
    rotateB();
}

function showPopup(company, url)
{
    var message = "You are leaving our website and linking to " + company + " at " + url + " which is not operated by Finance Center Federal Credit Union. \r\n\r\n";
    message += "We are not responsible for the content of this linked site.  We do not represent " + company + " or yourself if the two enter into any transaction.\r\n\r\n";
    message += "Privacy and security policies may differ between Finance Center Federal Credit Union and those practiced by " + company + ".\r\n";
    var c = confirm(message);
    if (c) { window.open(url); }
}

function showWindow(url)
{
	window.open(url);
}

function getFirstImage()
{
    var pageimage = document.getElementById('groupAimages');
    var img = imagesA[0];
    
    pageimage.src = img.GetImage();
    pageimage.setAttribute('alt', img.GetDescription());
	var l = document.getElementById('divgroupAimages');
	
    if (img.GetUrl() == "") { 
    	l.onclick = ""; 
    }
    else {
    	if (img.GetPopup().toLowerCase() == "yes") {
    		l.style.cursor = "hand";
    		l.onclick = function () { showPopup(img.GetCompany(), img.GetUrl()) };
    	}
	    else {
    		l.style.cursor = "hand";
	    	l.onclick = function() { showWindow(img.GetUrl()) };
    	} 
    }
    
    pageimage = document.getElementById('groupBimages');
    img = imagesB[0];
    
    pageimage.src = img.GetImage();
    pageimage.setAttribute('alt', img.GetDescription());
	l = document.getElementById('divgroupBimages');
	
    if (img.GetUrl() == "") { 
    	l.onclick = ""; 
    }
    else {
    	if (img.GetPopup().toLowerCase() == "yes") {
			l.style.cursor = "hand";
    		l.onclick = function () { showPopup(img.GetCompany(), img.GetUrl()) };
    	}
	    else { 
    		l.style.cursor = "hand";
	    	l.onclick = function() { showWindow(img.GetUrl()) };
    	} 
    }
}