function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		if (xmlHttp.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //xmlHttp.overrideMimeType('text/xml');
            xmlHttp.overrideMimeType('text/html');
         }
	}
	catch (e){
    	// Internet Explorer
	    try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
    }
	return xmlHttp;
}
function editblog(id){
	if(xmlHttp==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {	
		url = site+"/assist.php?editblog&id="+id;
		xmlHttp.open("GET", url, true);	
		xmlHttp.onreadystatechange=handleeditblog;
		xmlHttp.send(null);
	}
}
function handleeditblog(){
	if (xmlHttp.readyState == 4) {
		document.getElementById('blogentry').innerHTML = xmlHttp.responseText;
	}
}
function editnews(id){
	if(xmlHttp==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		url = site+"/assist.php?editnews&id="+id;
		xmlHttp.open("GET", url, true);	
		xmlHttp.onreadystatechange=handleeditnews;
		xmlHttp.send(null);
	}
}
function handleeditnews(){
	if (xmlHttp.readyState == 4) {
		document.getElementById('newsentry').innerHTML = xmlHttp.responseText;
	}
}
function searchsuggest(critty){
	if(critty==""){
		var crit = document.getElementById('criteria').value;
	} else {
		var crit = critty;
	}
	if(crit.length>=2){
		if(xmlHttp==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
			var crit = document.getElementById('criteria').value;
			url = site+"/assist.php?searchsuggest="+crit+"&highlight="+itemjj;
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange=handleSearchsuggest;
			xmlHttp.send(null);
		}
		setTimeout('searchsuggest(critty)', 100);
	} else {
		document.getElementById('suggestions').className = 'panel';
		document.getElementById('suggestions').innerHTML = "";
	}

}
function handleSearchsuggest(){
	if (xmlHttp.readyState == 4) {
		if(xmlHttp.responseText!="na"){
			respText = xmlHttp.responseText;
			tmp1 = respText.search(/go0o0o0otcha/);
			if(tmp1>=0){
				tmp2 = respText.substr(tmp1+44);
				tmp3 = tmp2.search(/to0o0o0otcha/);
				tmp4 = tmp2.substr(0, tmp3-15);
				getThisAddy = tmp4;
			} else {
				//alert(respText);
			}
			document.getElementById('suggestions').innerHTML = respText;
			document.getElementById('suggestions').className = 'suggestions';
		} else {
			document.getElementById('suggestions').className = 'panel';
			document.getElementById('suggestions').innerHTML = "";
		}
	}
}
function closepanel(){
		document.getElementById('panel').className = 'panel';
}
function showadmincontrols(){
	document.getElementById('showcontrols').style.visibility = 'hidden';
	document.getElementById('admincontrols').style.visibility = 'visible';
}
function hideadmincontrols(){
	document.getElementById('admincontrols').style.visibility = 'hidden';
	document.getElementById('showcontrols').style.visibility = 'visible';
}
function togglecheck(id){	
	if(id=="resetpass"){
		if(resetpass==0){
			document.getElementById('newpass').disabled = false;			
			resetpass = 1;
		} else {
			document.getElementById('newpass').disabled = true;
			
			resetpass = 0;
		}
	}
	if(id=="removepic"){
		if(removepic==0){
			document.getElementById('updatepicture').disabled = true;
			removepic = 1;
		} else {
			document.getElementById('updatepicture').disabled = false;
			removepic = 0;
		}
	}
}
function locateme(link){
	window.location = site+'/'+link;
}
function addtag(tag){
	document.getElementById('message').innerHTML += tag;
}
function massemailon(total){
	for(i=1; i<=total; i++){
		document.getElementById(i).checked = true;
	}	
}
function massemailoff(total){
	for(i=1; i<=total; i++){
		document.getElementById(i).checked = false;
	}
}
function blockSubmit(){
	return false;	
}
function blockSubmitAndPost(pref, gid){
	addComment(pref, gid);
	return false;	
}
function emailpage(){
	ref = encodeURIComponent(window.location.href);
	document.getElementById('panel').style.top = 80+"px";
	document.getElementById('panel').className = 'panel_email';
	document.getElementById('panel').innerHTML = "<div style='padding:5px;'><table width='100%'><tr><td align='left'><p class='heading'>Email to friend</p></td><td align='right'><a href='javascript:closepanel();'>Close</a></td></tr></table><div><br/><form onsubmit='return blockSubmit();' name='form1'>Friends email address <input type='text' id='email' class='inputbox' style='width:100px;'/><input type='text' id='email' style='display:none;'> <input type='hidden' name='link' value='"+ref+"' />  <input type='submit' name='emailfriend' value='Email Friend' onmousedown='emailNow(\""+ref+"\")' /></form></div>";
}
function emailNow(){
	var email = document.getElementById('email').value;
	if(email.length>5){
		if(xmlHttp==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
			var crit = document.getElementById('criteria').value;
			url = site+"/assist.php?email="+email+"&u="+Susername+"&link="+ref;
			xmlHttp.open("GET", url, true);	
			xmlHttp.onreadystatechange=handleEmailNow;
			xmlHttp.send(null);
		}
	} else {
		alert("You have not entered a valid email address");
	}
}
function handleEmailNow(){
	if (xmlHttp.readyState == 4) {
			document.getElementById('panel').innerHTML = xmlHttp.responseText;
			setTimeout('closepanel();', 3000);
	}
}
function savepage(outerpage){
	if(xmlHttp==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		if(outerpage==""){
			var page = escape(document.location.href);
		} else {
			page = escape(outerpage);
		}
		url = site+"/assist.php?savepage="+page;
		xmlHttp.open("GET", url, true);	
		xmlHttp.onreadystatechange=handlesavepage;
		xmlHttp.send(null);
			document.getElementById('panel').style.top = 100+"px";
		document.getElementById('panel').className = 'panel_email';
		document.getElementById('panel').innerHTML = "<div style='padding:5px;'><table width='100%'><tr><td align='left'><p class='heading'>Saving Page....</p></td><td align='right'><a href='javascript:closepanel();'>Close</a></td></tr></table></div>";
	}
}
function handlesavepage(){
	if (xmlHttp.readyState == 4) {
			document.getElementById('panel').innerHTML = xmlHttp.responseText;
	}
}
function updateFolders(){
	var av = document.getElementById('av').value;
	if(xmlHttp1==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttp1.readyState == 4 || xmlHttp1.readyState == 0) {
		url = site+"/assist.php?av="+av;
		xmlHttp1.open("GET", url, true);	
		xmlHttp1.onreadystatechange=handleupdateFolders;
		xmlHttp1.send(null);
	}
}
function handleupdateFolders(){
	if (xmlHttp1.readyState == 4) {
			document.getElementById('folderlist').innerHTML = xmlHttp1.responseText;
	}
}
function openPodFolder(theid){
	if(document.getElementById(theid).className == 'showFolder'){
		document.getElementById(theid).className = 'hideFolder';
	} else {
		document.getElementById(theid).className = 'showFolder';
	}
}
function editpic(id, image, height){
	var myMouseY = document.Show.MouseY.value;
	document.getElementById('panel').style.top = height+"px";
	document.getElementById('panel').className = 'panel_email';
	document.getElementById('panel').innerHTML = "<div style='padding:5px;'><table width='100%' border='0'><tr><td align='left'><p class='heading'>Change Picture</p></td><td align='right'><a href='javascript:closepanel();'>Close</a></td></tr><tr><td colspan='2'>Editting this image<br/><br/><div style='max-height:250px; overflow:auto;'><img style='max-width:250px;' src='"+site+"/images/skins/"+id+"/"+image+"' alt='"+id+"'></div></td></tr><tr><td colspan='2'><form action='' method='post' enctype='multipart/form-data'><input type='hidden' name='image' value='"+image+"'/><input type='hidden' name='skin' value='"+id+"'/><input type='file' name='picture'/><br/><br/><input class='submitbutton' type='submit' value='Update Picture' name='updatePiccy'/></form></td></tr></table></div>";
}
function allmails(limit){
	if(document.getElementById('selectall').checked === true){
		for(mi=0; mi<=limit; mi++){
			if(document.getElementById(mi)){
				document.getElementById(mi).checked = true;
			}
		}
	} else {
		for(mi=0; mi<=limit; mi++){
			if(document.getElementById(mi)){
				document.getElementById(mi).checked = false;
			}
		}
	}
}
function handleInformThem(){
	if (xmlHttp.readyState == 4) {
		alert(xmlHttp.responseText);
	}
}
function checkMe(user){
	if(xmlHttpQue==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpQue.readyState == 4 || xmlHttpQue.readyState == 0) {
		url = site+"/assist.php?checkme="+user;
		xmlHttpQue.open("GET", url, true);	
		xmlHttpQue.onreadystatechange=handlecheckMe;
		xmlHttpQue.send(null);
	}
}
function handlecheckMe(){
	if (xmlHttpQue.readyState == 4) {
		if(xmlHttpQue.responseText!=""){
		//	document.getElementById('inform').style.visibility = "visible";
		//	document.getElementById('inform').innerHTML = xmlHttpQue.responseText;
		}
		setTimeout('checkMe(user);', 30000);
	}
}
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = 1*event.clientX + 1*document.body.scrollLeft
    tempY = 1*event.clientY + 1*document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}
