// javascript to be executed inside the div "main"

// This is very silly as IE for Mac may fail to execute this script
// and it MUST be possible to set the width of a block. According to the
// spec:
//
//   width:300px;
//   margin-left: auto;
//   margin-right: auto;
//
// would do the trick, as it makes both margins equa, but IE fails to
// implement this on PC, but it does do this on a MAC, so it probably
// makes sense to put one definition of the "intext" stuff in main.css,
// using this, and over-write that here.

// stuff to sort out intext definitions

// first record the width of the maincontent div,
// this is the total width of the window, les the width of the menu div,
// left and right paddings of maincontents (both 20px)


// this could/should use javascript to measure the width of the
// menu bar, but it returns a value of 0 in IE.

var mainwidth=getInsideWindowWidth()-22;



//now compute ideal column width => margins
var colwidth=470;

var lrmargin=Math.round((mainwidth-colwidth)/2)-10;

if(lrmargin<0)lrmargin=0;

var lrmarginplus10 = lrmargin + 10;

var lrmarginwidetext=lrmargin-20;
if(lrmarginwidetext<10)lrmarginwidetext=10;


// now define the styles using document.write

document.write("<style>")
document.write(".intext{margin-left: " + lrmargin + "px; margin-right: " + lrmargin + "px; text-align: justify; color:black;}");



document.write(".intextpb6{margin-left: " + lrmargin + "px; margin-right: " + lrmargin + "px; text-align: justify; color:black; padding-bottom:6px;}");


document.write(".intextnojust{margin-left: " + lrmarginplus10 + "px; margin-right: " + lrmargin + "px; text-align: left;  color:black;}");
document.write(".intextalignright{margin-left: " + lrmargin + "px; margin-right: " + lrmargin + "px; text-align: right;  color:black;}");
document.write(".intextleft{margin-right: " + lrmargin + "px; color:black;}");
document.write(".intextright{margin-left: " + lrmargin + "px; color:black;}");


document.write(".intextwide{");
document.write("margin-left: " + lrmarginwidetext + "px;");
document.write("margin-right: " + lrmarginwidetext + "px;");
document.write("text-align: justify; color:black;}");

// definitions for blockquotes (and anything else in need of extra indentation)

var bqi=40;
var bqmargin=lrmargin+bqi;
document.write(".intextind40{margin-left: " + bqmargin + "px; margin-right: " + bqmargin + "px;  text-align: justify}");
document.write(".intextind40rm{font-style: normal; margin-left: " + bqmargin + "px; margin-right: " + bqmargin + "px;  text-align: justify}");
document.write("</style>");



// dividers
function divider1(){
  var dividerwidth=Math.round(lrmargin+(colwidth*2/3));
  if(arguments.length>0){
    document.write("<p><img src='" + arguments[0] + "pics/blue1.gif' height=4 width=" + dividerwidth + ">");
    }
  else{
    document.write("<p><img src='pics/blue1.gif' height=4 width=" + dividerwidth + ">");
  }
}

function divider2(){
  var dividerwidth=Math.round(lrmargin+(colwidth/3));
  if(arguments.length>0){
    document.write("<p><img src='" + arguments[0] + "pics/blue2.gif' height=4 width=" + dividerwidth + ">");
    }
  else{
    document.write("<p><img src='pics/blue2.gif' height=4 width=" + dividerwidth + ">");
  }
}


// like divider2, but inside the text area

function intextdivider2(){
  var dividerwidth=Math.round(colwidth/3);
  if(arguments.length>0){
    document.write("<p class=intext><img src='" + arguments[0] + "pics/blue2.gif' height=2 width=" + dividerwidth + "></p>");
    }
  else{
    document.write("<p class=intext><img src='pics/blue2.gif' height=2 width=" + dividerwidth + "></p>");
  }
}


// like divider2 but smaller and inside intext
function divider3(){
  var dividerwidth=Math.round(colwidth/3);
  if(arguments.length>0){
    document.write("<p><img src='" + arguments[0] + "pics/blue2.gif' height=2 width=" + dividerwidth + ">");
    }
  else{
    document.write("<p><img src='pics/blue2.gif' height=2 width=" + dividerwidth + ">");
  }
}

