// JavaScript Document

/** Create a Pop-In from the shipping_info div;
 *
 **/
var Shipping = new Class({
	'initialize':function() {
		this.links=$(document).getElements('.shipping_link');
		this.div=$('shipping_info');
		if(this.links && this.div) {
			this.hide();
			this.links.forEach(function(item){
				item.addEvents({
					'click':function(event) {
						event.stop();
						this.show(item);
					}.bindWithEvent(this),
					'mouseenter':function(){
						this.show(item);
					}.bindWithEvent(this)
				});						
			}.bind(this));
			this.div.addEvents({
				'mouseleave':function(){
					this.hide();
				}.bindWithEvent(this),
				'click':function() {
					this.hide();
				}.bindWithEvent(this)
			});
			
		}
	},
	'hide':function() {
		this.div.setStyle('display','none');
	},
	'show':function(item) {
		this.position=item.getPosition();
		this.div.setStyles({
				'position':'absolute',
				'top':this.position.y,
				'left':this.position.x-200,
				'width':400,
				'background-color':'white',
				'border':'2px solid grey',
				'padding':'0 5px',
				'display':'block'
			});
	}
});
$(document).addEvent('domready',function() {
	var sqn_shipping= new Shipping();
});