var isDOM=document.getElementById?1:0;isNS4=document.layers?1:0;isIE=document.all?1:0;isIE4=isIE&&!isDOM;isMAC=navigator.appVersion.indexOf("Mac")!=-1;isIE4M=isIE4&&isMAC;isIE5M=isIE&&isMAC;isIE5W=isIE&&!isMAC;isMOZ=(navigator.vendor=="Netscape6"||navigator.product=="Gecko")?1:0;isOP=self.opera?1:0,isDYN=isDOM||isIE||isNS4;
var KEYUP = 38;
var KEYDOWN = 40;
var KEYENTER = 13;
var KEYTAB = 9;

function getKeyCode(e)
{
   e=getEvent(e);
   if (isIE) return e.keyCode; else return e.which;f
}
function getKeyChar(e) { return String.fromCharCode(getKeyCode(e)); }
function getEvent(e) { return e||window.event; }
function getEventSrc(e) 
{
   e=getEvent(e);
   return (e.originalTarget?e.originalTarget:(e.srcElement?e.srcElement:null));
}
if (!self.page) var page = { win:self, minW:0, minH:0, MS:isIE&&!isOP };
page.db = function(p) { with (this.win.document) return (isDOM?documentElement[p]:0)||body[p]||0 };

page.winW=function() { with (this) return Math.max(minW, MS ? db('clientWidth') : win.innerWidth) };
page.winH=function() { with (this) return Math.max(minH, MS ? db('clientHeight') : win.innerHeight) };

page.scrollX=function() { with (this) return MS ? db('scrollLeft') : win.pageXOffset };
page.scrollY=function() { with (this) return MS ? db('scrollTop') : win.pageYOffset };

function CompareTag( )
{
   this.type='tagName';
   this.isEqual=function( e1, e2 ) { return e1.tagName == e2; }
}
function CompareClass(  )
{
   this.type='className';
   this.isEqual=function( e1, e2 )
   {
      var cname = " "+(e1.className||"").toLowerCase( )+" ";
      var kname = " "+(e2          ||"").toLowerCase( )+" ";

      return cname.indexOf( kname ) != -1;
   }
}
function CompareClassList( klassList )
{
   this.exps=[];

   for(var i=0; i<klassList.length; i++)
   {
      this.exps[i] = getTokenizedExp(klassList[i]);
   }

   this.isEqual=function( e1, e2 )
      {
         for(var i=0; i<this.exps.length; i++)
         {
            if ( this.exps[i].test( e1.className ) )
            {
               return true;
            }
         }
         return false;
      }
}
function CompareTagList( tagList )
{
   this.tags=tagList;

   this.isEqual=function( e1, e2 )
      {
         for(var i=0; i<this.tags.length; i++)
         {
            if ( e1.tagName == this.tags[i] )
            {
               return true;
            }
         }
         return false;
      }
}
function getNodeIndexByTagAndClass(e,tag,klass)
{
   var nodes = e.getElementsByTagName(tag);
   
   for (var i = 0; nodes && i<nodes.length; i++) if ( hasClass( nodes[i], "hover" ) )  return i;

   return -1;
}
// Find Parent Node By ? - You can specify whether to include the current node or not.
function getPNodeByTagName          ( e, tag     , includeE ) { return getPNodeBy( e, tag  , new CompareTag  ( ), includeE ); }
function getPNodeByClass            ( e, klass   , includeE ) { return getPNodeBy( e, klass, new CompareClass( ), includeE ); }

function getChildNodeByTagName      ( e, tag       ) { return getNodeBy ( e.childNodes, tag  , new CompareTag( ), 'tag' ); }
function getChildNodeByClass        ( e, klass     ) { return getNodeBy ( e.childNodes, klass, new CompareClass( ), 'class' ); }
function getChildNodesByTagName     ( e, tag       ) { return getNodesBy( e.childNodes, tag  , new CompareTag( ), 'tag' ); }
/*
function getChildNodesByTagNameList ( e, tagList   ) { return getNodesBy( e.childNodes, null, new CompareTagList( tagList ), 'tag' ); }
function getChildNodesByClass       ( e, klass     ) { return getNodesBy( e.childNodes, null, new CompareClass( klass ), 'class' ); }
*/
function getDeepChildNodesByTagAndClass    ( e, tag, klass     ) { return getNodesBy ( getDescendants( e, tag ), null, new CompareClass( klass ), 'class' ); }
function getDeepChildNodesByTagAndClassList( e, tag, klassList ) { return getNodesBy ( getDescendants( e, tag ), null, new CompareClassList( klassList ), 'class' ); }
function getDeepChildNodesByTagNameList    ( e, tag, tagList   ) { return getNodesBy ( getDescendants( e, tag ), null, new CompareTagList( tagList ), 'tags' ); }

