function toggleLayer(val){
	if(val == 'on' || val === true){
		document.getElementById('layer').style.display = 'block';
	}
	else if(val == 'off' || val === false){
		document.getElementById('layer').style.display = 'none';
	}
}
function toggleLayer1(val){
	if(val == 'on' || val === true){
		document.getElementById('layer1').style.display = 'block';
	}
	else if(val == 'off' || val === false){
		document.getElementById('layer1').style.display = 'none';
	}
}
function toggleLayer2(val){
	if(val == 'on' || val === true){
		document.getElementById('layer2').style.display = 'block';
	}
	else if(val == 'off' || val === false){
		document.getElementById('layer2').style.display = 'none';
	}
}

function validateChangePW() {
	  var valid = true, output = '';
	  var valid;
	  if (window.document.login.pw.value.length == 0) {
		  valid = false;
		 output += 'Please enter a password\n';
	  }
	  if (window.document.login.pw.value != window.document.login.pw2.value) {
		  valid = false;
		 output += 'Your passwords do not match\n';
	  }
	   if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }

function isNumberKey(evt){
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	 return true;
  }

function formFocus(){
	var bFound = false;
	// for each form
	for (f=0; f < document.forms.length; f++){
	// for each element in each form
	for(i=0; i < document.forms[f].length; i++){
	  // if it's not a hidden element
	  if (document.forms[f][i].type != "hidden"){
		// and it's not disabled
		if (document.forms[f][i].disabled != true){
			// set the focus to it
			document.forms[f][i].focus();
			var bFound = true;
		}
	  }
	  // if found in this element, stop looking
	  if (bFound == true)
		break;
	}
	// if found in this form, stop looking
	if (bFound == true)
	  break;
	}
}

