function WindowOverlay(windowcss,contentcss) {
 
	
	this.container =  document.body;
	
	// Assign instance variables
	this.content = new Element('div', {'class': contentcss}).hide();
	this.content.setAttribute("id", 'window_content');
	this.overlay = new Element('div', { 'class': 'overlay' }).hide();
	this.dialog = new Element('div').hide();
	this.dialog.setAttribute("id", 'fixme');
	this.dialog.setAttribute("class", windowcss);
	
	this.girolamo = new Element('div', { 'class': 'ovWaitingIcon'}).hide();
	
	this.topbanner = new Element('div', {'class': 'ovWindowTopBanner'});
	
	this.logoalf = new Element('div', {'class': 'ovWindowLogo'});
	this.greyalf = new Element('div', {'class': 'ovWindowInBan'});
	
	
	
	
	this.imager = document.createElement('img');
	this.imager.setAttribute('src','./html_images/close_img.png');
	this.imager.setAttribute('border','0px');
	
	this.aclose = document.createElement('a');
	this.aclose.setAttribute('class', 'ovWindowClose');
	this.aclose.setAttribute('href', '#');
	this.aclose.appendChild(this.imager);
	this.greyalf.appendChild(this.aclose);


	this.topbanner.appendChild(this.logoalf);
	this.topbanner.appendChild(this.greyalf);
	this.dialog.appendChild(this.topbanner);
	
	
	// Hide the overlay when clicked. Ignore clicks on the dialog.
	Event.observe(this.aclose, 'click', this.hide.bindAsEventListener(this));
	Event.observe(this.overlay, 'click', this.hide.bindAsEventListener(this));
	//Event.observe(this.dialog, 'click',  function(event) { Event.stop(event) });
	
	// Insert the elements into the DOM
	this.content.appendChild(this.girolamo);
	this.dialog.appendChild(this.content);
	this.container.appendChild(this.overlay);
	this.container.appendChild(this.dialog);
	
	
	// Content may have been hidden if it is embedded in the page
	this.girolamo.show();
	this.content.show();
};

WindowOverlay.prototype.show = function() {
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.8 });
	this.dialog.show();
	return this;
};

WindowOverlay.prototype.hide = function(event) {
	this.dialog.hide();
	this.overlay.hide();
	document.body.removeChild(this.overlay);
	document.body.removeChild(this.dialog);
	return this;
};

WindowOverlay.prototype.showpage = function(pagelink){
	this.girolamo.show();
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.8 });
	new Ajax.Updater(this.content, pagelink, { method: 'get'});
	this.girolamo.hide();
	this.dialog.show();
	return this;
};

function shoWindow(pagelink,wcss,ccss,jsfile,cssfile){
	if (typeof(jsfile) != "undefined") loadJs(jsfile);
	if (typeof(jsfile) != "undefined") loadCss(cssfile);
	var overlay = new WindowOverlay(wcss,ccss);
	overlay.showpage(pagelink);
};

function loadJs(filename){
  	var fileref=document.createElement('script');
  	fileref.setAttribute("type","text/javascript");
  	fileref.setAttribute("src", filename);
  	document.getElementsByTagName("head")[0].appendChild(fileref);
};

function loadCss(filename){
	var fileref=document.createElement("link");
 	fileref.setAttribute("rel", "stylesheet");
  	fileref.setAttribute("type", "text/css");
  	fileref.setAttribute("href", filename);
  	document.getElementsByTagName("head")[0].appendChild(fileref);
};


