var xmlhttp;
var postId;
var container;
function pull(where,id,what){
	xmlhttp=null;
	container = where;
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null){
		xmlhttp.onreadystatechange=state_Change;
		xmlhttp.open("GET","index.php?post="+id+"&action="+what,true);
		xmlhttp.send(null);
	}
	else{
		alert("Your browser does not support XMLHTTP.");
	}
}

function state_Change(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			document.getElementById(container).innerHTML=xmlhttp.responseText;
	    }
		else{
			alert("Problem retrieving data:" + xmlhttp.statusText);
	    }
	}
	else{
		document.getElementById(container).innerHTML="<img src='template/images/ajax-loader2.gif' alt=''/>";	
	}
}

displayStyle = 'inline';

function show(xname,pid,action){
	document.getElementById(xname).style.display=displayStyle;
	if(action == 'comments'){
		show("inner_"+xname);
		pull("inner_"+xname,pid,action);
	}
}
function hide(xname){
	document.getElementById(xname).style.display='none';
}

function select_option(option_id,select_id){
	document.getElementById(select_id).selectedIndex = option_id;
}
