
jQuery(document).ready(function(){
			//This script gives mozilla 3 seconds to download every necessary font
			var d = document, e = d.documentElement, s = d.createElement('style');
			  if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
				s.textContent = 'body{visibility:hidden}';
				e.firstChild.appendChild(s);
				function f(){ s.parentNode && s.parentNode.removeChild(s);
				}
				addEventListener('load',f,false);
				setTimeout(f,3000); 
			  }
  			//calcolo larghezza effettiva elemento contents_wrapper
			$('.singleBox').css({'width': $('#contents_wrapper').innerWidth() + 'px'});
			$('#contents').css({'width': 5*$('#contents_wrapper').innerWidth() + 'px'});
			$('#contents_wrapper').scrollTo('#1', 0);
			$('.singleBox').scrollTop(0);
			$('#header').css({backgroundPosition: '0px 0px'});
			var ua = navigator.userAgent;
			if (!ua.match(/iPad/i) && !ua.match(/iPhone/i) && !ua.match(/iPod/i)){
				var flashvars = {
			};
			var params = {
				menu: "false",
				scale: "scale",
				allowFullscreen: "false",
				allowScriptAccess: "always",
				wmode:"transparent"
			};
			var attributes = {
				id:"meduse"
			};
			swfobject.embedSWF("swf/process_cs3-10.swf", "flashWhatWeDo", "700", "310", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
				$('#menu a').bind('click', function() {
				scrollToSectionWeb($(this).attr('id'));
				return null;
			})}
			else{
			$('#menu a').bind('touchstart', function() {
				scrollToSection($(this).attr('id'));
				return null;
			})};
			
			
			
			
			if(($.browser.version =='7.0') && ($.browser.msie)){
				
    $('.right div').removeClass('nivoSlider');
    $('.hideForIE7').css('display','none');
	$('#mappaIE7').css('display','inline');
	$('#mappa').css('display','none');
    }
			
			//google maps
			var latlng = new google.maps.LatLng(45.471583,9.21489);
    			var myOptions = {
      				zoom: 15,
      				center: latlng,
      				mapTypeId: google.maps.MapTypeId.ROADMAP
    			};
    			var map = new google.maps.Map(document.getElementById("mappa"), myOptions);
    		var marker = new google.maps.Marker({
      			position: latlng, 
      			map: map, 
      			title:"Med-use"
  			});
			
  			
			
		});
		
			
		
		function setColourWeb(id) {
			var flashvars = {
			};
			var params = {
				menu: "false",
				scale: "scale",
				allowFullscreen: "false",
				allowScriptAccess: "always",
				wmode:"transparent"
			};
			var attributes = {
				id:"meduse"
			};
			switch(id)
			{
				case 'whatWeDo':
					setColorsWeb('#FFA412', '#52310e');
					swfobject.embedSWF("swf/process_cs3-10.swf", "flashWhatWeDo", "700", "310", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
					break;
				case 'ourWorks':
					setColorsWeb('#39CBF5', '#124250');
					$('.nivoSlider').nivoSlider({effect:'fade',pauseTime:4000})
					break;
				case 'team':
					setColorsWeb('#F76346', '#461e16');
					swfobject.embedSWF("swf/team.swf", "teamSwf", "700", "760", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
					break;
				case 'clients':
					setColorsWeb('#a382ff', '#040404');
					break;
				/*case 'partners':
					setColors('#A8C100', '#353e00');
					break;*/
				case 'contacts':
					setColorsWeb('#EE6FDE', '#46243f');
					swfobject.embedSWF("swf/periscopio.swf", "flashPeriscopio", "220", "180", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
					swfobject.embedSWF("swf/faro.swf", "flashFaro", "220", "180", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
					swfobject.embedSWF("swf/bottiglia.swf", "flashBottiglia", "220", "180", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
					
					break;
				
			};
			
		}
		function setColorsWeb(bg, border) {
			$('body').animate({ backgroundColor: bg }, { duration: 1000, queue: false });
			$('body').animate({ color: border }, { duration: 1000, queue: false });
			$('#menu li a').animate({ color: border }, { duration: 1000, queue: false });
			$('#header').animate({ borderRightColor: border }, { duration: 1000, queue: false })
		}
		function scrollToSectionWeb(id) {
			var diff = positionInterface(id);
			setColourWeb(id);
			$('#header').animate({backgroundPosition: '-'+diff+'px 0px'},{ duration: 1000, queue: false });	
		}
		
		
		$(window).resize(function () {
			resizePanel();
		});
		
		function resizePanel() {
			$('.singleBox').css({'width': $('#contents_wrapper').width() + 'px'});
			$('#contents').css({'width': 5*$('#contents_wrapper').innerWidth() + 'px'});
			$('#contents_wrapper').scrollTo('#'+$('.displayed').attr('id'), 0);
		}
		
		
		
		
		/*only for iphone/ipad*/
	
		function scrollToSection(id) {
			var diff = positionInterface(id);
			setColour(id);
		}
		
		function setColour(id) {
			switch(id)
			{
				case 'whatWeDo':
					setColors('#FFA412', '#52310e');
					break;
				case 'ourWorks':
					setColors('#39CBF5', '#124250');
					$('.nivoSlider').nivoSlider({effect:'fade',pauseTime:4000})
					break;
				case 'team':
					setColors('#F76346', '#461e16');
					break;
				case 'clients':
					setColors('#a382ff', '#040404');
					break;
				/*case 'partners':
					setColors('#A8C100', '#353e00');
					break;*/
				case 'contacts':
					setColors('#EE6FDE', '#46243f');
					
					break;
				
			};
		};
		function setColors(bg, border) {
			$('body').css('color',border);
			$('#menu li a').css('color',border);
			$('body').css('backgroundColor', bg);
			$('#header').css('borderRightColor',border)
		}
		
		/*functions*/
		function positionInterface(id) {
			$('#menu a').removeClass('selected');
			$('#'+id).addClass('selected');
			var contentId=0;
			var tempo=1000;
			switch(id)
			{
				case 'whatWeDo':
					contentId=1;
					break;
				case 'ourWorks':
					contentId=2;
					break;
				case 'team':
					contentId=3;
					break;
				case 'clients':
					contentId=4;
					break;
				/*case 'partners':
					contentId=5;
					break;*/
				case 'contacts':
					contentId=6;
					break;				
			};
			oldId=parseInt($('.displayed').attr('id'));
			if (contentId!=oldId) {$('.singleBox').css({'overflowY': 'hidden'});}
			diff=contentId-1;
			diff=diff*$('.singleBox').width();
			$('#contents div').removeClass('displayed');
			$('#'+contentId).addClass('displayed');
			$('#contents_wrapper').scrollTo('#'+contentId,tempo, function(){$('.singleBox').css({'overflowY': 'auto'}); });
			return diff;
		}
		
		
		
