
// function used to hide all sub nav items and turn on the requested id
function Appear(ShowDiv)
{
	var Div = document.getElementById(ShowDiv);
	if ( Div.style.display == 'none' )
	{
		new Effect.Appear(ShowDiv); 
		new Effect.BlindDown(ShowDiv); 
	}
	else {
		new Effect.Fade(ShowDiv); 
		new Effect.BlindUp(ShowDiv); 
	}
	return false;
}

function openNewWindow(URLtoOpen, windowName, windowFeatures){
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}
/*
example:
var img_array = ['first','second','third'];
imgLoader('about/prefix_',img_array,'gif');
image naming would be prefix_first_a.gif and prefix_first_i.gif
both located in /images/about/
*/
//image non-nav pre-loader
function imgLoader(pth,iNames,ext){
	if (document.images) {
		var act=['a','i'];
		for (i=0;i<iNames.length;i++){
			for (j=0;j<2;j++){
				eval(iNames[i]+act[j]+"= new Image();");
				eval(iNames[i]+act[j]+".src = '/images/"+pth+iNames[i]+"_"+act[j]+"."+ext+"';");
			}
		}
	}
}

var pop_n = null;

function OpenCenteredWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  features = 'width='+myWidth+',height='+myHeight+','+features;
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=',left='+myLeft+',top='+myTop;
  }
	window.open(theURL,winName,features);
}
// doPopup is same as OpenCenteredWindow but can be referred to for addressing same window 
function doPopup(theURL,winName,features,myWidth,myHeight,isCenter){
  features = 'width='+myWidth+',height='+myHeight+','+features;
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=',left='+myLeft+',top='+myTop;
  }
  if(pop_n == null || pop_n.closed){
    pop_n = window.open(theURL,winName,features);
  }else{
    pop_n.close();
    pop_n = window.open(theURL,winName,features);
  }
  pop_n.focus();
}

function popupWindow(url,win){
  window.open(url,win);
}
//required fields for contact form
reqFields=[['EmailAddress','Email Address','isEmail'],
  ['FirstName','First Name'],
  ['LastName','Last Name'],
  ['Company','Company'],
  ['BusinessAddress','Business Address'],
  ['City','City'],
  ['State','State'],
  ['Zip','Zip Code'],
  ['WorkPhone','Work Phone']];

function txtAreaCount(f,cmt){
	if(cmt.length >= 301){
		cmt_half = cmt.substr(0,299);
		cmt1 = cmt.substr(0,cmt_half.lastIndexOf(' ')).split(' ');
		cmt_sub='';
		for (i=cmt1.length-5;i<cmt1.length;i++){cmt_sub+=' '+cmt1[i];}
		alert('Please contain your comment to 250 characters.\nCurrently, your comment would end with:\n"...'+cmt_sub+'"');
		return false;
	}else{
		return formVal(f,f.EmailAddress.value);
	}
}

function swap(st,nm){
	eval("document.images['"+nm+"'].src="+nm+st+".src;");
}

function slideclose(div){
	h=div.offsetHeight;
	if(h >= 8){
		div.style.height=(h-8)+"px";
	}else{
		clearInterval(shrinkTimer);
		div.style.display="none";
	}
}

function slideopen(div,ht){
	h=div.offsetHeight;
	if(h >= ht){
		clearInterval(divTimer);
//		div.style.overflow="auto";
	}else{
		div.style.height=(h+4)+"px";
	}
}

function squeezer(divId,ht,others){
	if(others){
		for(i=0;i<others.length;i++){
			if((others[i]!=divId) && (document.getElementById(others[i]).style.display=='block')){
				divalt=document.getElementById(others[i]);
				shrinkTimer=setInterval('slideclose(divalt)',20);
			}
		}
	}
	div = document.getElementById(divId);
	
	if(div.style.display != 'block'){
		div.style.height="2px";
		div.style.display="block";
		divTimer=setInterval('slideopen(div,'+ht+')',20);
	}else{
		shrinkTimer=setInterval('slideclose(div)',20);
	}
}
function debugr(str){
	document.getElementById('debug').innerHTML=str;
}
/* #### left submenu #### */
var submenuOn='';
function lftSubFloat(dsply,section,w,what){
	divOff();
	bb= document.getElementById('lftSubFloat');
	if(dsply == 'hide'){
		hideLft(bb.id);
	}else{
		clearhideLft();
		cleardelayroll();
		flt=document.getElementById('float_'+section);
		populatemenu([flt.innerHTML],'lftSubFloat',w,section);
		bba=what.offsetWidth;
		lft = getposOffset(what,'left');
		bb.style.left='5px';
		tp = getposOffset(what,'top');
		bb.style.top=tp+'px';
		bb.style.width=(bb.getElementsByTagName('a')[0].offsetWidth)+'px';
		bb.style.visibility='visible';
		hsum=0;
		bbd=bb.getElementsByTagName('div');
		bbd=bb.getElementsByTagName('div');
		for(i=0;i<bbd.length;i++){hsum+=bbd[i].offsetHeight+2;}
		bb.style.left=(lft+bba)+'px';
		bb.style.display='none';
		squeezer('lftSubFloat',hsum,[]);
		what.className='lftMenuLev1_a';
		submenuOn = what.id;
	}
}
function rollLev1(what,onoroff){
//	what.className = 'lftMenuLev1'+onoroff;
	delayMS = (onoroff=='_a')?250:10;
//	delayroll=setTimeout(what.className = 'lftMenuLev1'+onoroff),delayMS);
}
function cleardelayroll(){
	if (typeof delayroll!="undefined"){
		clearTimeout(delayroll);
	}
}
function divOff(){
	if(submenuOn!=''){
		d=document.getElementById(submenuOn);
		d.className='lftMenuLev1';
	}
}
function hideLft(lft,t){
	t=(t)?t:250;
	delayhideLft=setTimeout("eval(\"document.getElementById('"+lft+"').style.visibility='hidden';divOff();\")",t);
}
function clearhideLft(){
	if (typeof delayhideLft!="undefined"){
		clearTimeout(delayhideLft);
	}
}

function initFloater(divID,cls){
	document.write('<div id="'+divID+'" class="'+cls+'" style="visibility:hidden;position:absolute;padding:2px;" onmouseover="clearhideLft()" onmouseout="hideLft(\'lftSubFloat\',2000);"></div>');
//	document.write('<div id="'+divID+'" class="'+cls+'" style="position:absolute;"></div>');
}
