var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
  try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (E) {
    xmlhttp = false;
   }
  }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

function mailECourse(url, elementID) {
    var targetElement = document.getElementById(elementID);
	xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4) {
	  	targetElement.innerHTML =  '| Message Sent';
      }
    }
    xmlhttp.send(null);
}

/*function buildURL(base) {
	var ceiling = document.newUserForm.elements.length;
	var i = 0;
	var getURL = new String;
	getURL = base + "?";
	for(i = 0; i < ceiling; i++) {
		getURL += document.newUserForm.elements[i].name + "=" +  document.newUserForm.elements[i].value + "&";
	}
	makeRequest(getURL, 'messages');
}*/


function flipNotif(threadID) {
	var url = '/community/actions/disc_flipnotif.php?threadid=' + threadID;
    var targetElement = document.getElementById('notifLink');
	var msgElement = document.getElementById('notifLinkMsg');
	xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4) {
	  	if(xmlhttp.responseText == '1') {
			msgElement.innerHTML = 'Your changes have been saved';
			//document.getElementById('notify_me').checked = true;
   targetElement.innerHTML =  '<img src="images/email-notify-disable.gif" width="28" height="23" border="0" alt="Disable Notifications" align="absmiddle" />Click here to <strong>stop</strong> receiving notifications for this thread.';
			setTimeout('clearElem("notifLinkMsg")', 2000);
		} else {
			msgElement.innerHTML = 'Your changes have been saved';
			//document.getElementById('notify_me').checked = false;
   targetElement.innerHTML =  '<img src="images/email-notify-enable.gif" width="28" height="23" border="0" alt="Enable Notifications" align="absmiddle" />Click here to be notified when there are new replies to this thread.';
			setTimeout('clearElem("notifLinkMsg")', 2000);
		}
      }
    }
    xmlhttp.send(null);
	
	return;
}

function clearElem(elementId) {
	var e = document.getElementById(elementId);
	e.innerHTML = '';
	return;
}
