var over

///////////////////////////////////////////////////////////////////////
// Developed from an original idea at brainerror.net, Communis 2004  //
///////////////////////////////////////////////////////////////////////
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart >= opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        	}
    	} else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++){
       	   	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
           	timer++;
			}
	    }
	}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	if (document.getElementById('ahem').style.display == 'none') {
	    var object = document.getElementById(id).style;
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
	} 
}

function dy(id){
document.getElementById(id).style.display = 'none';
}

function instantClear(id) {
	if (document.getElementById('ahem').style.display == 'none') {
		var object = document.getElementById(id).style;
		instantOpac(0,id)
		object.visibility = "hidden";
		object.display = "none";
	} 
}

function instantOpac(opac,id) {
	if (document.getElementById('ahem').style.display == 'none') {
	    var object = document.getElementById(id).style;
	    object.opacity = opac;
	    object.MozOpacity = opac;
	    object.KhtmlOpacity = opac;
	    object.filter = "alpha(opacity=" + opac + ")";
	} 
}
	
/////////////////Site-Specific Code -- by Communis 2004////////////////////

/////////// menu calls ////////////
	
	function bye(theId) {
	if (over==0) {
		instantClear(theId);
		}
	}

	function byeAllNow() {
	  instantClear('co'); // top menus
	  instantClear('re');
	  instantClear('tr');
	  instantClear('si');
	  instantClear('ar');
	  instantClear('rs');

	  instantClear('co2'); // base menus
	  instantClear('re2');
	  instantClear('tr2');
	  instantClear('si2');
	  instantClear('ar2');
	  instantClear('rs2');
	  }

	function byeAll() {
	if (over==0) {
	byeAllNow();
		}
	}	

	function mOver(){
	over=1;
	}

	function mOut(){
	over=0;
    string="byeAll();";
    setTimeout(string,1400);
	}

	function subnav(theId,num) {
	if (document.getElementById('ahem').style.display == 'none' && getActiveStyleSheet() != 'xpda') {
	  if (num == null) num = 0.5;
    	byeAllNow();
		mOver()
		emstring = ' '+num+'em';
		changeOpac(0, theId);
		document.getElementById(theId).style.display="inline";		// remove from some screenreaders
		document.getElementById(theId).style.visibility="visible";	// remove from other screenreaders
		document.getElementById(theId).style.position='absolute';		// relative to parent element
		document.getElementById(theId).style.top='1.75em';				// move down
		document.getElementById(theId).style.left=emstring;
		opacity(theId,0,90,300);
		}
	}

//////////// menu writes //////////////
var a = 'onmouseover="mOver();" onmouseout="mOut();">';
var b = '</a></li><li title=""><a';
var c = '" class="sub"><li title=""><a';

function submenu(id,here) {
	if (document.getElementById('ahem').style.display == 'none' && getActiveStyleSheet() != 'xpda') {
		if (here == 1) {
			here = ' class="here"';
		}
		else {
			here = ' ';
		}
		if (id == 'co2' || id == 'co') {
			document.write('<ul title="Consultancy submenu" id="' + id + c + here + ' href="consultancy.html#eval" ' + a + 'Evaluation' + b + here + ' href="consultancy.html#user" ' + a + 'Usability Testing' + b + here + ' href="consultancy.html#rewrites" ' + a + 'Template Rewrites' + b + here + ' href="consultancy.html#ongoing" ' + a + 'Ongoing Audit</a></li></ul>');
		}
		if (id == 're' || id == 're2') {
			document.write('<ul title="Research submenu" id="' + id + c + here + ' href="research.html#gis" ' + a + 'GIS Applications' + b + here + ' href="research.html#community" ' + a + 'Community Tools' + b + here + ' href="research.html#search" ' + a + 'Search Engine</a></li></ul>');
		}
	 	if (id == 'tr' || id == 'tr2') {
			document.write('<ul title="Training submenu" id="' + id + c + here + ' href="training.html#general" ' + a + 'General Courses' + b + here + ' href="training.html#technical" ' + a + 'Technical Courses</a></li></ul>');
		}
	 	if (id == 'si' || id == 'si2') {
			document.write('<ul title="Site Design submenu" id="' + id + c + here + ' href="sitedesign.html#rewrites" ' + a + 'Template Rewrites' + b + here + ' href="sitedesign.html#new" ' + a + 'New Sites' + b + here + ' href="sitedesign.html#examples" ' + a + 'Examples' + b + here + ' href="sitedesign.html#next" ' + a + 'What next?' + b + here + ' href="sitedesign.html#probono" ' + a + 'Pro Bono</a></li></ul>');
		}
	 	if (id == 'rs' || id == 'rs2') {
			document.write('<ul title="Resources submenu" id="' + id + c + here + ' href="resources.html#browser" ' + a + 'Browser Options' + b + here + ' href="resources.html#sites" ' + a + 'Web Sites' + b + here + ' href="resources.html#organisations" ' + a + 'Organisations' + b + here + ' href="resources.html#software" ' + a + 'Software</a></li></ul>');
		}
	}
}

function submenusep(id,here,subNum) {
	if (document.getElementById('ahem').style.display == 'none' && getActiveStyleSheet() != 'xpda') {
		if (here != 1) {
			subNum = 0;
			here = ' ';
		}
		else {
			here = ' class="here"';
//			subNum = subNum;
		}
	 	if (id == 'ar' || id == 'ar2') {
			if (subNum == 1 || subNum == 0) {
				document.write('<ul title="Articles submenu" id="' + id + c + here + ' href="articles.html" ' + a + 'Articles Index' + b + ' href="reach.html" ' + a + 'Reach More People' + b + ' href="legal.html" ' + a + 'Comply with the Law</a></li></ul>');
			}
			if (subNum == 2) {
				document.write('<ul title="Articles submenu" id="' + id + c + ' href="articles.html" ' + a + 'Articles Index' + b + here + ' href="reach.html" ' + a + 'Reach More People' + b + ' href="legal.html" ' + a + 'Comply with the Law</a></li></ul>');
			}
			if (subNum == 3) {
				document.write('<ul title="Articles submenu" id="' + id + c + ' href="articles.html" ' + a + 'Articles Index' + b + ' href="reach.html" ' + a + 'Reach More People' + b + here + ' href="legal.html" ' + a + 'Comply with the Law</a></li></ul>');
			}
		}
	}
}

