﻿function sendForm(){	
	
	var nome=$('nome');
	var txt=$('messaggio');
	var tst=$('messaggio').value;
	var fdb=$('fdb');
	var cnt=$('comments');
	var inc=$('inCommento');

	
	var e=0;
	
	nome.style.backgroundColor='#FFF';
	txt.style.backgroundColor='#FFF';
	
	if(trim(nome.value)==''){
		nome.style.backgroundColor='#FFC6C6';
		e++;
	}else if(trim(tst)==''){
		txt.style.backgroundColor='#FFC6C6';
		e++;
	}
	
	if(e==1){
		fdb.innerHTML='Completare il campo evidenziato';
	}else if(e>1){
		fdb.innerHTML='Completare i campi evidenziati';
	}else{
		
		cnt.innerHTML='<p><strong>Invio del messaggio in corso. Attendere prego.</strong></p><img src="Immagini/Struttura/commonIco/wait.gif" alt="Attendere prego" />';
		var r=a();
		
		r.onreadystatechange = function() {			
			if(r.readyState==4){
				if(r.status==200){
					cnt.innerHTML=r.responseText;
					txt.value="";
					nome.value="";
				}else{
					cnt.innerHTML="<p class=\"r\">Errore durante l'invio del messaggio!</p>";
				}
			}			
		};
		r.open("POST",'res/php/do/commenta.php',true);
		r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		r.send("n="+nome.value+"&m="+tst+"&s=sciAlp&c=Piste");
	}
}


