
// function to force very soft reloading of pages when browser resizes

function onResizeProc(){
  pagefoot();
}


var id_arr=new Array("id3","id4","id6");

function show(ID){
  hide_ids();
  document.getElementById(ID).style.visibility="visible";
}

function hide_ids(){
  var i;
  for(i=0;i<id_arr.length;i++){
    document.getElementById(id_arr[i]).style.visibility="hidden";
  }
}



function adjust_articles_pad(){
  var win_height=document.documentElement.clientHeight;
  var art_height=win_height-232;
  var art_bpad=art_height-document.getElementById("articles").offsetHeight;
  document.getElementById("articles").style.paddingBottom=art_bpad +"px";
}


function getInnerWidth(){
  var iw=0;
  var ddcw=0;
  var dbcw=0;

  if(window.innerWidth)iw=window.innerWidth;
  if(document.documentElement.clientWidth)ddcw=document.body.offsetWidth;
  if(document.body.clientWidth)dbcw=document.body.clientWidth;

  if(iw>0)return iw;
  if(ddcw>0) return ddcw;
  if(dbcw>0) return dbcw;
  alert("iw: " + iw + " ddcw: " + ddcw + " dbcw: " + dbcw);

  return 1000;
}

function getInnerHeight(){
  var ih=0;
  var ddch=0;
  var dbch=0;

  if(window.innerHeight)ih=window.innerHeight;
  if(document.documentElement.clientHeight)ddch=document.body.offsetHeight;
  if(document.body.clientHeight)dbch=document.body.clientHeight;

  if(ih>0)return ih;
  if(ddch>0) return ddch;
  if(dbch>0) return dbch;
  alert("ih: " + ih + " ddch: " + ddch + " dbch: " + dbch);

  return 1000;
}




// empty function, so it can be over-written in a page-specific way
function pre_pagefoot(){}

function pagefoot(){

  pre_pagefoot();


// adjust horizontal position of main title
  var topimg=document.getElementById("topimg");
  var topimg_w=topimg.offsetWidth;



  var title_left=160;              // default title position
  var spare_h_space=getInnerWidth()-title_left-topimg_w-document.getElementById("titling").offsetWidth;
  if(spare_h_space>2){
    title_left+=Math.round(spare_h_space*0.2);
    document.getElementById("titling").style.left=title_left + "px";
  }


// add right hand decoration if there is space


  var rhcellsty=document.getElementById("rhcell").style;
  var topimgsty=topimg.style;
  var windowheight=getInnerHeight();
  var contentheight=document.getElementById("maincontentwrapper").clientHeight+100;
  var menuheight=document.getElementById("menu").clientHeight+document.getElementById("articles").clientHeight;
  var h=windowheight;
  if(contentheight>h)h=contentheight;
  if(menuheight>h)h=menuheight;

//alert("windowheight: " +  windowheight + "contentheight: " + contentheight + "menuheight: " +    menuheight + "h: " +             h);



  rhcellsty.width=topimg_w + "px";
  rhcellsty.height=h + "px";
  rhcellsty.backgroundPosition="center " + topimg.offsetHeight + "px";

  if(getInnerWidth()<870){
    rhcellsty.visibility="hidden";
    rhcellsty.position="absolute";
  }
}


var quotes=new Array(
"&#147;The performances are full of Joy and sparkle as well as expressive****&#148;<br><i>Penguin Guide to Recorded Classical Music 2009</i>",
"&#147;fluently musical... a born chamber-music player&#148;<br><i>The Times</i>, reviewing a Wigmore Hall recital with Andrew Davis",
"&#147;The quality of the viola d&#146;amore is faint and sweet: there is something of the seraphic about it, partaking at once of the viola and of the harmonics of the violin&#148; <i>Berlioz</i>",
"&#147;In the Paris Opera I heard the lovely sounds of the viola d&#146;amore in Meyerbeer; it is so wonderful&#148; <i>Stravinsky</i>",
"&#147;The recorder music was all expertly played by Carl Dolmetsch and there was an admirably professional quality about the playing of Elizabeth Watson&#148; <i>Sunday Times</i> <!-- 5 May 1970 -->",
"&#147;The Bohemian Viola d&#146;amore is a particular pleasure to listen to.  I always imagined that the viola d&#146;amore would sound as beautiful as it looks, and now I know.&#148;",
"&#147;Sylvia Cleaver (violin), Elizabeth Watson (viola) and Haflidi Hallgrimsson (cello) gave a sensitive, intelligently-prepared reading [of the Schoenberg string trio] which managed to reveal many of the score&#146;s profound beauties&#148; <i>The&nbsp;Times</i> <!-- 29 October 1968 -->"
)






function insert_topimg(){
  var qi1=Math.round(Math.random()*100)%quotes.length;
  var qi2=qi1;
  while(qi1==qi2){qi2=Math.round(Math.random()*100)%quotes.length;}

  var rhcell=document.getElementById("rhcell");
  rhcell.innerHTML="<img id=topimg src='img/24670021-r-w140.jpg'>";
  rhcell.innerHTML+="<div class=quotes>" + quotes[qi1] + "<div class=qdiv>&#151;</div>" + quotes[qi2] + "</div>"
}



var blatarr=new Array();

blatarr[0]="mai";
blatarr[1]="l@e";
blatarr[2]="liz";
blatarr[3]="ab";
blatarr[4]="et";
blatarr[5]="hwa";
blatarr[6]="ts";
blatarr[7]="on";
blatarr[8]="-vi";
blatarr[9]="ola";
blatarr[10]="dam";
blatarr[11]="ore";
blatarr[12]=".or";
blatarr[13]="g.uk";


function blat(){
  var i;
  document.write("<a href='");
  document.write("ma");
  document.write("il");
  document.write("to:");
  for(i=0;i<blatarr.length;i++){ document.write(blatarr[i]); }
  document.write("'>");
  for(i=0;i<blatarr.length;i++){ document.write(blatarr[i]); }
  document.write("</a>");
}


function showdynamic(ID){
  var sty=document.getElementById(ID).style;
  sty.position="relative";
  sty.visibility="visible";
}

