var nav = navigator.appVersion.toLowerCase();
var navVersion=parseFloat(nav);
var navOK=true;
if(navVersion<4||nav.indexOf("msie 6")!=-1||nav.indexOf("msie 5")!=-1) navOK=false;

//create link line object
function linkline (display,lnk,lbl,abb,ttl,mbox,content) {
	this.length=8;
	this.disp= display;
	this.link= lnk;
	this.label = lbl;
	this.abbrev= abb;
	this.title = ttl;
	this.msgbox= mbox;
	this.cont= content;
}
//array of links
var line = new Array(14);
line[0] =14;
line[1] = new linkline(true,"home","Home","Home",2,1,0);
line[2] = new linkline(true,"intro","An Introduction","Introduction",1,0,1);
line[3] = new linkline(true,"who","Who We Are","Who",1,0,1);
line[4] = new linkline(true,"faith","Statement of Faith","Faith",1,0,1);
line[5] = new linkline(true,"practice","Our Practices","Practices",1,0,1);
line[6] = new linkline(true,"literature","Available Literature","Literature",1,0,1);
line[7] = new linkline(true,"eagles","The Way of Eagles","Eagles",0,0,1);
line[8] = new linkline(true,"nuggets","Nuggets","Nuggets",1,0,1);
line[9] = new linkline(true,"broadcast","Radio Broadcast","Broadcast",1,0,1);
line[10]= new linkline(true,"tabernacle","Tabernacle","KGT",2,1,1);
line[11]= new linkline(true,"message","Message for the Week","Message",2,1,1);
line[12]= new linkline(true,"contact","Contact Us","Contact",1,0,1);
line[13]= new linkline(true,"links","Links","Links",1,0,1);

function menuItem(act){
	buildMenu(act);
	buildPage(act);
	botMenu(act);
	if (navOK) scrollContent("contentbox");
}

function buildPage(act){
	var link=line[act]["link"];
	//title
	if (line[act]["title"]==1){
		$("#title").addClass("titlebar");
		$("#title").html(line[act]["label"]);
		$("#title").css("visibility:visible");
	}else if(line[act]["title"]==2){
		$("#title").removeClass("titlebar");
		$("#title").load("title-" + link + ".htm");
		$("#title").css("visibility:visible");
	}else{
		$("#title").css("visibility:hidden");
		$("#title").html("");
		$("#title").removeClass("titlebar");
	}

	//content
	if (line[act]["cont"]==1){
		$("#content").load("content-" + link + ".htm");
		$("#content").css("visibility:visible");
	}else{
		$("#content").css("visibility:hidden");
		$("#content").html("");
	}

	//message box
	if (line[act]["msgbox"]==1){
		$("#msgbox").load("msg-" + link + ".htm");
		$("#msgbox").css("visibility:visible");
	}else{
		$("#msgbox").css("visibility:hidden");
		$("#msgbox").html("");
	}
}

function buildMenu(act){
	var str='';
	for (i=1;i<line[0];i++){
		if (line[i]["disp"]){
			if (i==act) {
					str += '<div class="active" ';
					if(i==1) str += 'style="margin-left:168px;" ';
					str += '>' + line[i]["label"] + '</div>';
			}else{
				str += '<div class="inactive">';
				str += '<a href="#" onClick="menuItem(' + i + ');">';
				str += line[i]["label"] + '</a></div>';
			}
		}
	}
	document.getElementById("menu").innerHTML=str;
}

function botMenu(act){
	var count=0;
	var str='<div style="margin-bottom:12px;">';
	str += '<a href="#" onClick="scrollContent(\'contentbox\');">Back to Top</a>';
	str += '</div>';
	for (i=1;i<line[0];i++){
		if (line[i]["disp"]){
			if (i!=act) {
				str += '<a href="#" onClick="menuItem(' + i + ');">';
				str += line[i]["abbrev"] + '</a>';
				str += ((i==line[0]-1)||((act==line[0]-1)&&(i==line[0]-2))) ? '' : (++count==6) ? '<br>' : ' | ';
			}
		}
	}
	document.getElementById("botmenu").innerHTML=str;
}

function scrollContent(hash){
	if(!navOK){ //older IE browsers
		location.hash = '#' + hash;
	}else{
		document.getElementById("contentbox").scrollTop = document.getElementById(hash).offsetTop;
	}
}

function listenLink(){
	var link = 'http://player.amsinteractive.com/gospelword/?Channel_Id=1799';
	var str='<a href="' + link + '" target="_new">';
	str += '<img src="images/LogoHear-GospelWord.gif" alt="The Gospel Word" border="0">';
	str += '</a>';
	document.getElementById("listen").innerHTML=str;
}