var m=null;
var pm=null;
function asMap(){	
	
	var c=new google.maps.LatLng(46.37494476382117, 8.419561386108398);
	var o={zoom:15,center:c,mapTypeId:google.maps.MapTypeId.HYBRID,scrollwheel:false};

	sv=[new google.maps.LatLng(46.377460000000006,8.410480000000001),new google.maps.LatLng(46.377,8.41008),new google.maps.LatLng(46.376720000000006,8.408940000000001),new google.maps.LatLng(46.37644,8.40849),new google.maps.LatLng(46.37614000000001,8.40849),new google.maps.LatLng(46.37592,8.40868),new google.maps.LatLng(46.37574,8.409130000000001),new google.maps.LatLng(46.37554,8.40961),new google.maps.LatLng(46.375460000000004,8.410120000000001),new google.maps.LatLng(46.375600000000006,8.41066),new google.maps.LatLng(46.3757,8.41113),new google.maps.LatLng(46.37568,8.4116),new google.maps.LatLng(46.375600000000006,8.41197),new google.maps.LatLng(46.375400000000006,8.41224),new google.maps.LatLng(46.375260000000004,8.41267),new google.maps.LatLng(46.37536,8.413120000000001),new google.maps.LatLng(46.375330000000005,8.41357),new google.maps.LatLng(46.375370000000004,8.41411),new google.maps.LatLng(46.37523,8.41478),new google.maps.LatLng(46.375400000000006,8.41529),new google.maps.LatLng(46.37557,8.415890000000001),new google.maps.LatLng(46.375550000000004,8.41632),new google.maps.LatLng(46.375240000000005,8.41666),new google.maps.LatLng(46.374970000000005,8.41694),new google.maps.LatLng(46.37496,8.417520000000001),new google.maps.LatLng(46.37494,8.41793),new google.maps.LatLng(46.37483,8.418320000000001),new google.maps.LatLng(46.374750000000006,8.418700000000001),new google.maps.LatLng(46.37474,8.419300000000001),new google.maps.LatLng(46.37469,8.41971),new google.maps.LatLng(46.37500000000001,8.41995),new google.maps.LatLng(46.375260000000004,8.42003),new google.maps.LatLng(46.375420000000005,8.42031),new google.maps.LatLng(46.37529000000001,8.42051),new google.maps.LatLng(46.375170000000004,8.42089),new google.maps.LatLng(46.375150000000005,8.42164),new google.maps.LatLng(46.37534,8.422690000000001),new google.maps.LatLng(46.37527,8.423340000000001),new google.maps.LatLng(46.375310000000006,8.42385),new google.maps.LatLng(46.37518,8.42417)];
	svi=[new google.maps.LatLng(46.37509000000001,8.42398),new google.maps.LatLng(46.375710000000005,8.420160000000001),new google.maps.LatLng(46.377430000000004,8.410680000000001)];

	v2=[new google.maps.LatLng(46.37129,8.416730000000001),new google.maps.LatLng(46.37163,8.416970000000001),new google.maps.LatLng(46.371640000000006,8.41735),new google.maps.LatLng(46.372040000000005,8.41737),new google.maps.LatLng(46.372440000000005,8.41735),new google.maps.LatLng(46.372640000000004,8.41765),new google.maps.LatLng(46.372240000000005,8.417950000000001),new google.maps.LatLng(46.372530000000005,8.418190000000001),new google.maps.LatLng(46.37292,8.4181),new google.maps.LatLng(46.37326,8.418040000000001),new google.maps.LatLng(46.373380000000004,8.418320000000001),new google.maps.LatLng(46.373200000000004,8.41862),new google.maps.LatLng(46.373110000000004,8.41911),new google.maps.LatLng(46.37312000000001,8.41952),new google.maps.LatLng(46.37303000000001,8.41995),new google.maps.LatLng(46.372800000000005,8.420250000000001),new google.maps.LatLng(46.372490000000006,8.42042),new google.maps.LatLng(46.37229000000001,8.42068),new google.maps.LatLng(46.37232,8.42098),new google.maps.LatLng(46.372550000000004,8.421240000000001),new google.maps.LatLng(46.372780000000006,8.42154),new google.maps.LatLng(46.37277,8.421840000000001),new google.maps.LatLng(46.372550000000004,8.42209),new google.maps.LatLng(46.37227,8.422350000000002),new google.maps.LatLng(46.37228,8.422780000000001),new google.maps.LatLng(46.372310000000006,8.42314),new google.maps.LatLng(46.372490000000006,8.42347),new google.maps.LatLng(46.37241,8.423960000000001),new google.maps.LatLng(46.372150000000005,8.4246),new google.maps.LatLng(46.371880000000004,8.42495),new google.maps.LatLng(46.371700000000004,8.42566),new google.maps.LatLng(46.371660000000006,8.42628),new google.maps.LatLng(46.371640000000006,8.426770000000001)];
	v2i=[new google.maps.LatLng(46.37129,8.416730000000001),new google.maps.LatLng(46.371410000000004,8.421710000000001),new google.maps.LatLng(46.37154,8.426580000000001)];
	
	v1=[new google.maps.LatLng(46.3708,8.42252),new google.maps.LatLng(46.37044,8.422820000000002),new google.maps.LatLng(46.37041000000001,8.42355),new google.maps.LatLng(46.37059000000001,8.42473),new google.maps.LatLng(46.37093,8.425590000000001),new google.maps.LatLng(46.37118,8.42641)];
	v1i=[new google.maps.LatLng(46.371230000000004,8.42656),new google.maps.LatLng(46.3708,8.42252)];

	v11i=[new google.maps.LatLng(46.37228,8.42078),new google.maps.LatLng(46.37154,8.42169),new google.maps.LatLng(46.37118,8.42158),new google.maps.LatLng(46.37095,8.42145),new google.maps.LatLng(46.370740000000005,8.42154),new google.maps.LatLng(46.370430000000006,8.42145),new google.maps.LatLng(46.37021000000001,8.421320000000001),new google.maps.LatLng(46.37012000000001,8.42164),new google.maps.LatLng(46.37004,8.422590000000001),new google.maps.LatLng(46.370090000000005,8.423300000000001),new google.maps.LatLng(46.370250000000006,8.424520000000001),new google.maps.LatLng(46.370490000000004,8.42548),new google.maps.LatLng(46.37078,8.426060000000001),new google.maps.LatLng(46.371210000000005,8.42643)];
	
	snpi=[new google.maps.LatLng(46.376018282243585, 8.423584824630747),new google.maps.LatLng(46.37603308637438, 8.42053783518983)];
	snp=[new google.maps.LatLng(46.37603308637438, 8.42053783518983),new google.maps.LatLng(46.376323616628596, 8.420999175140391),new google.maps.LatLng(46.37644204890021, 8.421707278320322),new google.maps.LatLng(46.376486460935844, 8.422501212188731),new google.maps.LatLng(46.37636802876054, 8.423187857696543),new google.maps.LatLng(46.37602753482582, 8.423617011138926)];

	var ico='Immagini/Struttura/geoPointer/seggiovia2.gif';
	var icoh='Immagini/Struttura/geoPointer/skilift.gif';
	
	var mk=new Array();
	var iw=new Array();
	var k=true;


	var p=[	{x:46.3763511659725, y:8.416321277618408,ti:"Seggiovia Sagersboden",iwt:"Sciovia per sciatori esperti.",ico:"Immagini/Struttura/geoPointer/seggiovia2.gif"},
			{x:46.37133236494093,y:8.419218063354492,ti:"Skilift Valdo 2",iwt:"Pista media difficolt&agrave;.",ico:"Immagini/Struttura/geoPointer/skilift1.gif"},
			{x:46.3708585899875,y:8.424453735351562,ti:"Skilift Valdo 1",iwt:"Pista semplice.",ico:"Immagini/Struttura/geoPointer/skilift.gif"},
			{x:46.37604233895409, y:8.422200804779063,ti:"Snowpark Ponte",iwt:"Pista media.",ico:"Immagini/Struttura/geoPointer/skilift0.gif"}];

	this.mkiw=function(t,c){return "<h3>"+t+"</h3><p>"+c+"</p>";};
	
	this.aiw=function(i, mrk, map, t, wc){
 		iw[i] = new google.maps.InfoWindow({content: this.mkiw(t, wc)});
		google.maps.event.addListener(mrk, 'click', function() {iw[i].open(map,mrk);});
	};


	this.i=function() {
		m=new google.maps.Map($("loc"), o);
		po=new google.maps.Polyline({
			path: sv,
			strokeColor: "#FF6600",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});		
		po1=new google.maps.Polyline({
			path: snpi,
			strokeColor: "#0000FF",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});
		
		pon=new google.maps.Polyline({
			path: snp,
			strokeColor: "#FF6600",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});		
		pon1=new google.maps.Polyline({
			path: svi,
			strokeColor: "#0000FF",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});

		
		pv=new google.maps.Polyline({
			path: v1,
			strokeColor: "#FF6600",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});
		pv1=new google.maps.Polyline({
			path: v1i,
			strokeColor: "#0000FF",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});

		pvv=new google.maps.Polyline({
			path: v2,
			strokeColor: "#FF6600",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});
		pvv1=new google.maps.Polyline({
			path: v2i,
			strokeColor: "#0000FF",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});
		pvvv1=new google.maps.Polyline({
			path: v11i,
			strokeColor: "#FF6600",
			strokeOpacity: 0.8,
			strokeWeight: 2,
			map:m
		});

		
		for(i=0; i<p.length; i++){
			mk[i]=new google.maps.Marker({position: new google.maps.LatLng(p[i].x, p[i].y), map: m, icon:p[i].ico, title:p[i].ti});
			this.aiw(i, mk[i], m, p[i].ti, p[i].iwt);
		}

	};
}

var u=new asMap();

è(window, 'load', function(){	
	
	è($("invia"), 'click', function(){
		sendForm();
	});

	u.i();	
	hilight('scialpM');
});