var sBrowserName = window.navigator.appName;
var nBrowserVersion = parseInt(window.navigator.appVersion);
var Browser = new Is();
var sHideName= (Browser.isDOM ? 'hidden' : 'hidden');
var sShowName= (Browser.isDOM ? 'visible' : 'visible');

var zIdx = -1; // z-index of divisions
var sDivName="Division"; // for naming divisions
var sLink="Lnk"; // for naming links
var curDiv=0; // id number of the current division and link

function backward () {
	if (curDiv > 0)
	{
		hideSlide(sDivName + curDiv);
		curDiv--;
		showSlide(sDivName + curDiv);
	}
}


function Is() {
	
	// convert all characters to lowercase to ease comparison
	
	var agt=navigator.userAgent.toLowerCase();
	
	if (typeof(document.getElementById) == "function") {
		this.isDOM = true; // mozilla based browsers
	}
		
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	
	// browser
	
  	if (agt.indexOf('aol') != -1) {
		this.aol = true;
	}	
	else if (agt.indexOf('opera') != -1) {
		this.opera = true;
	}	
	else if (agt.indexOf('webtv') != -1) {
		this.webtv = true;
	}
	else if (agt.indexOf('konqueror') != -1) {
		this.konqueror = true;
	}
	else if (agt.indexOf('safari') != -1) {
		this.safari = true;
	}			
	else if (this.isDOM) {
		if ((agt.indexOf('netscape') != -1) && (this.major >= 5)) {
			this.nav = true; // Netscape and Mozilla have major 5
		}	
		else if (this.major >= 5){
			this.mozilla = true;
		}	 
	}			
	else if (agt.indexOf('msie') != -1) {
		this.ie = true;
    }
	
	//alert('Major ' + this.major + 'Minor' + this.minor);
	    
	this.ie4up  = (this.ie  && (this.major >= 4));
		 	
	// platform
	
	this.win = ( (agt.indexOf("win") != -1) || (agt.indexOf("16bit") != -1) );
	this.mac = (agt.indexOf("mac") != -1);
	this.ie52mac = (this.mac && (agt.indexOf('msie') != -1) && (agt.indexOf('5.2') != -1)); 

}


function jump (sDiv, sDivNum, z) {
	this.upperBound = sDivNum;
	this.curDiv = sDivNum;
	this.sDivName = sDiv;
	this.zIdx = z;
	this.ahead = function(){
		if (this.curDiv < this.zIdx)
		{
			hideSlide(this.sDivName + this.curDiv);
			this.curDiv++;
			showSlide(this.sDivName + this.curDiv);
		}
	};
	
	this.back = function (){
		if (this.curDiv > this.upperBound)
		{
			hideSlide(this.sDivName + this.curDiv);
			this.curDiv--;
			showSlide(this.sDivName + this.curDiv);
		}
	};
}


function forward () {
	if (curDiv < zIdx)
	{
		hideSlide(sDivName + curDiv);
		curDiv++;
		showSlide(sDivName + curDiv);
	}
}

function hideSlide (name)
{
	refSlide(name).visibility = sHideName;
}
 
// returns a string to describe a division

function refSlide (name) {
	if (Browser.isDOM)	{
		return document.getElementById(name).style;
	}
	else {
		return eval('document.all.' + name + '.style');
	}
}

// hide the current division, make another division visible

function swapDivisions (newDiv) {
	hideSlide(sDivName + curDiv);
	showSlide(sDivName + newDiv);
	
	if (curDiv != newDiv) {
		changeMenuColor(newDiv, '#CC6633'); // .highlight color
		restoreMenuColor(curDiv, '#000099');
	} 
	
	curDiv = newDiv;
}

function changeMenuColor (newDiv, color) {
   var name = sLink + newDiv;
     
   refSlide(name).color = color;
     
}

function restoreMenuColor (newDiv, color) {
   var name = sLink + newDiv;
   refSlide(name).color = color;

}

function showSlide (name)
{
	refSlide(name).visibility = sShowName;
		
}

function hang(form, category) {
	var el = document.getElementById(form);
	el.category.value=category;
	el.submit();
}
	 