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

//Object.extend(String.prototype, 









//
//function init() {
//
//}
///* */
//function obj_name() {
//	return $('object_name').value;
//}
//function obj_name_pl() {
//	return obj_name()+'s';
//}
//function obj_name_id() {
//	return obj_name()+'_id';
//}
///* Default actions and handlers */
//function item_create() {
//	alert(obj_name_id());
//	form = document.forms[0];
//
//	select = $(obj_name_id());
//	select.appendChild(new Option('',''));
//
//	Form.getInputs(document.forms[0]).each(function(input) { 
//												if (!is_button(input)) Field.clear(input); 
//										  });
//	select.selectedIndex = select.length-1;
//	first = Form.getInputs(form).detect(function(value, index) {
//												return !is_button(value);
//										   });
//	Field.focus(first);
//	
//}
//function item_save_success(request) {
//	r = request.responseText;
//	alert(r);
//	data = eval('('+r+')');
//	if (data) {
//		$(data.select).length = $(data.select).length-1;
//		select_insert(data);
//	}
//}
//function item_delete() {
//	var doit = confirm("Are you sure you want to delete "+$(obj_name()+'_title').value+"?");
//	var doit = confirm("Are you sure you want to delete?");
//	if (doit) {
//		new Ajax.Request('/'+obj_name_pl()+'/destroy/'+$(obj_name_id()).value, 
//							{asynchronous: true, 
//							 evalScripts: true, 
//							 onSuccess: function(request) {
//											item_delete_success(request)
//										}
//							}
//						 );
//	}
//}
//function item_delete_success(request) {
//	alert(request.responseText);
//	data = eval( "("+request.responseText+")" );
//	if (data) {
//		var sel = $(data.select);
//		opts = $A(sel.children);
//		var deleted = opts.detect(function(child, index) { return child.value == data.id });
//		Form.getInputs(document.forms[0]).each( function(input) { if (!is_button(input)) Field.clear(input); } );
//		sel.removeChild(deleted);
//	}
//}
//
//function select_item(id) {
//	new Ajax.Request('/'+obj_name_pl()+'/select/'+id, {onSuccess: select_news_success, evalScripts: true});
//}
//function select_item_success(r) {
//	text = r.responseText;
//	$('edit').innerHTML=text;
//}
///**
// * Model Specific Actions and Handlers
// */
// 
///* News */
//function select_news(id) {
//	new Ajax.Request('/news/select/'+id, {onSuccess: select_news_success, evalScripts: true});
//}
//function select_news_success(r) {
//	text = r.responseText;
//	$('edit').innerHTML=text;
//}
//
///* Workshop */
//function select_workshop(id) {
//	new Ajax.Request('/workshops/select/'+id, {onSuccess: select_workshop_success, evalScripts: true});
//}
//function select_workshop_success(r) {
//	text = r.responseText;
//	$('edit').innerHTML=text;
//}
//
///* Picture */
//function select_picture(id) {
//	new Ajax.Request('/pictures/select/'+id, {onSuccess: select_picture_success, evalScripts: true});
//}
//function select_picture_success(r) {
//	text = r.responseText;
//	$('edit').innerHTML=text;
//}
//
//
//
///* Util */
//function select_insert(data) {
//	new Insertion.Bottom(data.select, data.option);
//	$(data.select).selectedIndex = $(data.select).length-1;
//}
//
//function is_button(obj) {
//	if (obj.type) 
//		return obj.type == 'button' || obj.type == 'submit' || obj.type == 'reset'
//	else
//		return false;
//}