// JavaScript Document

var menuInt;
var nextTabDepth = 106;
var output;
var slideInt;

function init()
{ 
	
	//output = document.getElementById("output");
	var tabs = document.getElementsByTagName("div")
	for(i=0;i<tabs.length;i++)
	{
		if( tabs[i].id )
		{
			if( tabs[i].id.indexOf("tab_") > -1 )
			{
				//alert(tabs[i].id);
				tabs[i].style.marginTop = 35+"px";
				tabs[i].numid = tabs[i].id.split("_")[1];
				tabs[i].on = false;
				tabs[i].yPos = tabs[i].style.marginTop;
				tabs[i].h = 35;
				tabs[i].slideInt = null;
				tabs[i].hit = tabs[i].firstChild;
				
				tabs[i].onmouseover = function()
				{
					var id = this.id;
					$(id).setMarg = function(p)
					{
						this.setStyle('margin-top: '+p+'px');
					};
				 	new Effect.Tween(id, 35, 20, { duration: .15 }, 'setMarg');
				}
				
				tabs[i].onmouseout = function()
				{
					var id = this.id;
					$(id).setMarg = function(p)
					{
						this.setStyle('margin-top: '+p+'px');
					};
				 	new Effect.Tween(id, 20, 35, { duration: .15 }, 'setMarg');
				}
				
				/*tabs[i].hit.onmouseover = function()
				{
					clearInterval(slideInt);
					parent = this.parentNode;
					if(!parent.on)
					{
						//parent.style.background="#F00";
						parent.on = true;
						slideInt = setInterval("slideUp('"+parent.id+"')",40);
					}
				}	
				tabs[i].hit.onmouseout = function()
				{
					clearInterval(slideInt);
					parent = this.parentNode;
					parent.on = false;
					parent.style.background="#000";
					parent.style.marginTop = parent.h+"px";
				}*/
			}
		}
	}
}

function slideUp(id)
{
	
	var endH = 10;
	var speed = 2;
	var div = document.getElementById(id);
	var curH = parseInt(div.style.marginTop.replace("px",""));
	curH += ((endH-curH)/speed);
	div.style.marginTop = curH + "px";
	trace(curH + ":" + endH);
	if( curH == endH ) clearInterval(div.slideInt);
}


	
function menuOver(div,num)
{
	clearInterval(menuInt);
	if(div) showMenu(div,num);
}

function menuOut()
{
	menuInt = setTimeout('hideMenu()',500);
}

function showMenu(div,num)
{
	var w = Math.ceil(num/15)*185;
	var sub = document.getElementById('sub');
	var menuitems = document.getElementById('menuitems');
	var code = document.getElementById('sub'+div.id).innerHTML;
	var shadow = document.getElementById('shadow')
	sub.style.display = "block";
	//alert(findPosY(div))
	var amt = (BrowserDetect.browser == "Explorer") ? (div.offsetParent.offsetTop + div.offsetTop) + "px" : div.offsetTop + "px";
	sub.style.top = amt;
	sub.style.width = w + "px";
	shadow.style.width = (w+15) + "px";
	menuitems.innerHTML = code;
}

function hideMenu()
{
	var sub = document.getElementById('sub');
	sub.style.display = "none";
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popUp() {

/* begin configuration */
var url = "mapWi.htm"; 
var w = "750"; 
var h = "620"; 
var menu = "no"; 
var scroll = "no"; 
var tool = "no"; 
var location = "no"; 
var resize = "no";
/* end configuration */

var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'width='+w+', height='+h+', top='+wint+', left='+winl+', menubar='+menu+', scrollbars='+scroll+', toolbar='+tool+', location='+location+', resizable='+resize+''
window.open(url, 'popup', winprops);
}

function popUp2() {

/* begin configuration */
var url = "mapWi2.htm"; 
var w = "750"; 
var h = "620"; 
var menu = "no"; 
var scroll = "no"; 
var tool = "no"; 
var location = "no"; 
var resize = "no";
/* end configuration */

var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'width='+w+', height='+h+', top='+wint+', left='+winl+', menubar='+menu+', scrollbars='+scroll+', toolbar='+tool+', location='+location+', resizable='+resize+''
window.open(url, 'popup', winprops);
}

function confirmSubmit()
	{
		var agree=confirm("This action can not be undone. Are you sure you want to continue?");
		if (agree)
			return true ;
		else
			return false ;
	}
	
function validate(form)
{
	var error
	var errormsg = document.getElementById('errormsg')
	
		if( form.fname.value == "" )
		{
			form.fname.className = "ERROR"
			form.fname.focus();
			errormsg.style.display = "block"
			return false;
		}
		else
		{
			form.fname.className = "REQUIRED"
		}
		
		if( form.lname.value == "" )
		{
			form.lname.className = "ERROR"
			form.lname.focus();
			errormsg.style.display = "block"
			return false;
		}
		else
		{
			form.lname.className = "REQUIRED"
		}
		
		if( form.email_address.value == "" || form.email_address.value.indexOf("@") == -1 || form.email_address.value.indexOf(".") == -1 )
		{
			form.email_address.className = "ERROR"
			form.email_address.focus();
			errormsg.style.display = "block"
			return false;
		}
		else
		{
			form.email_address.className = "REQUIRED"
		}	
}

function trace(m)
{
	output.innerHTML += "<br />"+m;
}
