function JInit(){
	  $('body').find('.flash_obj').each(function(){
       _swf = $(this).find('#swf').val();
       _id = $(this).attr('id');
       _width = parseFloat($(this).css('width'));
       _height = parseFloat($(this).css('height'));
       s_flash = new SWFObject(_swf, _id, _width, _height, "0");
       s_flash.addParam("wmode", "transparent");
       s_flash.write(_id);
    });
    
    $(".form").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			msg: "required",
			agree: "required"
		},
		messages: {
			name: "Inserire il nome",
			email: "Inserire un email valido",
			msg: "Inserire un messaggio",
			agree: "Accettare la normativa sulla privacy"
		}
	});
	
	$(".prenotazioni").validate({
		rules: {
			name: "required",
			surname: "required",
			surname: "required",
			email: {
				required: true,
				email: true
			},
			persone: {
				required: true,
				number: true
			},
			agree: "required"
		},
		messages: {
			name: "Inserire il nome",
			surname: "Inserire il cognome",
			email: "Inserire un email valido",
			persone:"Inserire un numero valido",
			agree: "Accettare la normativa sulla privacy"
		}
	});


    
    $('.download').click(function(){
      file = $(this).attr('href');
      _href= 'download.php?f=' + file;
      $(this).attr('href', _href)
    });
    
    $("a[rel^='prettyPhoto']").prettyPhoto({
			
		});
		
		$(".datepicker").datepicker({
        dateFormat: 'dd/mm/yy'
    });
		
		$('a[target="_blank"]').click(function(){
      window.open(this.href);
      return false;
    });
		
    google_maps();
}


function google_maps(){
  $('body').find('.google_maps').each(function(){
    title = $(this).attr('title'); 
    _id = $(this).attr('id');
    _lat = $(this).find('#lat').val();
    _lng = $(this).find('#lng').val();
    _zoom = $(this).find('#zoom').val();
    _msg = $(this).find('#msg').val();
    if (_msg!=undefined){
      _msg = '';
    }
    if (_zoom!=undefined){
      _zoom = parseFloat(_zoom);
    }
    $('#lng').remove();
    $('#lat').remove();
    $('#zoom').remove();
    initialize(_id, _lng, _lat, _zoom, _msg);
  });
}



function initialize(id, lng, lat, zoom, msg) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById(id));
        map.setCenter(new GLatLng(lat, lng), zoom);
        map.setUIToDefault();
        var latlng = new GLatLng(lat, lng);
        map.addOverlay(new GMarker(latlng));
        if (msg!=undefined){
          map.addOverlay(createMarker(latlng, map, msg));
        }
      }
    }


function createMarker(latlng, map, msg) {
      var marker = new GMarker(latlng);
      GEvent.addListener(marker,"click", function() {
        map.openInfoWindowHtml(latlng, msg);
      });
      return marker;
	} 