function getrating(id, xmlHttpR, page){
	if(xmlHttpR==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpR.readyState == 4 || xmlHttpR.readyState == 0) {	
		url = site+"/assist.php?getrating="+id+"&page="+page;
		xmlHttpR.open("GET", url, true);	
		xmlHttpR.onreadystatechange = function(){
			handlegetRating(id, xmlHttpR);
		}
		xmlHttpR.send(null);
	}
}
function handlegetRating(id, xmlHttpR){
	if (xmlHttpR.readyState == 4) {
		document.getElementById(id+'-rating').innerHTML = xmlHttpR.responseText;
	}
}
function star(id,sid){
	for (i=1; i<=5; i++){
		document.getElementById(id+'star'+i).src=site+'/images/offStar.png';
	}
	for (i=1; i<=sid; i++){
		document.getElementById(id+'star'+i).src=site+'/images/onStar.png';
	}
	if(sid==1){
		document.getElementById(id+'-rateTitle').innerHTML=' No great value';
	}
	if(sid==2){
		document.getElementById(id+'-rateTitle').innerHTML=' Some interesting elements';
	}
	if(sid==3){
		document.getElementById(id+'-rateTitle').innerHTML=' Worthwhile read';
	}
	if(sid==4){
		document.getElementById(id+'-rateTitle').innerHTML=' Important article';
	}
	if(sid=='5'){
		document.getElementById(id+'-rateTitle').innerHTML=' Must Read';
	}
}
function killstar(id,sid){
	for (i=1; i<=sid; i++){
		document.getElementById(id+'star'+i).src=site+'/images/offStar.png';
	}
}
function voteStar(id, sid, xmlHttpR, page){
	if(xmlHttpR==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpR.readyState == 4 || xmlHttpR.readyState == 0) {	
		url = site+"/assist.php?starvote="+id+"&sid="+sid+"&page="+page;
		xmlHttpR.open("GET", url, true);	
		xmlHttpR.onreadystatechange = function(){
			handlevote(id, xmlHttpR, page);
		}
		xmlHttpR.send(null);
	}
}
function handlevote(id, xmlHttpR, page){
	if (xmlHttpR.readyState == 4) {
		getrating(id, xmlHttpR, page);
	}
}
function contactsCheck(id){
	if(document.getElementById(id).checked===false){
		document.getElementById(id).checked = true;
	} else {
		document.getElementById(id).checked = false;
	}
}
function startOnlineProcess(id, i,kp){
	if(xmlHttpSOLP==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpSOLP.readyState == 4 || xmlHttpSOLP.readyState == 0) {	
		url = site+"/assist.php?startOnlineProcess="+id+"&i="+i;
		xmlHttpSOLP.open("GET", url, true);	
		xmlHttpSOLP.onreadystatechange = function(){
			if (xmlHttpSOLP.readyState == 4) {
				//alert(xmlHttpSOLP.responseText);
				onlineOrNot(id, i, xmlHttpSOLP.responseText, kp);
			}
		}
		xmlHttpSOLP.send(null);
	}
}

