/***************************************************
//                                                           //
//  Modal CSS Dialog Javascript Code                         //
//  Copyright© BrandsPatch LLC                               //
//  http://www.explainth.at                                  //
//                                                           //
//  All Rights Reserved                                      //
//                                                           //
//  Permission is granted to use, modify and redistribute    //
//  this code on the condition that this notice is retained  //
//  unchanged.                                               //
//                                                           //
//  BrandsPatch  declines all responsibility for any losses, //
//  direct or indirect, that may arise  as a result of using //
//  this code.                                               //
**************************************************************/
var CRLF = String.fromCharCode(13) + String.fromCharCode(10);

function CloseDialog()
{
 var main = document.getElementById('main');
 e = document.getElementById('overlay');
 main.removeChild(e);
 var e = document.getElementById('diadiv');
 main.removeChild(e);

}

function BuildButton(ACaption,AClick)
{
 var buf = new StringBuffer();
 buf.xAppend(['<button ','onclick="javascript:',AClick,'">',ACaption,'</button>']);
 return buf.toString();
}

function BuildHRef(ARef)
{
 var buf = new StringBuffer();
 buf.xAppend(['href="javascript:',ARef,'"']);
 return buf.toString();
}

function BuildLink(AId,AClass,ACapt,ARef)
{
 var buf = new StringBuffer();
 buf.xAppend(['<a ',BuildHRef(ARef),' id="',AId,'">',ACapt,'</a>']);
 return buf.toString();
}

function BuildSpan(AId,AClass,AText)
{
 var buf = new StringBuffer();
 buf.xAppend(['<span class="',AClass,'" id="',AId,'">',AText,'</span>']);
 return buf.toString();
}

function BuildDiv(AId,AClass,AContents)
{
 var buf = new StringBuffer();
 buf.xAppend(['<div ','class="',AClass,'" id="',AId,'">',CRLF,AContents,CRLF,'</div>']);
 return buf.toString();
}

function BuildPara(AId,AClass,AContents)
{
 var buf = new StringBuffer();
 buf.xAppend(['<p ','class="',AClass,'" id="',AId,'">',CRLF,AContents,CRLF,'</p>']);
 return buf.toString();
}

function ShowDialog()
{
 var newdiv = document.createElement('div');
 var main = document.getElementById('main');
 newdiv.className = 'overlay';
 newdiv.id = 'overlay';
 var h = document.body.clientHeight + 'px';
 newdiv.style.height = h;
 var w = document.body.clientWidth - 40 + 'px';
 newdiv.style.width = w;
 main.appendChild(newdiv);
 
 newdiv = document.createElement('div');
 newdiv.className = 'diadiv';
 newdiv.id = 'diadiv';
 newdiv.style.height = h;
 newdiv.style.width = w;
 newdiv.innerHTML = MakeDialog();
 main.appendChild(newdiv); 
 AdjustSizes();
}

function AdjustSizes()
{
 var d = document.getElementById('dlg');
 if (d == null) return;
 var b = document.getElementById('dbody');
// var c = document.getElementById('capt');
 var t = document.getElementById('dtxt');
 var emPerpxX = 25/d.offsetWidth;
 var emPerpxY = 18/d.offsetHeight;
 
 b.style.height = d.offsetHeight*emPerpxY + 'em';
 var w = d.offsetWidth*emPerpxX + 'em';
 b.style.width = w;
 t.style.height = b.offsetHeight*emPerpxY - 2 + 'em';
 t.style.width = (b.offsetWidth - 20)*emPerpxX + 'em';
}

function MakeDialog()
{
 var buf = new StringBuffer();
 buf.xAppend([BuildLink('close','diaqbut','x','CloseDialog()'),
              BuildLink('help','diaqbut','?',"alert('You need help?')")]);
 var s = buf.toString();
 buf.cleanUp();
// var capt = BuildDiv('capt','diacapt',s);
 
 s  = BuildPara('para','diapara','<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td><font size=4>Looking for reViSiT Professional?</font></td><td align="right"><font size="2"><a href="javascript:CloseDialog()">close</a>&nbsp;</font></td></tr></table><br><font size="2">You have followed a link to the old <b>v0.94 Standard Edition</b>, which has not been updated since Aug 2008*, and has been surpassed by the faster, more stable and more powerful <b>Professional Edition (v1.0+)</b>, currently still <b><u>available for free</u></b> as part of the <a href="http://experiment.nashnet.co.uk">reViSiT Experiment</a>:<br><br><a href="http://experiment.nashnet.co.uk"><img border=0 style="margin-left:20px" src="/images/exp_title_small.gif"></a><br><br><em>* Work on the Experiment and Professional Edition has limited the time that can be spent maintaining the Standard Edition, which will nonetheless return as soon as the workload lightens.</em></font><br><br>');
 s =    BuildDiv('dtxt','diatxt',s)
 BuildDiv('dimg','diaimg','<img width=101 height=94 src="/images/dlgimg.png"');
 s = BuildDiv('dbody','diabody',s);
 return BuildDiv('dlg','diaframe',s);
}
/**********************************************************************
/
/
/    StringBuffer is a simple utility object which delivers
/     faster string concatenation than the Javascript + operator
/
***********************************************************************/
function StringBuffer() {this.buffer = []} 
StringBuffer.prototype.append = function append(string) {this.buffer.push(string)} 
StringBuffer.prototype.xAppend = 
function xAppend(strings)
{
 var i,ALen;
 ALen = strings.length;
 for (i=0;i<ALen;i++) this.buffer.push(strings[i]);
}
StringBuffer.prototype.cleanUp = function cleanUp(){this.buffer = []}
StringBuffer.prototype.toString = function toString(){return this.buffer.join("")}


