// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function change_cat(new_cat) {
	$(category+'_tab').style.fontWeight = "normal";
	Element.hide(category);
	cur_page = 0;
	category = new_cat;
	$(new_cat+'_tab').style.fontWeight = "bold";
	Effect.SlideDown(new_cat);
	return false;
}

function next_page(cat) {
  new_page = cur_page + 1;
  if(new_page > count[cat]) {
    new_page = 0;
  }
  
  hiding = $(cat+'_'+cur_page);
  showing = $(cat+'_'+new_page);
  Element.hide(hiding);
  Effect.Appear(showing);
  cur_page = new_page;
  return false
}

function prev_page(cat) {
  new_page = cur_page - 1;
  if(new_page < 0) {
    new_page = count[cat];
  }
  
  hiding = $(cat+'_'+cur_page);
  showing = $(cat+'_'+new_page);
  Element.hide(hiding);
  Effect.Appear(showing);
  cur_page = new_page;
  return false;
}

function add_comment(entry_id) {
	show_comment_add = function() {
		Element.show('entry'+entry_id+'_comments');
	}
	new Ajax.Updater('entry'+entry_id+'_comments',
									 '/comment_entry_form?id='+entry_id,
									 {asynchronous:true, evalScripts:true, insertion:Insertion.Bottom, onLoaded:show_comment_add});
}

/*Facebook share function*/
function fbs_click(url, title) {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
