// JavaScript Document
function change(image, boo, url) { //Without extension option.
if (boo==true) {
	image.src="http://www.genealogy.wieringafamily.net/images/images/"+url+".gif";
}
if (boo==false) {
	image.src="http://www.genealogy.wieringafamily.net/images/images/"+url+".gif";
}
}

function change(image, boo, url, ext) { //With extension option. Allows for control of extension.
if (ext == "" || ext == " " || ext == null) { ext="gif"; } //Fixes invalid/nonexisting extensions.
if (boo==true) {
	image.src="http://www.genealogy.wieringafamily.net/images/images/"+url+"."+ext;
}
if (boo==false) {
	image.src="http://www.genealogy.wieringafamily.net/images/images/"+url+"."+ext;
}
}

function go(where) { //Just a wrapper. :)
	window.location.assign(where);
}

function makeAlerts() {
	//Because IE8 and lower is  stupid...
	//They dont support CSS ':hover' attribute. -_____-
	//So...we change it through JS. Nifty huh?
		var x = -1;
		var q = document.getElementsByTagName('img');
		while (q[++x] != undefined) {
			if (q[x].id==="hist") {
			q[x].onmouseover= function() { this.src="images/images/historyon.gif";}
			q[x].onmouseout= function() { this.src="images/images/History.gif";}
			}
			if (q[x].id==="tree") {
			q[x].onmouseover= function() { this.src="images/images/familytreeon.gif";}
			q[x].onmouseout= function() { this.src="images/images/Family-Tree.gif";}
			}
			if (q[x].id==="obit") {
			q[x].onmouseover= function() { this.src="images/images/obitson.gif";}
			q[x].onmouseout= function() { this.src="images/images/Obituaries.gif";}
			}
			if (q[x].id==="book") {
			q[x].onmouseover= function() { this.src="images/images/guestbookon.gif";}
			q[x].onmouseout= function() { this.src="images/images/Guestbook.gif";}
			}
			if (q[x].id==="pics") {
			q[x].onmouseover= function() { this.src="images/images/photoson.gif";}
			q[x].onmouseout= function() { this.src="images/images/Photos.gif";}
			}
			if (q[x].id==="mems") {
			q[x].onmouseover= function() { this.src="images/images/memoirson.gif";}
			q[x].onmouseout= function() { this.src="images/images/Memoirs.gif";}
			}
		}
		x = -1;
		q = document.getElementsByTagName('td');
		while (q[++x] != undefined) {
			if (search(q[x].innerHTML.substring(0,600))) {
				q[x].align="center";
			}
			else {
				var xx = -1;
				var qq = document.getElementsByTagName('table');
				while (qq[++xx] != undefined) {
					if (search(qq[xx].innerHTML.substring(0,600))) {
						qq[xx].align="center";
					}
				}
			}
		}
}

window.onload = function() {
	if (getInternetExplorerVersion() <= 8.0 && getInternetExplorerVersion() >= 1.0) {
		makeAlerts();
	}
}

function preload() {
	var load = document.createElement("div");
	load.className = "preloader";
	load.innerHTML = "<img src=images/images/historyon.gif /><img src=images/images/familytreeon.gif /><img src=images/images/obitson.gif /><img src=images/images/guestbookon.gif /><img src=images/images/photoson.gif /><img src=images/images/memoirson.gif />";
	load.style.position = "absolute";
	load.style.width = "5000px";
	load.style.height = "5000px";
	load.style.left = "-9999px";
	load.style.top = "-9999px";
	var a = document.getElementsByTagName('head');
	a[0].appendChild(load);
}

preload();

function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function search(s) {
	var x = false;
	if (s.match('id="hMiddle"') != null || s.match('id="hist"') != null || s.match('id=hMiddle') != null || s.match('id=hist') != null) 
	  x = true;
	return x;
}
