function form_email_check() {						
	var form=document.forms['email'];

	if (form.nome.value=='') {
		form.nome.focus();
		return;
	} 
	if (form.cognome.value=='') {
		form.cognome.focus();
		return;
	} 
	if (form.email.value=='') {
		form.email.focus();
		return;
	} 
	if (form.pwd.value=='') {
		form.pwd.focus();
		return;
	} 
	if (form.confpwd.value=='') {
		form.confpwd.focus();
		retur;
	} 

	if (form.pwd.value!=form.confpwd.value) {
		form.pwd.focus();
		return;
	} 

	form.submit();
}

var map;
var gdir;
var geocoder = null;
var addressMarker;

function InitializeGoogleMaps() {
	if (GBrowserIsCompatible()) {      
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(43.264534,13.252623), 15);
		map.setMapType(G_HYBRID_MAP);

		// http://maps.google.com/maps?f=q&hl=it&geocode=&q=Rocchetta++62027+S.+Severino+Marche+(MC)&sll=37.0625,-95.677068&sspn=29.025693,59.501953&ie=UTF8&ll=43.264894,13.249834&spn=0.0065,0.014527&t=h&z=16&iwloc=addr
		var point = new GLatLng(43.264534,13.252623);  
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {    
			marker.openInfoWindowHtml("<b>Agroservice spa</b><br>C.da Rocchetta<br>62027 S. Severino Marche (MC)");  });
		map.addOverlay(marker);

		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);
	}
}

function setDirections(fromAddress, toAddress, locale) {
	gdir.load("from: " + fromAddress + " to: " + toAddress , { "locale": locale });
}

function handleErrors(){
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	else alert("An unknown error occurred.");
}

function onGDirectionsLoad(){ 
// Use this function to access information about the latest load()
// results.

// e.g.
// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
// and yada yada yada...
}

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(43.264534,13.252623), 8);

		var point = new GLatLng(43.264534,13.252623);  
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {    
		marker.openInfoWindowHtml("<b>Sotek Srl</b><br>Via Campo dell'olmo<br>60044 Fabirano (AN)");  });
		map.addOverlay(marker);
	}
}

var outer,inner1,inner2,elementwidth,outerwidth;
var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;
var speed=90;
var pixelstep=2;
var ImgPreload = null;
var TotalTopImgWidth = 0;

function getElWidth(el){
	if(ns4)return (el.document.width)? el.document.width : el.clip.right-el.clip.left;
	else if(ie4||ie5)return (el.style.width)? el.style.width:el.clientWidth;
	else if(w3c)return (el.style.width)?parseInt(el.style.width):parseInt(el.offsetWidth);
	else return -1;
}

function scrollheader() {
	if(ns4){
		inner1.left -= pixelstep;
		inner2.left -= pixelstep;
		if( inner1.left < -elementwidth ) {
			inner1.left = inner2.left+elementwidth;
		}
		if( inner2.left < -elementwidth ) {
			inner2.left = inner1.left+elementwidth;
		}
	}else{
		inner1.style.left=(parseInt(inner1.style.left)-pixelstep)+'px';
		inner2.style.left=(parseInt(inner2.style.left)-pixelstep)+'px';
		if( parseInt(inner1.style.left) < -elementwidth ) {
			inner1.style.left = (parseInt(inner2.style.left)+elementwidth)+'px';
		} else
		if( parseInt(inner2.style.left) < -elementwidth ) {
			inner2.style.left = (parseInt(inner1.style.left)+elementwidth)+'px';
		}
	}
}

function StartScroll(){
	outer=document.getElementById('outer');
	inner1=document.getElementById('inner1');
	inner2=document.getElementById('inner2');
	if( ImgPreload != null ) {
		inner1.style.width = ImgPreload.TotalWidth+'px';
		inner2.style.width = ImgPreload.TotalWidth+'px';
	} else {
		inner1.style.width = TotalTopImgWidth+'px';
		inner2.style.width = TotalTopImgWidth+'px';
	}
	elementwidth=parseInt(getElWidth(inner1));
	
	if(ns4){
		inner2.left = parseInt(getElWidth(inner1))+'px';
	}else{
		inner2.style.left = parseInt(getElWidth(inner1))+'px';
	}
	outerwidth=parseInt(getElWidth(outer));
	setInterval('scrollheader()',speed);
}

function StartScroll2(){
	outer=document.getElementById('outer');
	inner1=document.getElementById('inner1');
	inner2=document.getElementById('inner2');
	elementwidth=parseInt(getElWidth(inner1));
	outerwidth=parseInt(getElWidth(outer));
	setInterval('scrollheader()',speed);
}


function onPreload(aImages, nImages)
{
	StartScroll();
}

function openCentered(url,name,width,height){
	var WW = width;
	var HH = height;
	var TT = screen.height / 2 - HH / 2;
	var LL = screen.width / 2 - WW / 2;
	var opts = 'width='+WW+',height='+HH+',top='+TT+',left='+LL+',innerWidth='+WW+',innerHeight='+HH+',status=no,scrollbars=yes,resizable=no,menubar=no,copyhistory=no,toolbar=no,location=no,directories=no';
	var new_window = window.open(url,name,opts);
	new_window.focus();
	
	if( typeof( new_window.innerWidth ) == 'number' ) {
		//Non-IE
		new_window.innerWidth = WW;
		new_window.innerHeight = HH;
	} else if( new_window.document.documentElement && ( new_window.document.documentElement.clientWidth || new_window.document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		new_window.document.documentElement.clientWidth = WW;
		new_window.document.documentElement.clientHeight = HH;
	} else if( new_window.document.body && ( new_window.document.body.clientWidth || new_window.document.body.clientHeight ) ) {
		//IE 4 compatible
		new_window.document.body.clientWidth = WW;
		new_window.document.body.clientHeight = HH;
	}
}

