//11/3/11 removed status updates 

function ChangeFormAction(obj,anchor) {
var lnk=document.getElementById(obj);
lnk.action='activity.asp' + anchor;
}

function RemoveCheckbox(obj,answer_id,form_name,question_order,userid,usertype)
	{	
	obj.disabled = true;	
    var currentTime = new Date()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()

    var suffix = "AM";
    if (hours >= 12) {
    suffix = "PM";
    hours = hours - 12;
    }
    if (hours == 0) {
    hours = 12;
    }

    if (minutes < 10)
    minutes = "0" + minutes
    
    var rightnow = hours + ":" + minutes + " " + suffix
    
    toggleBox('A'+ answer_id,0) //hide div
    alert('Thanks. Post is now marked as read.');
    //do not use a <p> - ie js error
    var cls = "mentee_checkbox";
    if (usertype=="mentee") cls = "mentor_checkbox";
    var msg = "<span class=\"" + cls + "\">" + userid + " read this post today at " + rightnow + "<\/span>";
    document.getElementById('U' + answer_id).innerHTML = msg;
    //eval ('form_name.S' + question_order + '.focus');        
}
	
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


function openPage (url, wwidth, wheight, title, scroll, size) {
	ns4 = (document.layers)? true:false
	var scrolling = ',scrollbars=' + scroll;
        var sizing = ',resizable=' + size;
	if (ns4) wheight = parseInt(wheight) + 30;
	opts = 'width=' + wwidth + ',height=' + wheight + scrolling + sizing + ',top=100,screenY=100,left=100,screenX=100,';
	popupWin = window.open(url, title, opts);
}	


//------------------- AJAX SECTION -----------------

function ReadCheck(answer_id,user_type)

  {  
  var xmlHttp;
  try
    {    
    // Firefox, Opera 8.0+, Safari    
    xmlHttp=new XMLHttpRequest();    
    }
  catch (e)
    {    
    // Internet Explorer    
    try
      {      
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
      }
    catch (e)
      {      
      try
        {        
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
        }
      catch (e)
        {       
        alert("Sorry, your browser does not support AJAX!");        
        return false;        
        }      
      }    
    }
    xmlHttp.onreadystatechange=function()
    {
	  if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
		}
    }
    xmlHttp.open("GET","update_activity_read.asp?answer_id=" + answer_id + "&user_type=" + user_type);
    //alert ("update_activity_read.asp?answer_id=" + answer_id + "&user_type=" + user_type)
    xmlHttp.send(null);
}

function SetPref(val) {
    //alert(val);
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari    
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer    
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Sorry, your browser does not support AJAX!");
                return false;
            }
        }
    }
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            //alert(xmlHttp.responseText);
        }
    }
    xmlHttp.open("GET", "update_preference.asp?val=" + val);
    //alert("update_preference.asp?val=" + val);                         
    xmlHttp.send(null);
}

//------------------- AJAX SECTION END -----------------


function textCounter(field, maxlimit) {
	if (field.value.length > 6690){ 
		field.value = field.value.substring(0, maxlimit);		
		alert('No more than ' + maxlimit + ' characters, please!')}
}
function FormValidation(theForm)
{
	{
		//DO NOT REMOVE!! place validation here if needed
	}
	
} /*end of function*/			  

function CheckRejection(form)
{
    agree = confirm("Are you sure?  Until the unit is approved the mentee will not be able to continue.  The mentee will be told that the unit was not approved and needs more work.  Please be sure to make a post or email your mentee so they will know what needs to be done to complete the current unit.  Thanks!") 
    if (agree){ 
        document.form.submit(); 
    } 
    else { 
        return(false); 
    } 
}

