function alphaWin(idDiv,value){

		document.getElementById(idDiv).style.opacity=(value/100);
		document.getElementById(idDiv).style.MozOpacity = (value/100);
		document.getElementById(idDiv).style.KhtmlOpacity = (value/100);
		document.getElementById(idDiv).style.filter = "alpha(opacity=" + value + ")";		

}


function makeWindow(w,h,mydiv,nameClass){
		parentWin="BodyGen";
		if (document.getElementById("myPopUp")){
			removeMyNode(parentWin, 'myPopUp');
		
		}
		//alphaWin("mywindow","30");
		var HeightHeader=20;
		var HeightFooter=5;
		var sizeCol=5;

		var body2 = document.getElementById(parentWin);
		var mainContainer = document.createElement('div');
		body2.appendChild(mainContainer);
		//mainContainer.setAttribute("style", "position:absolute;height:" + h + "px;width:" + w + "px;");	
		mainContainer.setAttribute("id", "myPopUp");
		mainContainer.style.cssText = "position:absolute;zindex:100;left:100px;top:100px;height:" + h + "px;width:" + w + "px;border:0px solid #7C99E2;background:#fff;z-index:10;";	
		
		// angolo alto sx
		var angleUpSx = document.createElement('div');
		mainContainer.appendChild(angleUpSx);
		angleUpSx.style.cssText = "position:absolute;left:0px;top:0px;height:"+HeightHeader+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/cornerupsx.gif);";	

		// Header
		var header = document.createElement('div');
		mainContainer.appendChild(header);
		header.setAttribute("id", "myHeader");
		//header.setAttribute("onmousedown", "makeDraggable(this);");
		header.style.cssText = "position:absolute;left:5px;top:0px;height:"+HeightHeader+"px;width:" + (w-sizeCol*2) + "px;border:0px solid #7C99E2;background-image:url(images/icowin/horiz.gif);";			

		// angolo alto dx
		var angleUpDx = document.createElement('div');
		mainContainer.appendChild(angleUpDx);
		angleUpDx.style.cssText = "position:absolute;left:" + (w-sizeCol) + "px;top:0px;height:"+HeightHeader+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/cornerupdx.gif);";			

		// col Sx
		var colSx = document.createElement('div');
		mainContainer.appendChild(colSx);
		colSx.style.cssText = "position:absolute;left:0px;top:"+HeightHeader+"px;height:"+(h-HeightHeader-HeightFooter)+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/vertsx.gif);";			
		
		// col Dx
		var colDx = document.createElement('div');
		mainContainer.appendChild(colDx);
		colDx.style.cssText = "position:absolute;left:" + (w-sizeCol) + "px;top:"+HeightHeader+"px;height:"+(h-HeightHeader-HeightFooter)+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/vertdx.gif);";			

		// BUTTON CLOSE DIV
		var close = document.createElement('div');
		mainContainer.appendChild(close);
		close.setAttribute("id", "bottone");
		close.style.cssText = "cursor:pointer;position:absolute;left:" + (w-40) + "px;top:2px;height:16px;width:29px;border:0px solid #7C99E2;background-image:url(images/icowin/close.gif);background-repeat:no-repeat;";			
		//close.setAttribute("onClick", "removeMyNode(parentWin, 'myPopUp');" );
		close.onclick = function() { removeMyNode(parentWin, 'myPopUp'); }; 

		//close.setAttribute("onclick", "removeMyNode(parentWin, 'myPopUp');" );
		// corner Down Sx
		var angleDownSx = document.createElement('div');
		mainContainer.appendChild(angleDownSx);
		angleDownSx.style.cssText = "position:absolute;left:0px;top:"+(h-HeightFooter)+"px;height:"+HeightFooter+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/cornerdownsx.gif);background-repeat:repeat-x;";			

		// corner Down Dx
		var angleDownDx = document.createElement('div');
		mainContainer.appendChild(angleDownDx);
		angleDownDx.style.cssText = "position:absolute;left:" + (w-sizeCol) + "px;top:"+(h-HeightFooter)+"px;height:"+HeightFooter+"px;width:"+sizeCol+"px;border:0px solid #7C99E2;background-image:url(images/icowin/cornerdowndx.gif);background-repeat:repeat-x;";			

		// Footer
		var Footer = document.createElement('div');
		mainContainer.appendChild(Footer);
		Footer.style.cssText = "position:absolute;left:" + sizeCol + "px;top:"+(h-HeightFooter)+"px;height:"+HeightFooter+"px;width:"+(w-sizeCol*2)+"px;border:0px solid #900;background-image:url(images/icowin/footer.gif);background-repeat:repeat-x;";			

		// Crea DIV OUTPUT
		var output = document.createElement('div');
		mainContainer.appendChild(output);
		output.setAttribute("id", mydiv);
		output.style.cssText = "position:absolute;z-index:200;overflow:auto;left:20px;top:"+(HeightHeader/1+20)+"px;height:"+(h-HeightHeader-HeightFooter-40)+"px;width:"+(w-40)+"px;border:1px solid #ccc;";			
		//output.setAttribute("className", nameClass);
		
		$(function() {
			$("#myPopUp").draggable();
		});
		$(function() {
			$("#myPopUp").resizable();
		});
	
	
	
}
function centerMyPopUp(){

	Height=getYSize();
	Width=getXSize();	
	if (omyPopUp=document.getElementById('myPopUp')){
		w = omyPopUp.style.width;
		w=w.replace("px","");
		h = omyPopUp.style.height;
		h=h.replace("px","");
		myLeft=(Width-w)/2;
		myTop=(Height-h)/2;
		omyPopUp.style.left=myLeft+"px";
		omyPopUp.style.top=myTop+"px";
	}

}

function removeMyNode(divRef, NodeToRemove) {

	// esempio  removeMyNode(parentWin, 'myPopUp');
	
	//alphaWin("mywindow","100");
   if (navigator.appVersion.indexOf("MSIE")!=-1){
		nDiv=BodyGen.children.length;
		//alert(nDiv);
		var oChild=BodyGen.children(nDiv-1);
		BodyGen.removeChild(oChild);
	} else {
		var d = document.getElementById(divRef);
		var remdiv = document.getElementById(NodeToRemove);
		d.removeChild(remdiv);
	}
	
	if (document.getElementById("Cover")) document.getElementById("Cover").style.display="none";
	
}

function getXSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getYSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
