function getHTTPObject(){                                                                          
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");                        
   else if (window.XMLHttpRequest) return new XMLHttpRequest();                                    
   else {                                                                                          
      alert("Your browser does not support AJAX.");                                                
      return null;                                                                                 
   }                                                                                               
}                                                                                                  
                                                                                                   
// Change the value of the outputText field                                                        
function setOutput(outputid){ 
	 document.getElementById('fave'+outputid).value = 'Thanks!';  
                                                                                            
                                                                                                   
}                                                                                                  
                                                                                                   
// Implement business logic                                                                        
function doWork(messageid){                                                                                 
    httpObject = getHTTPObject();                                                                  
    if (httpObject != null) {                                                                      
        httpObject.open("GET", "/lib/faveThis.php?inputText="                                          
                        +messageid, true);                        
        httpObject.send(null);                                                                     
        httpObject.onreadystatechange = setOutput(messageid);                                                 
    }                                                                                              
}                                                                                                  
                                                                                                   
var httpObject = null;                                                                             
                                                                                                   
function elemOn(elem_id){
	if(document.getElementById(elem_id))
		document.getElementById(elem_id).style.display = "block";
}
function cancelReply(elem_id){
	if(document.getElementById(elem_id))
		document.getElementById(elem_id).style.display = "none";
}
function replyToPost(elem_id,parent_id){

	html = '';
	html+= '<p style="font-weight:normal;font: bold 10px sans-serif;">';
	html+= '&nbsp &nbsp You need to enter Subject and Message for a valid post.';
	html+= '<form class="twocols" action="/board/post.php" method="post" id="messageboardpost" onsubmit="return true;" style="margin:0px;">';
	html+= '<div style="font-size:11px;">';
	html+= 'Subject:<br>';
	html+= '<input type="text" name="subject" maxlength="255" style="width: 530px;" value=""></div>';
	html+= '<div style="font-size:11px;">';
	html+= '<br>Message:<br>';
	html+= '<textarea style="font-weight:normal;font: 12px verdana;" cols="85" name="message" rows="9"></textarea></div>';
	html+= '<div style="font:bold 12px sans-serif;margin-top:2px;">';
	html+= '<input type="checkbox" name="previewon" style="margin:0px;padding:0px;font-size:14px;"/>Preview';
	html+= '<input type="checkbox" name="favethis" style="margin:0px;padding:0px;font-size:14px;"/>Fave it';
	html+= '<input type="submit" value=" Post Message " style="margin:0px;padding:0px;font-size:14px;" />';
	html+= '<input type="hidden" name="postingtype" value="-1"/>';
	html+= '<input type="hidden" name="childOf" value="';
	html+= parent_id+'"/>';
	html+= '<input type="hidden" name="editing" value="false"/>';
	html+= '<input type="hidden" name="displaymess" value="false"/>';
	html+= '<br><br>';
    html+= '</form>';   
    html+= '<a style="color:red;" href="javascript:closeAll();" onClick="window.status=\'reply\'">cancel</a>';

    document.getElementById(elem_id).innerHTML=html;

	for( var i = 1; i <= 200; i++ )
		cancelReply( 'div'+i );
	elemOn( elem_id );
}
function showeOne(elem_id){
	for( var i = 1; i <= 3; i++ )
		cancelReply( 'div'+i );
	elemOn( elem_id );
}
lastone='empty';
function showIt(lyr)
{
	if (lastone!='empty') lastone.style.display='none';
	lastone=document.getElementById(lyr);
	lastone.style.display='block';
}
function closeAll()
{
	for( var i = 1; i <= 200; i++ )
		cancelReply( 'div'+i );
}
