function forward(msg){
//Use AJAX to send mail

var xmlReq = null 

if (typeof window.ActiveXObject != 'undefined' ) 
{ 
	xmlReq = new ActiveXObject("Microsoft.XMLHTTP"); 
	//doc.onreadystatechange = displayState; 
} 
else 
{ 
   	xmlReq = new XMLHttpRequest(); 
 	//doc.onload = displayState; 
}

var str = msg;


var url = "";

url = "/forwardComplaint.cgi";

xmlReq.open("POST",url,true); 

xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 

xmlReq.send(str);

// Send a confirm message if necessary

alert('Your e-mail has been successfully sent!');

}


//Set a cookie for login...
function setCookie(tag,name,expires)
{
	var the_date = new Date("December 31, 2099");
	var the_cookie_date = the_date.toGMTString();
	the_cookie_date = ";expires=" + the_cookie_date;


	// If user does not want to be remembered, default to session cookie only
	if(expires == 1){
		the_cookie_date = "";
	}


	var the_cookie = tag + "=" + name;
	the_cookie = the_cookie + the_cookie_date; 
	document.cookie = the_cookie + ";"
}


function comment(msg, cookie){
//Use AJAX to send mail

var xmlReq = null 

if (typeof window.ActiveXObject != 'undefined' ) 
{ 
	xmlReq = new ActiveXObject("Microsoft.XMLHTTP"); 
	//doc.onreadystatechange = displayState; 
} 
else 
{ 
   	xmlReq = new XMLHttpRequest(); 
 	//doc.onload = displayState; 
}

var str = msg;


var url = "";

url = "/postComment.cgi";

xmlReq.open("POST",url,true); 

xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 

xmlReq.send(str);

// Send a confirm message if necessary

alert('Your comment has been submitted!');

//Set a cookie for login...
setCookie("handle", cookie, 0);

// Refresh page to show comment
var sURL = unescape(window.location.pathname);
window.location.replace( sURL );


}




//Get the cookie value
function getCookie(tag)
{
	var name = tag;
        if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(name);
		if (offset != -1) {
			offset += name.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) 
				end = document.cookie.length;
			return document.cookie.substring(offset, end);
		}
	}
	return 0;
}

function printEmailForm(id){
	var emailForm = '';
	emailForm = emailForm + '<br><form name="f">';
	emailForm = emailForm + '<table>';
	emailForm = emailForm + '<tr><td><b>Send To: </b></td><td><input type="text" name="r"></td></tr>';
	emailForm = emailForm + '<tr><td><b>Your E-mail:</b> </td><td><input type="text" name="f"></td></tr>';
	emailForm = emailForm + '<tr>';
	emailForm = emailForm + '<td><b>Message:</b></td><td><input type="text" name="s" size="40"></td>';
	emailForm = emailForm + '</tr><tr><td>&nbsp;</td><td align="left">';
	emailForm = emailForm + '<input type="button" value="Send E-mail" onClick="forward(\'r=\' + document.f.r.value + \'&s=\' + document.f.s.value + \'&f=\' + document.f.f.value + \'&id=' + id + '\'); document.getElementById(\'e5\').className=\'Collapse\';">';
	emailForm = emailForm + '</td></tr></table></form>';
	return emailForm;
}

function printCommentForm(id){
	var cookie = "";
	var handle = "";
	cookie = getCookie("handle=");
	if(cookie!=0){
	   handle = cookie;
        }
	var cForm = '';
	cForm = cForm + '<br><form name="c">';
	cForm = cForm + '<table>';
	cForm = cForm + '<tr><td><b>Your E-mail:</b><br><input type="text" name="f" value="' + handle + '"> (valid e-mail required)</td></tr>';
	cForm = cForm + '<tr><td><b>Add Comment:</b><br><textarea name=c cols=50 rows=5></textarea></td></tr>';
	cForm = cForm + '<tr><td align="left">';
	cForm = cForm + '<input type="button" value="Submit Comment" onClick="comment(\'f=\' + document.c.f.value + \'&c=\' + document.c.c.value + \'&id=' + id + '\', document.c.f.value); document.getElementById(\'e5\').className=\'Collapse\';">';
	cForm = cForm + '</td></tr></table></form>';
	return cForm;
}
