

var passato = 5;
var passato_reset = 10;


function resizeIFRAME_reset(){
	//
	//alert("passato="+passato);
	//alert("passato_reset="+passato_reset);
	if ((passato_reset >= 0)&&(passato < 5)){
		//alert("passato_reset="+passato_reset);
		passato = 3;
		resizeIFRAME();
		//passato_reset--;
	}
	
	passato = 6;
}


function resizeIFRAME_3(){
	var divContentArea = document.getElementById("DIV_CONTENT_AREA");

   	var iframes = divContentArea.getElementsByTagName("IFRAME");
    
    alert("___");
    
	parent.pageSupport.ivuAdjustHeight(parent.pageSupport.getIvuId(iframes[0].contentWindow));
    alert("_xxxxyyyyyyyxxxx_");

}

function resizeIFRAME(){

   var divContentArea = document.getElementById("DIV_CONTENT_AREA");

   var iframes = divContentArea.getElementsByTagName("IFRAME");
   
   
   //alert("passato="+passato+"    iframes[0].style.height="+iframes[0].style.height );
	
	
   //put_message("passato="+passato+"    iframes[0].style.height="+iframes[0].style.height, false);
   
   
   if (passato == 3)
   	iframes[0].style.height = 600 + "px";
   
   
   put_message("passato="+passato, false);
   
   var root = iframes[0].contentWindow.document.compatMode=='BackCompat'? iframes[0].contentWindow.document.body : iframes[0].contentWindow.document.documentElement;
	var isVerticalScrollbar= (root.scrollHeight+20)>root.clientHeight;
	var isHorizontalScrollbar= root.scrollWidth>(root.clientWidth+12);
	
	
   put_message("root.scrollHeight = "+(root.scrollHeight+20), false);
   put_message("root.clientHeight = "+root.clientHeight, false);
   put_message("root.scrollWidth = "+root.scrollWidth, false);
   put_message("root.clientWidth = "+(root.clientWidth+12), false);
	
	
   put_message("isVerticalScrollbar = "+isVerticalScrollbar, false);
   put_message("isHorizontalScrollbar = "+isHorizontalScrollbar, false);
   
	   
   
   //if (iframes[0].style.height == iframes[0].contentWindow.document.body.scrollHeight + "px"){
   //if ((iframes[0].contentWindow.document.body.clientHeight+20) == iframes[0].contentWindow.document.body.offsetHeight){
   //if ((!isVerticalScrollbar)&&(!isHorizontalScrollbar)&&(passato<0)){
   if ((!isVerticalScrollbar)&&(passato<0)){
   	 passato = -1;	
   }
   else{
   	 passato = -1;	
   
   
   put_message("sto cambiando....", false);
   //alert(iframes[0].style.height);
   
   //iframes[0].style.height = iframes[0].contentWindow.document.body.scrollHeight + "px";
   
   iframes[0].style.height = (iframes[0].contentWindow.document.body.scrollHeight+20) + "px";
   
   //alert(iframes[0].style.height);
   
   //alert(iframes[0].style.height);
   
   //dimmi("iframes[0]",iframes[0],0);
   
   
  
   	if (iframes[0].addEventListener){
			iframes[0].addEventListener("load", resizeIFRAME_reset, false);
						
				
			
  			//alert("addedd:_||_:"+passato);
  
			if (passato >= 0)
				//iframes[0].contentWindow.document.body.addEventListener("onmousemove", resizeIFRAME, false);
				iframes[0].contentWindow.document.body.onmousemove = resizeIFRAME;
				iframes[0].contentWindow.document.body.onmouseover = resizeIFRAME;
				
			}
			
	else if (iframes[0].attachEvent){
				iframes[0].detachEvent("onload", resizeIFRAME_reset); // Bug fix line
				iframes[0].attachEvent("onload", resizeIFRAME_reset);
				
				
				//iframes[0].contentWindow.document.body.detachEvent("onclick", testtest);
				//iframes[0].contentWindow.document.body.attachEvent("onclick", testtest);
				
				
				if (passato >= 0){
					iframes[0].contentWindow.document.body.detachEvent("onmousemove", resizeIFRAME);
					iframes[0].contentWindow.document.body.attachEvent("onmousemove", resizeIFRAME);
					iframes[0].contentWindow.document.body.detachEvent("onmouseover", resizeIFRAME);
					iframes[0].contentWindow.document.body.attachEvent("onmouseover", resizeIFRAME);
				}
			}
   
  }
  //alert("fatto_____-->"+passato);
   
  //passato--;
  
  if (passato < 0){
	window.onload = null;
	window.onresize = null;
	//window.document.body.onmouseover = null;
	window.document.body.onmousemove = null;
	
	
	if (iframes[0].addEventListener){
			//iframes[0].contentWindow.document.body.removeEventListener("onmousemove", resizeIFRAME, false);
			iframes[0].contentWindow.document.body.onmousemove = null;
			iframes[0].contentWindow.document.body.onmouseover = null;
			//alert("annullo33333333333");
			}
	else if (iframes[0].attachEvent){
				iframes[0].contentWindow.document.body.detachEvent("onmousemove", resizeIFRAME);
				iframes[0].contentWindow.document.body.detachEvent("onmouseover", resizeIFRAME);
				//alert("annullooooooooooooooo5555555");
			}
	
  }
  
  //alert(passato);
   
  // alert("passato="+passato+"    iframes[0].style.height="+iframes[0].style.height );
  
}





