jQuery(document).ready(function(){
	jQuery("#selectPdf").change(function(){
		var title = jQuery("#selectPdf option:selected").text();
		jQuery("#pdfMakeTitle").val(title);
	});
	jQuery("#addPdf").click(function(e){
		e.preventDefault();
		// send json to php to get html to put in dialogue				
		var title = jQuery("#pdfMakeTitle").val();
		if(title.length > 0){	
			var data = {
				addPostData:jQuery("#selectPdf option:selected").val(),
				cmd:"add",
				givenTitle:title
			}
			jQuery.post("/wp-content/plugins/list-pdf/list-pdf-controller.php",data,function(result){
				//alert(result["html"]);
				jQuery("#loadedPdfs").append(result["html"]);
				jQuery(".removePdf").click(function(){				
					jQuery(this).parent().remove();
				});
			},"json");	
		}else{
			alert("Please enter a title for this pdf.");
		}
	});
	jQuery("#loadedPdfs input").focus(function(){
		jQuery(this).animate({fontSize:"16px"},500);
	});
	jQuery("#loadedPdfs input").blur(function(){
		jQuery(this).animate({fontSize:"11px"},500);
	});
	jQuery(".removePdf").click(function(e){
		jQuery(this).parent().remove();	
	});	

});
