function selectByBrowser( ns, ie, ie7 )
{
	if( navigator.appName.indexOf("Netscape") > -1 ) {
		return ns;
	}

	if( navigator.appName.indexOf("Explorer") > -1 ) {
		if( navigator.appVersion.indexOf("MSIE 7") )
			return ie7;
		else
			return ie;
	}

	return ns;
}

function getCookie( name )
{
	var dc     = document.cookie;
	var prefix = name + "=";
	var begin  = dc.indexOf("; " + prefix);

	if( begin == -1 ) {
		begin = dc.indexOf(prefix);
		if( begin != 0 )
			return null;
	} else
		begin += 2;

	var end = document.cookie.indexOf(";", begin);

	if( end == -1 )
		end = dc.length;

	return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie( name, value, expires, path, domain, secure )
{
	var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");

	document.cookie = curCookie;
}

function showOptions()
{
	if( parent.frames.length == 0 )
		return;

	var	popup  = getCookie("usePopups");
	var	size   = getCookie("imgSize");
//'	var	frames = getCookie("useFrames");
	var popToggle, popWord;
	var sizeToggle, sizeWord;
	var frameToggle, frameWord;

	if( popup == 1 ) {
		popToggle = 0;
		popWord = "on";
	} else {
		popToggle = 1;
		popWord = "off";
	}

	if( size == 1 ) {
		sizeToggle = 0;
		sizeWord   = "large";
	} else {
		sizeToggle = 1;
		sizeWord   = "small";
	}

	if( frames == 1 ) {
		frameToggle = 0;
		frameWord = "on";
	} else {
		frameToggle = 1;
		frameWord = "off";
	}

//'	document.write( "Frames <a href='javascript:setOption(\"useFrames\", " + frameToggle + ");'>" + frameWord + "</a>, " );
	document.write( "Popups <a href='javascript:setOption(\"usePopups\", " + popToggle + ");'>" + popWord + "</a>" );
	if( popup == 1 ) {
		document.write( ", Size <a href='javascript:setOption(\"imgSize\", " + sizeToggle + ");'>" + sizeWord + "</a>" );
	}

//'	func = getPopupFunc();
//'	document.write( "</td><td class='alignCC'>[usePopups='" + popup + "',&nbsp;imgSize='" + size + "',&nbsp;func='" + func + "',&nbsp;browser='" + navigator.appName + "']" );
}

function setOption( name, val )
{
	setCookie( name, val, 0, "/", 0, 0 );

	document.location = document.location;
}

function reloadFrames()
{
	var url = document.location.href;
	var pos = url.indexOf( "Main.html" );

	url = url.substring(0, pos);

	parent.title.location = url + "Title.html";
	parent.menu.location  = url + "Menu.html";
}

function checkForFramesViaCookie()
{
	var url = document.location.href;

	if( getCookie("useFrames") != 1 ) {
		if( url.indexOf("indexFrame.html") > 0 )
			document.location = "index.html";

		if( parent.frames.length != 0 )
			parent.location = "index.html";

		return;
	}

	if( (url.indexOf("indexMain.html") > 0) &&
		(frames.name != "main") ) {
		if( parent.frames.length == 0 )
			parent.location = "indexFrame.html";

		parent.main.location = document.location;
	}

	if( url.indexOf("indexFrame.html") > 0 )
		return;

	if( url.indexOf("indexTitle.html") > 0 )
		return;

	if( url.indexOf("indexMain.html") > 0 ) {
		if( parent.frames.length == 0 ) {
			document.location.href = newUrl;
		}

		return;
	}

	if( url.indexOf("indexMenu.html") > 0 )
		return;

	var pos = url.indexOf( "index.html" );
	var newUrl = url.substring(0, pos) + "indexMain.html";
//	document.write( "Url    = " + url + "<br>" );
//	document.write( "NewUrl = " + newUrl + "<br>" );
	document.location.href = newUrl;
}

function checkForFrames()
{
	var url = document.location.href;

	if( parent.frames.length == 0 ) {
//		if( url.indexOf("Main.html") > 0 ) {
//			parent.location = "indexFrame.html";
//		}

		return;
	}

	if( (url.indexOf("Main.html") > 0) &&
		(frames.name != "main") ) {

		parent.main.location = document.location;
	}

	if( url.indexOf("indexFrame.html") > 0 )
		return;

	if( url.indexOf("Title.html") > 0 )
		return;

	if( url.indexOf("Main.html") > 0 )
		return;

	if( url.indexOf("Menu.html") > 0 )
		return;

	var pos = url.indexOf( ".html" );
	var newUrl = url.substring(0, pos) + "Main.html";
	document.location.href = newUrl;
}

function writeCopyright()
{
//	document.write( "<div class='text textBlock'>AppName    = '" + navigator.appName + "'</div>" );
//	document.write( "<div class='text textBlock'>AppVersion = '" + navigator.appVersion + "'</div>" );
//	document.write( "<div class='text textBlock'>Navigator  = '" + navigator + "'</div>" );
//	document.write( "<div class='text textBlock'>Selected   = '" + selectByBrowser('NS', 'IE', 'IE7') + "'</div>" );

	document.write( "<div class='copyright'>All work &copy; me 2002-2007</div>\n" );
}
