/*------------------------------------------------------------------------

# JA Pyrite for Joomla 1.5 - Version 1.0 - Licence Owner JA20654

# ------------------------------------------------------------------------

# Copyright (C) 2004-2008 J.O.O.M Solutions Co., Ltd. All Rights Reserved.

# @license - Copyrighted Commercial Software

# Author: J.O.O.M Solutions Co., Ltd

# Websites:  http://www.joomlart.com -  http://www.joomlancers.com

# This file may not be redistributed in whole or significant part.

-------------------------------------------------------------------------*/

var JAMenuhover = new Class({	

	initialize: function(elements, options) {

		this.options = Object.extend({

			fade:					true,

			elastic:			true,

			elastic_dir:	'up',

			duration:			700,

			transition:		Fx.Transitions.Pow.easeOut,

			animout:			'JAMenuhover_center',

			animin:				'JAMenuhover_fade'

		}, options || {});

		

		pos = {'down':'top','up':'bottom','right':'left','left':'right'};

		size = {'down':'height','up':'height','right':'width','left':'width'};

		this.elements = $$(elements);

		this.animout = eval('new '+this.options.animout+'()');

		this.animin = eval('new '+this.options.animin+'()');

		this.elements.each (function (el){

			if (el.getParent().hasClass('active')) return;

			elp = el.getParent();

			el.setStyles ({

			position: 'relative',

			width: elp.offsetWidth-el.getStyle('padding-left').toInt()-el.getStyle('padding-right').toInt(),

			height: elp.offsetHeight-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt()

			});



			el.bg = new Element ('div');

			el.bg.addClass ('ja-menu-maskbg');

			el.bg.setStyles ({

				opacity: 0

			});

			this.animout.init(el);

			el.getChildren().setStyles({

				position: 'relative',

				'z-index': 2

			});

			el.bg.injectTop (el);

			el.fx = new Fx.Styles (el.bg, {duration: this.options.duration,transition: this.options.transition});

			el.getParent().addEvent ('mouseenter', function(){

				el.addClass('jahover');

				el.fx.stop();

				var obj = this.animout.getFxOut(el);

				if (this.options.fade) {

					obj['opacity'] = [0,1];

				}

				

				el.fx.stop();

				el.fx.start(obj);

			}.bind(this));

			el.getParent().addEvent ('mouseleave', function(){

				el.removeClass('jahover');

				var obj = this.animin.getFxIn(el);

				if (this.options.fade) {

					obj['opacity'] = [1,0];

				}

				el.fx.stop();

				el.fx.start(obj);

			}.bind(this));

		},this);		

	}

});



JAMenuhover_zoomout = new Class ({

	getFxOut: function (el) {

		if (el.bg.offsetHeight<=3 || el.bg.offsetWidth<=3 || el.bg.getStyle('opacity')<0.1) {

			this.init(el);

		}

		var cor = el.bg.getCoordinates();

		var obj = {

			top: [el.bg.offsetTop, 0],

			left: [el.bg.offsetLeft, 0],

			width: [el.bg.offsetWidth, el.offsetWidth],

			height: [el.bg.offsetHeight, el.offsetHeight]

		}

		return obj;

	}

});

JAMenuhover_fade = JAMenuhover_zoomout.extend ({

	init: function (el) {

		var t,l,b,r;

		t=b=l=r=0;

		var cor = el.getCoordinates();		

		el.bg.setStyles({

			top: t,

			left: l,

			width: cor.width,

			height: cor.height,

			opacity: 0

		});

	},

	getFxOut: function (el) {

		if (el.bg.offsetHeight<=3 || el.bg.offsetWidth<=3 || el.bg.getStyle('opacity')<0.1) {

			this.init(el);

		}

		var cor = el.bg.getCoordinates();

		var obj = {

			top: [el.bg.offsetTop, 0],

			left: [el.bg.offsetLeft, 0],

			width: [el.bg.offsetWidth, el.offsetWidth],

			height: [el.bg.offsetHeight, el.offsetHeight],

			opacity: [0,1]

		}

		return obj;

	},

	getFxIn: function (el) {

		return {opacity:[1,0]};

	}

});

JAMenuhover_center = JAMenuhover_zoomout.extend ({

	init: function (el) {

		var t,l,b,r;

		var cor = el.getCoordinates();

		t=b=cor.height / 2;

		l=r=cor.width / 2;

		el.bg.setStyles({

			top: t,

			left: l,

			width: 0,

			height: 0

		});

	},

	getFxIn: function (el) {

		var t,l,b,r;

		var cor = el.bg.getCoordinates();

		t=b=el.offsetHeight / 2;

		l=r=el.offsetWidth / 2;

		var obj = {

			top: [0, t],

			left: [0, l],

			width: [el.bg.offsetWidth, 0],

			height: [el.bg.offsetHeight, 0]

		};

		return obj;

	}

});

JAMenuhover_center_h = JAMenuhover_zoomout.extend ({

	init: function (el) {

		var t,l,b,r;

		var cor = el.getCoordinates();

		t=b=cor.height / 2;

		l=r=0;

		el.bg.setStyles({

			top: t,

			left: l,

			width: cor.width,

			height: 0

		});

	},

	getFxIn: function (el) {

		var t,l,b,r;

		var cor = el.bg.getCoordinates();

		t=b=el.offsetHeight / 2;

		l=r=0;

		var obj = {

			top: [0, t],

			left: [0, l],

			height: [cor.height, 0]

		};

		return obj;

	}

});

JAMenuhover_center_v = JAMenuhover_zoomout.extend ({

	init: function (el) {

		var t,l,b,r;

		var cor = el.getCoordinates();

		t=b=0;

		l=r=cor.width / 2;

		el.bg.setStyles({

			top: t,

			left: l,

			width: 0,

			height: cor.height

		});

	},

	getFxIn: function (el) {

		var t,l,b,r;

		var cor = el.bg.getCoordinates();

		t=b=0;

		l=r=el.offsetWidth / 2;

		var obj = {

			top: [0, t],

			left: [0, l],

			width: [cor.width, 0]

		};

		return obj;

	}

});

JAMenuhover_topdown = JAMenuhover_zoomout.extend ({

	init: function (el) {

		el.bg.setStyles({

			top: 0,

			left: 0,

			width: el.offsetWidth,

			height: 0

		});

	},

	getFxIn: function (el) {

		var t,l,b,r;

		t=el.offsetHeight;

		b=l=r=0;

		var obj = {

			top: [0, t],

			left: [0, l],

			height: [el.bg.offsetHeight, 0]

		};

		return obj;

	}

});

JAMenuhover_bottomup = JAMenuhover_zoomout.extend ({

	init: function (el) {

		el.bg.setStyles({

			top: el.offsetHeight,

			left: 0,

			width: el.offsetWidth,

			height: 0

		});

	},

	getFxIn: function (el) {

		var t,l,b,r;

		var cor = el.bg.getCoordinates();

		b=el.offsetHeight;

		t=l=r=0;

		var obj = {

			top: [0, t],

			left: [0, l],

			height: [el.bg.offsetHeight, 0]

		};

		return obj;

	}

});