// JavaScript Document
selectedBlog = 1;
numTabs = 2;
function showBlog(n) {
	if (selectedBlog==n) {
		// click occurred on active tab;
		// redirect to blog url
		blogURL = document.getElementById('blogTab'+n).getAttribute('blogURL');
		if (blogURL) {
			window.location = blogURL;
		}
	}
	selectedBlog = n;
	// iterate through tabs
	for (t=1;t<=numTabs;t++) {
		// set the correct image state for tab:
		tabEl = document.getElementById('blogTab'+t);
		tabEl.src = (n==t) ? "images/blog_tab"+t+"_1.gif" : "images/blog_tab"+t+"_3.gif";
		// show or hide tab contents
		tabContentsEl = document.getElementById('blog_content'+t);
		tabContentsEl.style.display = (n==t) ? "block" : "none";
	}
}

function initTabBehaviour() {
	for (t=1;t<=numTabs;t++) {
		// preload tab state images
		addPreload("images/blog_tab"+t+"_1.gif");
		addPreload("images/blog_tab"+t+"_2.gif");
		addPreload("images/blog_tab"+t+"_3.gif");
		// define the mouseover & mouseout behaviour
		tabEl = document.getElementById('blogTab'+t);
		tabEl.setAttribute('tabId',t);
		tabEl.onmouseover = function() {
			tabId = this.getAttribute('tabId');
			if (tabId!=selectedBlog) {
				this.src = "images/blog_tab"+tabId+"_2.gif"
			}
		}
		tabEl.onmouseout = function() {
			tabId = this.getAttribute('tabId');
			if (tabId!=selectedBlog) {
				this.src = "images/blog_tab"+tabId+"_3.gif"
			}
		}
	}
	preloadImages();
}


// generic preload script
preloadArray = new Array();
function addPreload(imgSrc) { preloadArray[preloadArray.length] = imgSrc; }
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		for (i=0; i<preloadArray.length; i++) eval("preloadImage"+i+" = newImage('"+preloadArray[i]+"');");
		preloadFlag = true;
	}
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// startup prodecure
setTimeout("initTabBehaviour();",1000);
