// functions for people.php
function recipeHonors(userID){
	$('honors').innerHTML = '<img src="http://www.grouprecipes.com/images/fork_loading.gif" alt="" /> <span class="loading">Loading</span>';
	new Ajax.Updater('honors', 'http://www.grouprecipes.com/get_people_honors.php', {
	method: 'get',
	parameters: 'userID=' + userID,
	onComplete: new Effect.Appear('honors')
 });
}

function addComment(to_userID) {
	$('comment_status').style.display='inline';
	$('comment_status').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" style="position: relative; top: 9px;" alt="" />';
    var comment = $('commentField').value;
	
	// validate
	if (comment == "") {
		$("commentsError").style.display = "inline";
		$("commentField").select();
		$("commentField").focus();
		$('comment_status').innerHTML='';
		return;
	}
	$("commentsError").style.display = "none";
	
	// make request
	new Ajax.Request('http://www.grouprecipes.com/people_post_comment.php', {
	method: 'get',
	parameters: 'to_userID=' + to_userID + '&comment=' + encodeURIComponent(comment),
	onComplete: function(response) {
		$('commentField').value ='';
		$('comment_status').innerHTML = '<img src="http://www.grouprecipes.com/images/tick.gif" alt="" /> <span class="green" style="font-weight:bold;">Comment Added!</span>';
		new Insertion.Top('commentAdded', response.responseText);
		new Effect.Highlight('comment_status', {startcolor:'#ffff99', endcolor:'#ffffff', duration:4.0});
		new Effect.Highlight('last_comment', {startcolor:'#ffff99', endcolor:'#ffffff', duration:4.0});
	}
 });
}

function editComment(wallID, owner_userID, username, timestamp){
	comment = $('edit_comment_field_' + wallID).value;
	new Ajax.Updater('comment_' + wallID, 'http://www.grouprecipes.com/people_edit_comment.php', {
		method: 'get',
		parameters: 'wallID=' + wallID + '&userID=' + owner_userID + '&comment=' + encodeURIComponent(comment) + '&username=' + username + '&date=' + timestamp,
		onComplete: function() {
			new Effect.Highlight('comment_' + wallID, {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});	
			$('wall_form_' + wallID).style.display='none';
		}
	});
}

function friends(desired_friend){
	document.getElementById('friend_req').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" alt="" />';
	new Ajax.Updater('friend_req', 'http://www.grouprecipes.com/friend_request.php', {
	method: 'get',
	parameters: 'desired_friend=' + desired_friend,
	onComplete: function() {
		new Effect.Highlight('friend_req', {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});
	}
 });
}

function friends2(desired_friend){
	document.getElementById('friend_req2').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" alt="" />';
	new Ajax.Updater('friend_req2', 'http://www.grouprecipes.com/friend_request.php', {
	method: 'get',
	parameters: 'desired_friend=' + desired_friend,
	onComplete: function() {
		new Effect.Highlight('friend_req2', {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});
	}
 });
}

function searchit(userID){
	var keywords = $('SearchField2').value;
	document.getElementById('search_results').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" alt="" />';
	new Ajax.Updater('search_results', 'http://www.grouprecipes.com/search_users_recipes_small.php', {
		method: 'get',
		parameters: 'keywords=' + encodeURIComponent(keywords) + '&userID=' + userID,
		onComplete: function(){
			new Effect.Highlight('search_results', {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});
		}
	});
}

function searchit2(userID){
	$('browse_user_tags').style.display='none';
	$('search_results2').style.display='block';
	var keywords = document.getElementById('SearchField3').value;
	document.getElementById('search_results2').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" alt="" />';
	new Ajax.Updater('search_results2', 'http://www.grouprecipes.com/search_users_recipes_submitted.php', {
		method: 'get',
		parameters: 'keywords=' + encodeURIComponent(keywords) + '&userID=' + userID,
		onComplete: function() {
			new Effect.Highlight('search_results2', {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});
		}
	});
}

function userTags(userID){
	document.getElementById('browse_user_tags').innerHTML = '<img src="http://www.grouprecipes.com/images/spinner.gif" alt="" />';
	$('search_results2').style.display='none';
	new Ajax.Updater('browse_user_tags', 'http://www.grouprecipes.com/people_browse_user_tags.php', {
		method: 'get',
		parameters: 'userID=' + userID,
		onComplete: function() {
			new Effect.Appear('browse_user_tags');
		}
 });
}

function refineFlavor(tag, userID){
	new Ajax.Updater('browse_user_tags', 'http://www.grouprecipes.com/people_tag_refine.php', {
	method: 'get',
	parameters: 'tag=' + tag + '&userID=' + userID,
	onComplete: function(){
		new Effect.Highlight('browse_user_tags');
	}
 });
}

/* popit */
function popIt(URL,width,height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height= " + height + "');");
}