var currentTimeout;
var LIs_To_Hover = new Array();
var browser=navigator.appName;
var b_version=navigator.appVersion;
/*

function hideFormInIE()
{
	if(browser=="Microsoft Internet Explorer" && b_version.indexOf('MSIE 6.0')!=-1)
	{
		var form_wrapper = document.getElementById('form_wrapper_inner');
		
		if(form_wrapper)
		{
			form_wrapper.className = form_wrapper.className.replace("visible","hidden");
		}
	}

}

function showFormInIE()
{
	if(browser=="Microsoft Internet Explorer" && b_version.indexOf('MSIE 6.0')!=-1)
	{
		var form_wrapper = document.getElementById('form_wrapper_inner');
		
		if(form_wrapper)
		{
			form_wrapper.className = form_wrapper.className.replace("hidden","visible");
		}
	}

}

*/
function enableMenuImageRollovers()
{
	var container = document.getElementById('Nav');

	if (!container)
	{
		return;
	}

	var lis = container.getElementsByTagName('li');


	for(x=0; x< lis.length; x++)
	{
		var li=lis[x];		
		if(li.className.indexOf("nli")!=-1)
		{
			LIs_To_Hover.push(li.id);
			
			li.onmouseover=function()
			{
				RollOver(this);
			}
			
			li.onmouseout=function()
			{
				RollOff(this);
			}
		}
	}
}

function RollOver(li)
{
	TurnOffAll();
	clearTimeout(currentTimeout);

	li.className=li.className.replace("hover_off","hover_on");

	//RollOverImages(li)
	//hideFormInIE();

}

function RollOverImages(li)
{
	var img_list = li.getElementsByTagName('img');

	img_list[0].src = img_list[0].src.replace("normal", "rollover");
}

function RollOffImages(li)
{
	var img_list = li.getElementsByTagName('img');

	img_list[0].src = img_list[0].src.replace("rollover", "normal");

}

function RollOff(li)
{
	currentTimeout = setTimeout("RemoveSynHover('" + li.id + "')",500);
}

function RemoveSynHover(LI_Id)
{
	var li = document.getElementById(LI_Id);

	li.className=li.className.replace("hover_on","hover_off");
	//RollOffImages(li)
	//showFormInIE();
}

function TurnOffAll()
{
	for(var i = 0; i < LIs_To_Hover.length; i++)
	{
		RemoveSynHover(LIs_To_Hover[i]);
	}
}


function bindBehaviors()
{

 if (arguments.callee.done) return;

 arguments.callee.done = true;

 enableMenuImageRollovers();
}


if (window.addEventListener)
{
 window.addEventListener('load', bindBehaviors, false);

}
else if (window.attachEvent)
{
 window.attachEvent('onload',bindBehaviors);

}

function MailTo(Subj) 
{
var today=new Date() 
var sdate=today.getMonth()+1+"/"+today.getDate()+"/"+(today.getFullYear())
window.location='mailto:'+'info'+'@'+'aitoyo.com'+'?subject='+Subj+': '+sdate;
}
function MailTo2(Subj) 
{
var today=new Date() 
var sdate=today.getMonth()+1+"/"+today.getDate()+"/"+(today.getFullYear())
window.location='mailto:'+'aitoyos'+'@'+'gmail.com'+'?subject='+Subj+': '+sdate;
}

var slideSpeed = 30;	// Higher value = faster
var timer = 4;	// Lower value = faster

var objectIdToSlideDown = false;
var activeId = false;
var slideInProgress = false;
function showHideContent(e,inputId)
{
	if(slideInProgress)return;
	slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(activeId &&  activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(activeId,(slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,slideSpeed);
		}
	}else{
		slideContent(numericId,(slideSpeed*-1));
		activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('a' + inputId);
	var contentObj = document.getElementById('ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('a' + objectIdToSlideDown).style.display='block';
				document.getElementById('a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,slideSpeed);				
			}else{
				slideInProgress = false;
			}
		}else{
			activeId = inputId;
			slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='infq' || divs[no].className=='infq2'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='infac';
			contentDiv.id = 'ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}
	}	
}
window.onload = initShowHideDivs;
