function gotolink(obj) {
	selectedval=obj.options[obj.selectedIndex].value;
	if(selectedval=='') {
		alert('Please choose a category');
	}
	else {
		document.location.href=selectedval + '.php';
	}
}
var openwin1='';
function newwin(thewidth,theheight,theloc) {
	if(thewidth==0 && theheight==0) {
		thewidth=screen.width-100;
		theheight=screen.height-100;
	}
	var theparams="height="+theheight+",width="+thewidth+",toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=1,resizeable=1,resizable=1";
	openwin1=open(theloc,"newWindow",theparams);
	openwin1.focus();
}
function gethandle(id) {
	if(document.getElementById) {
		return document.getElementById(id);
	}
	else if(document.all) {
		return document.all(id);
	}
}
function selectoption(box,checkval) {
    for(i=0;i<box.length;i++) {
        if(box.options[i].value==checkval) {
            box.selectedIndex=i;
        }
    }
}
function limitlength(obj,maxchars) {
	if(obj.value.length>maxchars) {
		obj.value=obj.value.substring(0,maxchars);
		alert('You have entered too much text.  Please shorten your input (1024 characters maximum).');	
	}
}


/* menu functions */
var cleartimer='';
var buttonwidth='161';
function closesiblings(obj,depth) {
	if(depth==2) {
		siblingnodes=obj.parentNode.parentNode.getElementsByTagName('div');
	}
	else if(depth==1) {
		siblingnodes=obj.parentNode.getElementsByTagName('div');
	}
	else {
		//root menu close
		rootobjs=obj.childNodes;
		for(z=0;z<rootobjs.length;z++) {
			if(rootobjs[z].tagName=='DIV') {
				curobj=rootobjs[z].getElementsByTagName('div');
				
					curobj[0].style.backgroundColor='#375dab';

			}
		}
		siblingnodes=obj.getElementsByTagName('div');
	}
	for(i=0;i<siblingnodes.length;i++) {
		if(siblingnodes[i].className=='menu_box') {
			gethandle(siblingnodes[i].id).style.visibility='hidden';
		}
	}
}
function openmenu(menu,obj) {
	cancelclose();
	closesiblings(obj,2);
	curmenu=gethandle('menu_' + menu);
	curmenu.style.left=buttonwidth + 'px';
	curmenu.style.top='0px';
	//Bug with Opera iframes..dont do this for opera
	if(!window.opera) {
		shim=gethandle('iframe_' + menu);
		shim.style.display='block';
		shim.style.height=(shim.offsetParent.offsetHeight-4) + 'px';
		shim.style.width=(shim.offsetParent.offsetWidth-4) + 'px';
	}
	curmenu.style.visibility='visible';
	highlightpath(obj);
}
function closeallmenus() {
	cancelclose();
	closesiblings(gethandle('menu_boxtop'),0);
}
function findxpos(obj) {
	var curleft=0;
	if(obj.offsetParent) {
		while(obj.offsetParent) {
			curleft+=obj.offsetLeft;
			obj=obj.offsetParent;
		}
	}
	else if(obj.x) {
		curleft+=obj.x;
	}
	return curleft;
}
function findypos(obj) {
	var curleft=0;
	if(obj.offsetParent) {
		while(obj.offsetParent) {
			curleft+=obj.offsetTop;
			obj=obj.offsetParent;
		}
	}
	else if(obj.y) {
		curleft+=obj.y;
	}
	return curleft;
}

/*
function checkclose(e,closemenus) {
	if(!e) var e=window.event;
	if(closemenus!='no') {
		closeallmenus();
	}
	e.cancelBubble=true;
	if(e.stopPropagation) e.stopPropagation();
}
*/

function startclose() {
	cleartimer=setTimeout('closeallmenus();',500);
}
function cancelclose() {
	clearTimeout(cleartimer);
}
function assignmouseovers() {
	clickcatchers=document.getElementsByTagName('div');
	for(i=0;i<clickcatchers.length;i++) {
		if(clickcatchers[i].className=='menu_tree') {
			clickcatchers[i].onmouseout=function() { startclose(); };
		}
		else if(clickcatchers[i].className=='menu_root') {
			clickcatchers[i].onmouseout=function() { startclose(); };
		}
	}
	clickcatchers=document.getElementsByTagName('a');
	for(i=0;i<clickcatchers.length;i++) {
		if(clickcatchers[i].className=='menu_leaf') {
			clickcatchers[i].onmouseover=function() { cancelclose();closesiblings(this,1);highlightpath(this); };
			clickcatchers[i].onmouseout=function() { startclose(); };
		}
	}
}
function highlightpath(obj) {
	curobj=obj;
	if(obj.className=='menu_leaf') {
		while(curobj.previousSibling) {
			curobj=curobj.previousSibling;
		}
		while(curobj!=null) {
			if(curobj.className=='menu_itemcontainer') {
				childobj=curobj.getElementsByTagName('div');
				childobj[0].style.backgroundColor='#375dab';
			}
			curobj=curobj.nextSibling;
		}
	}
	else if(obj.className.indexOf('menu_tree')>-1) {
		curobj=curobj.parentNode;			
		while(curobj.previousSibling) {
			curobj=curobj.previousSibling;
		}
		while(curobj!=null) {
			if(curobj.className=='menu_itemcontainer') {
				childobj=curobj.getElementsByTagName('div');
				childobj[0].style.backgroundColor='#375dab';
				
			}
			curobj=curobj.nextSibling;
		}
		obj.style.backgroundColor='#4d77c7';
	}
	else {
		allbuts=gethandle('menu_boxtop').getElementsByTagName('div');
		for(x=0;x<allbuts.length;x++) {
			if(allbuts[x].className=='menu_root' || allbuts[x].className=='menu_tree') {
				allbuts[x].style.backgroundColor='#375dab';
			}
		}
		obj.style.backgroundColor='#4d77c7';
	}
}
function ml(url) {
	closeallmenus();
	document.location.href=url;
}

