// JavaScript Document

/*	==========================================================

	Class: 		Callout
	Use:		Performs operations on the callouts boxes
	Version:	v1
	By:			Dave Calvert

========================================================	*/

var Callout = Class.create();
Callout.prototype = {
    
    initialize: function () {
		if($$('.callouts-panel-wrapper') !='' ) {
			$$('.callouts-panel-wrapper').each(this.setupcallouts.bind(this));
		} else {
			return false;
		}
    },
	
	setupcallouts: function (k,v){

		Event.observe($(k),'mouseover',this.open.bindAsEventListener(this));
		Event.observe($(k),'mouseout',this.close.bindAsEventListener(this));
		
	},
	
	open: function (e) {	

		elt = Event.element(e);
		el = $(elt).up();
	
		if (typeof(el) == 'object') {

			if(el.getStyle('top').replace('px','') == '-170' ) {
				new Effect.Move(el.id , { 
									x: 0, y: 0, mode: 'absolute', duration:0.5,
									queue: { scope: el.id.toString(), position:'end' }
				});
			}
		}
		
	},
	
	close: function (e) {
	
		elt = Event.element(e);
		el = $(elt).up();

		if (typeof(el) == 'object') {
			new Effect.Move(el.id, {
									x: 0, y: '-170', mode: 'absolute', duration:0.3,
									queue: { scope: el.id.toString(), position:'end' }
			});
		}
		
	}
	
};
