var switch_contact_form = function() {
    var parent = $('contact_us');
	if (this.shiftAmount == null) {
	    this.shiftAmount = -parseFloat(Element.getStyle(parent,'top') || '0');
	} else {
    	this.shiftAmount = -this.shiftAmount;
	}
	new Effect.MoveBy(parent, this.shiftAmount, 0);
};

var myrules = {
	'.hover' : function(element){
	    element.onmouseover = function(){
            this.src = this.src.replace(/(\.[^.]+)$/, '_hover$1');
	    };
	    element.onmouseout = function(){
	        this.src = this.src.replace(/_hover(\.[^.]+)$/, '$1');
	    };
	},
	'#contact_us_tab_img' : function(element) {
	   element.onclick = switch_contact_form;
	}
};

Behaviour.register(myrules);

function hideContactForm() {
    var contact_tab = $('contact_us_tab_img');
    var parent = $('contact_us');
    var message_height = 85;
    new Effect.MoveBy(parent, -(contact_tab.shiftAmount - message_height), 0);
    contact_tab.shiftAmount = -contact_tab.shiftAmount;

    var reset_form = function() {
        new Ajax.Updater('contact_us_form', '/contact/show_form');
    }

    var close_tab = function() {
        new Effect.MoveBy(parent, -message_height, 0);
        setTimeout(reset_form, 2000);
    }
    setTimeout(close_tab, 2000);
}