
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 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);
}

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 preVal(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);
	}
}

var bioTmr;
function initSlider(divH,divS){
	divHw = divH.offsetWidth;
	divSw = divS.offsetWidth;
	return [divHw,divSw];
}

function slideHor(dr,divH,divS){
	if (dr == 'r'){
		if(divS.offsetLeft <= 0){
			divS.style.left = (divS.offsetLeft+4)+'px';
		}else{
			clearInterval(bioTmr);
		}
	}
	if  (dr == 'l'){
		diff=(divS.offsetWidth-divH.offsetWidth);
		if(divS.offsetLeft >= (-diff)){
			divS.style.left = (divS.offsetLeft-4)+'px';
		}else{
			clearInterval(bioTmr);
		}
	}
}

function slidebios(dr){
	divS = document.getElementById('bioS');
	divH = document.getElementById('bioH');
	divS.style.width=document.getElementById('biotbl').offsetWidth+'px';
	pos = initSlider(divH,divS);
	bioTmr=setInterval("slideHor('"+dr+"',divH,divS)",20);
}
function stopSlide(){
	if(typeof(bioTmr)!='undefined') clearInterval(bioTmr);
}
