function findPosition( id ) {
	oElement = document.getElementById(id);
	if( typeof( oElement.offsetParent ) != 'undefined' ) {
		for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		return [ posX, posY ];
	}
	else{
		return [ oElement.x, oElement.y ];
	}
}
// Alert Javascript ***************************************************************************+
	function call_walert(){
		var id = prompt("Inserisci l'id dell'elemento da sbiancare","");
		if(id != null);
			w_alert(id, 'Sono un alert!');
	}
	
	function w_alert(elementId, testo, a1, b1, c1, d1, e1){
        //alert (a1);  
        if (a1==undefined) { a1 = '200' }
        if (b1==undefined) { b1 = '-100' }
        if (c1==undefined) { c1 = '50%' }
        if (d1==undefined) { d1 = '50%' }
        if (e1==undefined) { e1 = 0 }
        var table = '<div style="background:#FFFFFF; border:2px solid #663399; width: '+a1+'px; margin-left:'+b1+'px; left:'+c1+'; top:'+d1+'; position:absolute;">';
		table += '<div style="padding: 2px 0 2px 0"><div style="float:left; line-height: 22px; vertical-align: middle; margin-left: 8px"><font color="#663399">'+testo+'</testo></div>';
		//table += '<input type="button" value="ok" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'" />';
		table += '<div style="float:right; margin-right: 8px"><input type="image" src="http://www.tecnozoom.it/images/ok.png" alt="close" width="18" height="18" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'"/></div> <br style="clear:both"></div>';
		table += '</div>';
		var obj = document.getElementById(elementId);
		var sbiancante = document.getElementById('sbianca');
		if(obj != null){
			//estraggo dimensioni dell'object da sbiancare
			var larghezza = obj.clientWidth;
			var altezza = obj.clientHeight;
		        pippo = $(elementId).getDimensions();
            		larghezza = pippo["width"];
            		altezza   = pippo["height"];
			//Calcolo la posizione dell'oggetto da sbiancare
			var posXY = findPosition(elementId);
			//Assegno altezza e posizione all'object sbiancante
			sbiancante.style.width = larghezza+'px';
            		altezza = altezza + e1;
			sbiancante.style.height = altezza+'px';
			sbiancante.style.position = 'absolute';
			left = posXY[0]+parseInt(b1);
			sbiancante.style.left = left+'px';
			sbiancante.style.top = posXY[1]+'px';
			sbiancante.innerHTML = table;
			//lo rendo visibile
			sbiancante.style.display = 'block';
		}
	}

// Confirm Javascript ***************************************************************************+
function call_wconfirm(){
		var id = prompt("Inserisci l'id dell'elemento da sbiancare","");
		if(id != null);
			w_confirm(id, 'Sono un confirm');
}

function call_reportAbuse(Id, elementId, a1, b1, c1, d1, e1){
    w_confirmAbuse(Id, elementId, 'Sei sicuro di voler segnalare un abuso?', 'La tua segnalazione e\\\' stata inviata', a1, b1, c1, d1);
}


