var version="06";
var thispage=self.location.href;
thispage=thispage.substring(thispage.indexOf("bfdg")+7,thispage.indexOf(".htm"));

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;
var IE=(document.all) ? true : false;

var contentScroll=true;

//create PAGE line object
function pageline (display,link,hash,category,label) {
	this.length=6;
	this.dsp=display;
	this.url=link;
	this.hsh=hash;
	this.cat=category;
	this.lbl=label;
}

//array of PAGE parameters
var page = new Array(30);
page[0]=30;

page[1] = new pageline(true,"home.htm","miss","Home","Our Mission");
page[2] = new pageline(true,"home.htm","stor","Home","Student Showcase");

page[3] = new pageline(true,"whatwedo.htm","work","What We Do","Our Work");
page[4] = new pageline(true,"whatwedo.htm","been","What We Do","Where We've Been");
page[5] = new pageline(true,"whatwedo.htm","stor","What We Do","Student Showcase");

page[6] = new pageline(true,"programs.htm","desc","Programs","Description");
page[7] = new pageline(true,"programs.htm","opti","Programs","Program Options");
page[8] = new pageline(true,"programs.htm","grow","Programs","Personal Growth");
page[9] = new pageline(true,"programs.htm","resu","Programs","Results");
page[10] = new pageline(true,"programs.htm","stor","Programs","Student Showcase");

page[11] = new pageline(true,"redhouse.htm","welc","The Red House","Welcome");
page[12] = new pageline(true,"redhouse.htm","tale","The Red House","Talent Search");
page[13] = new pageline(true,"redhouse.htm","cont","The Red House","Contact Info");
page[14] = new pageline(true,"redhouse.htm","dire","The Red House","Directions");
page[15] = new pageline(true,"redhouse.htm","stor","The Red House","Store");

page[16] = new pageline(true,"whoweare.htm","lead","Who We Are","Leadership");
page[17] = new pageline(true,"whoweare.htm","fund","Who We Are","Funders");
page[18] = new pageline(true,"whoweare.htm","stor","Who We Are","Student Showcase");

page[19] = new pageline(true,"market.htm","show","Marketplace","Showcase");
page[20] = new pageline(true,"market.htm","even","Marketplace","Events");
page[21] = new pageline(true,"market.htm","stor","Marketplace","Store");

page[22] = new pageline(true,"involve.htm","dona","Get Involved","Donations");
page[23] = new pageline(true,"involve.htm","teac","Get Involved","Teach a Class");
page[24] = new pageline(true,"involve.htm","inte","Get Involved","Internships");
page[25] = new pageline(true,"involve.htm","serv","Get Involved","Service Learning");
page[26] = new pageline(true,"involve.htm","scho","Get Involved","Scholarship Fund");
page[27] = new pageline(true,"involve.htm","even","Get Involved","Events");

page[28] = new pageline(true,"contact.htm","info","Contact Us","Contact Info");
page[29] = new pageline(true,"contact.htm","stor","Contact Us","Store");

var menulines=0;

function buildLeftMenu(){
	var cat="";
	var str='<div>';
	var tabact=false;
	for(i=1;i<page[0];i++){
		if(page[i]["dsp"]){
			if(page[i]["cat"]!=cat){ //new category
				tabact = (page[i]["url"].indexOf(thispage)!=-1) ? true : false;
				cat=page[i]["cat"];
				if (tabact){  //text heading
					str += '</div><div id="active">';
					str += cat;
				}else{ //link to another page
					str += '</div><div class="menulink">';
					str += '<a href="bfdg' + version + '-' + page[i]["url"] + '">';
					str += cat;
					str += '</a>';
				}
				menulines++
			}
			//if(tabact && navOK){//sublinks
			if(tabact){//sublinks
				str += '<br>&nbsp;&nbsp;';
				str += '<a href="javascript:void(0);" onClick="scrollContent(\'' + page[i]["hsh"] + '\');">';
				str += page[i]["lbl"] + '</a>';
				menulines++;
			}
		}
	}
	str += '</div>';
	document.write(str);
}

function scrollContent(hash){
	if(!contentScroll){ //older IE browsers
		location.hash = '#' + hash;
	}else{
		document.getElementById("content").scrollTop = document.getElementById(hash).offsetTop;
	}
}

function checkHash(){
	chkLinkAi();
	var hash=document.location.search;
	if(hash.indexOf("?")!=-1){
		hash=hash.substring(hash.indexOf("?")+1,hash.length);
		scrollContent(hash);
	}
}

function gotoPage(pg,hsh){
	var page='bfdg' + version + '-' + pg + '.htm';
	if(hsh!="")page += '?' + hsh;
	document.location=page;
}

function buildBotMenu(){
	var cat="";
	var catcount=0;
	var str='<div class="botmenu">';
	var tabact=false;
	str += '<a href="javascript:void(0);" onClick="scrollContent(\'contentliner\');">^Top^</a>';
	for(i=1;i<page[0];i++){
		if(page[i]["cat"]!=cat){ //new category
			str += (catcount==4) ? '<br>' :  ' | ';
			catcount++;
			tabact = (page[i]["url"].indexOf(thispage)!=-1) ? true : false;
			cat=page[i]["cat"];
			if (tabact){  //text heading
				str += cat;
			}else{ //link to another page
				str += '<a href="bfdg' + version + '-' + page[i]["url"] + '">';
				str += cat;
				str += '</a>';
			}
		}
	}
	str += '</div>';
	document.write(str);
}

function buildStoreLink(){
	var pnum = document.body.className;
	pnum = pnum.substring(4,5);
	var str='<div id="stor">';
	str += (IE) ? '<a style="float:right; padding-top:10px;" ' : '<a style="float:right; padding-top:3px;" ';
	str += 'href="javascript:scrollContent(\'contentliner\');">Back to Top</a>';
	str += '<h2>Store</h2>';
	str += '<div style="height:4px; clear:both;"></div>';
	str += '<div class="stoff" ';
	str += 'onMouseOver="this.className=\'ston\';" onMouseOut="this.className=\'stoff\';">';
	str += '<a href="http://www.breakfreefashion.wordpress.com" target="_new">';
	str += '<img src="images/storelink' + version + '-' + pnum + '.gif" style="border:0px;">';
	str += '</a></div>';
	str += '</div>';
	document.write(str);
}


function chkLinkAi(){
	var vert=getVert()-(menulines*21)-345;
	if((!navOK)||(vert<-40)){
		contentScroll=false;
		document.getElementById("outerbox").style.overflow="visible";
		document.getElementById("container").style.overflow="visible";
		document.getElementById("content").style.overflow="visible";
		document.getElementById("content").style.bottom="auto";
		document.getElementById("container").style.bottom="auto";
		var conhgt = document.getElementById("content").offsetHeight;
		document.getElementById("container").style.height=(conhgt+130) + 'px';
		document.body.style.overflow="auto";
		document.body.style.height=(conhgt+192) + 'px';
		document.getElementById("linkai").style.display="none";
	}else if(vert<0){
		document.getElementById("linkai").style.display="none";
	}
}

function getVert(){
	try{
		var vert=document.body.parentNode.clientHeight;
	}
	catch(err){
		try{
			var vert=window.innerHeight;
		}catch(err){
			var vert=screen.availHeight;
		}
	}
	if(vert==0){
		try{
			var vert=window.innerHeight;
		}catch(err){
			var vert=screen.availHeight;
		}
	}
	return vert;
}


