function quickWlight(p){				
	if (!p.id) return;	
	if (p.toggle && ($(p.id)) ) {		
		if ( $(p.id).visible() ) { 
			$(p.id).hide();
			return
		}
		else
			$(p.id).show();
	}		
	var w = new Wlight({id: p.id});
	var widthWindow = 	p.w|| w.getPageSize().pageWidth;
	var heightWindow = 	p.h|| w.getPageSize().pageHeight;
	var viewPort_y = p.viewPort_y || false;
	w.setDimension({ w: widthWindow , h: heightWindow });
	if (p.htmlContent)  w.setContentHtml(p.htmlContent);
	if (p.idDomContent) w.setContent(p.idDomContent);
	var oPos = (p.oPos)? p.oPos : null;
	w.setPosX({ oMarkPos: oPos, spacer: p.hspacer });
	w.setPosY({ oMarkPos: oPos, spacer: p.vspacer, viewPortRelative_y: true });	
	var zindex = p.zindex || 999;
	w.toFront({ zIndex : zindex });		
	w.showD();
	return w;
}

/* CLASSE W (light-PopUp) */
var Wlight = Class.create();
Wlight.prototype = {	
 	//costruttore accetta :
 	//id : ID objDOM  	
	initialize: function(p) {
 		this.id = p.id;		
		if($(this.id)) {
			$(this.id).remove()
			// return
		}   
		this._appendDiv();		
		this.o = $(this.id);
		this.o.setStyle({position: 'absolute'});
		this.o.setStyle({display:'none'});	
			
//		this.o.setStyle({border:'1px solid #FF0000'});	
		//this.o.setStyle({ background : '#FF00FF'});			
		this.alpha = p.alpha || 1;
		this.effectAppear = p.effectAppear || false;
		this.effectFade = p.effectFade || false;
				
 	},
	toFront: function(index){		
		this.o.setStyle({ zIndex : index});
	},
	_appendDiv: function(){		
		if($(this.id)) return;
		var d = document.createElement("div");
		d.setAttribute("id",this.id);				
		document.body.appendChild(d);
	},	
	getContent: function(){
		return this.o.innerHTML
	},
	setContent: function(p){
		$(this.id).innerHTML = $(p).innerHTML;
	},	
	setContentHtml: function(p){
		$(this.id).innerHTML = '';
		$(this.id).innerHTML = p;
	},
	setDimension: function(p){				
		this.o.setStyle( {width: p.w + 'px'} );
		this.o.setStyle({height: p.h +'px'});
		this.w = p.w;
		this.h = p.h;
	},
	getCoord: function() {
		var o = {};
		o.minX = this.findPos($(this.id))[0];
		o.minY = this.findPos($(this.id))[1];
		o.maxX = o.minX + Element.getDimensions(this.o).width;
		o.maxY = o.minY + Element.getDimensions(this.o).height;
		return o
 	},
	setPosX: function (p) {			
		//se la pagina non ï¿½ caricata esco
		
		//if (p.pageloaded){return}			
		var x = 0;			
		if($(p.oMarkPos)){
			x = this.findPos($(p.oMarkPos))[0]
		}
		var spacer = (p.spacer)? parseInt( p.spacer ) : 0;
		x += spacer;	
		this.o.setStyle({left:x + 'px'})	
			
	},	
	setPosY: function (p) {			
		// se la pagina non ï¿½ caricata esco
		//if (p.pageloaded){ return }
		var y = 0;
		if($(p.oMarkPos)) { y = this.findPos($(p.oMarkPos))[1] }		
		var spacer = (p.spacer)? parseInt(p.spacer) : 0;
		y += spacer;
		
		// se il posizionamento è relativo al viewPort lo considero
		if( p.viewPortRelative_y && (p.oMarkPos==null) ) {
			y += document.viewport.getScrollOffsets()[1];
			if (p.valign == 'center'){
				y = ((this.getDimension().height - this.h) / 2) + document.viewport.getScrollOffsets()[1];
			}
		}
		
		this.o.setStyle({top: y + 'px'})	
	},
	showD: function (p)
	{		
		if (typeof this.o != 'object') { return; }	//esco	
		p = p ||{};	// config parametri	
		var effectAppear = ( p.effectAppear )? p.effectAppear  : this.effectAppear;
		if (effectAppear) {
			Effect.Appear(this.o,effectAppear);
		}
		else{			
			this.o.show();
		}	
	},
	setPreloader: function (p)
	{
		// carica interfaccia loading
		$(p.id).innerHTML ='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="25" HEIGHT="25" id="pensino_ok" ALIGN="center"> <PARAM NAME=movie VALUE="/images/sito/pensino_ok.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="/images/sito/pensino_ok.swf" quality=high scale=exactfit wmode=transparent bgcolor=#FFFFFF  WIDTH="25" HEIGHT="25" NAME="pensino_ok" ALIGN="center" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';			
	},	
	setAjaxContent: function (p)
	{
		var idElement = p.idCont;
		// connection Ajax
		var ajax = new Ajax.Updater
		(	   
	         p.idCont,						// DIV id
	         p.url,        					// URL
	         {                
	         	method: p.method,			// get	
	            onComplete: showResponse	// callBack	
	         }
		)		
	},		
	findPos: function (objmarkerposition) {
		var curleft = curtop = 0;
		if(objmarkerposition){
			if (objmarkerposition.offsetParent) {
				curleft = objmarkerposition.offsetLeft
				curtop = objmarkerposition.offsetTop
				while (objmarkerposition = objmarkerposition.offsetParent) {
					curleft += objmarkerposition.offsetLeft
					curtop += objmarkerposition.offsetTop
				}
			}
			return [curleft,curtop];
		}
	},	
	getPageSize: function(){
    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {  
      xScroll = document.body.scrollWidth;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

	if (document.documentElement && document.documentElement.clientHeight) { 
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    } else if (self.innerHeight) {  // others
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
    }
	
    var pageHeight, pageWidth;

    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else { 
      pageHeight = yScroll;
    }
	// for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){  
      pageWidth = windowWidth;
    } else {
      pageWidth = xScroll;
    }
    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
	},
	
	getDimension: function()
	{
		this.width = 0;
		this.height = 0;
		this.result = null;
		if (self.innerWidth)
		{
			/* Firefox  */
			this.width = self.innerWidth;
			this.height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientWidth)
		{
			this.width = document.documentElement.clientWidth;
			this.height = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			/* IE 6  */
			this.width = document.body.clientWidth;
			this.height = document.body.clientHeight;
		}

		result = {width:this.width, height:this.height};
		return result;
	}
}

function showResponse(req)
{	
	idElement.innerHTML = req.responseText ;
}