var spanObjects =  document.getElementsByTagName("span");
function checkprint(img){
   var content = '';
   var idx = '';
   for (i=0;i<10;i++) {
      if (i == 0) {
         idx = "toprint";
      } else {
         idx = "toprint" + i;
      }

      for (j=0;j<spanObjects.length;j++) { 
         if (content == '' )  {
            try {
               if (spanObjects[j].attributes["name"].nodeValue == idx) {
               //if (spanObjects[j].name == idx) {
                  try { 
                    spanObjects[j].innerHTML;
                    if (spanObjects[j].innerHTML != '') {
                      content = content + "x";
                    }
                  } catch( e ){}
               }
            } catch( e ){}
         }
      }
   }
   if (content == '' )  {
      try {
          img.parentElement.innerHTML = '';
      } catch( e ){}
   }
   return;
}
function pause(numberMillis) {

 var dialogScript =
           'window.setTimeout(' +
           ' function () { window.close(); }, ' + numberMillis + ');';
        var result =
 // For IE5.
         window.showModalDialog(
           'javascript:document.writeln(' +
            '"<script>' + dialogScript + '<' + '/script>")');
     }
 function pauseIE7(numberMillis)
 {
    window.open("/portal/pls/portal/portal_sutils.s994_pa_common.p_LOAD_PRINT","_blank",
              "left=250,top=200,fullscreen=no,titlebar=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=150");
 }
 function printlayout(callingobj){

    var win = window.open("",
              "_blank",
              "left=36,top=0,fullscreen=no,titlebar=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=646,height=600");
    win.document.writeln('<html>\n<head>\n');
    try {
      mystyles = document.getElementsByTagName("title");
      for (i=0; i< mystyles.length; i++) {
            win.document.writeln('<title>' +  mystyles[i].innerHTML +  '</title>');
      }
    } catch( e ){
      win.document.writeln("");
    }
    try {
      mybase= document.getElementsByTagName("base");
      for (i=0; i< mybase.length; i++) {
            win.document.writeln('<base href="' +  mybase[i].href +  '" />');
      }
    } catch( e ){
      win.document.writeln("");
    }
    try {
      mylinks = document.getElementsByTagName("link");
      for (i=0; i< mylinks.length; i++) {
         if (mylinks[i].type == 'text/css') {
            win.document.writeln('<link rel="' +  mylinks[i].rel + '" href="' + mylinks[i].href + '" type="text/css" />');
         }
      }
    } catch( e ){
      win.document.writeln("");
    }
    try {
      mystyles = document.getElementsByTagName("style");
      for (i=0; i< mystyles.length; i++) {
            win.document.writeln('<style>' +  mystyles[i].innerHTML +  '</style>');
      }
    } catch( e ){
      win.document.writeln("");
    }
    var htmlarr = document.getElementsByTagName("html");
    if  (htmlarr[0].attributes.getNamedItem("lang")){
       var lang = htmlarr[0].attributes.getNamedItem("lang").value
    } else {
       var lang = 'us';
    }
    win.document.writeln('<style type="text/css">body{background-color: #FFFFFF;}</style>');    
    win.document.writeln('</head>\n');
    win.document.writeln('<body bgcolor="#FFFFFF">\n');
    win.document.writeln('<table height="163" cellspacing="0" width="646"   border="0" celpadding="0">');
    win.document.writeln('<tr>');
    win.document.writeln('<td>');
    try {
       var flashsrc = document.getElementById("sitebanner").data;
       if (flashsrc != "") {
          win.document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="646" height="163" id="loader" align="middle">');
          win.document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
          win.document.writeln('<param name="allowFullScreen" value="false" />');
          win.document.writeln('<param name="movie" value="' + flashsrc + '" />');
          win.document.writeln('<param name="quality" value="high" />');
          win.document.writeln('<param name="bgcolor" value="#ffffff" />');
          win.document.writeln('<embed src="' + flashsrc + '" type="application/x-shockwave-flash" menu="true" loop="true" play="true" scale="exactfit" width="646" height="163" />');
          win.document.writeln('</object>');

       }
    } catch( e ){
    }
    //win.document.writeln('<img width="646" align="top" border="0" src="/files/inf2_e/images/navbar.banner.jpg" />');
    win.document.writeln('<style type="text/css">.l {font-family:"Trebuchet MS",verdana, Arial, Helvetica, sans-serif,"Book Antiqua", monospace;font-size: 28px;font-weight: bold;color: #000;text-decoration:none;position: relative;top:-160px;left:380px;}</style>');
    win.document.writeln('<span class="l">');
      try {
         win.document.writeln(document.getElementById("resident").innerHTML);
      } catch( e ){
      }
    win.document.writeln('</span>');
    win.document.writeln('</td>');
    win.document.writeln('</tr>');
    win.document.writeln('<tr valign="top">');
    win.document.writeln('<td valign="top">');
    try {
      win.document.writeln(document.getElementById("breadcrump").innerHTML);
    } catch(e) {};

   var content = '';
   var idx = '';
   for (i=0;i<10;i++) {
      if (i == 0) {
         idx = "toprint";
      } else {
         idx = "toprint" + i;
      }

      for (j=0;j<spanObjects.length;j++) { 
         try {
            if (spanObjects[j].attributes["name"].nodeValue == idx) {
            //if (spanObjects[j].name == idx) {
               content = content + spanObjects[j].innerHTML;
            }
         } catch( e ){}
      }
   }

   if (content == '' )  {
      if (lang == 'us') content = 'No Printable Content';
      if (lang == 'nl') content = 'Geen afdrukbare inhoud';
      if (lang == 'de') content = 'Kein einhalt';
      if (lang == 'fr') content = 'Pas de contenu imprimable';
   }

   if (navigator.appVersion.indexOf("MSIE")!=-1)
   {
      versionIE=0;
      if (navigator.appVersion.indexOf("MSIE")!=-1)
      {
        temp=navigator.appVersion.split("MSIE");
        versionIE=parseFloat(temp[1]);
        if (versionIE <= 6)
        {
           pause(1000);
        }
        if (versionIE >= 7)
        {
           pauseIE7(1000);
        }
      }
    }
    win.document.writeln('</td></tr>');
    win.document.writeln('<tr valign="top" bgcolor="#FFFFFF"><td valign="top">');
    win.document.writeln(content);
    win.document.writeln('</td>');
    win.document.writeln('</tr>');
    win.document.writeln('</table>');
    win.document.writeln('<script>\n');
    win.document.writeln('function addLoadEvent(func) {');
    win.document.writeln('   var oldonload = window.onload;');
    win.document.writeln('   if (typeof window.onload != \'function\'){');
    win.document.writeln('      window.onload = func;');
    win.document.writeln('   } else {');
    win.document.writeln('      window.onload = function() {');
    win.document.writeln('         if (oldonload) {');
    win.document.writeln('             oldonload();');
    win.document.writeln('         }');
    win.document.writeln('         func();');
    win.document.writeln('      }');
    win.document.writeln('   }');
    win.document.writeln('}');
    win.document.writeln('addLoadEvent (function() { window.print();;})');
    win.document.writeln('addLoadEvent (function() { setTimeout(\'window.close()\',500);;})');
    win.document.writeln('<\/script>\n');
    win.document.writeln('</body>\n</html>');
    win.document.close();

    return;
 }
