//-------------------------------------------------------------------------------------------

function docElem(strID)
{
  if (document.all) return(document.all(strID));
  if (document.getElementById) return(document.getElementById(strID));
  return false;
}

//-------------------------------------------------------------------------------------------

function unicodeEscape(strText)
{
  if (typeof(encodeURIComponent)!='undefined')
    return encodeURIComponent(strText);
  var output = escape(strText);
  if (document.all)
  {
    var re = /%([89A-Fa-f][0-9A-Fa-f])/g ; 
    output = output.replace(re, '%u00$1');
  }
  return output;
}

//-------------------------------------------------------------------------------------------

function IEBrowserVer()
{
  if (window.navigator.userAgent.indexOf('MSIE') == -1) return 0;
  return eval(window.navigator.userAgent.substr(window.navigator.userAgent.indexOf('MSIE')+5,1))
}

//-------------------------------------------------------------------------------------------

function setPage(newAddress){
  if (newAddress != '') window.location.href = newAddress;
}

//-------------------------------------------------------------------------------------------

function setOpener(newAddress){
  if (newAddress != '')
    if (window.opener)
      window.opener.location.href = newAddress;
}

//-------------------------------------------------------------------------------------------

function changeImg(imageName,isOn)
{
  if (document.images)
  {
    if (isOn==true) document.images[imageName].src = eval(imageName + 'on' + '.src');
    else document.images[imageName].src = eval(imageName + 'off' + '.src');
  }
}

//------------------------------------------------------------------------------------

function createPosStrWindowNormal(wndWidth,wndHeight)
{
  mwidth = wndWidth;
  mheight = wndHeight;
  mtop = (window.screen.height - mheight) / 2;
  mleft = (window.screen.width - mwidth) / 2;
  return('height=' + mheight + ',width=' + mwidth + ',top=' + mtop + ',left=' + mleft + ',')
}

//-------------------------------------------------------------------------------------------

function openWindowImg(wndPath, wndName, wndTitle)
{
  if (typeof(wndPath) == 'undefined') wndPath='';
  if (typeof(wndName) == 'undefined') wndName='';
  if (typeof(wndTitle) == 'undefined') wndTitle='&nbsp;';
  var newWin
  newWin = window.open('',wndName,createPosStrWindowNormal(100,100) + 'status=no,toolbar=no,menubar=no,location=no,resizable=yes');
  newWin.focus();
  newWin.document.open("text/html", "replace");
  newWin.document.write('<html><head><title>' + wndTitle + '</title></head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0"><table border="0" cellPadding="0" cellSpacing="0" width="100%" height="100%"><tr><td align="center" valign="middle"><img src="' + wndPath + '" border="0" onLoad="window.resizeTo(this.width+14, this.height+36);window.moveTo((screen.availWidth-(this.width+14))/2,(screen.availHeight-(this.height+14))/2);if (document.body) if (document.body.clientWidth) { window.resizeTo((this.width+14+this.width-document.body.clientWidth), (this.height+36+this.height-document.body.clientHeight)) }"></td></tr></table></body></html>');
  newWin.document.close();
  return newWin
}

//-------------------------------------------------------------------------------------------

function openWindowCenter(wndPath, width, height)
{
  if (typeof(wndName) == 'undefined') wndName='';
  var newWin
  newWin = window.open(wndPath,wndName,createPosStrWindowNormal(width,height) + 'status=no,toolbar=no,menubar=no,location=no,resizable=yes');
  newWin.focus();
}

//------------------------------------------------------------------------------------

function setPosWindowAttachment(wndWidth,wndHeight)
{
  mwidth = wndWidth;
  mheight = wndHeight-20;
  mtop = (window.screen.height - mheight-60) / 2;
  mleft = (window.screen.width - mwidth-15) / 2;
  return('height=' + mheight + ',width=' + mwidth + ',top=' + mtop + ',left=' + mleft + ',')
}

function openWindowAttachment(wndPath)
{
  window.open(wndPath,'',setPosWindowAttachment(700,500) + 'scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no,resizable=yes');
}

