var blatstrs=new Array();
var domn= "ham" + "and" + "hig" + "hfe" + "st.c" + "o.u" + "k";

blatstrs["info"]="in" + "fo@" + domn;
blatstrs["friends"]="em" + "sm" + "ag" + "nu" + "s@" + "bt" + "in" + "te" + "rn" + "et" + ".co" + "m";


function blat(str){
  document.write("<A href='mailto:" + blatstrs[str] + "'>" + blatstrs[str] + "</a>");
}


function getDocumentHeight(){
  var a=0;
  var b=0;
  if(document.documentElement)a=document.documentElement.scrollHeight;
  if(document.body)b=document.body.offsetHeight;
  return Math.max(a,b);

}


function getWindowHeight(){
  var ih=1000;
  if(document.documentElement.clientHeight)ih=document.documentElement.clientHeight;
  if(ih==1000){
    if(window.innerHeight)ih=window.innerHeight;
  }
  if(ih==1000){
    if(document.body.clientHeight)ih=document.body.clientHeight;
  }
  return ih;
}


function getWindowWidth(){
  var iw=1000;
  if(document.documentElement.clientWidth)iw=document.documentElement.clientWidth;
  if(iw==1000){
    if(window.innerWidth)iw=window.innerWidth;
  }
  if(iw==1000){
    if(document.body.clientWidth)iw=document.body.clientWidth;
  }
  return iw;
}



function show(ID){
  document.getElementById(ID).style.visibility="visible";
}

function hide(ID){
  document.getElementById(ID).style.visibility="hidden";
}



var SearchWarnStr =""


SearchWarnStr+="This will use the Google site search facility, ";
SearchWarnStr+="which means it won't work until the site has been ";
SearchWarnStr+="implemented and found its way onto Google ";


function dobg(ID,imgval,x,y){
  var sty=document.getElementById(ID).style;
  sty.backgroundImage="url('" + imgval + "')";
  sty.backgroundRepeat="no-repeat";
  sty.backgroundPosition=x + "px " + y + "px";
}


function hidbg(ID){
  document.getElementById(ID).style.backgroundImage="url('')";
}

function over_events(){
  dobg('events','../img2/p-01-sm.gif',0,0);
  document.getElementById("m1a").style.color="#31285c";
}

function out_events(){
  hidbg('events');
  document.getElementById("m1a").style.color="#444444";
}

function over_venues(){
  dobg('venues','../img2/p-02-sm.gif',0,-10);
  document.getElementById("m1b").style.color="#31285c";
}

function out_venues(){
  hidbg('venues');
  document.getElementById("m1b").style.color="#444444";
}


function searchboxon(){
  var ssty=document.getElementById("search").style;
  ssty.border="2px solid";
  ssty.borderColor="#31285c";
}


function searchboxoff(){
  var ssty=document.getElementById("search").style;
  ssty.border="";
}




// function to position footer banner (force to bottom of window if there would be no scrolling)



function pagefooter(){

  var menu=document.getElementById("menu");
  var menuinner=document.getElementById("menuinner");
  var menuinner_height=menuinner.offsetHeight;
  var banner=document.getElementById("banner");
  var banner_height=banner.offsetHeight;
  var mainwrapper=document.getElementById("mainwrapper");
  var mainwrapper_height=mainwrapper.offsetHeight;
  var footer=document.getElementById("footer");
  var footer_height=footer.offsetHeight;

  var menuheight=Math.max(mainwrapper_height,getWindowHeight())
  menu.style.height=menuheight + "px";

  var total_height=banner_height+ mainwrapper_height+ footer_height;
  var fsty=footer.style;


  var menu_plus_banner_plus_footer=menuinner_height+banner_height+footer_height;


 // content greater than window height

//alert("menu_plus_banner_plus_footer: " +  menu_plus_banner_plus_footer + " getWindowHeight(): " + getWindowHeight());

  var will_scroll=0;
  var too_small_for_menu=0;

  if(total_height>getWindowHeight())will_scroll=1;
  if(menu_plus_banner_plus_footer>getWindowHeight())too_small_for_menu=1;


  if((will_scroll>0) || (too_small_for_menu>0)){
    fsty.position="relative";
    }
  else{
    fsty.bottom="0px";
    fsty.left="0px";
    fsty.position="fixed";
    document.getElementsByTagName("body")[0].style.paddingBottom="80px";
  }

  if(too_small_for_menu){
    menuinner.style.position="relative";
    if(document.getElementById("h1main")){document.getElementById("h1main").style.position="relative";}
  }
}






var ven_arr=new Array(
  "<img src='img/ven-BurghHouse-w100.jpg'>",
  "<img src='img/ven-ChristChurch-w100.jpg'>",
  "<img src='img/ven-DyneHouse-w100.jpg'>",
  "<img src='img/ven-EmbassyTheatre-w100.jpg'>",
  "<img src='img/ven-EverymanCinema-w100.jpg'>",
  "<img src='img/ven-HampsteadHeath-w100.jpg'>",
  "<img src='img/ven-HampsteadObservatory-w100.jpg'>",
  "<img src='img/ven-HampsteadParishChurch-w100.jpg'>",
  "<img src='img/ven-HampsteadTheatre-w100.jpg'>",
  "<img src='img/ven-HighgateLit-w100.jpg'>",
  "<img src='img/ven-JewishCultural(IvyHo)-w100.jpg'>",
  "<img src='img/ven-KeatsHouse-w100.jpg'>",
  "<img src='img/ven-LauderdaleHo-w100.jpg'>",
  "<img src='img/ven-StAnneHighgate-w100.jpg'>"
);




function random_images(num){
  var ind=Math.round((Math.random()*100))%ven_arr.length;

  var str="<div id=h1mainimgs style='padding:2px 12px 0px 0px; text-align: right;'>";

  var i;
  for(i=0;i<num;i++){
    str+="<br>" + ven_arr[ind];
    ind=(ind+1)%ven_arr.length;
  }
  str+="</div>";
  document.write(str);
}






function set_h1_width(){
  var h1_wid=document.getElementById("alleventshd").offsetWidth+8;
  var mainwrapper_lmarg=h1_wid + 5;
  var sstr="<style>#mainwrapper{margin-left: " + mainwrapper_lmarg + "px;}</style>";
  document.write(sstr);
  var dates=document.getElementById("dateswrapper");
  dates.style.height="500px";
  dates.style.width=h1_wid + "px";
}





// function to adjust width of mainwrapper to accommodate H1 material
// and to suppess H1 images and add a shorter divder if the screen is
// short and the argument to the function is not 0


function adjust_h1(arg){
  var h1main=document.getElementById("h1main");
  var banner=document.getElementById("banner");
  var footer=document.getElementById("footer");

  if(arguments.length==0)alert("adhjust_h1() called with no arguments");


  var mainwrapper_marginleft=h1main.offsetWidth + 30;

  document.getElementById("mainwrapper").style.marginLeft=mainwrapper_marginleft  + "px";

  var vspaceforcontent=getWindowHeight()-banner.offsetHeight-10;

  if(arg==1){ // make scrolling box smaller so it doesn't hit bottom
    if(vspaceforcontent<=h1main.offsetHeight){
      h1main.style.backgroundImage="url('img/gfxDivider.gif')";
      if(document.getElementById("h1mainimgs")){
        document.getElementById("h1mainimgs").innerHTML="";
      }
    }
  }


  if(arg==2){ // make scrolling box fixed
    document.getElementById("h1main").style.position="static";
  }
}


function onResizeProc(){
  location.reload(true);
}