function w_confirmAbuse(Id, elementId, testo, testo1, a1, b1, c1, d1, e1){

        if (a1==undefined) { a1 = '200' }
        if (b1==undefined) { b1 = '-100' }
        if (c1==undefined) { c1 = '50%' }
        if (d1==undefined) { d1 = '50%' }
        if (e1==undefined) { e1 = 0 }

        var table = '<div style="background:#FFFFFF; border:2px solid #663399; width: '+a1+'px; margin-left:'+b1+'px; left:'+c1+'; top:'+d1+'; position:absolute;">';
        table += '<div style="padding: 2px 0 2px 0"><div style="float:left; line-height: 22px; vertical-align: middle; margin-left: 8px;"><font color="#663399">'+testo+'</font></div>';
        table += '<div style="float:right; margin-right: 8px"><input type="image" src="http://www.tecnozoom.it/images/no.png" alt="close" width="18" height="18" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\';"/></div>';
        table += '<div style="float:right; margin-right: 8px"><input type="image" src="http://www.tecnozoom.it/images/si.png" alt="close" width="18" height="18" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'; reportAbuse(\''+Id+'\'); w_alert(\''+elementId+'\', \''+testo1+'\', \''+a1+'\', \''+b1+'\', \''+c1+'\', \''+d1+'\' )"/></div>';
        table += '<br style="clear:both"></div>';
        table += '</div>';

        var obj = document.getElementById(elementId);
        var sbiancante = document.getElementById('sbianca');
        if(obj != null){
            //estraggo dimensioni dell'object da sbiancare
            var larghezza = obj.clientWidth;
            var altezza = obj.clientHeight;
            //Calcolo la posizione dell'oggetto da sbiancare
            var posXY = findPosition(elementId);
            //Assegno altezza e posizione all'object sbiancante
            sbiancante.style.width = larghezza+'px';
            sbiancante.style.height = altezza+'px';
            sbiancante.style.position = 'absolute';
            sbiancante.style.left = posXY[0]+'px';
            sbiancante.style.top = posXY[1]+'px';
            sbiancante.innerHTML = table;
            //lo rendo visibile
            sbiancante.style.display = 'block';
        }
}




var retcon = null;
function w_confirm(elementId, testo, testo1, a1, b1, c1, d1, e1){

        if (a1==undefined) { a1 = '200' }
        if (b1==undefined) { b1 = '-100' }
        if (c1==undefined) { c1 = '50%' }
        if (d1==undefined) { d1 = '50%' }
        if (e1==undefined) { e1 = 0 }

        var table = '<div style="background:#FAF0F7; border:1px solid #A09D97; width: '+a1+'px; margin-left:'+b1+'px; left:'+c1+'; top:'+d1+'; position:absolute;">';
        table += '<div style="padding: 2px 0 2px 0"><div style="float:left; line-height: 22px; vertical-align: middle; margin-left: 8px">'+testo+'</div>';
        table += '<div style="float:right; margin-right: 8px"><input type="image" src="http://www.tecnozoom.it/images/close.gif" alt="close" width="22" height="22" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'; retcon = false;"/></div>';
        table += '<div style="float:right; margin-right: 8px"><input type="image" src="http://www.tecnozoom.it/images/close.gif" alt="close" width="22" height="22" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'; w_alert(\''+elementId+'\', \''+testo1+'\')"/></div>';
        table += '<br style="clear:both"></div>';
        table += '</div>';

		var obj = document.getElementById(elementId);
		var sbiancante = document.getElementById('sbianca');
		if(obj != null){
			//estraggo dimensioni dell'object da sbiancare
			var larghezza = obj.clientWidth;
			var altezza = obj.clientHeight;
			//Calcolo la posizione dell'oggetto da sbiancare
			var posXY = findPosition(elementId);
			//Assegno altezza e posizione all'object sbiancante
			sbiancante.style.width = larghezza+'px';
			sbiancante.style.height = altezza+'px';
			sbiancante.style.position = 'absolute';
			sbiancante.style.left = posXY[0]+'px';
			sbiancante.style.top = posXY[1]+'px';
			sbiancante.innerHTML = table;
			//lo rendo visibile
			sbiancante.style.display = 'block';
		}
}


// Prompt Javascript ***************************************************************************+
function call_wprompt(){
		var id = prompt("Inserisci l'id dell'elemento da sbiancare","");
		if(id != null);
			w_prompt(id, 'Sono un prompt');
}

var text_wprompt = null;
function w_prompt(elementId, testo){
		var table = '<table width="100%" height="60%"><tr><td align="center"><b>' + testo + '</b></td></tr>';
table += '<tr><td align="center"><input type="text" style="border:2px solid black" onKeyUp="javscript:text_wprompt=this.value"/></td></tr></table>';
table += '<center><input type="button" value="ok" onClick="javascript:this.offsetParent.style.display=\'none\';alert(text_wprompt);"/>';
table += '<input type="button" value="annulla" onClick="javascript:this.offsetParent.style.display=\'none\';text_wprompt=null;alert(text_wprompt);"/></center>';
		var obj = document.getElementById(elementId);
		var sbiancante = document.getElementById('sbianca');
		if(obj != null){
			//estraggo dimensioni dell'object da sbiancare
			var larghezza = obj.clientWidth;
			var altezza = obj.clientHeight;
			//Calcolo la posizione dell'oggetto da sbiancare
			var posXY = findPosition(elementId);
			//Assegno altezza e posizione all'object sbiancante
			sbiancante.style.width = larghezza;
			sbiancante.style.height = altezza;
			sbiancante.style.position = 'absolute';
			sbiancante.style.left = posXY[0];
			sbiancante.style.top = posXY[1];
			sbiancante.innerHTML = table;
			//lo rendo visibile
			sbiancante.style.display = 'block';
		}
}

// ************************************** Sbiancamento BODY ************************


function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return [ myWidth, myHeight ];
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}




    function walert_body(testo){
		var ws = windowSize();
		var gs = getScrollXY();

		var posX = ws[0] + gs[0];
		var posY = ws[1] + gs[1];

		//alert(posY);
		posX = Math.round(posX/2);
		posY = Math.round(posY/2);


        var table = '<div style="position:absolute; top:'+posY+'px; width:100%"><center><div style="text-align:center; border:1px solid #F00; width: 200px">';
		table += testo;
		table += '<input type="button" value="ok" onClick="javascript:document.getElementById(\'sbianca\').style.display=\'none\'" />';
		table +='</div></center></div>';
        //table += '<center><input type="button" value="ok" onClick="javascript:this.offsetParent.style.display=\'none\'" /></center>';
        var obj = document.body;
        var sbiancante = document.getElementById('sbianca');
        if(obj != null){
            //estraggo dimensioni dell'object da sbiancare
            var larghezza = obj.clientWidth;
            var altezza = obj.scrollHeight;
            //Calcolo la posizione dell'oggetto da sbiancare
            //Assegno altezza e posizione all'object sbiancante
            sbiancante.style.width = larghezza + 'px';
            sbiancante.style.height = altezza + 'px';

			//alert(altezza);
            //sbiancante.style.width = '100%';
            //sbiancante.style.height = '100%';
            sbiancante.style.position = 'absolute';
            sbiancante.style.left = 0 + 'px';
            sbiancante.style.top = 0 + 'px';
            sbiancante.innerHTML = table;
            //lo rendo visibile
            //sbiancante.style.fixedcenter = true;
            sbiancante.style.display = 'block';
        }
    }


function wconfirm_body(testo){
        var table = '<table width="100%" height="60%"><tr><td align="center"><b>' + testo + '</b></td></tr></table>';
table += '<center><input type="button" value="ok" onClick="javascript:this.offsetParent.style.display=\'none\';retcon=true;alert(retcon);"/>';
table += '<input type="button" value="annulla" onClick="javascript:this.offsetParent.style.display=\'none\';retcon=false;alert(retcon);"/></center>';
        var obj = document.body;
        var sbiancante = document.getElementById('sbianca');
        if(obj != null){fixedcenter: true,fi
            //estraggo dimensioni dell'object da sbiancare
            var larghezza = obj.clientWidth;
            var altezza = obj.clientHeight;
            //Calcolo la posizione dell'oggetto da sbiancare
            //Assegno altezza e posizione all'object sbiancante
            sbiancante.style.width = larghezza;
            sbiancante.style.height = altezza;
            sbiancante.style.position = 'absolute';
            sbiancante.style.left = 0;
            sbiancante.style.top = 0;
            sbiancante.innerHTML = table;
            //lo rendo visibile
            sbiancante.style.display = 'block';
        }
}

function wprompt_body(testo){
        var table = '<table width="100%" height="60%"><tr><td align="center"><b>' + testo + '</b></td></tr>';
table += '<tr><td align="center"><input type="text" style="border:2px solid black" onKeyUp="javscript:text_wprompt=this.value"/></td></tr></table>';
table += '<center><input type="button" value="ok" onClick="javascript:this.offsetParent.style.display=\'none\';alert(text_wprompt);"/>';
table += '<input type="button" value="annulla" onClick="javascript:this.offsetParent.style.display=\'none\';text_wprompt=null;alert(text_wprompt);"/></center>';
        var obj = document.body;
        var sbiancante = document.getElementById('sbianca');
        if(obj != null){
            //estraggo dimensioni dell'object da sbiancare
            var larghezza = obj.clientWidth;
            var altezza = obj.clientHeight;
            //Calcolo la posizione dell'oggetto da sbiancare
            //Assegno altezza e posizione all'object sbiancante
            sbiancante.style.width = larghezza;
            sbiancante.style.height = altezza;
            sbiancante.style.position = 'absolute';
            sbiancante.style.left = 0;
            sbiancante.style.top = 0;
            sbiancante.innerHTML = table;
            //lo rendo visibile
            sbiancante.style.display = 'block';
        }
}



	function ripristina(){
		var sbiancante = document.getElementById('sbianca');
		sbiancante.style.display = 'none';
	} 

