function load() {
	document.getElementById("indicator-photo").style.display="block";
	new Effect.Pulsate('indicator-photo', {duration: 6});
}

// show all pictures
function showPictures(placeID) {
	document.getElementById('centered').style.display='block';
	document.getElementById('load-pictures').style.display='block';
	new Ajax.Updater('load-pictures', 'http://www.grouprecipes.com/place_photos.php', {
	method: 'get',
	parameters: 'placeID=' + placeID,
	onComplete: document.getElementById('centered').style.display='none'
 });
}

// edit comment
function editComment(commentID, userID, username, timestamp){
	comment = $('edit_comment_field_' + commentID).value;
	rating = $('edit_rating_' + commentID).value;
	if(rating==1){
		$('rating_image_' + commentID).innerHTML = '<img src="http://www.grouprecipes.com/images/ratings/small_rating1.gif" style="margin:3px 0px 2px 0px;">';
	}else if(rating==2){
		$('rating_image_' + commentID).innerHTML = '<img src="http://www.grouprecipes.com/images/ratings/small_rating2.gif" style="margin:3px 0px 2px 0px;">';
	}else if(rating==3){
		$('rating_image_' + commentID).innerHTML = '<img src="http://www.grouprecipes.com/images/ratings/small_rating3.gif" style="margin:3px 0px 2px 0px;">';
	}else if(rating==4){
		$('rating_image_' + commentID).innerHTML = '<img src="http://www.grouprecipes.com/images/ratings/small_rating4.gif" style="margin:3px 0px 2px 0px;">';
	}else if(rating==5){
		$('rating_image_' + commentID).innerHTML = '<img src="http://www.grouprecipes.com/images/ratings/small_rating5.gif" style="margin:3px 0px 2px 0px;">';
	}
	new Ajax.Updater('comment_' + commentID, 'http://www.grouprecipes.com/place_edit_comment.php', {
	method: 'get',
	parameters: 'commentID=' + commentID + '&userID=' + userID + '&comment=' + encodeURIComponent(comment) + '&username=' + username + '&date=' + timestamp + '&rating=' + rating,
	onComplete: editAdded
 });
	
	function editAdded(){
		new Effect.Highlight('comment_' + commentID, {startcolor:'#ffff99', endcolor:'#ffffff', duration:2.0});	
		$('wall_form_' + commentID).style.display='none';
	}
}

// add new comment & rating
function addPlaceComment(placeID){
	field = document.getElementById("entry").value;
	rating = document.getElementById("rating").value;
	document.getElementById('place_comments').innerHTML = '<img src="http://www.grouprecipes.com/images/fork_loading.gif" style="position:relative; top:3px;"> <span class="loading">Loading</span>';
	new Ajax.Updater('place_comments', 'http://www.grouprecipes.com/add_place_comment.php', {
	method: 'get',
	parameters: 'rating=' + rating + '&entry=' + encodeURIComponent(field) + '&placeID=' + placeID,
	onComplete: document.getElementById('commentDiv').style.display='none'
 });
}

// add tags
function addTags(placeID){
	var tags = document.getElementById('tags').value;
	if(tags==''){
	document.getElementById('tags').style.border='1px solid #ff0000';
	return;
	}
	$('tag-list').innerHTML = '<img src="http://www.grouprecipes.com/images/fork_loading.gif" style="position:relative; top:3px;"> <span class="loading">Submitting</span>';
	new Ajax.Updater('tag-list', 'http://www.grouprecipes.com/add_place_tags.php', {
	method: 'get',
	parameters: 'placeID=' + placeID + '&tags=' + encodeURIComponent(tags),
	onComplete: document.getElementById('tag-this').style.display='none'
 });
}
 
// validate
function checkForm() {
entry = document.getElementById("entry").value;

  if(entry==""){
  hideAllErrors();
document.getElementById("entryError").style.display = "inline";
document.getElementById("entry").select();
document.getElementById("entry").focus();
  return false;
  }
  return true;
  } 
  function hideAllErrors() {
document.getElementById("entryError").style.display = "none"
  }

// check add photos form
function checkFormAddPhotos() {
field = document.getElementById("imgfile").value;

  if(field==""){
document.getElementById("addPhotoError").style.display = "inline";
document.getElementById("imgfile").select();
document.getElementById("imgfile").focus();
  return false;
  }
document.getElementById("addPhotoError").style.display = "none";
document.getElementById('centered').style.display='block';
  return true;
  } 

// check update photos form
function checkUpdateForm() {
field = document.getElementById("imgfile").value;

  if(field==""){
document.getElementById("updatePhotoError").style.display = "inline";
document.getElementById("imgfile").select();
document.getElementById("imgfile").focus();
  return false;
  }
document.getElementById("updatePhotoError").style.display = "none";
document.getElementById('centered').style.display='block';
document.updateForm.submit();
  return true;
  } 

// check comment form
function checkCommentForm() {
field = document.getElementById("entry").value;

  if(field==""){
document.getElementById("entryError").style.display = "inline";
document.getElementById("imgfile").select();
document.getElementById("imgfile").focus();
  return false;
  }
document.getElementById("entryError").style.display = "none";
document.getElementById('centered').style.display='block';
document.commentForm.submit();
  return true;
  } 

/* 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 + "');");
}