
	var t = 0;
	var l = 0;
	var popUp = null;


var Pop = 
{


	
	
	
	getBounds:function(mouse) {
		
		//trace(mouse.y + 40 + parseInt(popUp.getStyle('height')) + " h == " + getHeight());
		if( (mouse.y + 40 + parseInt(popUp.getStyle('height'))) > getHeight() ) {
			//t = getHeight() - ( parseInt(popUp.getStyle('height')) + 20);
			
			t = mouse.y - (40 + parseInt(popUp.getStyle('height')));
			
		} else {
			t = mouse.y + 20;
		}
				
				
		if( (mouse.x + 40 + parseInt(popUp.getStyle('width'))) > getWidth() ) {
			//l = getWidth() - ( parseInt(popUp.getStyle('width')) + 20);;
			
			l = mouse.x - (40 + parseInt(popUp.getStyle('width')));
			
		} else {
			l = mouse.x + 20;
		}
		
		
	},
	
	

	/*
	**
	** TODO:	
	**
	**
	*/
	init:function() {
			

		
		var aPreLoad = new Array();
		var aPreLoadi = 0;
		
		
		var menuItems = $$('.vignette img');
		

		
		popUp = new Element('div', { 'id': 'pop-up' });
		popUp.setOpacity(0);
		popUp.injectBefore('menu');
		
		
		//var fi = new Fx.Style(popUp, 'opacity', {duration:333, wait: true });

		
		// loop through the main nav elements
		menuItems.each(function(element) {


			aPreLoad[aPreLoadi] = new Image();
			aPreLoad[aPreLoadi].src = element.src.replace(element.src.replace('small', 'medium'));
			aPreLoadi++;



			// the mouse over event
			element.addEvent('mouseenter', function(e) {


				
				var e = new Event(e);
				Pop.getBounds(e.page);
				
				popUp.setStyles('top: ' + t + 'px; left: ' + l + 'px;');
				popUp.addClass('popup_bg' );
				
				
				var chunk = this.getProperty('alt');
				var title = chunk.substring(0,chunk.indexOf("|"));
				var desc = chunk.substring(chunk.indexOf("|")+1, chunk.length);

				
				popUp.setHTML("<h3>" + title + "</h3><img src=" + this.src.replace("small","medium") + " />");
				

		
			});
			
			
			
			
			element.addEvent('mousemove', function(e) {
				//trace(e.pageY);

				var e = new Event(e);
				Pop.getBounds(e.page);

				
			
				popUp.setStyles('top: ' + t + 'px; left: ' + l + 'px;');
			});
	
				
				
			// the mouse out event
			element.addEvent('mouseleave', function() {
				 popUp.removeClass('popup_bg');
				 popUp.setOpacity(0);
			});

		});
	}
};
		
		

window.addEvent('domready', Pop.init);
