var copyright	= "&copy; Copyright 2005-2006 Jodie Langel";
var sections	= {
					noshow	: {
								text	: "Intensives",
								link	: "http://www.makingitonbroadway.net"
							},
					home	: {
								text	: "Home",
								link	: "/index.html"
							},
					actor	: {
								text	: "Actor",
								link	: "/resume.html",
								submenu	: [
											{
												text	: "Resume",
												link	: "/resume.html"
											},
											{
												text	: "Photo Gallery",
												link	: "/photogallery-resume.html"
											},
											{
												text	: "Sound Clips",
												link	: "/sounds-resume.html"
											},
											{
												text	: "Latest News",
												link	: "/cgi-bin/jodielangel/redBlogReader.pl?action=readIndex&section=on_stage"
											}
										]
							},
					author	: {
								text	: "Author",
								link	: "/book.html",
								submenu	: [
											{
												text	: "Making it on Broadway",
												link	: "/book.html"
											},
											{
												text	: "Photo Gallery",
												link	: "/photos-book.html"
											}
										]
							},
					teacher	: {
								text	: "Teacher",
								link	: "/teaching.html",
								submenu	: [
											{
												text	: "Seminars",
												link	: "/teaching.html"
											},
											{
												text	: "FAQ",
												link	: "/faq-teaching.html"
											}
										]
							},
					masterclass	: {
								text	: "Master Classes",
								link	: "/masterclass-teaching.html",
								submenu	: [
											{
												text	: "Master Classes",
												link	: "/masterclass-teaching.html"
											},
											{
												text	: "Intensives",
												link	: "http://www.makingitonbroadway.net"
											}
										]
							},
					news	: {
								text	: "Latest News",
								link	: "/cgi-bin/jodielangel/redBlogReader.pl"
							},
					contact	: {
								text	: "Contact",
								link	: "/contact.html"
							}
};

var pageTabs				= new tabStrip('tab1','tabsGoHere');
pageTabs.autoUpdate			= true;

pageTabs.setStyle('tabOnClass','mainTabOn');
pageTabs.setStyle('tabOffClass','mainTabOff');
pageTabs.setStyle('tabDisabledClass','mainTabDisabled');
pageTabs.setStyle('tabTextClass','mainTabText');
pageTabs.setStyle('tabTextHoverClass','mainTabTextHover');

pageTabs.setImage('tabOff_firstImg', '/rbsl/tabStrip/images/FirstTabOff.gif', 28, null);
pageTabs.setImage('tabOn_firstImg', '/rbsl/tabStrip/images/FirstTabOn.gif', 28, null);
pageTabs.setImage('tabOff_lastImg', '/rbsl/tabStrip/images/LastTabOff.gif', 28, null);
pageTabs.setImage('tabOn_lastImg', '/rbsl/tabStrip/images/LastTabOn.gif', 28, null);
pageTabs.setImage('tabOffBgImg', '/rbsl/tabStrip/images/TabOffBg.gif', 28, null);
pageTabs.setImage('tabOffEndImg', '/rbsl/tabStrip/images/TabOffEnd.gif', 28, null);
pageTabs.setImage('tabOnBgImg', '/rbsl/tabStrip/images/TabOnBg.gif', 28, null);
pageTabs.setImage('tabOnEndImg', '/rbsl/tabStrip/images/TabOnEnd.gif', 28, null);
pageTabs.setImage('tabOnStartImg', '/rbsl/tabStrip/images/TabOnStart.gif', 28, null);
pageTabs.setImage('tabOffJoinImg', '/rbsl/tabStrip/images/TabsOffJoin.gif', 28, null);

for (idx in sections) {
	if (idx != "noshow")
		pageTabs.addTab(idx,sections[idx].text, 'Javascript: void getSection(\''+idx+'\');');	
}
				