function getDescendants( p, tag )
{
   return (tag == "*" && p.all) ? p.all : p.getElementsByTagName(tag);
}
/*
function getDescendantById( p, tag )
{
   for(var nodes=getDescendant( p, tag ), i=0; i<nodes.length; i++)
   {
      if( nodes[i].id==id )
      {
         return nodes[i];
      }
   }
}
*/
function getPNodeBy( e, value, comp, startFromCurentNode )
{
   var p = ( startFromCurentNode ? e : (e?e.parentNode:null) );

   while ( p!=null && !comp.isEqual( p, value ) ) p = p.parentNode;
   
   assert( p, "Could not find parent for " + comp.type + " " + value );

   return p;
}
function getNodeBy( nodes, value, comp, vType )
{
   for ( var i=0; i<nodes.length; i++ )
   {
      if ( comp.isEqual( nodes[i], value ) )
      {
         return nodes[i];
      }
   }
   assert( false, "Could not find child for " + vType + " " + value );
}
function getNodesBy( nodes, value, comp, vType )
{
   var result = [];

   for ( var i=0, resultI=0; i<nodes.length; i++ )
   {
      if ( comp.isEqual( nodes[i], value ) )
      {
         result[resultI++] = nodes[i];
      }
   }
   assert( false, "Could not find child for " + vType + " " + value );

   return result;
}
function isArray(o)
{
   return o != null && typeof o == 'object' && typeof o.length == 'number';
}
function isNum(s)
{
   return parseFloat(s)==s.trim();
}
function isTrue(v) { return (v)&&(v=="true"||v==true); }
function toFixed(n,size)
{
   return n.toFixed?n.toFixed(size):n;
}
function getValueAsFloat(o)
{
   o=$(o);
   if (!o) return parseFloat("0");
   if (o.tagName.toLowerCase()=="input") return parseFloat(o.value);
   return parseFloat(o.innerText);
}
function getValue(o)
{
   o=$(o);
   if (!o) return "";
   if (o.tagName.toLowerCase()=="input") return o.value;
   return o.innerText;
}
function setValue(o,val) // Should this move into protoType
{
   o=$(o);
   if (!o) return;
   if (o.tagName.toLowerCase()=="input") { o.value = val; }
   else { o.innerText = val; }
}
// Should try this loadCss alternative, FoundAt: http://www.quirksmode.org/navi.js
function loadCss(url, media)
{
   var e = document.createElement("link");
   e.src = url;
   e.type="text/css";
   e.rel="stylesheet";
   e.media=media == null ? "all" : media;
   document.getElementsByTagName("head")[0].appendChild(e);
}
function loadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}
function getPath()
{
   var path = location.pathname;
   return path.substring(0, path.lastIndexOf("/")+1);
}
// DOM Methods
function createE(type,id,klass)
{
   var o=document.createElement( type );
   if ( id ) o.id=id;
   if ( klass ) o.className=klass;
   document.body.appendChild(o);
   return o;
}
function setRelativePosition( obj, relObj, x, y, relPos )
{
   if ( relPos )
   {
      var relX=relObj.offsetLeft;
      var relY=relObj.offsetTop;
   
      if ( relPos.indexOf('top')>-1 ) relY-=(relObj.offsetHeight+2);
      if ( relPos.indexOf('bottom')>-1 ) relY+=(relObj.offsetHeight+2);
      if ( relPos.indexOf('right')>-1 ) relX+=(relObj.offsetWidth+2);

      x+=relX; y+=relY;
   }
   while (relObj.offsetParent) 
   {
      relObj = relObj.offsetParent;
      x += relObj.offsetLeft;
      y += relObj.offsetTop;
   }
   obj.style.left = x + "px";
   obj.style.top = y + "px";
}
function appendChild( objId, childObj )
{
   var obj=document.getElementById( objId );

   assert( obj, 'Could not find object with id: ' + objId );

   obj.appendChild( childObj );
}
function maskWin(isOn)
{
   var o=$('maskWin');
   if (!o) o=createE( 'div','maskWin');
   setVisible(o,isOn);
}
/* Cache Tokenized Expressions */
TokenizedExps = {};
function getTokenizedExp(token, flag)
{
   var x = TokenizedExps[token];
   return ( x ? x : TokenizedExps[token] = new RegExp("(^|\\s)"+token+"($|\\s)", flag||"") );
}
function hasToken(s, token)
{
   return getTokenizedExp(token).test(s);
}
function hasClass(o, klass)
{
   var cname = " "+(o.className||"").toLowerCase( )+" ";
   var kname = " "+(klass      ||"").toLowerCase( )+" ";
   
   return (cname).indexOf( kname ) > -1;
}
function removeClass(o, klass) { toggleClass(o, klass, false ); }
function addClass   (o, klass) { toggleClass(o, klass, true  ); }
function toggleClass(o, klass, isOn)
{
   try
   {
      var cname = " "+(o.className||"").toLowerCase( )+" ";
      var kname = " "+(klass      ||"").toLowerCase( )+" ";

      if ( isOn )
      {
         if ( (cname).indexOf( kname ) == -1 ) 
         {
            cname+= kname;
         }
      }
      else
      {
         while ( (cname).indexOf( kname ) != -1 )
         {
            cname = cname.replace( kname, " " );
         }
      }
      o.className = cname.normalize( );
   }
   catch(e) {}
}
// New String methods
var trimExp = /^\s+|\s+$/g;
String.prototype.trim = function()
{
   return this.replace(trimExp, "");
};
var wsMultExp = /\s\s+/g;
String.prototype.normalize = function()
{
   return this.trim().replace(wsMultExp, " ");
};
String.prototype.replicate = function(count)
{
   var result = "", i=0; while ( i++<count ) { result += this; } return result;
};
var extExp = /(\.(.[^\.]+)$)/;
if(!Array.prototype.unshift)
{
   Array.prototype.unshift = function()
   {
      this.reverse();
      for(var i=arguments.length-1; i > -1; i--)
      {
         this[this.length] = arguments[i];
      }
      this.reverse();
      return this.length;
   };
}
function getCssStyle( selector, styleSheet )
{
   var sheet = ( typeof styleSheet == "string" ? document.getElementById( styleSheet ) : styleSheet );

   if ( sheet )
   {
      if ( Browser.IE )
      {
         for ( var i=0; i<sheet.styleSheet.rules.length; i++ )
         {
            if ( sheet.styleSheet.rules[i].selectorText == selector )
            {
               return sheet.styleSheet.rules[i].style;
            }
         }
      }
      if ( Browser.MOZ )
      {
         for ( var i=0; i<sheet.sheet.cssRules.length; i++ )
         {
            if ( sheet.sheet.cssRules[i].selectorText == selector )
            {
               return sheet.sheet.cssRules[i].style;
            }
         }
      }
   }
   return null;
}
function suppressTab(e) {return getKeyCode(e)!=Event.KEY_TAB;}
function openStdWin(sPath, sName, iW, iH)
{// ABR must have AutoScroll Bars
   openWin( sPath, sName, "width=" + (iW||700) + ",height=" + (iH||500) + ",left=0,top=0,status=no,resizable=yes,scrollbars=yes,top=0" );
}
function openWin(sPath, sName, atts)
{
   atts=atts||"width=700,height=500,left=0,top=0,status=no,resizable=yes,scrollbars=yes,top=0";
	try { window.open(sPath, sName, atts); } catch(e) {}
}

