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

// Ajax Pagination
// http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes
Event.addBehavior.reassignAfterAjax = true;
Event.addBehavior({
})

function do_cancel( divid ){
	div = document.getElementById( divid );
	Effect.BlindUp( divid, { duration: 1.0 });
}

function show_loading( divid, image, type, opts ){
	
	if( image == null ){
		image = 'loading.gif';
	}else if( image == '' ){
		type = "text";
		opts = "";
	}

	div = document.getElementById( divid );
	if( type == null || type == "div" ){
		div.innerHTML = "<div style='text-align:center;vertival-align:middle;padding:2px;'><img src='/images/"+image+"' alt='Loading...' /></div>";
	}else if( type == "clear" ) {
		div.innerHTML = "";
	}else if( type == "tablerow" ) {
		div.innerHTML = "<tr><td colspan="+opts+" style='text-align:center;vertical-align:middle'><img src='/images/"+image+"' alt='Loading...' /></td></tr>";
	}else if( type == "image" ){
		div.innerHTML = "<img src='/images/"+image+"' alt='Loading...' />";
	}else if( type == "formfield" ){
		div.innerHTML = "<div class='formfield'><label>&nbsp;</label><img src='/images/"+image+"' alt='Loading...' /><div class='clear'></div></div>";
	}else if( type == "text" ){
		if( opts == null ){
			div.innerHTML = "Loading..";
		}else{
			div.innerHTML = opts;
		}
	}

	Effect.BlindDown( divid, { duration: 1.0 });
}

function goto_anchor( anchor_name ){
	location.href="#" + anchor_name;
}

function reset_on_focus( divid, value ){
	if( $(divid).value == value )
		$(divid).value = '';
}
