$(document).ready(function() {

var maps = "map=";
var url = document.location.toString(); 
var splot = url.split(maps);    
var map = splot[1];
//console.log(map);

function gmap (id){
	// inserisco la mappa di google
	if (GBrowserIsCompatible()) {
		if(id == 'map-a' || id == 'North-America'){
			coorX = 35.467258726706675;
			coorY = -97.54106283187866;
		}
		else if(id == 'map-b' || id == 'Vittoria-SpA'){
			coorX = 45.657593;
			coorY = 9.554026;
		}
		else if(id == 'map-c' || id == 'Lyon-Tyres'){
			coorX = 13.53306734921549;
			coorY = 100.65761804580688;
		}
		else if(id == 'map-d' || id == 'Vittoria-Industries'){
			coorX = 22.28133313436372;
			coorY = 114.15526628494263;
		}
		else if(id == 'map-e' || id == 'Vittoria-Logistic'){
			coorX = 25.058252647949523;
			coorY = 121.5253758430481;
		}
		//Setto le coordinate
		var coordsLeasing = new GLatLng(coorX,coorY);
		//Creo la mappa 
		var mapLeasing = new GMap2(document.getElementById( 'gMap'+id ));
		mapLeasing.setCenter(coordsLeasing, 12);
		mapLeasing.setUIToDefault();
			
		//Definisco il path per la tip.png
		var tip = new GIcon(G_DEFAULT_ICON);
		
		tip.iconSize = new GSize(150, 44);
		tip.shadowSize = new GSize(150, 44);
		tip.image = "http://www.geax.com/wp-content/themes/new-geax/style/images/tipGeaxMap.png";										  
		
		markerOptions = { icon:tip };
		
		//Creo le tip
		mapLeasing.addOverlay(new GMarker(coordsLeasing, markerOptions));
	}
}

if(map)
{
if(map == 'North-America'){
	icon = 'a';
	info = '<strong>Vittoria Industries North America Inc.</strong> 1639 West Sheridan Ave Oklahoma City, OK 73106 USA <br /><strong>phone: +1 800 223 3207 fax: +1 800 561 6737</strong>';
}
else if(map == 'Vittoria-SpA'){
	icon = 'b';
	info = '<strong>Vittoria S.p.A.</strong> Via Papa Giovanni XXIII, 1 24040 Madone (BG) <br /><strong>phone: +39 0354993911 fax: +39 035 4993912</strong>';
}
else if(map == 'Lyon-Tyres'){
	icon = 'c';
	info = '<strong>Lion Tyres (Thailand) Co., Ltd.</strong> 241 Bangpoo Industrial Estate Soi 3, Patana 1 Road, Praeksa, <br />Muang Samutprakarn 10280 Thailand - <strong>phone: +662 792 8000 fax: +662 709 4775</strong>';
}
else if(map == 'Vittoria-Industries'){
	icon = 'd';
	info = '<strong>Vittoria Industries Limited</strong> - 38 - 44 D’Aguilar Street, Central, Hong Kong <br /><strong>phone. +852 2868 3330 fax: +852 2524 2350</strong>';
}
else if(map == 'Vittoria-Logistic'){
	icon = 'e';
	info = '<strong>Vittoria Logistics Taiwan</strong> Operated by Asfour Room 510, 5th floor, No.372 Linsen North Rd. Taipei, Taiwan 104<br /><strong>phone: +886 2 25371879 fax: +886 2 25372785</strong>';
}
	$('div.mapHere').html('<div class="mapInfo">'+ info +'</div><div class="mapDiv" id="gMap'+ map +'"></div>');
	gmap(map);
	$('div.icon-'+icon).animate({marginLeft : '0'},500);
	$('div.mapHere').animate({height:'318px'},900);
}

$('a.punto')
	/*
	.hover(
		function(){
			$(this).css({'background':'#000', 'opacity':'0.1'});
		}, function(){
			$(this).css('background','');
		}
	)
	*/
	.hover(
		function(){
			$(this).css('background-position', '0 0');
		}, function(){
			$(this).css('background-position', '0 200px');
		}
	)
	.click(
		function(){
			var icon = $(this).attr('id');
			var id 	= $(this).attr('name');
			//alert(icon)
			$('div.mapHere').animate({height:'1px'},500);
			$('div.mapHere').html('&nbsp;');
			$('div.block').animate({marginLeft : '-300px'},200);
			$('div.icon-'+icon).animate({marginLeft : '0'},500);
			$(this).siblings().removeClass('active');
			$(this).addClass('active');
			if(id == 'map-a'){
				info = '<strong>Vittoria Industries North America Inc.</strong> 1639 West Sheridan Ave Oklahoma City, OK 73106 USA <br /><strong>phone: +1 800 223 3207 fax: +1 800 561 6737</strong>';
			}
			else if(id == 'map-b'){
				info = '<strong>Vittoria S.p.A.</strong> Via Papa Giovanni XXIII, 1 24040 Madone (BG) <br /><strong>phone: +39 0354993911 fax: +39 035 4993912</strong>';
			}
			else if(id == 'map-c'){
				info = '<strong>Lion Tyres (Thailand) Co., Ltd.</strong> 241 Bangpoo Industrial Estate Soi 3, Patana 1 Road, Praeksa, <br />Muang Samutprakarn 10280 Thailand - <strong>phone: +662 792 8000 fax: +662 709 4775</strong>';
			}
			else if(id == 'map-d'){
				info = '<strong>Vittoria Industries Limited</strong> - 38 - 44 D’Aguilar Street, Central, Hong Kong <br /><strong>phone. +852 2868 3330 fax: +852 2524 2350</strong>';
			}
			else if(id == 'map-e'){
				info = '<strong>Vittoria Logistic Taiwan</strong> Operated by Asfour Room 510, 5th floor, No.372 Linsen North Rd. Taipei, Taiwan 104<br /><strong>phone: +886 2 25371879 fax: +886 2 25372785</strong>';
			}
			$('div.mapHere').html('<div class="mapInfo">'+ info +'</div><div class="mapDiv" id="gMap'+ id +'"></div>');
			gmap(id);
			$('div.mapHere').animate({height:'318px'},900);
			return false;

		}
	)

$('a.close')
	.click(
		function(){
			$('div.mapHere').animate({height:'1px'},500);
			$('div.mapHere').html('&nbsp;');
			$(this).parents('div.block').animate({marginLeft : '-300px'},800);
		}
	)

});