function apriChiudi(leftImg, rightImg){
   //alert("777");
   var navPanelTlb = document.getElementById("navigationAreaTlb");
   var navPanelImg = document.getElementById("navigationAreaTlbImg");
   
   
   //allert = EPCM.loadClientData("urn:com.sap.myObjects", "CollapseNavPanTLB3");
   
   //alert("CollapseNavPanTLB3 is open? --> " + allert);
   
   //dimmi("navPanelImg", navPanelImg, 0);
   //dimmi("navigationAreaTlb.runtimeStyle", navPanelTlb.runtimeStyle, 0);
   //dimmi("navigationAreaTlb", navPanelTlb, 0);
   //alert("____________");
   
   //style.visibility=visible|hidden|collapse
   //alert(navPanelTlb.style.visibility);
   
   if ( navPanelTlb.style.display == "none" ){
        //alert("metto in VISIBLE");
   		//navPanelTlb.style.visibility = "visible";
   		//navPanelTlb.runtimeStyle.visibility = "visible";
   		navPanelImg.src = rightImg;
   		navPanelTlb.style.display = "inline";
   		navPanelTlb.runtimeStyle.display = "inline";   	
   		navPanelImg.alt = "Cliccare per chiudere";
   		
   		//navPanelTlb.width = 192;
   		//navPanelTlb.clientWidth = 192;   		
   		
   		
   		EPCM.storeClientData( "urn:com.sap.myObjects", "CollapseNavPanTLB", "yes" );
   		
   		
   }
   else{
        //alert("metto in HIDDEN");
   		//navPanelTlb.style.visibility = "hidden";
   		//navPanelTlb.runtimeStyle.visibility = "hidden";
		navPanelImg.src = leftImg;
   		navPanelTlb.style.display = "none";
   		navPanelTlb.runtimeStyle.display = "none";
		navPanelImg.alt = "Cliccare per aprire";
   		//navPanelTlb.width = 10;
   		//navPanelTlb.clientWidth = 10;  
   		
   		EPCM.storeClientData( "urn:com.sap.myObjects", "CollapseNavPanTLB", "no" );
   }
   
   //alert(" vediamo EPCM level:"+EPCM.getLevel());
   
   //dimmi("EPCM", EPCM,0);
   
   //allert = EPCM.loadClientData("urn:com.sap.myObjects", "CollapseNavPanTLB");
   
   //alert("navTab is open? --> " + allert);
      
}


///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers




function resizeCaller_s() {

//alert(passato);

passato = 3;

if (document.getElementById)
		resize_Iframe(iframeids[0]);
		


}

function resizeCaller() {

//alert("p:"+passato);

if (document.getElementById)
		resize_Iframe(iframeids[0]);
		


}

function resize_Iframe(frameid){


   put_message("resizeIframe....", false);

//var currentfr=document.getElementById(frameid)
   var divContentArea = document.getElementById("DIV_CONTENT_AREA");

   var iframes = divContentArea.getElementsByTagName("IFRAME");

var currentfr = iframes[0];


   //iframes[0].style.height = (iframes[0].contentWindow.document.body.scrollHeight+20) + "px";

if (currentfr && !window.opera){



		put_message("currentfr.style.height="+currentfr.style.height, false);
		put_message("getMaxHeigth(currentfr)+px="+getMaxHeigth(currentfr)+"px", false);
	
	
			if ( currentfr.style.height == (getMaxHeigth(currentfr)+"px") ){
				put_message("UGUALI!!!!   passato="+passato, false);
				
				if (passato < 0){
					if (window.addEventListener){
						window.document.body.onmousemove = null;
						window.document.body.onmouseover = null;
						currentfr.contentWindow.document.body.onmousemove = null;
						currentfr.contentWindow.document.body.onmouseover = null;
					}
					else 
					if (window.attachEvent){
							window.document.body.detachEvent("onmousemove", resizeCaller);
							window.document.body.detachEvent("onmouseover", resizeCaller);
							
							currentfr.contentWindow.document.body.detachEvent("onmousemove", resizeCaller);
							currentfr.contentWindow.document.body.detachEvent("onmouseover", resizeCaller);
						}
				}
				
				passato--;
				
				
			}
		   	else{	
		   	
		
				currentfr.style.display="block";
				
				currentfr.style.height = 300;
				currentfr.style.height = getMaxHeigth(currentfr);
			

					
				if (currentfr.addEventListener){
					currentfr.addEventListener("load", readjustIframe, false);
					
					
					currentfr.contentWindow.document.body.addEventListener("onmousemove", readjustIframe, false);
					currentfr.contentWindow.document.body.addEventListener("onmouseover", readjustIframe, false);
					
					//currentfr.contentWindow.document.documentElement.style.overflow = 'hidden';	 // firefox, chrome
					
				}
				else if (currentfr.attachEvent){
					currentfr.detachEvent("onload", readjustIframe); // Bug fix line
					currentfr.attachEvent("onload", readjustIframe);
					
					
					
					
					currentfr.contentWindow.document.body.detachEvent("onmousemove", readjustIframe);
					currentfr.contentWindow.document.body.attachEvent("onmousemove", readjustIframe);
					currentfr.contentWindow.document.body.detachEvent("onmouseover", readjustIframe);
					currentfr.contentWindow.document.body.attachEvent("onmouseover", readjustIframe);
					
					//currentfr.contentWindow.document.body.scroll = "no";	// ie only
					
					
					
					}
				
				
			}
	}

}

