// ------------------------------------------ AJAX functions

var xmlHttp;
var targetDivID;
var messageID;

function GetXmlHttpObject(){
	var xmlHttp=null;
	try	{ // Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
 	}
	catch (e){ // Internet Explorer
  		try	{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e){
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}

function AJAXrequest(message,messID,url,poststr,toDivID){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
  		alert ("Your browser does not support AJAX!");
  		return;
  	}
	messageID=messID; 
	DisplayMessage(message,messageID);
	targetDivID=toDivID;
	if(poststr.indexOf("&")==0) poststr=poststr.substring(1,poststr.length);

	xmlHttp.onreadystatechange = changeHTML;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  
// use this for POST - must come after open
	xmlHttp.send(poststr);
}

function changeHTML(){ 

	try{
		if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){ 
document.getElementById(targetDivID).innerHTML=xmlHttp.responseText;
				DisplayMessage('',messageID);
			}
			else{
				alert('There is a problem connecting to the server.');
			}
		}
	}
	catch(e) {
		alert('Caught Exception: ' + e.description);
	}
}

function DisplayMessage(message,messID) {
	if(message.length>0) {
		document.getElementById(messID).innerHTML=message;
		document.getElementById(messID).style.visibility="visible";
	}
	else {
		document.getElementById(messID).innerHTML="";
		document.getElementById(messID).style.visibility="hidden";
	}	
}

function PostStr(InptElmnt) {
	var i, outstr, cked, eltype;
	cked=false;
	outstr="";
	eltype=InptElmnt.type;
	if (eltype==null) eltype=InptElmnt[0].type;
	switch (eltype) {
	case "checkbox":
	case "radio":
		if(InptElmnt.length>1) {
			for(i=0; i<InptElmnt.length; i++) {
				if(InptElmnt[i].checked) {
					if(cked==false) cked=true;
					if(outstr.length>0) outstr=outstr + ",";
					outstr=outstr + encodeURIComponent(InptElmnt[i].value);
				}
			}
			if(cked) outstr="&" + InptElmnt[0].name + "=" + outstr;
		}
		else {
			if(InptElmnt.checked) outstr="&" + InptElmnt.name + "=" + encodeURIComponent(InptElmnt.value);
		}
		break;
	case "text":
	case "hidden":
	case "textarea":
	case "password":
		outstr="&" + InptElmnt.name + "=" + encodeURIComponent(InptElmnt.value);
		break;
	case "select-one":
		if (InptElmnt.selectedIndex>-1) outstr="&" + InptElmnt.name + "=" + encodeURIComponent(InptElmnt.options[InptElmnt.selectedIndex].value);
		break;
	}
	return outstr;
}	


header='<div class="banner"><p>Michigan Alliance of Reading Professors</p></div>'

menu = '<div class="menubox">';
menu = menu + '<a class="menuitem" href="default.asp">Home</a>';
menu = menu + '<a class="menuitem" href="aboutus.asp">About Us</a>';
menu = menu + '<a class="menuitem" href="mission.asp">Mission/Bylaws</a>';
menu = menu + '<a class="menuitem" href="events.asp">Upcoming Events</a>';
menu = menu + '<a class="menuitem" href="papers.asp">White Papers</a>';
menu = menu + '<a class="menuitem" href="FORUMdisplay.asp">Forum</a>';
menu = menu + '<a class="menuitem" href="links.asp">Useful Links</a></div>';

footer='<div class="footer">Copyright &copy; 2011 -  Michigan Alliance of Reading Professors<br><a href="admin.asp"><img src="images/Key.gif" border=0></a> <a href="http://www.cleverInSite.com" style="text-decoration:none; color:black;">another Clever InSite</a></div>'