function openStdDlg(sPath, oArgs, iW, iH)
{
	return window.showModalDialog(sPath, oArgs, "dialogWidth:" + iW + "px;dialogHeight:" + iH + "px;help:0;status:0;scroll:0;center:1");
}
function openPopup()
{
	return window.createPopup();
}
function buildWinName(s)
{
	if (s) return s.replace(/[-\{\}]/g, "");
	var d = new Date();
	return d.getTime();
}
function printPage( )
{
   window.open("/Mt/_Std/PrintPage.aspx","print","toolbar=yes,resizable=yes,scrollbars=yes,left=0,top=0,screenX=0,screenY=0,width=850,height=650");
}
function emailPage()
{
   openStdWin( '/Mt/_Std/EmailPage.aspx?targetPage=' + location.href,"EmailThisPage", 510, 500 );
}
function ratePage()
{
   openStdWin('/Mt/_Std/RatePage.aspx?targetPage=' + location.href, 'RateThisPage', 610, 610 );
}
function helpPage() 
{
    alert('Sorry, there is no help available at this time.'); 

   //openStdWin('/Mt/_Std/HelpPage.aspx?targetPage=' + location.href, 'HelpThisPage', 580, 600 );
}
function addToFavorites()
{
   window.external.AddFavorite(location.href, document.title);
}
function tip( e, msg ) 
{ 
}
/*
Use an "iFrame shim" to deal with problems where the lookup div shows up behind selection list elements, 
if they're below the queryField. The problem and solution are described at:
http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx
http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx
*/
function shimObject( div, isShow, shimId )
{
   div=$(div);
   shimId=shimId||"shim_"+div.id;
   var shim = $(shimId);

   if ( !shim )
   {
      shim = document.createElement( "<iframe id='" + shimId + "' name='" + shimId + "' scrolling='no' frameborder='0' src='javascript:true;' style='position:absolute; top:0px; left:0px; display:none'></iframe>" );
      document.body.appendChild(shim);
   }
   try
   {
      div.style.display = ( isShow ? "block" : "none" );
      shim.style.display = ( isShow ? "block" : "none" );
      shim.style.width = div.offsetWidth;
      shim.style.height = div.offsetHeight;
      shim.style.top = div.style.top;
      shim.style.left = div.style.left;
      shim.style.zIndex = div.style.zIndex - 1;
   } catch(e) { alert( e.message ); }
}
/* function $(o) { return typeof(o)=="string"?document.getElementById(o):o; } */ // function getElem(o) {return $(o);}
function setVisible(o, isShow) { o=$(o); if ( o ) o.style.display=(isShow?"block":"none"); }
function setInnerHTML(o, s) { o=$(o); if ( o ) o.innerHTML=s; }
function setFoc(o) { o=$(o); if ( o ) o.focus(); }
function displayPanel(o,isShow,isModal)
{
   shimObject(o,isShow);
   if(isModal) maskWin(isShow);
}
function showModalPanel(o,isShow)
{
   shimObject(o,isShow);
   maskWin(isShow);
}
function showPanel(o,isShow)
{
   shimObject(o,isShow);
}
function openPanel( panelId, focusId, ajaxId, ajaxDomId )
{
   showPanel( panelId, true );
   RenderPanelHtml( ajaxDomId, ajaxId );
   setFoc( focusId );      
}
function RenderPanelHtml( domId, ajaxId, p1 )
{
   try
   {
      if ( domId )
      {
         var o = document.getElementById( domId );
         
         if ( o )
         {
            o.innerHTML = Mt.Ws.UiBuilder.GetPanelHtml( ajaxId, p1 ).value;
         }
      }
   }
   catch (e) {alert( "david"+e.message );}
}
var scQryObj; // Query Object (InputField)
var scPanObj; // Temp Panel Object for holding search list
var scQryTypeObj; // Query Type
var scQryButObj; // Query Button
var scLastQry = "";
var scCache = new Object();
var scSearching = false;
var scAutoSuggest = false;
var scW = new Object( );
scW[1] = '720px';
scW[2] = '720px';
scW[3] = '720px';
scW[4] = '465px';
scW[5] = '520px';
scW[6] = '520px';

