/* Hover Morpher 0.1 by WebTek */


window.addEvent('domready', function(){

	/* image morph */

	$each($$('.hovermorpherwidgetfore'), function(imagemorph) {

		var hover = $$('.hover');
		hover.setStyle('visibility', 'visible' );
		hover.set('opacity',0.001);
		imagemorph.morph({'background-position-y':'-76px'}); //couse of IEs bg positioning suxx

		imagemorph.addEvents({
			'mouseenter' : function() {
            if(this.getNext('.hover'))
            {
               this.getNext('.hover').set('morph', { duration: 350/*, link: 'chain'*/, transition: 'bounce:in' } );
               this.getNext('.hover').morph({ opacity: 1 });
               this.morph('.hovermorpherwidgetfore_hover');
            }
			 },
			'mouseleave' : function() {
            if(this.getNext('.hover'))
            {
               this.getNext('.hover').set('morph', { duration: 1000/*, link: 'chain'*/, transition: 'sine:out' } );
               this.getNext('.hover').morph({ opacity: 0.0001 });
               this.morph('.hovermorpherwidgetfore');
            }
			 }
		});
	});


	/* link morph */

	$each($$('a[class^=hovermorpherlinks]'), function(linkmorph) {

		var fader = linkmorph.get('class');

		linkmorph.addEvents({
			'mouseenter' : function() {
				linkmorph.set('morph', { duration: 200/*, link: 'chain'*/ } );
				this.morph('.'+fader+'_hover');
			 },
			'mouseleave' : function() {
				linkmorph.set('morph', { duration: 500/*, link: 'chain'*/ } );
				this.morph('.'+fader);
			 }
		});
	});

	/* fade in out morph */ // ( new, eddie IE optim. ) 

	$each($$('.fadeinout'), function(fadeinoutmorph) {
	
		$each(fadeinoutmorph.getChildren(), function(children) {
			children.set('opacity',0.001);
			children.setStyle('visibility', 'visible' );
		});
		fadeinoutmorph.set('opacity',0.001);

		fadeinoutmorph.addEvents({
			'mouseenter' : function() {
				$each(fadeinoutmorph.getChildren(), function(children) {
					children.set('morph', { duration: 350/*, link: 'chain'*/, transition: 'sine:in' } );
					children.morph({ opacity: 1 });
               $each(children.getChildren(), function(subchildren) {
                  subchildren.set('morph', { duration: 350/*, link: 'chain'*/, transition: 'sine:in' } );
                  subchildren.morph({ opacity: 1 });
               });
				});
				fadeinoutmorph.set('morph', { duration: 350/*, link: 'chain'*/, transition: 'sine:in' } );
				fadeinoutmorph.morph({ opacity: 1 });
			 },
			'mouseleave' : function() {
				$each(fadeinoutmorph.getChildren(), function(children) {
					children.set('morph', { duration: 1000/*, link: 'chain'*/, transition: 'sine:out' } );
					children.morph({ opacity: 0.0001 });
               $each(children.getChildren(), function(subchildren) {
                  subchildren.set('morph', { duration: 1000/*, link: 'chain'*/, transition: 'sine:out' } );
                  subchildren.morph({ opacity: 0.0001 });
               });
				});
				fadeinoutmorph.set('morph', { duration: 1000/*, link: 'chain'*/, transition: 'sine:out' } );
				fadeinoutmorph.morph({ opacity: 0.0001 });
			 }
		});

	});



});



