/* funzioni varie */

//aggriona form
function aggiorna_dati(){

	if(!checkdata()){
		return false;		
	}
	
	layer_interni("full" , "apri");
	document.getElementById("frm").submit();
}

//funzione per aprire pop-up
function openWin2(nome,width,height){
	
if(!width)
	width=540;

if(!height)
	height=360;

var winWidth = screen.availWidth;
var winHeight = screen.availHeight;
var popupWidth = width;
var popupHeight = height;

var xCoord = ((winWidth-popupWidth)/2);
var yCoord = ((winHeight-popupHeight)/2);

var w=window.open(nome,'NuovaFinestra','toolbar=no, scrollbars=yes, width='+popupWidth+',height='+popupHeight+',left='+xCoord+',top='+yCoord+'screenX='+xCoord+',screenY='+yCoord+'');
return w;
}

function esci(){
	parent.myLightWindow.deactivate();
}


function URLEncode(CODE){
	
	var plaintext = CODE;
	
	var SAFECHARS = "0123456789" +                                                     // Numeric
	
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +        // Alphabetic
	"abcdefghijklmnopqrstuvwxyz" +
	                 "-_.!~*'()";   

	var HEX = "0123456789ABCDEF";
	
	var encoded = "";
	
	for (var i = 0; i < plaintext.length; i++ ) {
	
		var ch = plaintext.charAt(i);
	
	    if (ch == " ") {
	           encoded += "+";                                          // x-www-urlencoded, rather than %20
	    } else if (SAFECHARS.indexOf(ch) != -1) {
	           encoded += ch;
	    } else {
	           var charCode = ch.charCodeAt(0);
	           if (charCode > 255) {
	               alert( "IL Carattere '" + ch + "' non può essere decodificaro.\n" +
	                                                 "Verrà sostituito con uno spazio (+)." );
	
	               encoded += "+";
	
	           } else {
	
	               encoded += "%";
	               encoded += HEX.charAt((charCode >> 4) & 0xF);
	               encoded += HEX.charAt(charCode & 0xF);
	
	           }
	
	 	}
	} // for
	// VALORE CODIFICATO
	return encoded;

};

function adaptIframe() {
	var divParent=parent.document.getElementById('lightwindow_contents');
	var h=divParent.getHeight()-3;
	
	if (divParent)
		divParent.getElementsByTagName('iframe')[1].style.height=h+'px';
}

window.onload = function () {adaptIframe();}