function initSearch(scQryObjId)
{
   try
   {
      scQryObj = document.getElementById("scQueryValue");
      scPanObj = createE('div',"scPanel", "suggest" ); //document.getElementById( "scPanel" );
      scPanObj.style.display="none";
      scPanObj.style.zIndex=100;
      scQryTypeObj = document.getElementById("menu_scQueryType");  // Search for DropDown
      scQryButObj = document.getElementById("scQueryButton"); 

      scQryObj.onblur = scHidePanel;
      scQryObj.onkeydown = scKeyPress;

      scLastQry = escape(scQryObj.value);
      scCache[""] = "";
      searchState();
  } catch(e) {}
}
function searchState()
{
   scAutoSuggest = !( scQryTypeObj.value == 1 || scQryTypeObj.value == 2 );

   setVisible( scQryButObj, !scAutoSuggest );
   setRelativePosition( scPanObj, scQryObj, scQryObj.offsetLeft+scQryObj.offsetWidth+2, scQryObj.offsetTop-22 );
   
   scQryObj.value = '';
   try { scQryObj.focus(); } catch(e){}
   scPanObj.style.width=scW[scQryTypeObj.value];

   scLoopStart();
}
function scLoopStart()
{
   if ( scAutoSuggest )
   {
      setTimeout("scLoop()", 100);
   }
}
scLoop = function() 
{
   scQuery();
   scLoopStart();
   return true;
}
;
function scQuery()
{
   var val = escape(scQryObj.value);
   var cacheId = scQryTypeObj.value+'_'+val;

   if(scLastQry != val && !scSearching)
   {
      scSearching = true;

      if ( ! scCache[cacheId] )
      {
         scCache[cacheId] = Mt.Ws.UiBuilder.GetPanelHtml( "QuickSearch" + scQryTypeObj.value, val ).value;
      }
      scPanObj.innerHTML = scCache[cacheId];
      showPanel( scPanObj, val.trim( ).length>0 );

      scLastQry = val;
      scSearching = false;
   }
}
function scKeyPress(evt)
{
   if (hasClass(scPanObj, "hidden") )
   {
      return true;
   }
   if(!evt && window.event) 
   {
      evt = window.event;
   }
   var key = evt.keyCode;

   if ((key != KEYUP) && (key != KEYDOWN) && (key != KEYENTER) && (key != KEYTAB))
   {
      return true;
   }

   var rowNo = getNodeIndexByTagAndClass(scPanObj,'div','hover');

   if (key == KEYUP)
   {
      scSetSelectRow(rowNo-1);
   }
   else if (key == KEYDOWN)
   {
      scSetSelectRow(rowNo+1);
   }
   else
   {
      scRowSelect(scSetSelectRow(rowNo));
      evt.cancelBubble=true;
      return rowNo==-1;
   } 
 
   showPanel(scPanObj, true);
   return true;
}
function scRowSelect(e)
{
   if (e==null) return;
   var spans = e.getElementsByTagName("span");

   for (var i = 0; spans && i<spans.length; i++) 
   {
      if (spans[i].className == "sc1") 
      {
         scQryObj.value = spans[i].innerHTML;
         scLoop();
         scQryObj.focus();
         showPanel(scPanObj, false);
         return;
      }
   }
}
function scSetSelectRow(rowNo)
{
   var result;
   var spans = scPanObj.getElementsByTagName("div");

   for (var i = 0; spans && i<spans.length; i++) 
   {
      if (i == rowNo) 
      {
         scRow(spans[i],1);
         result = spans[i];
      } 
      else 
      {
         scRow(spans[i],0);
      }
   }

   return result;
}
function scRow(e,isOn)
{
   toggleClass(e, "hover", isOn )
}
function scHidePanel()
{// Resolve Firefox Issue where event is passed as param
  showPanel(scPanObj, false);
}
//http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
function getViewportHeight()
{
   if (window.innerHeight!=window.undefined) return window.innerHeight;
   if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
   if (document.body) return document.body.clientHeight;
   return window.undefined;
}
function getViewportWidth()
{
	if (window.innerWidth!=window.undefined) return window.innerWidth;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
	if (document.body) return document.body.clientWidth;
	return window.undefined;
}
// May move this into class
function calcTax(isInc, amt, rate)
{
   var perc=(1+(rate/100));
   return isInc ? amt-(amt/perc) : (amt*perc)-amt;
}
/*
// Tax Calculator
var curTaxCalc=new taxCalculator();
function taxCalculator() {};
with (taxCalculator) 
{
   prototype.panelRef=null;
   prototype.sourceId='';
   prototype.sourceRef=null;
   prototype.targetId='taxAmtCalc_txtAmt';
   prototype.targetRef=null;

   prototype.doInit=function()
   {
      this.panelRef=new dynaPanel(); 
      with(this.panelRef) 
      { 
         panelId='taxCalcPanelId';
         contentId='TaxCalculator';
         cssClass='panel calcPanel';
         title='Tax Calculator';
         isModal=true;
         panelBarHtml=getHtmlDynaPanelBar(panelId,title,"javascript:curTaxCalc.doClose();");
         doInit(); 
      }
   }
   prototype.keyHandler=function(e)
   {
      e=getKeyCode(e);
      if(e==Event.KEY_ESC) {curTaxCalc.doClose();}
      if(e==Event.KEY_RETURN) {curTaxCalc.doApply();}
   }
   prototype.doOpen=function(parent,sourceId)
   {
      if (this.panelRef==null) this.doInit();
      this.sourceId=sourceId;
      this.sourceRef=$(sourceId);
      this.targetRef=$(this.targetId);
      this.panelRef.relTo=parent;
      this.panelRef.doOpen();

      this.targetRef.isIncTax=!this.sourceRef.isIncTax;

      setFoc(this.targetRef);
      
      Event.observe(document,'keypress',this.keyHandler);
   }
   prototype.doClose=function()
   {
      Event.stopObserving(document,'keypress',this.keyHandler);

      setFoc(this.sourceId);
      this.panelRef.doClose();
   }
   prototype.doApply=function()
   {
      this.sourceRef.setAmount(this.sourceRef.isIncTax,this.targetRef.getAmount(this.targetRef.isIncTax));
      this.sourceRef.calc();
      this.doClose();
   }
}
*/

