// Global Variables 

var myTimer; // used for onMouseOver Delay timer for more info and rating popups
var cursorX;
var cursorY; // global vars x and y position of mouse cursor 
var windowWidth;
var windowHeight;
var scrollX;
var scrollY;
var myPID;
var mySID;

function cursorXY(e) {
		if (navigator.appName == "Microsoft Internet Explorer"){
			cursorX = e.clientX+document.documentElement.scrollLeft;
			cursorY = e.clientY+document.documentElement.scrollTop;
		}
		else {
			cursorX = e.pageX;
			cursorY = e.pageY;
		}

		if (self.innerHeight) // all except Explorer
		{
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		if (self.pageYOffset) // all except Explorer
		{
			scrollX = self.pageXOffset;
			scrollY = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			scrollX = document.documentElement.scrollLeft;
			scrollY = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			scrollX = document.body.scrollLeft;
			scrollY = document.body.scrollTop;
		}

return true;
}

function showLinkDesc(e,content,boxwidth,title) {

	//we need to decode the content string, so that we can handle encoded UTF-8/foreign chars
	content = decodeURIComponent(content);

	var pointerobj=document.all? document.all["tippointer"] : document.getElementById? document.getElementById("tippointer") : ""
	var cleancontent = unescape(content);
	var objName = "descpopup";
	var objNameTitle = "descpopuptitle";
	var objNameHtml = "descpopupcontent";
	var tempX;
	var tempY;
	var pointX;
	var pointY;
	document.getElementById(objNameTitle).innerHTML = "<h6>" + title + "</h6>";

	cursorXY(e);
	cursorX +=10;
	cursorY +=8;
	
	tempX = cursorX-14;
	tempY = cursorY+21;
	tempX = tempX+"px";
	tempY = tempY+"px";
	cursorX = cursorX+"px";
	cursorY = cursorY+"px";
	
	document.getElementById(objName).style.width = boxwidth+"px";		
	document.getElementById(objName).style.top = tempY;
	document.getElementById(objName).style.left = tempX;				
		
	document.getElementById(objNameHtml).innerHTML = cleancontent;
		
	pointerobj.style.left = cursorX;				
	pointerobj.style.top = cursorY;
	pointerobj.style.visibility="visible"
	document.getElementById(objName).style.visibility = 'visible';

return false;
}

function hideLinkDesc() {
	document.getElementById("descpopup").style.visibility = 'hidden';
	document.getElementById("tippointer").style.visibility = 'hidden';
	return false;
}

// functions showAlert and hideAlert display/hide the css boxes for rating and more information
// pWidth - width of the popup, iType is the type of the content (corresponds to box type, i.e. 3 for complex links, 4 for files, 6 for events)
// iId - item ID (contentid), iScript - link.php or rating.php
function showAlert(pWidth, iType, iId, iScript) {

	var objName = "popupinfo"
	var objNameHtml = "popupinfocontent";
	var objNameTitle = "popupinfotitle";

	if (iScript == 0) { url="link.php?btype="+iType+"&cid="+iId; document.getElementById(objNameTitle).innerHTML = "<h6>More Information</h6>"; }
	if (iScript == 1) { url="rating.php?btype="+iType+"&cid="+iId; document.getElementById(objNameTitle).innerHTML = "<h6>Resource Rating</h6>";  }
	if (iScript == 2) { url="inlinestat.php?table="+iType+"&cid="+iId; document.getElementById(objNameTitle).innerHTML = "<h6>Quick Statistics</h6>"; }
	
	if (url) {
		dojo.xhrGet ({
			url: url,
			load: function (data) {		document.getElementById(objNameHtml).innerHTML = data;		},
			error: function (error) { alert("Error: " + error);},
			preventCache: true
		});	
	}
	
	document.getElementById(objName).style.width = pWidth+"px";	
	document.getElementById(objName).style.top = cursorY+"px";
	document.getElementById(objName).style.left = cursorX+"px";				
//	dojo.lfx.fadeShow(document.getElementById(objName), 700).play();
	document.getElementById(objName).style.visibility='visible';
}

function showAlertContent(pWidth, iType, iContent) {
	var objName = "popupinfo"
	var objNameHtml = "popupinfocontent";
	var objNameTitle = "popupinfotitle";
	var c = unescape(iContent);

	document.getElementById(objNameHtml).innerHTML = c;
	document.getElementById(objName).style.width = pWidth+"px";	
	document.getElementById(objName).style.top = cursorY+"px";
	document.getElementById(objName).style.left = cursorX+"px";				
	dojo.lfx.fadeShow(document.getElementById(objName), 700).play();
}

function hideAlert(pVal) {
	var objName = pVal;
	var objNameHtml = pVal+"content";
	//dojo.lfx.fadeHide(document.getElementById(pVal), 1000).play();
	document.getElementById(pVal).style.visibility='hidden';

	document.getElementById(objNameHtml).innerHTML = "Loading data";

//	dojo.lfx.fadeHide(parent.document.getElementById(pVal),1000,dojo.lfx.easeIn,function() {
//		//document.getElementById(objName).style.height = "10px";
//		}).play();
	return false;
}


function reloadBox(pid,sid,bid) {   
	dojo.xhrGet ({
		url: 'writebox.php?qs=1&mode=view&pid='+pid+'&bid='+bid+'&sid='+sid,
		load: function (data) {			document.getElementById('wrapbox' + bid).innerHTML = data;		},
		error: function (error) { alert("Error: " + error);},
		preventCache: true
	});	
}


function showPortalDesc(e,content,boxwidth,boxheight) {
	var pointerobj=document.all? document.all["tippointer"] : document.getElementById? document.getElementById("tippointer") : ""
	var cleancontent = unescape(content);
	var objName = "descpopup";
	var objNameHtml = "desccontent";
	var tempX;
	var tempY;
				
	cursorXY(e);
	cursorX +=10;
	cursorY +=8;
	tempX = cursorX-14;
	tempY = cursorY+21;
	tempX = tempX+"px";
	tempY = tempY+"px";
	cursorX = cursorX+"px";
	cursorY = cursorY+"px";
	
	document.getElementById(objName).style.top = tempY;
	document.getElementById(objName).style.left = tempX;
	document.getElementById(objName).style.width = boxwidth+"px";
	document.getElementById(objNameHtml).innerHTML = cleancontent;
	pointerobj.style.left = cursorX;				
	pointerobj.style.top = cursorY;
	pointerobj.style.visibility="visible";
	document.getElementById(objName).style.visibility = 'visible';

//dojo.lfx.fadeShow(pointerobj, 700).play();


//	dojo.lfx.fadeShow(document.getElementById(objName), 700).play();
	return false;
}

function limitFormLength(obj, length){
	var maxlength=length;
	if (obj.value.length>maxlength) { obj.value=obj.value.substring(0, maxlength); }
}

function limitQLength(obj, length){
	var maxlength=length;
	if (obj.value.length>maxlength) { obj.value=obj.value.substring(0, maxlength); 
		alert("Your Question is longer than "+length+" characters! Please rephrase it to make it shorter. Remember that you can add more detail in the field below.");
	}
	
}



function newQuestion(iid) {     
		if (checkBlankField(document.newq.pn,"name") == 0) {return false;}
		if (checkBlankField(document.newq.pe,"email") == 0) {return false;}
		if (checkBlankField(document.newq.qt,"title") == 0) {return false;}
		if (checkBlankField(document.newq.qc,"question") == 0) {return false;}

//		document.getElementById('status'+t+itemid).innerHTML = '<img src=\"images/indicator_black.gif\" align=\"top\"><h2 style=\"display:inline;\">&nbsp;Working...</h2>';
		if (document.newq.priv.checked == true) {document.newq.kp.value=1;} // whether to keep it private

		dojo.xhrPost ({
			url: 'process.php?m=newq&iid='+iid,		
			form: 'newq',
			load: function (data) {		
					document.getElementById('qform').innerHTML = data;
			},
			error: function (error) { alert("Error #112: " + error);}
		});
}	

function chColor(elem, fgcolor, bgcolor){
	elem.style.backgroundColor = bgcolor;
return true;}

function bgC(el,color){
	if (!color) { var color = '#FFEFCF';}
	el.style.backgroundColor = color;
}


function handleEnter(e, formobj, formfield) {
var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
var keycode = evtobj.keyCode;
if (keycode == 13) {
             //they hit enter so do something;
 			eval("document."+formobj+"."+formfield+".focus()");
 			return false;
}
else { return true; }
}

function handleEnterSearch(e, formobj, func) {
var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
var keycode = evtobj.keyCode;
if (keycode == 13) {
             //they hit enter so do something;
// 			eval(func+"()");
// 			eval(func);
		filterK(formobj);
		return false;
}
else { return true; }
}


function checkBlankField(obj, msg){
		var fieldvalue = dojo.string.trim(obj.value);
		obj.value = fieldvalue;
		if (fieldvalue == "") {
				alert ("The "+msg+" field can not be left blank!");
				return 0;
		}	else {return 1; }	
}


function userSubmitLink(bid,sid) {

	var uform="<span class=\"resdesc\">Fill out the form below to submit your link. All fields are required</span><BR>";
	uform += "<form method=post id=usform name=usf><input type=hidden name=box value=\"" + bid + "\">";
	uform += "<input type=hidden name=subj value=\"" + sid + "\">";
	uform += "<table><TR><TD><span class=\"resdesc\">Your Name:</span><BR>";
	uform += "<input type=\"text\" name=\"un\" style=\"width:200px\" class=\"inputtext\" ";
	uform += "onFocus=\"chColor(this,'#FFFFFF','#FFEFCF');\" onBlur=\"chColor(this,'#FFFFCC','#F4F4F4');\"></td></TR>";	
	uform += "<TR><TD><span class=\"resdesc\">Your Email:</span><BR>";
	uform += "<input type=\"text\" name=\"ue\" style=\"width:200px\" class=\"inputtext\" ";
	uform += "onFocus=\"chColor(this,'#FFFFFF','#FFEFCF');\" onBlur=\"chColor(this,'#FFFFCC','#F4F4F4');\"></td></TR>";	
	uform += "<TR><TD><span class=\"resdesc\">Link Title:</span><BR>";
	uform += "<input type=\"text\" name=\"lt\" style=\"width:200px\" class=\"inputtext\" ";
	uform += "onFocus=\"chColor(this,'#FFFFFF','#FFEFCF');\" onBlur=\"chColor(this,'#FFFFCC','#F4F4F4');\"></td></TR>";	
	uform += "<TR><TD><span class=\"resdesc\">Link URL:</span><BR>";
	uform += "<input type=\"text\" name=\"ul\" style=\"width:200px\" class=\"inputtext\" ";
	uform += "onFocus=\"chColor(this,'#FFFFFF','#FFEFCF');\" onBlur=\"chColor(this,'#FFFFCC','#F4F4F4');\"></td></TR>";	
	uform += "<TR><TD><span class=\"resdesc\">Description:</span><BR>";
	uform += "<textarea name=\"ud\" rows=\"4\" style=\"width:200px\" class=\"inputtext\" ";
	uform += "onFocus=\"chColor(this,'#FFFFFF','#FFEFCF');\" onBlur=\"chColor(this,'#FFFFCC','#F4F4F4');\"></textarea>";
	uform += "</td></TR>";
	uform += "<TR><TD><div id=\"buttondiv\"><INPUT style=\"submitbutton\" type=\"button\" value=\"Submit Link\" onclick=\"usl2()\">";
	uform += "&nbsp;&nbsp;<INPUT style=\"submitbutton\" type=\"button\" value=\"Cancel\" ";
	uform += "onclick=\"cancelUserSubmission("+bid+","+sid+");\"></div></TD></TR></table>";
	document.getElementById('linksubmit_'+bid).innerHTML = uform;
return false;
} // end userSubmitLink

function cancelUserSubmission(bid,sid) {	
	document.getElementById('linksubmit_'+bid).innerHTML = "<A HREF=\"#\" onclick=\"return userSubmitLink("+bid+","+sid+")\"><IMG SRC=\"http://www.libguides.com/images/additem.gif\" BORDER=\"0\"> Submit a Link</A>";
}

function usl2() {
	if (checkBlankField(document.usf.un,"Name") == 0) {return false;}
	if (checkBlankField(document.usf.ue,"Email") == 0) {return false;}
	if (checkBlankField(document.usf.ul,"URL") == 0) {return false;}
	if (checkBlankField(document.usf.lt,"Link Title") == 0) {return false;}
		
	// check the URL and format it properly
	var linkurl = document.usf.ul.value;

	urlRegex = /^(rtsp|ftp|https?):\/\//
	 if	(!linkurl.match( urlRegex )) {
			document.usf.ul.value = "http://" + linkurl;
		}
	else {
		document.usf.ul.value = linkurl;
	}

	changeButtonDiv();
	dojo.xhrPost ({
				url: 'process_usersubmit.php?m=a',
				form: 'usform',
				load: function (data) {
					if (parseInt(data) > 0) {
						myBID = data;
						reloadBox(myPID,mySID,myBID);
					}
					else {alert("There was an error with the user submission  - Error #71. Pleaase reload page and try again."); }
				},
				error: function (error) {
						alert("Error #72: " + error);
				}
	});
}

function changeButtonDiv(bn) {
	document.getElementById('buttondiv').innerHTML = '&nbsp<img src=\"images/indicator_black.gif\" align=\"top\"><h2 style= "display:inline;\">&nbsp;Working...</h2>';
	return true;
}



var tooltip=function(){
 var id = 'tt';
 var top = 3;
 var left = 3;
 var maxw = 250;
// var speed = 10;
// var timer = 20;
 var endalpha = 95;
 var alpha = 0;
 var delay = 50;
 var tt,c,h;
 var ie = document.all ? true : false;
 return{
  show:function(mode,w){
   if(tt == null){
    tt = document.createElement('div');
    tt.setAttribute('id',id);
//    c = document.createElement('div');
 //   c.setAttribute('id',id + 'cont');
  //  tt.appendChild(c);
    document.body.appendChild(tt);
//    tt.style.opacity = 0;
//    tt.style.filter = 'alpha(opacity=0)';
    document.onmousemove = this.pos;
   }
   tt.style.display = 'block';
   tt.innerHTML = "Loading help... please wait";

				dojo.xhrGet ({
					url: '/gethelp.php?m='+mode,
					load: function (data) {   tt.innerHTML = data; },
					error: function (error) {alert("Error: " + error);}
				});			

   tt.style.width = w ? w + 'px' : 'auto';
   if(!w && ie){
    tt.style.width = tt.offsetWidth;
   }
  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
  h = parseInt(tt.offsetHeight) + top;
	   dojo.fadeIn({node:tt}).play(delay); 
  },
  pos:function(e){
   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
   tt.style.top = (u - h) + 'px';
   tt.style.left = (l + left) + 'px';
  },
 hide:function(){
   dojo.fadeOut({node:tt}).play(delay); 
  }
 };
}();



	
		
var slider=function(){
	var array=[];
	var speed=3;
	var timer=10;
	return{
		init:function(t,c){ array=[];
			var s,ds,l,i;
			s=document.getElementById(t); ds=s.getElementsByTagName('div'); l=ds.length; i=0;
			for(i=0;i<l;i++){
				var d,did; d=ds[i]; did=d.id;
				if(did.indexOf("header")!=-1){
					d.onclick=new Function("slider.process(this)");
				}else if(did.indexOf("content")!=-1){
					array.push(did.replace('-content',''));
					d.maxh=d.offsetHeight;
					if(c==1&&i==1){
						d.style.display='block';
					}else{
						d.style.height='0px';
						d.style.display='none';
					}
				} 
			}
		},
		process:function(d){
			var cl,i; cl=array.length; i=0;
			for(i;i<cl;i++){
				var s,h,c,cd;
				s=array[i]; h=document.getElementById(s+'-header');
				c=s+'-content'; cd=document.getElementById(c);
				clearInterval(cd.timer);
				if(h==d&&cd.style.display=='none'){
					cd.style.display='block';
					this.islide(c,1);
				}else if(cd.style.display=='block'){this.islide(c,-1)}
			}
		},
		islide:function(i,d){
			var c,m; c=document.getElementById(i); m=c.maxh; c.direction=d;
			c.timer=setInterval("slider.slide('"+i +"')",timer);
		},
		slide:function(i){
			var c,m,h,dist; c=document.getElementById(i); m=c.maxh; h=c.offsetHeight;
			dist=(c.direction==1)?Math.round((m-h)/speed):Math.round(h/speed);
			if(dist<=1){dist=1}
			c.style.height=h+(dist*c.direction)+'px';
			c.style.opacity=h/c.maxh;
			c.style.filter='alpha(opacity='+(h*100/c.maxh)+')';
			if(h<2&&c.direction!=1){
				c.style.display='none';
				clearInterval(c.timer);
			}else if(h>(m-2)&&c.direction==1){clearInterval(c.timer)}
		}
	};
}();






function askQSubmit(nq,labels,inst) {

	e=window.encodeURIComponent;

	var l_array=labels.split("#@#@");
	
	if (document.askqform.pquestion.value == "Type your question - 150 char max") {document.askqform.pquestion.value = "";}
	if (document.askqform.pdetails.value == "Add detail/explanation (optional)") {document.askqform.pdetails.value = "";}
	
	if (checkBlankField(document.askqform.pquestion,"question") == 0) {return false;}
	if (checkBlankField(document.askqform.pemail,"email") == 0) {return false;}

	if ((nq == 1) || (nq == 2)) {
		var st1 = document.askqform.val1.value;
		if (st1 == 0) {alert("Please select a value for " + l_array[0]); return false;}
	}
	if (nq == 2) {
		var st2 = document.askqform.val2.value;
		if (st2 == 0) {alert("Please select a value for " + l_array[1]); return false;}
	}

	dijit.byId('dlg').hide()
	dojo.xhrPost ({
		url: 'process.php?m=newq&iid='+inst+'&uri='+e(location.href)+'&urititle=System',		
		form: 'aqform',
		load: function (data) {
				var dd_array=data.split("#@#@");
				if (parseInt(dd_array[0]) > 0) { alert('Thank you! We will email you at ' + dd_array[1] + ' when the question is answered.'); 
					window.location.reload(true);
				}
				else {	alert('There was an error submitting your question. Please reload the page and try again.'); }
		},
		error: function (error) { alert("Error #112: " + error);}
	});

}

function gotoAnswer(t,s,newwin) { // target, source, newwindow if this request is from a widget
	dojo.xhrGet ({
		url: 'process.php?m=gotoa&qid='+t+'&s='+s,
		load: function (data) { var url = "a.php?qid="+data; if (newwin == 1) { window.open(url,'answer'); self.close();} else {window.location = url;} return false;	 },
		error: function (error) {alert("Error: " + error);},
		preventCache: true
	});	

return false;
}



function showTweets(t) {
	dojo.byId('showtweet').style.display="block";
	dojo.byId('showtweet').innerHTML = '<img src="/images/indicator_black.gif" align="top">&nbsp;Working...';
	dojo.xhrGet ({
		url: 'twitter_stream.php?a='+t,
		load: function (data) {
				dojo.byId('showtweet').innerHTML = data;
		 },
		error: function (error) {alert("Error: " + error);}
	});
	
return false;
}

function askQ() {
	var txt = dojo.string.trim(document.qform.qtext.value);
	if (txt.indexOf("Type your question") === 0) { alert('Please type your question first.'); return false;}
	if (txt == "") {alert('Please type your question first.'); return false;}
	document.qform.qentry.value = txt;
	dojo.byId('maincontent').style.display = 'block';	
	dojo.byId('maincontent').style.paddingTop = '8px';	
	dojo.byId('maincontent').innerHTML = '&nbsp<img src=\"images/indicator.gif\" align=\"top\">&nbsp; Searching...please wait';

	var hidestr = "<BR clear='all'><a href=\"#\" onClick=\"document.getElementById('maincontent').style.display = 'none'\"><strong>Hide Results</strong></a>";

	dojo.xhrPost ({
		url: 'search_process.php?p=i&iid='+gIID,		
		form: 'qform',
		load: function (data) {
				var dd_array=data.split("#@#@");
				if (parseInt(dd_array[0]) == 1) { window.location = "a.php?qid="+dd_array[1]; return false;}
				if (parseInt(dd_array[0]) == 2) { dojo.byId('maincontent').innerHTML = dd_array[1]+hidestr; return false;}				
		},
		error: function (error) { alert("Error #112: " + error);}
	});

return false;
} // end function askQ2						



function askQOLD() {
	var txt = dojo.string.trim(document.qform.qtext.value);
	if (txt == "") {alert('Please type your question first.'); return false;}
	document.qform.qentry.value = txt;
	dojo.byId('maincontent').innerHTML = '&nbsp<img src=\"images/indicator.gif\" align=\"top\">&nbsp; Searching...please wait';

	dojo.xhrPost ({
		url: 'search_process.php?iid='+gIID,		
		form: 'qform',
		load: function (data) {
				var dd_array=data.split("#@#@");
				if (parseInt(dd_array[0]) == 1) { window.location = "a.php?qid="+dd_array[1]; return false;}
				if (parseInt(dd_array[0]) == 2) { dojo.byId('maincontent').innerHTML = dd_array[1]; return false;}				
		},
		error: function (error) { alert("Error #112: " + error);}
	});

return false;
} // end function askQ						
				

function loadSearch(bcol) {
	if (bcol=="") {bcol="aeaeae";}
	store = new ComboBoxReadStore({url: "process_searchitem.php"});
	dstore = new dijit.form.ComboBox({
		name:"dstore",
		autoComplete:false,
		higlightMatch:"all",
		hasDownArrow:false,
		store: store,
		pageSize:20
	}, dojo.byId("qtext"));
	var at = "width:670px;height:20px;border: 3px solid #"+bcol+";font: bold 14px Arial, Trebuchet ms, Tahoma, sans-serif; color:#696969";
	dstore.setAttribute('style', at);
	dojo.byId('qtext').focus();
	dojo.byId('qtext').focus();
	dojo.connect(dstore, 'onKeyDown', function(e) {if (e.keyCode == dojo.keys.ENTER) { askQ(); }});

} // end loadSearch


function chatClick(i) {
if (chathit == 0) { 
	dojo.xhrGet ({
		url: 'recordhit.php?t=2&id='+i,
		load: function (data) { chathit = 1; },
		error: function (error) { },
		preventCache: true
	})
}
return false;
} // end chatClick

function emailQ(id) {

	dojo.xhrPost ({
		url: 'process.php?m=emailquestion',		
		form: 'emailit',
		load: function (data) {
			dijit.byId('dlg').hide();
			var ot=data.split("#@#@#");
			if (parseInt(ot[0]) > 0) {
				var divname = 'note' + id;
				var nt = ot[1] + " <a href=\"#\" onclick=\"return showDlg('Add/Edit note for question"+id+"','process.php?m=addnote&iid="+iid+"&qid="+id+"',0)\">(edit note)</a>";								
				dojo.byId(divname).innerHTML = nt;
			}
			else {calert("Error #725 - could not save note. Please reload and try again");}			
		},
		error: function (error) { alert("Error #112: " + error);}
	});

	
return false;
}


function submitQ(nq,inst) {
	
	if (document.askqform.pquestion.value == "Type your question - 150 char max") {document.askqform.pquestion.value = "";}
	if (document.askqform.pdetails.value == "Add detail/explanation (optional)") {document.askqform.pdetails.value = "";}
	
	if (checkBlankField(document.askqform.pquestion,"question") == 0) {return false;}
	if (checkBlankField(document.askqform.pemail,"email") == 0) {return false;}

	if (document.askqform.pquestion.value.length > 149) {
		alert("Your Question is longer than 150 characters! Please rephrase it to make it shorter. Remember that you use the More Detail/Explanation field as well.");
		return false;
	}


	if ((nq == 1) || (nq == 2)) {
		var st1 = document.askqform.val1.value;
		if (st1 == 0) {alert("Please answer all required questions in the Your Info area."); return false;}
	}
	if (nq == 2) {
		var st2 = document.askqform.val2.value;
		if (st2 == 0) {alert("Please answer all required questions in the Your Info area."); return false;}
	}

	dojo.byId('buttondiv').innerHTML = '<img src="/images/indicator_black.gif" align="top">&nbsp;Working...';

	dojo.xhrPost ({
		url: 'process.php?m=newq&iid='+inst+'&uri='+location.href+'&urititle=System',		
		form: 'aqform',
		load: function (data) {
				var dd_array=data.split("#@#@");
				if (parseInt(dd_array[0]) > 0) { alert('Thank you! We will email you at ' + dd_array[1] + ' when the question is answered.'); 
					window.location.reload(true);
				}
				else {	alert('There was an error submitting your question. Please reload the page and try again.'); }
		},
		error: function (error) { alert("Error #112: " + error);}
	});

}