function getSection(key) {
	if (sections[key]) {
		if (sections[key].submenu) {
			location.href = sections[key].submenu[0].link;
		} else {
			location.href = sections[key].link;
		}
	} else {
		location.href = "/";
	}
}
function writeSubNav() {
	var links		= [];
	var sublinks	= [];
	var subMenu;
	var i = j		= 0;
	var count		= 0;
	
	for (i in sections) {
		if (sections[i].submenu) {
			for (j=0;j<sections[i].submenu.length;j++) {
				if (location.toString().indexOf(sections[i].submenu[j].link) != -1) {
					subMenu	= sections[i].submenu;
					for (k=0;k<subMenu.length;k++) {
						if (location.toString().indexOf(subMenu[k].link) != -1) {
							sublinks.push('<div style="display:inline;cursor:default;font-weight:700;color:#A64A1F" class="content">&nbsp;&nbsp;'+subMenu[k].text+'&nbsp;&nbsp;</div>');
						} else {
							sublinks.push('<div style="display:inline">&nbsp;&nbsp;<a href="'+subMenu[k].link+'" class="content">'+subMenu[k].text+'</a>&nbsp;&nbsp;</div>');
						}
					}
					break;
				}
			}
			count++;
		}
	}
	if (sublinks.length > 0) {
		document.write('<div id="subnav" align="left">');
		document.write(sublinks.join(' | '));
		document.write('</div>');
	}
}
function writeFooter(bHomeNav) {
	var links	= [];
	var i		= 0;
	var textClass	= (bHomeNav) ? "homeNav" : "footertext";
	
	for (i in sections) {
		if ((bHomeNav && i == "home")) {
			continue;
		}
		links.push('<a href="'+sections[i].link+'" class="'+textClass+'" hidefocus="true">'+sections[i].text+'</a>');
	}
	document.write('<div align="center" class="'+textClass+'">');
	if (bHomeNav) {
		document.write(links.join('&nbsp;&nbsp; '));
	} else {
		document.write(links.join(' | '));
	}
	document.write('</div>');
	if (!bHomeNav) {
		document.write('<div align="center" class="'+textClass+'">');
		document.write(copyright);
		document.write('</div>');
	}
}
function sizeContentFrame() {
	var frame	= document.getElementById('content');
	var measure	= document.getElementById('measureStick');
	var nav		= document.getElementById('nav');
	
	if (frame && measure) {
		frame.style.height	= measure.offsetHeight - nav.offsetHeight - ((BROWSER.detectBrowser().code == 'mozilla') ? 20 : 0);
	}
}
browserInfo	= function() {
	this.userAgent			= navigator.userAgent.toLowerCase();
	this.browser			= this.detectBrowser();
	this.os					= this.detectOs();
};
browserInfo.prototype.detectBrowser			= function() {
	var ret	= new Object();
	var versionTest;
	ret.name	= navigator.appName.toLowerCase();
	
	if (this.userAgent.indexOf('msie') >= 0) {
		// Internet explorer
		ret.code	= 'msie';
		versionTest	= /msie\s+(\d+\.\d+)/.exec(this.userAgent);
	} else if (this.userAgent.indexOf('mozilla') >= 0) {
		// Mozilla / Netscape
		ret.code	= 'mozilla';
		versionTest	= /mozilla\/(\d+\.\d+)/.exec(this.userAgent);
	}
	ret.version	= versionTest[1];
	
	return ret;
}
browserInfo.prototype.detectOs				= function() {
	var platform	= null;
	var version		= null;
	var versionNum	= null;
	
	if (this.userAgent.indexOf('windows') >= 0) {
		platform	= 'windows';
		if (this.userAgent.indexOf('nt 5.1') >= 0) {
			version		= 'xp';
			versionNum	= 5.1;
		} else if (this.userAgent.indexOf('nt 5.0') >= 0) {
			version		= '2000';
			versionNum	= 5.0;
		} else {
			version		= 'below 2000';
			versionNum	= 4.9;
		}
	}
	if (this.userAgent.indexOf('linux') >= 0) {
		platform	= 'linux';
	}
	if (this.userAgent.indexOf('mac') >= 0) {
		platform	= 'mac';
	}
	return {
		platform	: platform,
		version		: version,
		versionNum	: versionNum
	};
}
BROWSER	= new browserInfo();