function mapOverlay(type){
	this.container = document.body;

	
	this.overlay = new Element('div', { 'class': 'overlay' }).hide();
	this.mapWindow = new Element('div', { 'class': 'mapWindow' }).hide();
	//this.girolamo = new Element('div', { 'class': 'girolamo'}).show();
	this.topbanner = new Element('div', {'class': 'mapTopBanner'}).show();
	this.logoalf = new Element('div', {'class': 'ovWindowLogo'}).show();
	this.greyalf = new Element('div', {'class': 'ovWindowInBan'}).show();
	
	
	
	this.imager = document.createElement('img');
	this.imager.setAttribute('src','./html_images/close_img.png');
	this.imager.setAttribute('border','0px');
	this.aclose = document.createElement('a');
	this.aclose.setAttribute('class', 'ovWindowClose');
	this.aclose.setAttribute('href', '#');
	this.directionInfo;
	this.mapcontainer;
	this.mainMap = new Element('div', {'class': 'mainMap'}).show();
	this.directionInfo = new Element('div', {'class': 'mapDirection'}).show();

	if(type==true){
		this.mapcontainer = new Element('div', {'id': 'mapcontainer'}).show();
		this.mainMap.appendChild(this.mapcontainer);
		this.mainMap.appendChild(this.directionInfo);
	}else{
		this.mapcontainer = new Element('div', {'id': 'mapcontainer2'}).show();
		this.mainMap.appendChild(this.mapcontainer);
	}
	this.aclose.appendChild(this.imager);
	this.greyalf.appendChild(this.aclose);

	

	this.topbanner.appendChild(this.logoalf);
	this.topbanner.appendChild(this.greyalf);
	this.mapWindow.appendChild(this.topbanner);
	
	
	this.mapWindow.appendChild(this.mainMap);
	
	
	
	
	Event.observe(this.aclose, 'click', this.hide.bindAsEventListener(this));
	Event.observe(this.overlay, 'click', this.hide.bindAsEventListener(this));
	
	
	this.container.appendChild(this.overlay);
	this.container.appendChild(this.mapWindow);
	//this.container.insert(this.directionInfo);
	this.alfIcon = new GIcon();
		this.alfIcon.image = "./html_images/ico.png";
                
		// Set up our GMarkerOptions object
		
		
		this.alfIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		this.alfIcon.iconSize = new GSize(30, 23);
		this.alfIcon.shadowSize = new GSize(30, 23);
		this.alfIcon.iconAnchor = new GPoint(15, 12);
		this.alfIcon.infoWindowAnchor = new GPoint(30, 23)
		
	
	 	
};


mapOverlay.prototype.show = function(from) {
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.8 });
	//this.girolamo.hide();
	this.mapWindow.show();
	//this.directionInfo.show();
	
        markerOptions = { icon:this.alfIcon };    
       	this.map = new GMap2(this.mapcontainer);
       	this.map.addControl(new GSmallMapControl());
		this.map.addControl(new GMapTypeControl());
	
		
		this.gdir = new GDirections(this.map, this.directionInfo);
		
		

		var center = new GLatLng(45.557600,11.558394);
		this.map.setCenter(center, 15);
		this.map.openInfoWindowHtml(center,"Ristorante e Pizzeria<br>\"Al Fornareto\"<p>Viale Trieste 110,<br> 36100 Vicenza (Italy)</p>");
                   
		var marker = new GMarker(center, markerOptions);

		GEvent.addListener(marker, "click", function() { this.map.openInfoWindowHtml(center,"Ristorante e Pizzeria<br>\"Al Fornareto\"<p>Viale Trieste 110,<br> 36100 Vicenza (Italy)</p>");});
  
		this.map.addOverlay(marker);
		this.gdir.load("from: "+from+" to: 45.557600,11.558394", { "locale": "it_IT" });

	return this;
};

mapOverlay.prototype.hide = function(event) {
	this.mapWindow.hide();
	this.overlay.hide();
	this.directionInfo.hide();
	GUnload();
	return this;
};




function showMap(from){
	var overlay;
	if(from!='')
		overlay = new mapOverlay(true);
	else 
		overlay = new mapOverlay(false);
		
	overlay.show(from);
};


function deleteImage(status){
	if (status==false){
		if(window.confirm("Sei sicuro di voler cancellare questa immagine?")){
			return false;
		}
		return true;
	}
	return true;
	
};
