// Browser / OS Detection
var IE = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;
var NS4 = (document.layers) ? 1 : 0;
var MAC = ((navigator.appVersion.indexOf("PPC") >0) || (navigator.appVersion.indexOf("Mac") >0)) ? 1 : 0;
var SAF = (navigator.appVersion.indexOf("Safari") >0) ? 1 : 0;

var docX, docY;
document.onmousemove = listener; 

function listener( e )
{
   if( e )
   {
      if( typeof( e.pageX ) == 'number' )
      {
         docX = e.pageX;
         docY = e.pageY;
      }
      else
      {
         docX = e.clientX;
         docY = e.clientY;
      }
   }
   else
   {
      e = window.event;
      docX = e.clientX;
      docY = e.clientY;
      if( document.documentElement
        && ( document.documentElement.scrollTop
            || document.documentElement.scrollLeft ) )
      {
         docX += document.documentElement.scrollLeft;
         docY += document.documentElement.scrollTop;
      } 
      else if( document.body
         && ( document.body.scrollTop
             || document.body.scrollLeft ) )
      {
         docX += document.body.scrollLeft;
         docY += document.body.scrollTop;
      }
   }
}

function ResizeWindow(width, height, hasscroll) {
  self.window.resizeTo(width,height);
}

function getElementById( id ) {
  if ( document.getElementById )
    return document.getElementById( id );
  else
    return document.all(id);
}

function showfloathelp(message, vShift, hShift, width) {
  getElementById("floathelp").innerHTML=message;
  var hScrollAdjustment;
  var vScrollAdjustment;

  hScrollAdjustment = docY + vShift;
  vScrollAdjustment = docX + hShift;
  
  getElementById("floathelp").style.top=(hScrollAdjustment)+"px";
  getElementById("floathelp").style.left=(vScrollAdjustment)+"px";
  getElementById("floathelp").style.visibility="visible";
  if (width != null)
   getElementById("floathelp").style.width=(width)+"px";
}

function hidefloathelp() {
  getElementById('floathelp').style.visibility="hidden";
}



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")
         {
            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
            + " 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
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);

function showDynamicFocus(main, element) {
 mainE = document.getElementById(main);
 mainE.style.backgroundImage = "url(images/highlight.gif)";
 mainE.style.color = "#d69621";
 mainE.style.cursor = "pointer";
 element.style.backgroundImage = "url(images/drop_bg.gif)";
 element.style.color = "#d69621";
 element.style.cursor = "pointer";
}
function showMOFocus(element) {
 element.style.backgroundImage = "url(images/highlight.gif)";
 element.style.color = "#d69621";
 element.style.cursor = "pointer";
}
function showTDFocus(main) {
 mainE = document.getElementById(main);
 mainE.style.backgroundImage = "url(images/highlight.gif)";
 mainE.style.color = "#d69621";
 mainE.style.cursor = "pointer";
}

function hideDynamicFocus(main, element) {
 element.style.color = "#ffffff";
 element.style.border = "none";
 element.style.cursor = "normal";
} 
function hideTDFocus(main) {
 mainE = document.getElementById(main);
 mainE.style.color = "#a6c5be";
 mainE.style.background = "none";
 mainE.style.border = "none";
 mainE.style.borderRight = "solid 1px #005a46";
 mainE.style.cursor = "normal";
}

function linkSiteAdmin() {
 window.open( "https://siteadmin.asparity.com", "SiteAdmin", "resizable=yes, menubar=no, status=no, titlebar=no, scrollbars=yes, height=600,width=800, top=5, left=5" );
}

function printPage() {
  window.print();
}

function linkPrint( url ) {
 window.open( url, "Print", "resizable=no, menubar=no, status=no, titlebar=no, scrollbars=yes, width=640, top=5, left=5" );
}

function linkDemo( url ) {
  self.window.resizeTo(1000,800);
  location.href=url;
}

function linkGeneric( url, width ) {
 window.open( url, "Demo", "resizable=yes, menubar=no, status=no, titlebar=no, scrollbars=yes, width="+width+", top=5, left=5" );
}

function linkDocuments( url, name ) {
 window.open( url, name );
}

function searchText( ) {

  try {
  var term = document.getElementById("searchelement"); 
  location.href="search.aspx?SearchType=any&SearchTerm="+term.value;
  } catch (exception) {
   alert(exception);
  }
}