function popup2(lPage,lId,formfield){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var lId;
var formfield;

switch(lPage){
	case 'cDate':
		strPage = ("/admin/start.asp?field=" + formfield)	
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "400"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage + "&id=" + lId,"Intranet","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}


function popup(lPage,lId){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var lId;

switch(lPage){
	case 'imageInsert':
		strPage = ("/admin/imageInsert.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'sponsorImage':
		strPage = ("/ASPUploads/Upload-SponsorImage.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'confImage':
		strPage = ("/ASPUploads/Upload-SponsorImage.asp?c=yes&")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'cDate':
		strPage = ("/admin/start.asp?")	
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "400"
		break
	case 'left':
		strPage = ("/admin/align.asp?a=left&")	
		strResize = "no"
		strScroll = "no"
		strHeight = "100"
		strWidth = "100"
		break
	case 'right':
		strPage = ("/admin/align.asp?a=right&")	
		strResize = "no"
		strScroll = "no"
		strHeight = "100"
		strWidth = "100"
		break
	case 'imageCode':
		strPage = ("/admin/imageCode.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'pdf':
		strPage = ("/admin/pdf.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "300"
		break
	case 'print':
		strPage = ("/print.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "100"
		strWidth = "100"
		break
	case 'email':
		strPage = ("/emailSession.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "200"
		strWidth = "600"
		break
	case 'conf':
		strPage = ("/popup.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'confInvoice':
		strPage = ("/invoice.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'confInvoices':
		strPage = ("invoice.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'confSponsors':
		strPage = ("/confSponsors.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'confExcel':
		strPage = ("/admin/confExcel.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "100"
		strWidth = "100"
		break
	case 'vendorExcel':
		strPage = ("/admin/vendorExcel.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "100"
		strWidth = "100"
		break
	case 'apInvoice':
		strPage = ("/invoice.asp?ap=yes&")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'branch':
		strPage = ("/branch.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "700"
		break
	case 'password':
		strPage = ("/password.asp?")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "600"
		break
	case 'emailInvoice':
		strPage = ("/emailInvoice.asp?")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "600"
		break
	case 'apemailInvoice':
		strPage = ("/emailInvoice.asp?ap=yes&")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "600"
		break
	case 'emailLog':
		strPage = ("/admin/popupLog.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "750"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage + "id=" + lId,"Intranet","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}

function pdfPopup(lPage,lId){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var lId;

switch(lPage){
	case 'ConfPDF':
		strPage = ("/images/" + lId)	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "600"
		strWidth = "600"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage + ".pdf","Intranet","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}

function validateagencypayrequest() {
	  var valid = true, output = '';
	  var valid;
	  if (window.document.frmReg.na.value.length == 0) {
		  valid = false;
		  output += 'Please enter the name of the person making this payment\n';
	  }
	  if (window.document.frmReg.ag.value.length == 0) {
		  valid = false;
		  output += 'Please enter the agency making this payment\n';	  
	  }
	if (window.document.frmReg.em.value.length == 0) {
        valid = false;
        output += 'Please enter the E-mail address this request will be sent to\n';
	}else{
		//EMail validation
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
	
		if(((window.document.frmReg.em.value.search(exclude) != -1)||(window.document.frmReg.em.value.search(check)) == -1)||(window.document.frmReg.em.value.search(checkend) == -1)){
			valid = false;
        	output += 'That does not appear to be a valid E-mail address! Please enter your E-mail address again\n';
		}
		}
		 if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }  

function validateregistration() {
	  var valid = true, output = '';
	  var valid;
	  if (window.document.frmReg.fn.value.length == 0) {
		  valid = false;
		  output += 'Please enter your first name\n';
	  }
	  if (window.document.frmReg.ln.value.length == 0) {
		  valid = false;
		  output += 'Please enter your last name\n';	  
	  }
	if (window.document.frmReg.em.value.length == 0) {
        valid = false;
        output += 'Please enter your E-mail address\n';
	}else{
		//EMail validation
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
	
		if(((window.document.frmReg.em.value.search(exclude) != -1)||(window.document.frmReg.em.value.search(check)) == -1)||(window.document.frmReg.em.value.search(checkend) == -1)){
			valid = false;
        	output += 'That does not appear to be a valid E-mail address! Please enter your E-mail address again\n';
		}
		}
		 if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }  


/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var timeBeforeAutoHide = 700;	// Microseconds to wait before auto hiding menu(1000 = 1 second)
var slideSpeed_out = 10;	// Steps to move sub menu at a time ( higher = faster)
var slideSpeed_in = 10;
	

var slideTimeout_out = 25;	// Microseconds between slide steps ( lower = faster)
var slideTimeout_in = 10;	// Microseconds between slide steps ( lower = faster)

var showSubOnMouseOver = false;	// false = show sub menu on click, true = show sub menu on mouse over
var fixedSubMenuWidth = false;	// Width of sub menu items - A number(width in pixels) or false when width should be dynamic

var xOffsetSubMenu = 0; 	// Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu

var slideDirection = 'right';	// Slide to left or right ?

/* Don't change anything below here */

var activeSubMenuId = false;
var activeMainMenuItem = false;
var currentZIndex = 1000;		
var autoHideTimer = 0;
var submenuObjArray = new Array();
var okToSlideInSub = new Array();
var subPositioned = new Array();


function stopAutoHide()
{
	autoHideTimer = -1;
}

function initAutoHide()
{
	autoHideTimer = 0;
	if(autoHideTimer>=0)autoHide();
}

function autoHide()
{
	
	if(autoHideTimer>timeBeforeAutoHide)
	{
		
		if(activeMainMenuItem){
			activeMainMenuItem.className='';
			activeMainMenuItem = false;
		}
		
		if(activeSubMenuId){
			var obj = document.getElementById('subMenuDiv' + activeSubMenuId);
			showSub();
		}
	}else{
		if(autoHideTimer>=0){
			autoHideTimer+=50;
			setTimeout('autoHide()',50);
		}
	}
}	

function getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue;
}

function getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  return returnValue;
}

function showSub()
{
	var subObj = false;
	if(this && this.tagName){
		var numericId = this.parentNode.id.replace(/[^0-9]/g,'');
		okToSlideInSub[numericId] = false;
		var subObj = document.getElementById('subMenuDiv' + numericId);
		if(activeMainMenuItem)activeMainMenuItem.className='';
		if(subObj){
			if(!subPositioned[numericId]){
				if(slideDirection=='right'){
					subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px';
				}else{
					subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px';
					
				}
				submenuObjArray[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,'');
				subObj.style.top = getTopPos(submenuObjArray[numericId]['parentDiv']) + 'px';
				subPositioned[numericId] = true;
			}				
			subObj.style.visibility = 'visible';
			subObj.style.zIndex = currentZIndex;
			currentZIndex++;	
			this.className='activeMainMenuItem';
			activeMainMenuItem = this;
		}
	}else{
		var numericId = activeSubMenuId;
	}
	if(activeSubMenuId && (numericId!=activeSubMenuId || !subObj))slideMenu(activeSubMenuId,(slideSpeed_in*-1));
	if(numericId!=activeSubMenuId && this && subObj){
		subObj.style.width = '0px';	
		slideMenu(numericId,slideSpeed_out);
		activeSubMenuId = numericId;
	}else{
		if(numericId!=activeSubMenuId)activeSubMenuId = false;
	}
	if(showSubOnMouseOver)stopAutoHide();
}

function slideMenu(menuIndex,speed){
	var obj = submenuObjArray[menuIndex]['divObj'];
	var obj2 = submenuObjArray[menuIndex]['ulObj'];
	var width = obj.offsetWidth + speed;
	if(speed<0){
		if(width<0)width = 0;
		obj.style.width = width + 'px';
		if(slideDirection=='left'){
			obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
			obj2.style.left = '0px';
		}else{
			obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
		}
		if(width>0 && okToSlideInSub[menuIndex])setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{
			obj.style.visibility = 'hidden';
			obj.style.width = '0px';
			if(activeSubMenuId==menuIndex)activeSubMenuId=false;
		}
		
	}else{
		if(width>submenuObjArray[menuIndex]['width'])width = submenuObjArray[menuIndex]['width'];
		if(slideDirection=='left'){
			obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
			obj2.style.left = '0px';
		}else{
			obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
		}		
		
		obj.style.width = width + 'px';
		if(width<submenuObjArray[menuIndex]['width']){
			setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_out);
		}else{
			okToSlideInSub[menuIndex] = true;
		}
	}
}
function resetPosition()
{
	subPositioned.length = 0;
}
		
function initLeftMenu()
{
	var menuObj = document.getElementById('dhtmlgoodies_menu');	
	var mainMenuItemArray = new Array();
	
	var mainMenuItem = menuObj.getElementsByTagName('LI')[0];
	while(mainMenuItem){
		if(mainMenuItem.tagName && mainMenuItem.tagName.toLowerCase()=='li'){
			mainMenuItemArray[mainMenuItemArray.length] = mainMenuItem;
			var aTag = mainMenuItem.getElementsByTagName('A')[0];
			if(showSubOnMouseOver)
				aTag.onmouseover = showSub;	
			else
				aTag.onclick = showSub;	
		}
		mainMenuItem = mainMenuItem.nextSibling;
	}		
	
	var lis = menuObj.getElementsByTagName('A');
	for(var no=0;no<lis.length;no++){
		if(!showSubOnMouseOver)lis[no].onmouseover = stopAutoHide;
		lis[no].onmouseout = initAutoHide;
		lis[no].onmousemove = stopAutoHide;
	}
			
	for(var no=0;no<mainMenuItemArray.length;no++){
		var sub = mainMenuItemArray[no].getElementsByTagName('UL')[0];
		if(sub){
			mainMenuItemArray[no].id = 'mainMenuItem' + (no+1);
			var div = document.createElement('DIV');
			div.className='dhtmlgoodies_subMenu';
			document.body.appendChild(div);
			div.appendChild(sub);
			if(slideDirection=='right'){
				div.style.left = getLeftPos(mainMenuItemArray[no]) + mainMenuItemArray[no].offsetWidth + xOffsetSubMenu + 'px';
			}else{
				div.style.left = getLeftPos(mainMenuItemArray[no]) + xOffsetSubMenu + 'px';
			}
			div.style.top = getTopPos(mainMenuItemArray[no]) + 'px';
			div.id = 'subMenuDiv' + (no+1);
			sub.id = 'submenuUl' + (no+1);
			sub.style.position = 'relative';	

			if(navigator.userAgent.indexOf('Opera')>=0){
				submenuObjArray[no+1] = new Array();
				submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
				submenuObjArray[no+1]['divObj'] = div;
				submenuObjArray[no+1]['ulObj'] = sub;
				submenuObjArray[no+1]['width'] = sub.offsetWidth;
				submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
			}
			sub.style.left = 1 - sub.offsetWidth + 'px';	
			
			// if(document.all)div.style.width = '1px';	
				
			if(navigator.userAgent.indexOf('Opera')<0){
				submenuObjArray[no+1] = new Array();
				submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
				submenuObjArray[no+1]['divObj'] = div;
				submenuObjArray[no+1]['ulObj'] = sub;
				submenuObjArray[no+1]['width'] = sub.offsetWidth;
				
				
				
				submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
				if(fixedSubMenuWidth)submenuObjArray[no+1]['width'] = fixedSubMenuWidth;
			}	

			if(!document.all)div.style.width = '1px';			
				
		}			
	}
		

	
	
	menuObj.style.visibility = 'visible';
	
	window.onresize = resetPosition;
}


window.onload = initLeftMenu;
