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

// Highlight validation errors. Called when validation fails
function showErrors() 
{
	$$("span.error").each(function(e) {
			Element.hide(e);
			new Effect.Appear(e);
			})
}
                       
// Called when admin wants to toggle admin content
function toggle_admin()
{
	$$('.admin').each(function (i) { i.toggle(); })
}

// Called when user wants to cancel the current action
function cancel_action() 
{
	// We could be inside a modalbox or this could be a normal HTML action
	// in which case we have to go back in history.
  // check to see modalbox is active
	if (document.getElementById('MB_content'))
		Modalbox.hide();
	else
		history.back();
}

// Init Control.Tabs
Event.observe(window,'load',function(){
		$$('.tabs').each(function(tabs){
			window.product_tabs = new Control.Tabs(tabs);
			});
		});

// Public behaviors
var pub_behaviors = {
	'div.picturerow img': function(i) {
		i.onmouseover = function(e) {
			$('cover-picture').src = Element.readAttribute(i, 'medium_src');
		}
	}
}

Behaviour.register(pub_behaviors);
