

function extendTables(){

       	var i,oldTable,newTable,blockquote;

	for(i=0;i<document.getElementsByTagName("table").length;i++)
	{

                oldTable = document.getElementsByTagName("table")[i];

                if(oldTable.className==""){

		blockquote = document.createElement("blockquote");

		newTable = oldTable.cloneNode(true);
		newTable.className="grid1";
		newTable.border=0;
		newTable.cellspacing="0";

		blockquote.appendChild(newTable);

		oldTable.parentNode.insertBefore(blockquote, oldTable);
                oldTable.parentNode.removeChild(oldTable);
               }
        }
}

/*============================================
*
* Catching all 'div' elements in the document and sending them to be treated by the isTextClass(el) function
*
===============================================*/
function runElementsAnalyse(){



         var el;
         var allDiv=document.getElementsByTagName("div");

	for(var i=0;i<allDiv.length;i++)
	{
		el = allDiv[i];

        if (el.className == "text" || el.className == "textList") {

            var allHREF=el.getElementsByTagName("a");
              isILORef(allHREF);
             isPDF(allHREF);
             noOldOpen(allHREF);
            }
        }
}

function noOldOpen(el){
    for (var i=0;i<el.length;i++){
        if (el[i].href.indexOf("oPenImag2")!=-1){
          el[i].href=el[i].href.substring(el[i].href.indexOf("(")+2,el[i].href.length-2);
        }
    }

}



/*====================================================
*
* Discriming the ILO sites
*
======================================================*/
function isILORef(el){


  for (var i=0;i<el.length;i++){
  var isNewPopup=0;

  // quick and dirty solution for the new url to popup filter
  // just for a speed test
  // to be changed with a reg exp set
  var hrefBuffer = el[i].href;
  // first: check if this is a relative or absolute anchor
  if ((hrefBuffer.indexOf("http://")!=-1) || (hrefBuffer.indexOf("https://")!=-1)) {
    // this is an absolute anchor
    // second, check if this is an external url
    if ((hrefBuffer.indexOf (".ilo.org/")!=-1)){
      if ((hrefBuffer.indexOf (".ilo.org/dyn/")!=-1) || (hrefBuffer.indexOf (".ilo.org/intranet/")!=-1)|| (hrefBuffer.indexOf ("papyrus.ilo.org/")!=-1) || (hrefBuffer.indexOf (".ilo.org/ilolex/")!=-1)){
        // absolute internal via popup
        isNewPopup=1;
      } else {
        // absolute internal in page
        isNewPopup=0;
      }
    } else {
      // this is an absolute external link, that is, a popup
      isNewPopup=1;
    }
  } else {
    // this is a relative anchor
    // second, check if it is in page or not
    if ((hrefBuffer.indexOf ("/dyn/")!=-1) || (hrefBuffer.indexOf ("/intranet/")!=-1) || (hrefBuffer.indexOf ("/ilolex/")!=-1)){
      isNewPopup=1;
    } else {
      isNewPopup=0;
    }
  }


  if (isNewPopup){
    var newLink= document.createElement("a");
       if (navigatorDetection()=="Explorer"){
          newLink.onclick=function(){newWin(this.href);return false;};
          }
          else{
          newLink.setAttribute("onclick","newWin(this.href);return false;");

          }
          newLink.innerHTML=el[i].innerHTML;
          newLink.href= el[i].href;
           el[i].parentNode.replaceChild(newLink,el[i]);


  }


}


}


/*====================================================
*
* Discriming the PDF files extensions
*
======================================================*/
function isPDF(el){


for (var i=0;i<el.length;i++){


  var linkPDF=el[i].href.indexOf(".pdf")!=-1;

  if (linkPDF){
          var newLink= document.createElement("a");

          if (navigatorDetection()=="Explorer"){
          newLink.onclick=function(){newWin(this.href);return false;};
          }
          else{
          newLink.setAttribute("onclick","newWin(this.href);return false;");

          }

          newLink.innerHTML=el[i].innerHTML;
          newLink.href= el[i].href;

          el[i].parentNode.replaceChild(newLink,el[i]);

    }

}


}// end isPDF


/*====================================================
*
* Navigator detection
*
======================================================*/
function navigatorDetection(){
  if (navigator.appName.indexOf("Netscape") > -1) {return "Netscape";}
  if (navigator.appName.indexOf("Explorer") > -1) {return "Explorer";}
  return "Unknown";}