function doOnLoad() {
	var tabMatch	= false;
	try {
		pageTabs.makeTabs();
		// Check tabs
		for (i in sections) {
			if (i != 'submenu') {
				if (location.toString().indexOf(sections[i].link) != -1) {
					pageTabs.setTab(i,true);
					tabMatch	= true;
					break;
				}
				if (sections[i].submenu) {
					for (j=0;j<sections[i].submenu.length;j++) {
						if (location.toString().indexOf(sections[i].submenu[j].link) != -1) {
							pageTabs.setTab(i,true);
							tabMatch	= true;
							break;
						}
					}
				}
			}
		}
	} catch (e) {}
	sizeContentFrame();
}

function doOnResize() {
	sizeContentFrame();
}

function scrollContent(content, container, w, h, dir, speed, delay) {
	this.content	= content;
	this.container	= document.getElementById(container);
					this.container.style.overflow	= 'hidden';
	this.speed		= (speed) ? parseInt(speed*1000) : 20;
	this.pause		= (delay) ? parseInt(delay*1000) : 1000;
	this.msgPause	= 1000;
	this.pos		= null;
	this.scrollId	= Math.random(new Date());
	this.h			= h;
	this.w			= w;
	this.scrollPos	= 0;
	this.scrollDir	= dir || 0;
	this.scrollMe	= new createElement("div");
	this.scrollMe.setParams({
								id					: 'scrollerHost',
								'style.position'	: 'relative',
								content				: this.content[this.scrollPos]
							});
	this.scrollMe.render(this.container.id);
	this.scrollMe	= document.getElementById('scrollerHost');
	
	window[this.scrollId]	= this;
	
	this.doScroll	= function () {
						var containerHeight	= this.h || this.container.clientHeight;
						var containerWidth	= this.w || this.container.clientWidth;
						var bDoPause	= false;
						
						if (!this.h) {
							this.h	= this.container.style.height	= containerHeight;
						}
						if (!this.w) {
							this.w	= this.container.style.width	= containerWidth;
						}
						
						if (this.pos == null || this.pos == undefined) {
							this.pos	= (this.scrollDir == 0)
											? parseInt(containerHeight)
											: parseInt(containerWidth);
						}
						if (this.pos == 0) {
							this.msgPause	= this.pause;
							bDoPause		= true;
						} else {
							this.msgPause	= 500; // Time between messages.
						}
						if ((this.pos * -1) >= ((this.scrollDir == 0) ? containerHeight : containerWidth)) {
							this.pos	= (this.scrollDir == 0)
											? parseInt(containerHeight) + 3
											: parseInt(containerWidth) + 3;
							bDoPause	= true;
							// Increment the scrolling content
							if (!this.content[++this.scrollPos]) {
								this.scrollPos	= 0;
							}
							this.scrollMe.innerHTML	= this.content[this.scrollPos];
						}
						
						this.scrollMe.style.height	= containerHeight;
						this.scrollMe.style.width	= containerWidth;
						
						if (this.scrollDir == 0) {
							this.scrollMe.style.top		= --this.pos;
						} else {
							this.scrollMe.style.left	= --this.pos;
						}
						
						setTimeout("window["+this.scrollId+"].doScroll()",((bDoPause) ? this.msgPause : this.speed));
					};

	if (this.content && this.container) {
		setTimeout("window["+this.scrollId+"].doScroll()",this.speed);
	} else {
		alert ("Missing required element:\nContent	= "+this.content+"\nContainer	= "+this.container);
	}
}

window.onload = doOnLoad;
window.onresize = doOnResize;