var xmlHttp;
function profile_ajax(opt){
try {xmlHttp=new XMLHttpRequest();}  // Firefox, Opera 8.0+, Safari  
	catch (e){try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer
		catch (e){try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e) {alert("Your browser does not support AJAX!");return false;}
			}
		}
		


var prof_id=document.getElementById('selected').innerHTML;




	if (opt == 1){ // Refresh Comments
	var queryString = "method=1&prof_id=" + prof_id + "&upd=" + new Date().getTime();
	xmlHttp.open("POST", "/includes_profiles/ajax_prof.php", true);

	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", queryString.length);
	xmlHttp.setRequestHeader("Connection", "close");

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var ajaxDisplay = document.getElementById('comments_display');
			ajaxDisplay.innerHTML = xmlHttp.responseText;
			}
		}
	xmlHttp.send(queryString);
	}


	if (opt == 2){ // Post Message
	document.getElementById('error').innerHTML=ticker;
	var message=encodeURIComponent(document.getElementById('post').value);
	
	var queryString = "method=2&post="+message+"&prof_id=" + prof_id + "&upd=" + new Date().getTime();
	xmlHttp.open("POST", "/includes_profiles/ajax_prof.php", true);
	
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", queryString.length);
	xmlHttp.setRequestHeader("Connection", "close");

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			var ajaxDisplay = document.getElementById('error');
			ajaxDisplay.innerHTML = xmlHttp.responseText;
			if(document.getElementById('posted')){clearpost();profile_ajax(1);ajaxDisplay.innerHTML = successtable + document.getElementById('posted').innerHTML + successtable2;setTimeout ("disappear('disappear')",2500);}
			}
		}
	xmlHttp.send(queryString);
	}
		
	
	
	if (opt == 3){ // Watch List functions
	var queryString = "method=3&prof_id=" + prof_id + "&upd=" + new Date().getTime();
	xmlHttp.open("POST", "/includes_profiles/ajax_prof.php", true);

	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", queryString.length);
	xmlHttp.setRequestHeader("Connection", "close");

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var ajaxDisplay = document.getElementById('watch_status');
			ajaxDisplay.innerHTML = xmlHttp.responseText;
			}
		}
	xmlHttp.send(queryString);
	}




	if (opt == 4){ // Set up profile edit
	var queryString = "method=4&prof_id=" + prof_id + "&upd=" + new Date().getTime();
	xmlHttp.open("POST", "/includes_profiles/ajax_prof.php", true);

	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", queryString.length);
	xmlHttp.setRequestHeader("Connection", "close");

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var ajaxDisplay = document.getElementById('profile_info');
			ajaxDisplay.innerHTML = xmlHttp.responseText;
			}
		}
	xmlHttp.send(queryString);
	}
	
	
	if (opt == 5){ //Edit Profile and return
	var prof_info=encodeURIComponent(document.getElementById('post_profile_info').value);
	var queryString = "method=5&profile_text=" + prof_info + "&prof_id=" + prof_id + "&upd=" + new Date().getTime();
	xmlHttp.open("POST", "/includes_profiles/ajax_prof.php", true);

	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", queryString.length);
	xmlHttp.setRequestHeader("Connection", "close");

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var ajaxDisplay = document.getElementById('profile_info');
			ajaxDisplay.innerHTML = xmlHttp.responseText;
			}
		}
	xmlHttp.send(queryString);
	}

}

function cancelprofileedit(){var oldtext=document.getElementById('cancelprofileedit').innerHTML;document.getElementById('profile_info').innerHTML=oldtext;}

