/*
    **************************************************************
      NetFace SmallPortal|engine v2.1 @BETA | XHTML 1.0 | CSS 2.0
      created: 04/10/2006
      common.js
      
      functions list:
                - generatePicturePopup
                - generatePrintPopup
                - getObj
                - reload
                - loadImage
                - submitEnter
      
      author:  Gabor Nemeth | www.netface.hu | ngabor@netface.hu
      All rights reserved!
    **************************************************************      
*/

 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;
     window.open( Src, 
                  "sp_print",  
                  "scrollbars=1,resizable=0,height="+h+",width="+w+""
     ); 
 }  

 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
         }
      }
   }   
 }

  