// Refactor to prototype
var ImageRotate=function(targetId,interval,path)
{
   document.getElementById(targetId).imageRotate=this;
   this.targetId=targetId;
   this.interval=interval*1000;
   this.path=path;
   this.images=new Array();
   this.imageIndex=0;
   this.addImage=function(img)
   {
      this.images[this.imageIndex++]=img;
   },
   this.start=function()
   {
      rotateOn(this.targetId, this.interval);
   },
   this.getImage=function()
   {
      return this.path + this.images[ (this.imageIndex++)%this.images.length ];
   }
}
function rotateOn(id,interval)
{
   setTimeout("rotateImage('"+id+"')", interval);
}
function rotateImage(imgId)
{
   var img=document.getElementById(imgId);
   var ir=img.imageRotate;

   img.src=ir.getImage();

   rotateOn(ir.targetId, ir.interval);
}

var Dialog=Class.create();
Dialog.prototype=
{
   initialize: function(panelId,title,contentId,cssClass,isModal,width)
   {
      this.panelId=panelId;
      this.title=title||'';
      this.contentId=contentId||'';
      this.cssClass=cssClass||'ajaxPanel'; 
      this.isModal=isModal||false;
      this.width=width||-1;
      
      this.panelRef=null;
      this.panelBarHtml=null;
      this.relTo=null;
      this.relX=0;
      this.relY=0;
      this.relPos='bottom';
   },
   init:function()
   {
      this.panelRef=$(this.panelId);
      if (!this.panelRef)
      {
         this.panelBarHtml=this.panelBarHtml||Dialog.getHeader(this.panelId,this.title);

         this.panelRef=createE('div',this.panelId,this.cssClass);
         this.panelRef.style.display='none'; 
         if (this.width>0) this.panelRef.style.width=this.width;

         this.panelRef.innerHTML=this.panelBarHtml +
            Mt.Ws.UiBuilder.GetPanelHtml("CachedPanel",this.contentId).value;
      }
   },
   open:function()
   {
      if (this.relTo) setRelativePosition(this.panelRef,this.relTo,parseInt(this.relX),parseInt(this.relY),this.relPos);
      displayPanel(this.panelRef,true,this.isModal);
      Event.observe(document,'keypress',suppressTab );
   },
   close:function()
   {
      displayPanel(this.panelRef,false,true);
      Event.stopObserving(document,'keypress',suppressTab );
   }
}
Dialog.getHeader=function(panelId,title,closeHandler)
{
   closeHandler=closeHandler||"javascript:displayPanel(\""+panelId+"\",false,true);";
   return "<table class='fixed' style='width: 100%;'><tr class='hand drag' dragId='"+panelId+"'><th class='left'>"+title+"</th><th class='right'><a class='iconLink' href='"+closeHandler+"'>X</a></th></tr></table>";
}



