var speed = 20;
		
		menuParts = new Array();
					
		function initMenu(menuID) {
			
			if(!document.getElementById(menuID)) return;
		
			menuDiv = document.getElementById(menuID);
						
			headings = menuDiv.getElementsByTagName('h2');
			
			var handle,section,sectBody,isClosed;
			
			for(var i = 0; i < headings.length; i++) {
			
						
				handle = section = sectBody = null;
			
				handle = headings[i];
				
				
				section = handle;
				
				//# Find title's 'section' 
				while(section.className.indexOf('section') == -1  || section.parentNode == null) {
					
					section = section.parentNode;
					
				}
				
				if(section.className.indexOf('sectionLink') == -1) {
				
					isClosed = (section.className.indexOf('Closed') != -1);
					
					//# Add title click event
					handle.onclick = function() { toggleSection(this)};
					
					//# Find sectionBody
					for(var ii =0; ii < section.childNodes.length; ii++) {
						if(section.childNodes[ii].className == "sectionBody") {
							sectBody = section.childNodes[ii];
							
							ii = section.childNodes.length;
							
						}
					}
									
					
					//# Create object with section info
					menuParts[menuParts.length] = {handle: headings[i],section: section, sectionBody: sectBody, dir: 0, openHeight: parseInt(sectBody.offsetHeight), isOpen: !isClosed};
					
					if(isClosed) {
						sectBody.style.height = '1px';
						sectBody.style.display = 'none';
					} else {
						sectBody.style.height = parseInt(sectBody.offsetHeight)+'px';
					}
				
				}
				
			}
			
		}
		
		
				
		function toggleSection(handle) {
			
			for(var i =0 ; i< menuParts.length; i++) {
				if(menuParts[i].handle == handle) {
					
					if(!menuParts[i].isOpen ) {
						menuParts[i].dir = 1;
						
						menuParts[i].isOpen = true;
						handle.parentNode.className = 'section';
						if (menuParts[i].sectionBody.innerHTML!="")	{
							menuParts[i].sectionBody.style.display = 'block';
						} else {
							handle.parentNode.className = 'sectionLink';
//							handle.onclick = null;
						}
						
						
					} else {
						if (menuParts[i].sectionBody.innerHTML!="") {
							menuParts[i].dir = -1;
					
							menuParts[i].openHeight = parseInt(menuParts[i].sectionBody.offsetHeight);
							menuParts[i].sectionBody.style.height = menuParts[i].openHeight+'px';
							menuParts[i].handle.parentNode.className = 'sectionClosed';
							if (menuParts[i].sectionBody.innerHTML!="") {
								menuParts[i].sectionBody.style.overflow = 'hidden';
							} 
						}
					}
					
					
										
				} else {
					if (menuParts[i].isOpen){
					//if(menuParts[i].handle.parentNode.className = 'section') {
						menuParts[i].dir = -1;
						menuParts[i].openHeight = parseInt(menuParts[i].sectionBody.offsetHeight);
						menuParts[i].sectionBody.style.height = menuParts[i].openHeight+'px';
						menuParts[i].handle.parentNode.className = 'sectionClosed';
						menuParts[i].sectionBody.style.overflow = 'hidden';
					}
				}
			}
			animateSections();
						
		}
		
		
		
		var tID = null;
		function animateSections() {
									
			var stop = true;
		
			for(var i =0 ; i< menuParts.length; i++) {
				if(menuParts[i].dir != 0) {
					slideSection(menuParts[i]);
					stop = false;
				}
			}

			if(!stop) {
				
				if(tID == null) {
					tID = setInterval('animateSections()',10);
					
				}
			} else {
				clearInterval(tID);
				tID = null;
				
				
			}
		}
		
		
		
		function slideSection(part) {
			
			var currHeight = parseInt(part.sectionBody.style.height);
			
			if((part.dir == -1 && currHeight > speed) || (part.dir == 1 && currHeight <= part.openHeight-speed)) {
				
				part.sectionBody.style.height = (currHeight+(part.dir*speed))+'px';
				
			} else {
			    
			    //# If opening, fully open sction.
				if(part.dir == 1) {
				    part.sectionBody.style.height =  part.openHeight+'px';
					part.sectionBody.style.height = 'auto';
					part.sectionBody.style.overflow = 'visible';
					
				} else {
				    //# otherwise, close section.
					part.sectionBody.style.height = '1px';
					part.sectionBody.style.display = 'none';
					part.isOpen = false;
				}
				
				part.dir = 0;
			}
		
		}
		

function toggleVis(id,type)
{
	if(type == null) type = 'block';

	el = document.getElementById(id);
	if (el.style.display == 'none')
	{
		el.style.display = type;
		
		
	} else {
		el.style.display = 'none';
		
	}
}

function toggleActive() {
	if(document.getElementById) 
	document.getElementById.className='sectionLink';
}

function toggleInactive() {
	if(document.getElementById) 
	document.getElementById.className='sectionLink';
}


function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
{
	myfield.form.submit();
	return false;
}
	else
	return true;
}
