// javascript to set up stuff within pages



// find  width of inner window
innerwidth=550; // default
if(window.innerWidth>0){innerwidth=window.innerWidth;}
if(window.document.body.offsetWidth>0){innerwidth=window.document.body.offsetWidth;}


//now compute ideal column width => margins
var colwidth=540;
var marginval=0;

if(innerwidth>colwidth){
  marginval=Math.round((innerwidth-colwidth)/2);
}
if(marginval<10){marginval=10;}

document.write("<style>.intext{text-align: justify; margin-left: " + marginval + "; margin-right: " + marginval + ";}</style>");

// on front page text is different as it is inside a table whose leftmsoe cell 
// is approx 100 px wide, but main gext is indented. so rduce this by less than 100px:

var frontmarginval=marginval-20;
if(marginval<0)marginval=0;

document.write("<style>.intextfront{    margin-left: " + frontmarginval + "; margin-right: " + frontmarginval + ";}</style>");


document.write("<style>.intextwid{width: " + colwidth + "px;}</style>");





// fudge value to allow for tables to be set up so that hanging
// text in the margin works, but stops 10 pixels left of the text

var titlewid=marginval-10;
if(titlewid<10)titlewid=10;




// now set a linelength value so tables can be te normal linelength (e.g. in diary)

var linelength=0;

linelength=innerwidth-marginval-marginval;

// now adjust this for the fact that there is a 20 pixel margin on page;

linelength=linelength-40;


// now get middle of window for when this is needed

var halfwidth = innerwidth/2;


document.write("<style>p.intextright{margin-left: " + halfwidth + ";}</style>");



