$(document).ready(function(){

	$('.add_definition').click(function() {
		var the_definition = prompt("Please provide a new definition:", "");
		if ( the_definition == null ) {
			return false;
		}
		else {
				
			//location.href = "http://intranet/gallery/add_album_sql.php?album_title="+album_title;
			/*$.ajax({
				type: "GET",
				url: "/wp-content/plugins/image_of_the_day/php/add_album.php?album_title="+album_title,
				dataType: "script"
				 success: function(msg){
					alert( "Data Saved: " + msg );
				}
			});*/
			var query = this.getAttribute("href").split("?")[1];
			

			term_id = query.split("=")[1];
			
			$.post("/wp-content/themes/cantoresliterati/insert_definition.php",	{ 
				term_id: term_id, 
				definition:  the_definition },
			
		  	//data = what is returned from the server i.e. the new album ID
				function(data){
				
					add_to_page(term_id, the_definition); 
				
			
		  	});
			
		  return false;
		}
 });

	$('#fontResizeSelector').change(function() {
		var new_size = this.value;
		setFontsize(new_size);
		$.cookie('fontsize', new_size, {expires: 7, path: '/'});
	 });
	
	/*var fs_c = $.cookie('fontsize');
	if ($.cookie('fontsize')) {
		setFontsize(fs_c)
		if (document.getElementById('fontResizeSelector') ) {
			//make the option id which = the cookie value be selected
			$('#'+fs_c).attr("selected", "selected");							
		}
	}*/

});

function add_to_page(term_id, the_definition) {
	new_term_id  = term_id;
	var new_definition = "<p class='fade'>"+the_definition+"</p>";
	$('#term-'+new_term_id+ '+dd').append("<p>"+new_definition+"</p>");
}

function setFontsize(size) {

	$('body').attr("class", size);
	
}