function OpenWindow (theURL,winName,features)
{
  window.open (theURL,winName,features);
}
function PreLoad (s)
{
  var I = new Image ();
  I.src = s;
}
function SwitchMode (Lay)
{
  if ( document.getElementById(Lay).style.display == 'none' )
    document.getElementById(Lay).style.display = 'block';
  else
    document.getElementById(Lay).style.display = 'none';
}

function SwitchVisible (Lay)
{
  if ( document.getElementById(Lay).style.visibility == 'hidden' )
    document.getElementById(Lay).style.visibility = 'visible';
  else
    document.getElementById(Lay).style.visibility = 'hidden';
}
function Popup (Pars)  
{
  var V = Pars.split (',');
  var theURL = '', winName = '', features = new Array ();
  var Width = 0, Height = 0;
  for ( i = 0; i < V.length; i++ )
  {
    var V1 = V[i].split ('=');
    if ( V1[0] == 'url' )
      theURL = V[i].replace (/url=/, '');
    else
      if ( V1[0] == 'winname' )
        winName = V[i].replace (/winname=/, '');
      else
      {
        if ( V1[0] == 'width' )
          Width = V1[1];
        if ( V1[0] == 'height' )
          Height = V1[1];
        features.push (V[i]);
      }
  }
  var Left = (window.screen.availWidth - Width) / 2;
  var Top = (window.screen.availHeight - Height) / 2;
  features.push ('left=' + Left);
  features.push ('top=' + Top);
  window.open (theURL, winName, features.join(','));
}                                     

function URLEncode (Text1)
{
        var SAFECHARS = "0123456789" +                                  
                                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                                        "abcdefghijklmnopqrstuvwxyz" +
                                        "-_.!~*'()";                            
        var HEX = "0123456789ABCDEF";

        var plaintext = Text1;
        var encoded = "";
        for (var i = 0; i < plaintext.length; i++ ) {
                var ch = plaintext.charAt(i);
            if (ch == " ") {
                    encoded += "+";                             
                } else if (SAFECHARS.indexOf(ch) != -1) {
                    encoded += ch;
                } else {
                    var charCode = ch.charCodeAt(0);
                        if (charCode > 255) {
                                encoded += "+";
                        } else {
                                encoded += "%";
                                encoded += HEX.charAt((charCode >> 4) & 0xF);
                                encoded += HEX.charAt(charCode & 0xF);
                        }
                }
        } // for

        return Text1;
};

function Rand ()
{
  return Math.round (Math.random () * 12345678); 
}

function MakeFavorite (Obj, URL) 
{
  Obj.style.behavior = 'url(#default#homepage)';
  Obj.setHomePage (URL);
  // example: MakeFavorite (this, 'http://www.site.com');
}