function onlineOrNot(id, i, userid, kp){
	if(xmlHttp33==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttp33.readyState == 4 || xmlHttp33.readyState == 0) {	
		url = site+"/assist.php?onlineOrNot="+userid;
		xmlHttp33.open("GET", url, true);	
		xmlHttp33.onreadystatechange = function(){
			if (xmlHttp33.readyState == 4) {
				document.getElementById('onlineOrNot'+userid).innerHTML = xmlHttp33.responseText;		
				var j = eval(i+1);
				m = 0;
				if(kp==0){
					m=1;
					kp = userid;
				}
				//alert(kp);
				if(kp==userid && m==0){
					setTimeout('startOnlineProcess('+id+', '+j+', 0)', 30000);
				} else {
					setTimeout('startOnlineProcess('+id+', '+j+', '+kp+')', 1);
				}
			}	
		}
		xmlHttp33.send(null);
	}
}
function imHere(){
	if(xmlHttpImHere==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpImHere.readyState == 4 || xmlHttpImHere.readyState == 0) {	
		url = site+"/assist.php?imHere=1";
		xmlHttpImHere.open("GET", url, true);	
		xmlHttpImHere.onreadystatechange = handleimHere;
		xmlHttpImHere.send(null);
	}
}
function handleimHere(){
	setTimeout('imHere()', 30000);
	if (xmlHttpImHere.readyState == 4) {
		var gid = xmlHttpImHere.responseText.substring(5,10);
		while(gid.substring(0,1)=='0'){
			gid = gid.substring(1);
		}
		if(xmlHttpImHere.responseText.substring(0,5)=='nudge'){
			choice  = window.confirm(xmlHttpImHere.responseText.substring(10));
			if(choice===true){
				window.location=site+'/groups/'+gid;
			} else {
				killInformernudge();
			}
		}
	}
}
function nudge(id, gid){
	if(xmlHttpNudge==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpNudge.readyState == 4 || xmlHttpNudge.readyState == 0) {
		url = site+"/assist.php?nudge="+id+"&gid="+gid;
		xmlHttpNudge.open("GET", url, true);	
		xmlHttpNudge.onreadystatechange = handleNudge;
		xmlHttpNudge.send(null);
	}
}
function handleNudge(){
	if (xmlHttpNudge.readyState == 4) {
	alert(xmlHttpNudge.responseText);
	}
}
function killInformernudge(){
	if(xmlHttpNudge2==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpNudge2.readyState == 4 || xmlHttpNudge2.readyState == 0) {
		url = site+"/assist.php?killnudge=1";
		xmlHttpNudge2.open("GET", url, true);	
		xmlHttpNudge2.onreadystatechange = handlekillInformernudge;
		xmlHttpNudge2.send(null);
	}
}
function handlekillInformernudge(){
	if (xmlHttpNudge2.readyState == 4) {
	}
}
function getFiles(id){
	mj= "";
	if(xmlHttpGetFiles==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpGetFiles.readyState == 4 || xmlHttpGetFiles.readyState == 0) {
		url = site+"/assist.php?getfiles="+id;
		xmlHttpGetFiles.open("GET", url, true);	
		xmlHttpGetFiles.onreadystatechange = function(){
			handlegetFiles(id);
		}
		xmlHttpGetFiles.send(null);
	}
}
function handlegetFiles(id){
	if (xmlHttpGetFiles.readyState == 4) {
		document.getElementById('fileManager').innerHTML = xmlHttpGetFiles.responseText;
		mj = setInterval('getFiles('+id+')', 30000);
	}
}
function removeFile(name, gid){
	ask = window.confirm('Are you sure you wish to delete the file '+name+'?\n\nYou cannot restore this file once it is deleted.');
	if(ask===true){
		if(xmlHttpDelFiles==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpDelFiles.readyState == 4 || xmlHttpDelFiles.readyState == 0) {
			url = site+"/assist.php?delfiles="+name+"&gid="+gid;
			xmlHttpDelFiles.open("GET", url, true);	
			xmlHttpDelFiles.onreadystatechange = handleremoveFile;
			xmlHttpDelFiles.send(null);
		}
	}
}
function handleremoveFile(){
	if (xmlHttpDelFiles.readyState == 4) {
		startOnlineProcess(xmlHttpDelFiles.responseText, 0, 0);
	}
}
function delComment(id, gid){
	ask = window.confirm('Are you sure you wish to delete this comment?\n\nYou cannot restore it once it is deleted.');
	if(ask===true){
		if(xmlHttpDF==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpDF.readyState == 4 || xmlHttpDF.readyState == 0) {
			url = site+"/assist.php?delcomment="+id+"&gid="+gid;
			xmlHttpDF.open("GET", url, true);	
			xmlHttpDF.onreadystatechange = handledelComment;
			xmlHttpDF.send(null);
		}
	}
}
function handledelComment(){
	if (xmlHttpDF.readyState == 4) {
		//alert(xmlHttpDF.responseText);
		startOnlineProcess(xmlHttpDF.responseText, 0, 0);
	}
}
function pausecomp(millis){
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); }
	while(curDate-date < millis);
} 
function getGroupDiscussion(gid, pref){
	if(xmlHttpGDB==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpGDB.readyState == 4 || xmlHttpGDB.readyState == 0) {
		url = site+"/assist.php?getGroupDiscussion="+gid+"&pref="+pref;
		xmlHttpGDB.open("GET", url, true);	
		xmlHttpGDB.onreadystatechange=function(){
			handlegetGroupDiscussion(gid, pref);
		}
		xmlHttpGDB.send(null);
	}
}
function handlegetGroupDiscussion(gid, pref){
	if (xmlHttpGDB.readyState == 4) {
		
		document.getElementById('discussionBoard').innerHTML = xmlHttpGDB.responseText;
		setInterval('getGroupDiscussion('+gid+', '+pref+');', 30000);
	}
}
function addComment(pref, gid){
	if(xmlHttpAC==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	var comment = document.getElementById('yourMessage').value;
	
	if (xmlHttpAC.readyState == 4 || xmlHttpAC.readyState == 0) {
		url = site+"/assist.php?addComment="+escape(comment)+"&pref="+pref+"&gid="+gid;
		xmlHttpAC.open("GET", url, true);	
		xmlHttpAC.onreadystatechange=handleaddComment;
		xmlHttpAC.send(null);
	}
}
function handleaddComment(){
	if (xmlHttpAC.readyState == 4) {
		document.getElementById('yourMessage').value='';
	}
}
function permmy(id){
	if(document.getElementById(id).style.height.substring(0,document.getElementById(id).style.height.search('px'))!=myHeight){
		openPerms(id);
	}else{
		closePerms(id);
	}
}
function openPerms(id){
	if (document.getElementById(id).style.height.substring(0,document.getElementById(id).style.height.search('px')) <= myHeight){
		//alert(document.getElementById(id).style.height.substring(0,document.getElementById(id).style.height.search('px')));
		document.getElementById(id).style.height = x+"px";
		y+=2;
		x +=y; 
		setTimeout('openPerms("'+id+'")',20);
	} else {
		document.getElementById(id).style.height = myHeight+"px";
		document.getElementById(id).style.overflow = 'auto';
		x=0;
		y=0;
	}
}
function closePerms(id){
	if (document.getElementById(id).style.height.substring(0,document.getElementById(id).style.height.search('px')) > 0){
		y+=2;
		z -=y;
		if(z<0){
			z=0;
		}
		document.getElementById(id).style.height = z+"px";
		setTimeout('closePerms("'+id+'")',20);
	} else {
		document.getElementById(id).style.height = 0+"px";
		z=myHeight;
		y=0;
	}
}
function closeGroup(id){
	mert = window.confirm("Are you sure you wish to close this group?\n\nYou will no longer be able to use the discussion board or upload files once the group is closed.");
	if(mert===true){
		if(xmlHttpCloseGrp==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpCloseGrp.readyState == 4 || xmlHttpCloseGrp.readyState == 0) {
			url = site+"/assist.php?closegroup="+id;
			xmlHttpCloseGrp.open("GET", url, true);	
			xmlHttpCloseGrp.onreadystatechange = function(){
				handleCloseGrp(id);
			}
			xmlHttpCloseGrp.send(null);
		}
	}
}
function handleCloseGrp(id){
	if (xmlHttpCloseGrp.readyState == 4) {
		window.location=site+'/debrief/'+id;
	}
}
function delFile(file){
	mert = window.confirm("Are you sure you wish to delete this file?\n\nThis is not deletion is not reversible.");
	if(mert===true){
		if(xmlHttpDelFile==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpDelFile.readyState == 4 || xmlHttpDelFile.readyState == 0) {
			url = site+"/assist.php?delFile="+escape(file);
			xmlHttpDelFile.open("GET", url, true);	
			xmlHttpDelFile.onreadystatechange = function(){
				handleDelFile(file);
			}
			xmlHttpDelFile.send(null);
		}
	}
}
function handleDelFile(file){
	if (xmlHttpDelFile.readyState == 4) {
		window.location=site+'/files';
	}
}
function delpack(file){
	mert = window.confirm("Are you sure you wish to delete this package?\n\nThis is not deletion is not reversible.");
	if(mert===true){
		if(xmlHttpDelpack==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpDelpack.readyState == 4 || xmlHttpDelpack.readyState == 0) {
			url = site+"/assist.php?delpack="+escape(file);
			xmlHttpDelpack.open("GET", url, true);	
			xmlHttpDelpack.onreadystatechange = function(){
				handleDelpack(file);
			}
			xmlHttpDelpack.send(null);
		}
	}
}
function handleDelpack(file){
	if (xmlHttpDelpack.readyState == 4) {
		window.location=site+'/uploadzip';
	}
}
function resourceEvents(){
	r_type1 = document.getElementById('r_type1').checked;
	r_type2 = document.getElementById('r_type2').checked;
	z_type1 = document.getElementById('z_type1').checked;
	z_type2 = document.getElementById('z_type2').checked;
	if(r_type1===true){
		document.getElementById('z_type1').disabled = true;
		document.getElementById('z_type2').disabled = true;
		document.getElementById('z_typea').disabled = true;
		document.getElementById('z_typeb').disabled = true;
		document.getElementById('r_typea').disabled = false;
	}
	if(r_type2===true){
		document.getElementById('z_type1').disabled = false;
		document.getElementById('z_type2').disabled = false;
		document.getElementById('z_typea').disabled = false;
		document.getElementById('z_typeb').disabled = false;
		document.getElementById('r_typea').disabled = true;
		if(document.getElementById('z_type1').checked === true){
			document.getElementById('z_typeb').disabled = true;
			document.getElementById('z_typea').disabled = false;
		}
		if(document.getElementById('z_type2').checked === true){
			document.getElementById('z_typeb').disabled = false;
			document.getElementById('z_typea').disabled = true;
		}

	}
}

function tag(section, page, dbfinder, extra, extraFinder){
	if(xmlHttpAC==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpAC.readyState == 4 || xmlHttpAC.readyState == 0) {
		url = site+"/assist.php?tag="+section+"&page="+page+"&dbfinder="+dbfinder+"&extra="+extra+"&extraFinder="+extraFinder;
		xmlHttpAC.open("GET", url, true);	
		xmlHttpAC.onreadystatechange=function(){
			handleTags(section, page, dbfinder, extra, extraFinder)
		}
		xmlHttpAC.send(null);
	}
}
function handleTags(section, page, dbfinder, extra, extraFinder){
	if (xmlHttpAC.readyState == 4) {
		if(section == 'region' || section == 'research' || section == 'book' || section == 'podcast' || section == 'vodcast'){
			var tagplace = "tagplace"+page;
			document.getElementById(tagplace).innerHTML = "<div style='padding:5px;'><table width='100%' border='0'><tr><td align='left'><p class='heading' style='font-size:14px;'>Tagging...</p></td><td align='right'><a href='javascript:refreshPage();'>Close</a></td></tr><tr><td colspan='2'><br/><br/>Keyword: <input type='text' autocomplete=off name='tagcrit' id='tagcrit' class='inputbox' onkeyup='filterwords(\""+section+"\", \""+page+"\", \""+dbfinder+"\");'/><br/><br/><div style='text-align:left; border:1px solid #cccccc; padding:5px; max-height:150px; overflow:auto; background-color:#ffffff;' id='tagresults'></div></td></tr></table><input type='submit' value='Finish Tagging' name='endtagging' class='submitbutton'/></form></div>";
		} else {
			var tagplace = "tagplace";
			document.getElementById(tagplace).innerHTML = "<div style='padding:5px;'><form name='tagform' action='' method='post'><table width='100%' border='0'><tr><td align='left'><p class='heading' style='font-size:14px;'>Tagging...</p></td><td align='right'><a href='javascript:refreshPage();'>Close</a></td></tr><tr><td colspan='2'><br/><br/>Keyword: <input type='text' autocomplete=off name='tagcrit' id='tagcrit' class='inputbox' onkeyup='filterwords(\""+section+"\", \""+page+"\", \""+dbfinder+"\");'/><br/><br/><div style='text-align:left; border:1px solid #cccccc; padding:5px; max-height:150px; overflow:auto; background-color:#ffffff;' id='tagresults'></div></td></tr></table><input type='submit' value='Finish Tagging' name='endtagging' class='submitbutton'/></form></div>";
		}
		document.getElementById('tagcrit').focus();
		document.getElementById(tagplace).style.height = '350px';
		document.getElementById(tagplace).className = 'bordered';
		document.getElementById('tagresults').innerHTML = xmlHttpAC.responseText;
	}
}
function filterwords(section, page, dbfinder, extra, extraFinder){
	var tagcrit = document.getElementById('tagcrit').value;
	if(xmlHttpAC==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpAC.readyState == 4 || xmlHttpAC.readyState == 0) {
		url = site+"/assist.php?filtertag="+section+"&page="+page+"&filter="+tagcrit+"&dbfinder="+dbfinder+"&extra="+extra+"&extraFinder="+extraFinder;
		xmlHttpAC.open("GET", url, true);	
		xmlHttpAC.onreadystatechange=function(){
			handleFilterTags(section, page, tagcrit, dbfinder, extra, extraFinder);
		}
		xmlHttpAC.send(null);
	}
}
function handleFilterTags(section, page, tagcrit, dbfinder, extra, extraFinder){
	if (xmlHttpAC.readyState == 4) {
		document.getElementById('tagresults').innerHTML = xmlHttpAC.responseText;
	}
}
function iClickedATag(section, page, crit, dbfinder, extra, extraFinder){
	if(xmlHttpiClickedATag==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpiClickedATag.readyState == 4 || xmlHttpiClickedATag.readyState == 0) {
		url = site+"/assist.php?iClickedATag="+section+"&page="+page+"&dbfinder="+dbfinder+"&crit="+crit+"&extra="+extra+"&extraFinder="+extraFinder;
		xmlHttpiClickedATag.open("GET", url, true);	
		xmlHttpiClickedATag.onreadystatechange=function(){
			handleiClickedATag(section, page, crit, dbfinder, extra, extraFinder);
		}
		xmlHttpiClickedATag.send(null);
	}
}
function handleiClickedATag(section, page, crit, dbfinder, extra, extraFinder){
	if (xmlHttpiClickedATag.readyState == 4) {
		document.getElementById('tagcrit').value="";
	}
}
function refreshPage(){
	window.location = window.location;
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=650,height=400');");
}
function showTeachingNotes(){
	document.getElementById('teachingNotes').style.visibility = 'visible';
	document.getElementById('teachingNotes').style.height = '280px';
}
function addAttach(i){
	var j = i + 1;
	document.getElementById("attachments").innerHTML += "<br/><input type='file' name='attach"+j+"'/>";
	document.getElementById("attachments2").innerHTML = "<input type='hidden' name='attachlimit' value='"+j+"'/><a href='javascript:addAttach("+j+");'>Add another attachment</a>";
}
function opencourseparticipants(){
	var h = document.getElementById('courseparticipants').style.height.substr(0, document.getElementById('courseparticipants').style.height.length-2);
	h = h*1 + 10;
	document.getElementById('courseparticipants').style.height = h+"px";
	opencourseparticipants2();
	document.getElementById("opencoursediv").innerHTML = "<b>Course Participants (<a href='javascript:closecourseparticipants();'>Hide</a>):</b><br/><br/>"
}
function opencourseparticipants2(){
	var h = document.getElementById('courseparticipants').style.height.substr(0, document.getElementById('courseparticipants').style.height.length-2);
	if(h < 110){
		setTimeout( 'opencourseparticipants();', 1);
	} else {
		document.getElementById('courseparticipants').style.height = "110px";
		document.getElementById('courseparticipants').style.overflow = "scroll";
	}
}
function closecourseparticipants(){
	var h = document.getElementById('courseparticipants').style.height.substr(0, document.getElementById('courseparticipants').style.height.length-2);
	h = h*1 - 10;
	document.getElementById('courseparticipants').style.height = h+"px";
	closecourseparticipants2();
	document.getElementById("opencoursediv").innerHTML = "<a href='javascript:opencourseparticipants();'>View Course Participants</a><br/>"
}
function closecourseparticipants2(){
	var h = document.getElementById('courseparticipants').style.height.substr(0, document.getElementById('courseparticipants').style.height.length-2);
	if(h > 0){
		setTimeout( 'closecourseparticipants();', 1);
	} else {
		document.getElementById('courseparticipants').style.height = "0px";
		document.getElementById('courseparticipants').style.overflow = "scroll";
	}
}
function deleteItem(p){
	j = confirm("Are you sure you want to delete this item?");
	if(j){
		if(xmlHttpdeleteItem==(null)){
			alert("Your browser does not support AJAX!");
			return;
		}
		if (xmlHttpdeleteItem.readyState == 4 || xmlHttpdeleteItem.readyState == 0) {
			url = site+"/assist.php?deleteItem="+p;
			xmlHttpdeleteItem.open("GET", url, true);	
			xmlHttpdeleteItem.onreadystatechange=handledeletedItem
			xmlHttpdeleteItem.send(null);
		}
	}
}
function handledeletedItem(){
	if (xmlHttpdeleteItem.readyState == 4) {
		alert(xmlHttpdeleteItem.responseText);
		window.location= site+'/material';
	}
}
function doSomething(e) {
	var code;
	critty = document.getElementById('criteria').value;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if(code==38){
		if(itemjj>1){
			itemjj--;
			setTimeout('searchsuggest(critty)', 100);
			document.getElementById('criteria2').focus();
		} else {
			document.getElementById('criteria').focus();
			getThisAddy = "";
		}
	}
	if(code==40){
		itemjj++;
		setTimeout('searchsuggest(critty)', 100);
		document.getElementById('criteria2').focus();
	}
	if(code==27){
		itemjj=0;
		critty = "";
		closepanel();
		document.getElementById('criteria').value = "";
		document.getElementById('criteria2').innerHTML = "";
	}
	if(code==13){
		if(getThisAddy!=""){
			window.location = site+"/"+getThisAddy;
		}
	}
}
function to0o0o0otcha(){
	return false;
}
function devhide(){
	document.getElementById('devp').style.visibility = 'hidden';
	document.getElementById('devp_con').style.backgroundColor = '';
	document.getElementById('devp_con').innerHTML ='<span style=\'font-size:8px; color:#aaaaaa; \'><b>DEVELOPMENT PANEL [<a href=\'javascript:devshow();\'>SHOW</a>]</b></span><br/>';
}
function devshow(){
	document.getElementById('devp').style.visibility = 'visible';
	document.getElementById('devp_con').innerHTML ='<span style=\'font-size:8px;\'><b>DEVELOPMENT PANEL [<a href=\'javascript:devhide();\'>HIDE</a>]</b></span><br/>';	
}
function confirmPageChange(page, message){
	j = confirm(message);
	if(j===true){
		window.location = page;
	}
}

function passwordMetre(){
	if(xmlHttpPM==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpPM.readyState == 4 || xmlHttpPM.readyState == 0) {	
		password = escape(document.getElementById('newpass').value);
		url = site+"/assist.php?passwordMetre&strength="+escape(password);
		xmlHttpPM.open("GET", url, true);	
		xmlHttpPM.onreadystatechange=handlePasswordMetre;
		xmlHttpPM.send(null);
	}
}
function handlePasswordMetre(){
	if (xmlHttpPM.readyState == 4) {
		document.getElementById('passwordMetre').style.visibility = "visible";
		document.getElementById('passwordMetre').innerHTML = xmlHttpPM.responseText;
	}
}

function togglePickLook(e){
	var choice = document.getElementById('chooseLook').options[document.getElementById('chooseLook').selectedIndex].value;
	if (choice == "1"){
		document.getElementById('pickNewLayout').style.visibility = "visible";
		//document.getElementById('pickNewLayout').style.height = "100px";
	} else {
		document.getElementById('pickNewLayout').style.visibility = "hidden";
		//document.getElementById('pickNewLayout').style.height = "0px";
	}
}
