
 function generatePicturePopup( pictureSrc ) { 
     var pictureSrc;
     window.open( "popup.php?picture="+pictureSrc, 
                  "",  
                  "scrollbars=1,resizable=0,height=1,width=1"
     ); 
 } 
 
 function generatePrintPopup( Src, h, w ) { 
     var pictureSrc;
     tmp = window.open( Src,
                        "sp_print",
                        "scrollbars=1,resizable=0,height="+h+",width="+w+""
            );
     tmp.focus();
 }  

 function getObj(str){
     if(document.getElementById(str))
       return document.getElementById(str);
     else
       return false;
 }

 function reload( w, h ) { 
     window.resizeTo(w, h); 
 } 
  
 function loadImage(target, id, windowWidth, windowHeight ){
     if( getObj(target+id) ){
        reload( 1, 1 ); 
        if ( getObj(target+id).complete ) {
           clearInterval(eval('img_timer_'+id));
           getObj(target+id).style.display = '';
           getObj('pictureLoader_'+id).style.display = 'none';    
           if( windowWidth>0 && windowHeight>0 ) {
             reload( windowWidth, windowHeight );
           }
        }
     }
 }

 function submitEnter(evt,frmId) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
        document.getElementById(frmId).submit();
    }
 }
 
 function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
 {
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {               
          
            if(img.onmouseover) {
             var imgOverStr = img.onmouseover+"";
             var imgOver  =  imgOverStr.replace('function anonymous()','');
             var imgOver  =  imgOver.replace("\n",'');
             var imgOver  =  imgOver.replace("\n",'');
             var imgOver  =  imgOver.replace("\n",'');                          
             var imgOver  =  imgOver.replace('}','');             
             var imgOver  =  imgOver.replace('{',''); 
             var imgOver  =  imgOver.replace('src','filters(0).src');  
             var imgOver  = 'onmouseover="' + imgOver + '"';                                     
            }else{
             var imgOver  =  "";                      
            }
            
            if(img.onmouseout) {
             var imgOutStr = img.onmouseout+"";
             var imgOut  =  imgOutStr.replace('function anonymous()','');
             var imgOut  =  imgOut.replace("\n",'');
             var imgOut  =  imgOut.replace("\n",'');
             var imgOut  =  imgOut.replace("\n",'');                          
             var imgOut  =  imgOut.replace('}','');             
             var imgOut  =  imgOut.replace('{',''); 
             var imgOut  =  imgOut.replace('src','filters(0).src');  
             var imgOut  = 'onmouseout="' + imgOut + '"';                                     
            }else{
             var imgOut  =  "";                      
            }         
               
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle + imgOver + imgOut
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }   
 }

  function createIEaddEventListeners()
  {
      if (document.addEventListener || !document.attachEvent)
          return;

      function ieAddEventListener(eventName, handler, capture)
      {
          if (this.attachEvent)
              this.attachEvent('on' + eventName, handler);
      }

      function attachToAll()
      {
          var i, l = document.all.length;

          for (i = 0; i < l; i++)
              if (document.all[i].attachEvent)
                  document.all[i].addEventListener = ieAddEventListener;
      }

      var originalCreateElement = document.createElement;

      document.createElement = function(tagName)
      {
          var element = originalCreateElement(tagName);

          if (element.attachEvent)
              element.addEventListener = ieAddEventListener;

          return element;
      }

      window.addEventListener = ieAddEventListener;
      document.addEventListener = ieAddEventListener;

      var body = document.body;

      if (body)
      {
          if (body.onload)
          {
              var originalBodyOnload = body.onload;

              body.onload = function()
              {
                  attachToAll();
                  originalBodyOnload();
              };
          }
          else
              body.onload = attachToAll;
      }
      else
          window.addEventListener('load', attachToAll);
  }

  createIEaddEventListeners();


 var showBanners = {
    init: function()
    {
        var bannersContent = document.getElementById('r_banners');
        if(bannersContent) {
          setTimeout(
           function(){
             bannersContent.style.display='block';
           }, 500 );
        }
    }
 };
 addEventListener("load", showBanners.init, false);
  
  

function changeInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
  if(!oldElm || !oldElm.parentNode || (iType.length<4) ||
    !document.getElementById || !document.createElement) return;
  var isMSIE=/*@cc_on!@*/false; //http://dean.edwards.name/weblog/2007/03/sniff/
  if(!isMSIE){
    var newElm=document.createElement('input');
    newElm.type=iType;
  } else {
    var newElm=document.createElement('span');
    newElm.innerHTML='<input type="'+iType+'" name="'+oldElm.name+'" style="width:'+oldElm.style.width+';height:'+oldElm.style.height+'">';
    newElm=newElm.firstChild;
  }
  var props=['name','id','className','size','tabIndex','accessKey'];
  for(var i=0,l=props.length;i<l;i++){
    if(oldElm[props[i]]) newElm[props[i]]=oldElm[props[i]];
  }
  newElm.onfocus=function(){return function(){
    if(this.hasFocus) return;
    var newElm=changeInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur=function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      changeInputType(this,'text',iValue,false,true);
    }
  }}();
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  // some browsers need the value set before the element is added to the page
  // while others need it set after
  if(!blankValue) newElm.value=iValue;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!isMSIE && !blankValue) newElm.value=iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm=newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}