function readjustIframe(loadevt) {

//alert("ppppp:"+passato);

var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement


   put_message("readjustIframe....", false);
   put_message("iframeroot = "+iframeroot.id, false);

	if (iframeroot)
		resize_Iframe(iframeroot.id);
}



function checking(doResize){

   var divContentArea = document.getElementById("DIV_CONTENT_AREA");

   var iframes = divContentArea.getElementsByTagName("IFRAME");

   var currentfr = iframes[0];
   
   
   //currentfr.style.height = currentfr.Document.body.scrollHeight+20;
   
   
   put_message("checking", true);
   put_message("currentfr.style.height = "+currentfr.style.height, false);
   
   if (currentfr && !window.opera){
	
		
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			put_message("currentfr.contentDocument.body.offsetHeight+FFextraHeight+20 = "+currentfr.contentDocument.body.offsetHeight+" "+FFextraHeight+"+20 = "+(currentfr.contentDocument.body.offsetHeight+FFextraHeight+20), false); 

			
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
				put_message("currentfr.Document.body.scrollHeight+20 = "+currentfr.Document.body.scrollHeight+"+20 = "+(currentfr.Document.body.scrollHeight+20), false); 
				   
		
	}
   
   
   if (doResize)
      resize_Iframe("");

}


function getMaxHeigth(currentfr){



   var ifrm_height = parseInt(document.getElementById("ifrm_height").value);
   
   //var ifrm_height2 = 0;
   //alert(ifrm_height);
   
   
   //alert(ifrm_height);
   
   if (ifrm_height > 0){
   
   		ifrm_height = windowSize();
   		
   		//if(ifrm_height2 != ifrm_height)
   		//	alert(ifrm_height);
   		
   		ifrm_height = ifrm_height-3;
   		
   		return ifrm_height;
   }

   if (currentfr && !window.opera){
	
	   put_message("getMaxHeigth...", false);
		
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			return (currentfr.contentDocument.body.offsetHeight+FFextraHeight+20);
			//put_message("currentfr.contentDocument.body.offsetHeight+FFextraHeight+20 = "+currentfr.contentDocument.body.offsetHeight+" "+FFextraHeight+"+20 = "+(currentfr.contentDocument.body.offsetHeight+FFextraHeight+20), false); 

			
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
				return (currentfr.Document.body.scrollHeight+20);
				//put_message("currentfr.Document.body.scrollHeight+20 = "+currentfr.Document.body.scrollHeight+"+20 = "+(currentfr.Document.body.scrollHeight+20), false); 
				   
		
	}
}





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 myHeight;
}






function put_message(msg, clear){

   var messageArea = document.getElementById("MESSAGE_LOG_AREA");
   
   
   if (clear)
   	messageArea.innerHTML = "";
   
   //messageArea.innerHTML = messageArea.innerHTML + "<br/>" + msg;
   
}



/*


function onWakeup( eventObj ) {
	alert( "got a wakeup call from " + eventObj.sourceId + ": " + eventObj.dataObject );
}


function test(  ) {
	EPCM.raiseEvent( "urn:com.sap:alarmClock", "morningCall", "Good morning ladies and gentlemen", "iView_0815" );
}




function testtest(  ) {
	EPCM.raiseEvent( "urn:com.sap:alarmClock", "morningCall", "Good morning ladies and gentlemen", "iView_0815" );
}




EPCM.subscribeEvent( "urn:com.sap:alarmClock", "morningCall", onWakeup );

function onWakeup(  ) {
	alert( "got a wakeup call from " );
}


function dimmi(m,ogge,visualizza) {
	 var mest = "";
	 var j = 0;
	 var k = 0;
	
	 var mi;

	 if (visualizza == "1") k = 5;
		 else k = 15;
	
	 for(mi in ogge) {
	  j++;
	  
	  if (visualizza == "0") mest += m + "." + mi + "=" + ogge[mi] +"\n";
		  else mest += m + "." + mi + "=" + "       ";
	  if (j==k){
		  alert(mest);
		  mest = "";
		  j = 0;
	  }
	  
	 }
	 alert(mest);
}

*/