/* my bookmarks */
var dls_timer;
var dls_dest;
var dls_mover;
var dls_mover_text;
var isIE=(document.all)?true:false;
var curmouse_x,curmouse_y;
var dls_opacity;
var downloadhandler;
function mouselocs(evt) {
  curmouse_x=!isIE?evt.pageX:window.event.clientX;
  curmouse_y=!isIE?evt.pageY:window.event.clientY;
  return false;
}
if(!isIE) document.captureEvents(Event.MOUSEUP);
document.onmouseup=mouselocs;
function dls_displaymsg(dlname,dlurl,obj) {
	clearTimeout(dls_timer);
	dls_mover.style.top=curmouse_y+'px';
	dls_mover.style.left=curmouse_x+'px';
	dls_mover.style.visibility='visible';
	dls_mover_text.style.fontSize='8pt';
	dls_mover.style.opacity=1;
	dls_mover.style.filter='alpha(opacity=100)';
	dls_opacity=100;
	dls_timer=setTimeout(function() { dls_resizemove(obj) },750);
	dls_addtodownloads(dlname,dlurl);
}
function dls_resizemove(obj) {
	if(parseFloat(dls_mover_text.style.fontSize)>.2) {
		dls_mover.style.top=(Math.abs(parseFloat(dls_mover.style.top))+findypos(dls_dest))/2 + 'px';
		dls_mover.style.left=(Math.abs(parseFloat(dls_mover.style.left))+findxpos(dls_dest))/2 + 'px';
		dls_mover_text.style.fontSize=(parseFloat(dls_mover_text.style.fontSize))/1.5 + 'px';
		dls_mover.style.opacity=dls_opacity/100;
		dls_mover.style.filter='alpha(opacity=' + dls_opacity + ')';
		dls_opacity=dls_opacity-10;
		dls_timer=setTimeout(function() { dls_resizemove(obj) },25);
	}
	else {
		clearTimeout(dls_timer);
		dls_mover.style.visibility='hidden';
	}
}
function dls_handleaddition() {
	if(downloadhandler.readyState==4) {
		if(downloadhandler.status==200) {
			dls_updatecounter(downloadhandler.responseText);
		}
	}	
}
function dls_addtodownloads(dlname,dlurl) {
	if(window.XMLHttpRequest) {
		downloadhandler=new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		downloadhandler=new ActiveXObject("Msxml2.XMLHTTP");
	}
	else {
		downloadhandler=new ActiveXObject("Msxml.XMLHTTP");
	}
	downloadhandler.onreadystatechange=dls_handleaddition;
	downloadhandler.open('GET','/acsd/favorites_change.php?action=add&dlname=' + escape(dlname) + '&dlurl=' + escape(dlurl),true);
	downloadhandler.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT');
	downloadhandler.send('');
}
function dls_updatecounter(curvalues) {
	viewtext='&nbsp;<a href="/acsd/favorites_view.php" style="font-size:7pt;line-height:14px;">Bookmarks...</a>';
	if(parseInt(curvalues)==25) {
		dls_dest.style.color='#710000';
		dls_dest.innerHTML='MAX saved!' + viewtext;
	}
	else if(parseInt(curvalues)==0) {
		dls_dest.style.color='#ac9e43';
		dls_dest.innerHTML='<a href="/acsd/favorites_view.php">No bookmarks</a>';	  
	}
	else {
		dls_dest.style.color='#0272a4';
		dls_dest.innerHTML=curvalues + ' saved.' + viewtext;
	}
}

var modelblocks_live=new Array();
function modelblocks_open(obj) {
	if(!gethandle('modelblock_' + obj)) {
		alert('There are currently no downloads or information for this section.');
		return false;
	}
	for(var i=0;i<modelblocks_live.length;i++) {
		gethandle('modelblock_' + modelblocks_live[i]).style.visibility='hidden';
		gethandle('modelblockbut_' + modelblocks_live[i]).className='modelblock';
	}
	if(obj!='') {
		gethandle('modelblock_' + obj).style.visibility='visible';
		gethandle('modelblockbut_' + obj).className='modelblocklive';
	}
}

function printflash(width,height) {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '" title="Introduction">');
    document.writeln('<param name="WMode" value="transparent">');
	document.writeln('<param name="movie" value="./flash/introduction.swf" />');
    document.writeln('<param name="quality" value="high" />');
    document.writeln('<embed wmode="transparent" src="./flash/introduction.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
    document.writeln('</object>');
}