//<![CDATA[

	var GB_ANIMATION = false;
	var GB_IMG_DIR = "/styles/default/greybox/";

	//Clicking on the transparent overlay closes the GreyBox window?
	var GB_overlay_click_close = true;

	function displayAnimation()
	{
		document.write('<object type="application/x-shockwave-flash" data="/images/header_animation.swf" width="710" height="300">\n');
		document.write('\t<param name="movie" value="/images/header_animation.swf" />\n');
		document.write('\t<param name="wmode" value="transparent" />\n');
		document.write('</object>');
	}

	function displayStaticAnimation(section)
	{
		switch(section)
		{
			case 'company':
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_company.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_company.swf" />\n');
				break;
			}
			case 'lombardini':
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_engines.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_engines.swf" />\n');
				break;
			}
			case 'parts':
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_parts.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_parts.swf" />\n');
				break;
			}
			case 'services':
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_services.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_services.swf" />\n');
				break;
			}
			case 'contacts':
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_contacts.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_contacts.swf" />\n');
				break;
			}
			default:
			{
				document.write('<object type="application/x-shockwave-flash" data="/images/header_company.swf" width="710" height="150">\n');
				document.write('\t<param name="movie" value="/images/header_company.swf" />\n');
				break;
			}
		}
		document.write('\t<param name="wmode" value="transparent" />\n');
		document.write('</object>');
	}


	function mapThumbnailInitialize() 
	{
		if(GBrowserIsCompatible()) 
		{
			var map = new GMap2(document.getElementById("mapThumbnail"));
			map.setCenter(new GLatLng(41.795292, 12.527885), 15);
			map.disableDragging();
		}
	}

	function mapInitialize() 
	{
		if (GBrowserIsCompatible()) 
		{
			var map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(41.795292, 12.527885), 17);
			map.disableDragging();
			map.setMapType(G_NORMAL_MAP);
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			
			// Creates a marker at the given point with the given text data
			function createMarker(point) 
			{
				var marker = new GMarker(point);
				GEvent.addListener(marker, "click", function() 
					{
						map.closeInfoWindow();
					}
				);
				return marker;
			}
	
			// Add 10 markers to the map at random locations
			var point = new GLatLng(41.795292, 12.527885);
			headquarter = createMarker(point);
			map.addOverlay(headquarter);
			headquarter.openInfoWindowHtml('<div style="color: #ec6100; font: 11px verdana;"><strong>Ippoliti ricambi</strong><br /><address>Via Vittore Ghiliani, 9<br />00134 - Roma (Italia)</address>Tel. +39 (06) 575-0809<p style="color: #666;">Uscita 24 de Grande Raccordo Anulare, Ardeatina</p></div>');
		}
	}

	function workshopInitialize(lat,lon,text) 
	{
		if (GBrowserIsCompatible()) 
		{
			var map = new GMap2(document.getElementById("map"));
			var info;
			map.setCenter(new GLatLng(lat,lon), 17);
			map.disableDragging();
			map.setMapType(G_NORMAL_MAP);
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			
			// Create our "tiny" marker icon
			var icon = new GIcon();
			icon.image = "/images/marker.png";
			icon.shadow = "/images/marker_shadow.png";
			icon.iconSize = new GSize(27, 26);
			icon.shadowSize = new GSize(40, 26);
			icon.iconAnchor = new GPoint(14, 26);
			icon.infoWindowAnchor = new GPoint(27, 26);
	
			// Creates a marker at the given point with the given text data
			function createMarker(point) 
			{
				var marker = new GMarker(point,icon);
				GEvent.addListener(marker, "click", function() 
					{
						map.closeInfoWindow();
					}
				);
				return marker;
			}
	
			// Add 10 markers to the map at random locations
			var point = new GLatLng(lat,lon);
			headquarter = createMarker(point);
			map.addOverlay(headquarter);
			opts = {maxWidth:300};
			headquarter.openInfoWindowHtml(text,opts);
		}
	}

	function sendMessage()
	{
		var errors = 0;
		var email_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		$('errorFeedback').style.display = 'none';
	
		if($F('name') == '')
		{
			errors++;
			$('name').style.borderColor = '#c00';
		}
		else
		{
			$('error_name').style.display = 'none';
			$('name').style.borderColor = '#666';
		}
		if($F('email') == '')
		{
			errors++;
			$('email').style.borderColor = '#c00';
		}
		else
		{
			$('error_email_empty').style.display = 'none';
			$('email').style.borderColor = '#666';
		}
		if(!email_filter.test($F('email')))
		{
			errors++;
			$('email').style.borderColor = '#c00';
		}
		else
		{
			$('error_email_invalid').style.display = 'none';
			$('email').style.borderColor = '#666';
		}
		if($F('message') == '')
		{
			errors++;
			$('message').style.borderColor = '#c00';
		}
		else
		{
			$('error_message').style.display = 'none';
			$('message').style.borderColor = '#666';
		}
	
		if(errors == 0)
		{
			return true;
		}
		else
		{
			new Effect.BlindDown('errorFeedback');
			return false;
		}
	}

	function sendRegistration()
	{
		var errors = 0;
		var email_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		$('errorFeedback').style.display = 'none';
	
		if($F('firstname') == '')
		{
			errors++;
			$('firstname').style.borderColor = '#c00';
			$('error_firstname').style.display = 'list-item';
		}
		else
		{
			$('error_firstname').style.display = 'none';
			$('firstname').style.borderColor = '#666';
		}
		if($F('lastname') == '')
		{
			errors++;
			$('lastname').style.borderColor = '#c00';
			$('error_lastname').style.display = 'list-item';
		}
		else
		{
			$('error_lastname').style.display = 'none';
			$('lastname').style.borderColor = '#666';
		}
		if($F('email') == '')
		{
			errors++;
			$('email').style.borderColor = '#c00';
			$('error_email_empty').style.display = 'list-item';
			$('error_email_invalid').style.display = 'none';
		}
		else
		{
			$('error_email_empty').style.display = 'none';
			$('email').style.borderColor = '#666';
	
			if(!email_filter.test($F('email')))
			{
				errors++;
				$('email').style.borderColor = '#c00';
				$('error_email_invalid').style.display = 'list-item';
			}
			else
			{
				$('error_email_invalid').style.display = 'none';
				$('email').style.borderColor = '#666';
			}
		}
		if($F('userpassword') == '')
		{
			errors++;
			$('userpassword').style.borderColor = '#c00';
			$('error_password_empty').style.display = 'list-item';
				$('error_password_invalid').style.display = 'none';
		}
		else
		{
			$('error_password_empty').style.display = 'none';
			$('userpassword').style.borderColor = '#666';
	
			if($F('userpassword') != $F('confirmpassword'))
			{
				errors++;
				$('userpassword').style.borderColor = '#c00';
				$('confirmpassword').style.borderColor = '#c00';
				$('error_password_invalid').style.display = 'list-item';
			}
			else
			{
				$('error_password_invalid').style.display = 'none';
				$('userpassword').style.borderColor = '#666';
				$('confirmpassword').style.borderColor = '#666';
			}
		}
	
		if(errors == 0)
		{
			return true;
		}
		else
		{
			new Effect.BlindDown('errorFeedback');
			return false;
		}
	}

	function sendProfile()
	{
		var errors = 0;
		var email_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		$('errorFeedback').style.display = 'none';
	
		if($F('firstname') == '')
		{
			errors++;
			$('firstname').style.borderColor = '#c00';
			$('error_firstname').style.display = 'list-item';
		}
		else
		{
			$('error_firstname').style.display = 'none';
			$('firstname').style.borderColor = '#666';
		}
		if($F('lastname') == '')
		{
			errors++;
			$('lastname').style.borderColor = '#c00';
			$('error_lastname').style.display = 'list-item';
		}
		else
		{
			$('error_lastname').style.display = 'none';
			$('lastname').style.borderColor = '#666';
		}
		if($F('email') == '')
		{
			errors++;
			$('email').style.borderColor = '#c00';
			$('error_email_empty').style.display = 'list-item';
			$('error_email_invalid').style.display = 'none';
		}
		else
		{
			$('error_email_empty').style.display = 'none';
			$('email').style.borderColor = '#666';
	
			if(!email_filter.test($F('email')))
			{
				errors++;
				$('email').style.borderColor = '#c00';
				$('error_email_invalid').style.display = 'list-item';
			}
			else
			{
				$('error_email_invalid').style.display = 'none';
				$('email').style.borderColor = '#666';
			}
		}
	
		if(errors == 0)
		{
			return true;
		}
		else
		{
			new Effect.BlindDown('errorFeedback');
			return false;
		}
	}

	function sendRecover()
	{
		var errors = 0;
		var email_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
		$('errorFeedback').style.display = 'none';
	
		if($F('email') == '')
		{
			errors++;
			$('email').style.borderColor = '#c00';
			$('error_email_empty').style.display = 'list-item';
			$('error_email_invalid').style.display = 'none';
		}
		else
		{
			$('error_email_empty').style.display = 'none';
			$('email').style.borderColor = '#666';
	
			if(!email_filter.test($F('email')))
			{
				errors++;
				$('email').style.borderColor = '#c00';
				$('error_email_invalid').style.display = 'list-item';
			}
			else
			{
				$('error_email_invalid').style.display = 'none';
				$('email').style.borderColor = '#666';
			}
		}
	
		if(errors == 0)
		{
			return true;
		}
		else
		{
			new Effect.BlindDown('errorFeedback');
			return false;
		}
	}

	function sendPassword()
	{
		var errors = 0;
	
		$('errorFeedback').style.display = 'none';
	
		if($F('newpassword') == '')
		{
			errors++;
			$('newpassword').style.borderColor = '#c00';
			$('error_password_empty').style.display = 'list-item';
				$('error_password_invalid').style.display = 'none';
		}
		else
		{
			$('error_password_empty').style.display = 'none';
			$('newpassword').style.borderColor = '#666';
	
			if($F('newpassword') != $F('confirmpassword'))
			{
				errors++;
				$('newpassword').style.borderColor = '#c00';
				$('confirmpassword').style.borderColor = '#c00';
				$('error_password_invalid').style.display = 'list-item';
			}
			else
			{
				$('error_password_invalid').style.display = 'none';
				$('newpassword').style.borderColor = '#666';
				$('confirmpassword').style.borderColor = '#666';
			}
		}
	
		if(errors == 0)
		{
			return true;
		}
		else
		{
			new Effect.BlindDown('errorFeedback');
			return false;
		}
	}
//]]>

