
	jQuery(document).ready(function () {
		//jQuery(document).pngFix();
		
		jQuery("#nav-main li").bind('mouseenter', function() {
			jQuery(this).addClass("sfhover");
		});
		
		jQuery("#nav-main li").bind('mouseleave', function() {
			jQuery(this).removeClass("sfhover");
		});
		
		
		jQuery('#area-south-america').mouseenter(function() {
			//jQuery('#south-am-over').css('display', 'block');
			//console.log('mouseenter');
		});
		
		jQuery('#area-south-america').click(function(e) {
			//e.preventDefault();
			
			//jQuery('ul.navid-1138 li:first').addClass('sfhover');
			
			//console.log('click');
			return false;
		});
		
		jQuery('#area-south-america').mouseleave(function() {
			//jQuery('#south-am-over').css('display', 'none');
			//console.log('mouseleave');
		});
		
		
		jq.milon.map.init();
		
		
		var fancyDefaults = {
			 'width' : 550,
			 'height' : 470,
			 'padding': 0,
			 'margin': 0,
			 'scrolling' : 'no',
			 'overlayOpacity': 0.7,
			 'overlayColor': '#000',
			 'showCloseButton': false,
			 'autoScale' : false,
			 'transitionIn' : 'none',
			 'transitionOut' : 'none',
			 'type' : 'iframe'
		};
		
		jQuery(".fancybox").fancybox(fancyDefaults); 
		
		//SWF Fancybox
		var links = jQuery('a.fancybox-swf').get();
		for (var i=0; i < links.length; i++) {
				
				links[i].onclick = function() {
					return false;
				}
				
				var href = jQuery(links[i]).attr('href');
				var content = [
					'<object height="367" width="600" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">',
					'<param value="',
					href,
					'" name="movie">',
					'<param value="transparent" name="wmode">',
					'<embed height="367" width="600" wmode="transparent" type="application/x-shockwave-flash" src="',
					href,
					'">',
					'</object>'
				].join('');
				
				
				
				jQuery(links[i]).fancybox({
					'width' : 600,
					'height' : 406, //366,
					'padding': 4,
					'margin': 0,
					'scrolling' : 'no',
					'overlayOpacity': 0.7,
					'overlayColor': '#000',
					'showCloseButton': true,
					'autoScale' : false,
					'transitionIn' : 'none',
					'transitionOut' : 'none',
					'titleShow': false,
					'content' : content,
					'type' : 'swf', 
					'swf' : {
						'wmode' : 'transparent',
						'allowfullscreen' : 'true'
					}
				}); 
			
		}
		
		
		
	});
	

	
	/*
	North America 		1229
	South America 		1216
	Europe 		  		1211
	Africa 		  		1174
	Asia Pacific 		1171
	*/

	jq.milon.map = {
		
		_lib: jq.milon.lib,
		
		regionIds : {
			'north-america' : 1229,
			'south-america' : 1216,
			'europe'		: 1211,
			'africa'		: 1174,
			'asia-pacific'	: 1171	
		},
		
		init: function() {
			this.areas = jQuery('map#map area').get();
			
			jQuery(this.areas).bind('click', {fn: 'onClick', scope: this}, this._lib.onEvent);
			jQuery(this.areas).bind('mouseenter', {fn: 'onMouseEnter', scope: this}, this._lib.onEvent);
			jQuery(this.areas).bind('mouseleave', {fn: 'onMouseLeave', scope: this}, this._lib.onEvent);

		},
		
		getRegion: function(trg) {
			return trg.attr('id').replace(/area-/, '');	
		},
		
		onMouseEnter: function(e) {
			var trg = jQuery(e.currentTarget);
			var region = this.getRegion(trg);
			
			
			jQuery('#'+ region +'-over').css('display', 'block');
			//console.log(region);
		},
		
		onMouseLeave: function(e) {
			var trg = jQuery(e.currentTarget);
			var region = this.getRegion(trg);
			
			jQuery('#'+ region +'-over').css('display', 'none');
			//console.log(region);
		},
		
		onClick: function(e) {
			e.preventDefault();
			e.stopPropagation();
			
			var trg = jQuery(e.currentTarget);
			var region = this.getRegion(trg);
			
			if (this.regionIds[region]) {
				if (this.currentLi) this.currentLi.removeClass('sfhover');
					
				var li = jQuery('#nav-main a.'+region).parent('li');
				li.addClass('sfhover');
				
				this.currentLi = li;
				
				//console.log(li);
			}
			
			//console.log(region);
			
			/*
			this.curImg = trg.attr('href');
			this.curText = trg.html();
			
			this.trgImg.fadeTo(600, 0.00, function() {
					jQuery(this).attr('src', trg.attr('href'));
				}
			);*/

		}
		
	};
	
