
// - - - > MAMANURI DESIGN, 2011 < - - - //

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EXPAND TO FULL SCREEN

self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);





// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CHECK FOR THE USER AGENT

var iPod = navigator.userAgent.match(/iPod/i) != null;
var iPad = navigator.userAgent.match(/iPad/i) != null;
var iPhone = navigator.userAgent.match(/iPhone/i) != null;
var msIE = navigator.userAgent.match(/msie/i) != null;
var FF = navigator.userAgent.match(/firefox/i) != null;

// ---> FOR APPLE MOBILES

var iDevice = false;
if (iPod || iPad || iPhone) {
	iDevice = true;
}





// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SET IMAGES TO PRELOAD

var images = [
				'immagini/splash/logo.jpg',
				'immagini/splash/olive.jpg',
				'immagini/splash/flags/flag-shadow.jpg',
				'immagini/splash/flags/it.jpg',
				'immagini/splash/flags/en.jpg',
				'immagini/splash/flags/fr.jpg',
				'immagini/splash/flags/de.jpg',
				'immagini/splash/flags/es.jpg',
				'immagini/splash/flags/pt.jpg',
				'immagini/splash/flags/ru.jpg',
				'immagini/splash/flags/jp.jpg',
				'immagini/splash/flags/zh.jpg',
				'immagini/splash/nverde.jpg'
			 ];






// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - START PRELOAD IMAGES

$({}).imageLoader({
    images: images,
    async: true,
    allcomplete: function(e, ui) {
    
		$(document).ready(function() {
		    
		    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FIXES
			
		    // ---> INTERNET EXPLORER
		    
			if (msIE) {
			
				// fixes here
			}
			
		    // ---> FIREFOX
		    
			if (FF) {
			
				// fixes here
			}
			
			
			
			
			
			// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FANCYBOX INIT
			
			if (!iDevice) {
				$("#news").fancybox({
					'width'				: 860,
					'height'			: 600,
					'autoScale'			: false,
					'overlayOpacity'	: 1,
					'overlayColor'		: '#c2cdc3',
					'transitionIn'		: 'fade',
					'transitionOut'		: 'fade',
					'speedIn'			: 1000,
					'type'				: 'iframe'
				});
			}
			
			
			
			
			
			// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LAYOUT INIT
			
			// - - - - - - - - - - - - - - - - - - - - - - - TEMPORARY HIDE FUTURE LANGUAGES FLAGS
			
			if (iDevice) {
				//$('#it').hide();
			}
			
			
			
			
			
			// - - - - - - - - - - - - - - - - - - - - - - - SHOW UP SITE
			
			$('#main-wrapper').css({visibility:'visible'});
			$('#overlay').css({backgroundImage:'none'}).fadeTo(2000, 0, function() {
				$('#overlay').hide();
			});
			
			
			
			
			
			// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UI EFFECTS HANDLERS
			
			// - - - - - - - - - - - - - - - - - - - - - - - LINK COMMON COLOR EFFECT HANDLER
  	
		  	if (!iDevice) {
		  		
		  		// ---> MOUSE ROLLOVER/ROLLOUT
				  		
		        $('a').hover(function() {
		        	$(this).css({color:'#f57d00'});
		        }, function() {
		        	$(this).css({color:'#395b3c'});
		        });
				
				// ---> MOUSE UP
				
				$('a').mouseup(function() {
					$(this).css({color:'#395b3c'});
				});
			}
			
		  	// - - - - - - - - - - - - - - - - - - - - - - - LINK VERTICAL NUDGE EFFECT HANDLER
		  	
		  	if (!iDevice) {
		  	
			  	// ---> MOUSE DOWN
			  	
				$('.nudge').mousedown(function() {
					$(this).css({top:'1px'});
				});
				
				// ---> MOUSE UP
				
				$('.nudge').mouseup(function() {
					$(this).css({top:'0px'});
				});
				
				// ---> MOUSE OUT
				
				$('.nudge').mouseout(function() {
					$(this).css({top:'0px'});
				});
			}
			
			// - - - - - - - - - - - - - - - - - - - - - - - FLAG BUTTON EFFECT HANDLER
  	
		  	if (!iDevice) {
		  		
		  		// ---> MOUSE ROLLOVER/ROLLOUT
				  		
		        $('.flag-holder').hover(function() {
		        	$(this).children('.flag').stop().animate({bottom:'15px'}, 100);
		        	$(this).children('.flag-shadow').stop().animate({opacity:'1'}, 200);
		        }, function() {
		        	$(this).children('.flag').stop().animate({bottom:'0px'}, 500);
		        	$(this).children('.flag-shadow').stop().animate({opacity:'0'}, 500);
		        });
				
				// ---> MOUSE UP
				
				$('.flag-holder').mouseup(function() {
					$(this).children('.flag').css({bottom:'0px'});
		        	$(this).children('.flag-shadow').css({opacity:'0'});
				});
			}
		});
		
	}
});





// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTILITIES

// ---> OPEN SITE

function openSite(theURL,winName,features) {
	if (!iDevice) {
		theURL = 'plugin_detect.php?lingua=' + theURL;
		window.open(theURL,winName,features);
		return false;
	} else {
		location.href = 'ios/' + theURL + '/azienda';
	}
}

// ---> OPEN NEW WINDOWS IN FULL SCREEN

function openFullScreen(url) {
	params  = 'width='+screen.width;
	params += ', height='+screen.height;
	params += ', top=0, left=0'
	params += ', directories=yes'
	params += ', location=yes'
	params += ', resizable=yes'
	params += ', menubar=yes'
	params += ', toolbar=yes'
	params += ', scrollbars=yes'
	params += ', status=yes'
	
	newWin=window.open(url,'', params);
	if (window.focus) {
		newWin.focus();
	}
}
