var xmlHttp
var pic_id

//------------------------------------------------------------------------
function showComments(pic_id) {
	xmlHttpComment=GetXmlHttpObject()
	if (xmlHttpComment==null) {
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="http://www.stuffonmymate.com/comment.php"
	url=url+"?id="+pic_id
	xmlHttpComment.onreadystatechange=stateChangedComment
	xmlHttpComment.open("POST",url,true)
	xmlHttpComment.send(null)
} 

function stateChangedComment()  { 
	if (xmlHttpComment.readyState==4 || xmlHttpComment.readyState=="complete") { 
		document.getElementById("comments_"+pic_id).innerHTML=xmlHttpComment.responseText
		document.getElementById("comments_toggle_"+pic_id).innerHTML='<a href="javascript:pic_id='+pic_id+';hideComments(\''+pic_id+'\');">Hide comments</a>'
	} 
} 
//------------------------------------------------------------------------
//------------------------------------------------------------------------
function hideComments(pic_id) {
	document.getElementById("comments_"+pic_id).innerHTML=''
	document.getElementById("comments_toggle_"+pic_id).innerHTML='<a href="javascript:pic_id='+pic_id+';showComments(\''+pic_id+'\');">Show comments</a>'
} 
//------------------------------------------------------------------------
//------------------------------------------------------------------------
function postComment(pic_id,comment,user_name,security_code) {
	xmlHttpComment=GetXmlHttpObject()
	if (xmlHttpComment==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="http://www.stuffonmymate.com/post_comment.php"
	url=url+"?id="+pic_id+"&comment="+escape(comment)+"&user_name="+user_name+"&security_code="+security_code
	xmlHttpComment.onreadystatechange=stateChangedComment	
	xmlHttpComment.open("POST",url,true)
	xmlHttpComment.send(null)
} 

function stateChangedComment()  { 
	if (xmlHttpComment.readyState==4 || xmlHttpComment.readyState=="complete") { 
		document.getElementById("comments_"+pic_id).innerHTML=xmlHttpComment.responseText
		document.getElementById("comments_toggle_"+pic_id).innerHTML='<a href="javascript:pic_id='+pic_id+';hideComments(\''+pic_id+'\');">Hide comments</a>'
	} 
}  
//------------------------------------------------------------------------




//------------------------------------------------------------------------
function GetXmlHttpObject() { 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 
//------------------------------------------------------------------------