// ********** SmartCard Signon **********

var reqSignon = new XMLHttpRequest();
var submittingSignon = false;


function signOn(url) 
{
//alert(url);
   setVisible("showLoading",true);
   
   if (window.XMLHttpRequest) 
   {
      reqSignon = new XMLHttpRequest();
      reqSignon.onreadystatechange = function() {signOnDone();};
//alert('get');
      reqSignon.open("POST", url, true);
//alert('send');
      reqSignon.send(null);
//alert('done');
   } 
   else if (window.ActiveXObject) 
   {
      reqSignon = new ActiveXObject("Microsoft.XMLHTTP");
      if (reqSignon) 
      {
         reqSignon.onreadystatechange = function() {signOnDone();};
         reqSignon.open("POST", url, true);
         reqSignon.send();
      }
   }
} 



function signOnDone() 
{
    // complete?
//alert(reqSignon.readyState);
   if (reqSignon.readyState == 4) 
   {
      // ok?
//alert(reqSignon.status);
      if (reqSignon.status == 200) 
      {
         if ( ! submittingSignon )
         {
            // submit this page back to itself.
		    document.forms[0].submit();   		
            submittingSignon = true;
         }         
      } 
      else 
      {
         setVisible("showLoading",false);
         setVisible("signInMessage",true);
         alert( reqSignon.status + " - " + reqSignon.statusText );
      }
   }
}

// ********** End - SmartCard Signon **********

