bodyContent='';
maze_xpos=0;
maze_ypos=0;
initialized=false;
lastclick=0;
lastname='http://www.start-web.it/template/b_home.png';
all_loaded=0;

function tick() {}

function move(name,wich,x,y){
	document.getElementById('button'+lastclick).src=lastname;
	lastclick=wich;
	lastname=document.getElementById('button'+wich).src;
	document.getElementById('button'+wich).src='http://www.start-web.it/template/'+name;;
	x=0+900*(x-1);
	y=0+560*(y-1);
	dx=x-maze_xpos;
	dy=y-maze_ypos;
	if (dx<0) l_sign="+"; else l_sign="-";
	if (dy<0) t_sign="+"; else t_sign="-";
	stringa1 =l_sign+ '=' + Math.abs(dx) + "px";
	stringa2 =t_sign+ '=' + Math.abs(dy) + "px";
	$('#bc').animate({"left" : stringa1, "top" : stringa2},500);
	maze_xpos=x;
	maze_ypos=y;
}

function shakemebaby(){
	if (initialized)return;
	 $('#start_logo').effect('shake', { times:3,distance:10 }, 100);
	 setTimeout(shakemebaby,5000);
}

function center(obj){
	// centra l'oggetto all'interno del browser
	h = screen.availHeight;
	w = screen.availWidth;	
	hobj = $(obj).height();
	wobj = $(obj).width();
	h = Math.floor((h-hobj)/3)+'px';
	w = Math.floor((w-wobj)/2)+'px';		
	$(obj).css('position','absolute');
	$(obj).css('top',h);
	$(obj).css('left',w);
	$(obj).fadeIn('slow');
	setTimeout(shakemebaby,5000);
	load_contents();
}



function init_maze(obj){
	if (initialized) return;
	initialized=true;
	// centra l'oggetto all'interno del browser

	// ricalcolo la posizione del logo start centrato e verifico lo scostamento per generare l'animazione
	h = screen.availHeight;
	w = screen.availWidth;	
	hobj = $(obj).height();
	wobj = $(obj).width();
	h = Math.floor((h-hobj)/4);
	w = Math.floor((w-wobj)/2);
		
	hobj = new String($('#start_logo').css('top'));
	hobj=hobj.replace('px','');
	wobj = new String($('#start_logo').css('left'));
	wobj=wobj.replace('px','');
	wl=(hobj-h);
	hl=(wobj-w)+130;
	
	stringa1 ='-=' + hl + "px";
	stringa2 ='-=' + wl + "px";
	//$('#start_logo').animate({"left" : stringa1, "top" : stringa2},500,function(){$('#menubar').animate({"left" : "+=900px", "top" : "+=0px"},500,function(){$(obj).fadeIn('slow',function{initialize_gmaps()});})});	
	$('#start_logo').animate({"left" : stringa1, "top" : stringa2},500,function(){$(obj).fadeIn('slow',function(){$('#menubar').animate({"left" : "+=1000px", "top" : "+=0px"},500)})});
	h = screen.availHeight;
	w = screen.availWidth;	
	hobj = $(obj).height();
	wobj = $(obj).width();
	h = Math.floor((h-hobj)/4)+'px';
	w = Math.floor((w-wobj)/2)+'px';
	$(obj).css('position','absolute');
	$(obj).css('top',h);
	$(obj).css('left',w);
	
	//fading_maindiv();
}

function load_start_button(attempt) {
	// attendi il caricamento dell'immagine	
	if (attempt>100) {
		// il pulsante non č stato caricato in almeno 10 secondi, forzo il caricamento della prima pagina
		location.href="index.php?azione=start";
	}	else {			
			if (!document.getElementById("img_start_button").complete){
				attempt++;
				window.setTimeout("load_start_button("+attempt+")", 100);
			} 	else $('#img_start_button').fadeIn("slow");				
		}
}

function load_contents(){
	for (i=1;i<10;i++){
		r=Math.random(10000);
		id= '#cc'+i;
		$(id).load("contents.php", {"blocco": i,"r":r});
	}
}

function initialize_gmaps() {      
	  if (GBrowserIsCompatible()) {
	    var map = new GMap2(document.getElementById("mapsbox")); 
		map.enableScrollWheelZoom();
		map.addControl(new GLargeMapControl());	
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = "http://www.start-web.it/template/logo_start_icon.png";
		blueIcon.iconSize = new GSize(41, 48);
		//blueIcon.shadowSize = new GSize(51, 58);
		markerOptions = { icon:blueIcon };
		center=new GLatLng(45.192933, 11.301005);
		map.setCenter(center, 13);
		var marker = new GMarker(center,markerOptions);
		/*GEvent.addListener(marker, "mouseover",
			function() {
				marker.openInfoWindowHtml('<img src="http://www.dicogroup.it/template/logodicopiccolo.gif" />');
			}
		);*/
		map.addOverlay(marker);	
		map.setMapType(G_HYBRID_MAP);
	  }	
	}
	
function send_information(cnumber){
	res= prompt (cnumber,"immettere il numero proposto per procedere all'invio");
	if (res!=cnumber) {
		alert ('Codice non corretto, richiesta non inviata');
	} else alert('Richiesta inviata correttamente, sarete contattati al pių presto. Grazie.');
}
