
function testIFRAME(){
 if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
}
function DocNameExtract(set)
{  
		 //estraggo filename da dir "art/filename.ext" or complete url "http://localhost/etc/filename.ext
			wholeurl = (set != undefined)? set  : window.location.href;
   x = wholeurl.length;
   while((wholeurl.substring(x,x-1)) != "."){ x--; } clipend = x;
   while((wholeurl.substring(x,x-1)) != "/"){ x--; } clipstart = x;
   return wholeurl.substring(clipend-1,clipstart);
}

function processReqChange()
{
 if (req.readyState == 4 && req.status == 200 && req.responseXML != null)
 {
   var dto = document.getElementById( 'dataTable' );

    var items = [];
    var nl = req.responseXML.getElementsByTagName( 'slide' );
    for( var i = 0; i < nl.length; i++ )
    { 
      var nli = nl.item( i );
      var src = nli.getAttribute( 'src' ).toString();
						
				  var file_src = DocNameExtract(src);//alert (file_src);
	   		var currentPage = DocNameExtract();//alert (currentPage);
						if (file_src == 	currentPage)//("art_"+ file_src || file_src == 	currentPage)
						{
							var ifrm = document.createElement('iframe');
							ifrm.setAttribute("src", src);
							ifrm.setAttribute('id','myFrame');//aggiunto l'attributo id per poter inserire pił pagine nello stesso frame
							ifrm.style.width = 94+"%";
							ifrm.style.height = 700+"px";
								
							return dto.appendChild( ifrm ); 
						}
    }

  }
}

function loadXMLDoc( url )
{
  req = false;
  if(window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch(e) {
      req = false;
    }
  }
  else if(window.ActiveXObject)
  {
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
    try {
      req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
      req = false;
    }
  }
  }
  if(req) {
    req.onreadystatechange = processReqChange;
    req.open("GET", url, true);
    req.send("");
  }
}

