var rootpath = 'http://www.kamermuziek-nieuwkoop.nl/';

function MM_openBrWindow(theURL,winName,features)
{
  window.open(theURL,winName,features);
}

function FindObj(n, d)
{
var p,i,x;

  if(!d) d=document;
  if( (p = n.indexOf("?") )>0 && parent.frames.length )
  {
    d = parent.frames[n.substring(p+1)].document;
    n = n.substring( 0, p );
  }
  if(!(x = d[n]) && d.all ) x = d.all[n];
  for( i=0; !x&&i<d.forms.length; i++ ) x = d.forms[i][n];
  for( i=0; !x&&d.layers && i<d.layers.length;i++) x = MM_findObj( n,d.layers[i].document );
  if( !x && document.getElementById ) x = document.getElementById( n );
return x;
}

function ShowHideLayers()
{
var frame,i,p,v,obj,args=ShowHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)if( ( obj=FindObj(args[i]) )!=null )
  {
    v=args[i+2];
    if (obj.style)
    {
      obj=obj.style;
      if( navigator.appName == "Netscape" )
      {
        if( v=='hide' && obj.visibility == 'visible' ) v = 'visible';
      }
      v = ( v == 'show' )?'visible':(v='hide')? 'hidden': v;
    }
    if( navigator.appName != "Netscape" )
    {
      frame = args[i].substring(args[i].indexOf("?")+1,args[i].length);
    //obj.top = top.Header.document.body.scrollTop;
    }
    obj.visibility=v;
  }
}

function mailadres( naam )
{
  document.write('<a href="mailto:');
  document.write( naam );
	document.write('@');
	document.write('kamermuziek-nieuwkoop.nl');
  document.write('">');
  document.write( naam );
	document.write('@');
	document.write('kamermuziek-nieuwkoop.nl');
	document.write('</a>');
}

function PopUpWindow(Name, Pagina, leftmargin, topmargin, width, height)
{
var Breedte = screen.width * width;
var Hoogte = screen.height * height;
  leftmargin = screen.width * leftmargin;
  topmargin = screen.height * topmargin;
  WinProperties = 'height='+Hoogte+',width='+Breedte+',top='+topmargin+',left='+leftmargin+',scrollbars=yes,resizable=yes';
  win = window.open(Pagina, Name, WinProperties);
  win.window.focus();
}

function FilteredPopUpLine( ExcludeName, Caption, PageRef )
{
  if( window.name.indexOf(ExcludeName) != 1 )
  {
    layer = window.name == "MainWindow"? 0 : Number( window.name.charAt(0) ) + 1;
    string = "<a href='' onClick=\"PopUp('"+ layer + document.title + "','"+ PageRef + "');return false;\">"+ Caption + "</a>"
    document.write( string );
  }
  else document.write(Caption);
}

function HighlightPopUpLine( ExcludeName, Caption, PageRef, Highlight, newl )
{
  if( newl == undefined )newl = true;
  if( window.name.indexOf(ExcludeName) != 1 )
  {
    layer = window.name == "MainWindow"? 0 : Number( window.name.charAt(0) ) + 1;
    string = "<a href='' onClick=\"PopUp('"+ layer + document.title + Highlight + "','"+ PageRef + "');return false;\">"+ Caption + "</a>"
    document.write( string );
  }
  else if( window.name != "MainWindow" && window.name.substring( window.name.length - 3, window.name.length )==Highlight ) document.write( "<span style='background-color:#aaffaa; color:#008800'>"+Caption+"</span>" );
  else document.write(Caption);
  if( newl == true )document.write("<br />");
}

function HighlightLine( Exclude, Caption, PageRef, Highlight,newl)
{
  if( newl == undefined )newl = true;
  if( document.URL.indexOf(Exclude) < 0 )
  {
    string = "<a href='' onClick=\"window.location.href='" + PageRef + "';return false;\">"+ Caption + "</a>";
    document.write( string );
  }
  if( document.URL.indexOf(Exclude) > 0 ){ document.write('<span style="background-color:' + highlightgreen + '; color:#000000;">'+Caption+'</span>');}
  if( newl == true )document.write("<br />");
}

function CompositionLine( Exclude, Caption, PageRef, Highlight)
{
  if( document.URL.indexOf(Exclude) < 0 )
  {
    string = "<a href='' onClick=\"window.location.href='" + PageRef + "?" + Highlight + "';return false;\">"+ Caption + "</a>";
    document.write( string );
  }
  if( document.URL.indexOf(Exclude) > 0 )
  {
    document.write('<span');
    if( document.URL.indexOf(Highlight) > 0 ){document.write(' style="background-color:' + highlightgreen + '; color:' + colorcontent + ';"');}
    document.write('>' + Caption + '</span>');
  }
  document.write("<br />");
}


function HighlightProgrammeItem( Item, ExcludeName, Caption, PageRef, Highlight, nw )
{
  if( nw == undefined )nw = false;
  if(nw)
  {
    if( window.location.href.indexOf(Highlight) > 0 )
	{
	  document.getElementById(Item).bgColor="#aaffaa";
      document.write( Caption );
	}
	else
	{
	  document.write('<a href="" onClick="window.location.href=\'' + PageRef + '\';return false;">'+ Caption + '</a>');
	}
  }
  else
  {
    if( window.name.indexOf(ExcludeName) != 1 )
    {
      layer = window.name == "MainWindow"? 0 : Number( window.name.charAt(0) ) + 1;
      string = "<a href='' onClick=\"PopUp('"+ layer + document.title + Highlight + "','"+ PageRef + "');return false;\">"+ Caption + "</a>"
      document.write( string );
    }
    else if( window.name != "MainWindow" && window.name.substring( window.name.length - 3, window.name.length )==Highlight )
    {
      document.getElementById(Item).bgColor="#aaffaa";
      document.write( Caption );
    }
    else document.write(Caption+"<br/>");
  }
}

function PopUp(Name, Pagina)
{
var Breedte = screen.width * 0.6;
var Hoogte = screen.height * 0.6;
var Layer = Number( Name.charAt(0) );
  leftmargin = screen.width * (0.15 + Layer * .02);
  topmargin = screen.height * (0.15 + Layer * .02);
  WinProperties = 'height='+Hoogte+',width='+Breedte+',top='+topmargin+',left='+leftmargin+',scrollbars=yes,resizable=yes'
  win = window.open(Pagina, Name, WinProperties);
  win.window.focus();
}

function ProgramsummaryHeader(datum, tijd, plaats, foto)
{
  document.write('<tr><td width="100%" class="Line" height="1px"></td></tr><tr><td class="Red" height="18px" align="center"></td></tr><tr><td width="100%" class="Line" height="1px"></td></tr><tr><td class="Red" height="18px" align="center">');
  document.write(datum + '</td></tr>');
  document.write('<tr><td width="100%" class="Line" height="1px"></td></tr><tr><td class="Red" height="18px" align="center">Aanvang: ');
  document.write(tijd + ' uur</td></tr>');
  document.write('<tr><td width="100%" class="Line" height="1px"></td></tr><tr><td class="Red" height="18px" align="center">');
  document.write(plaats + ' kerk</td></tr><tr><td width="100%" class="Line" height="1px"></td></tr><tr><td class="Red" height="18px" align="center"></td></tr>');
  document.write('<tr><td height="170px" align="center" valign="top" ><img style="position:relative; top:-2px;" height="140" width="150" border="0" alt="" src="Foto/' + foto + '"></td></tr>');
}

//Contentpages
var clwdth, clhght,headerheight, bodytp,bodyhght;
var bodytopmarge,fotosize,fontsize;

  function contentInit( caption, level )
  {
    clwdth = document.body.clientWidth == 0 ? window.outerWidth : document.body.clientWidth; clhght = window.innerHeight;

  var StyleSheet, styleElt, styleString;

	  if(document.createStyleSheet)styleSheet = document.createStyleSheet();
	  else{var head = document.getElementsByTagName('head')[0]; styleElt = document.createElement('style'); head.appendChild(styleElt); styleSheet = document.styleSheets[document.styleSheets.length-1];}
	  styleString = '.menu{background-color:transparent; color:' + menuorange + ';} .menu:hover{background-color:' + menuorange + '; color:' + bgcontent + ';}';
	  if(styleElt)styleElt.innerHTML = styleString; else styleSheet.cssText = styleString;

  var s = '<header id="pageheader"><div id="headln1" style="position:fixed; top:0px; width:100%; height:' + Math.round(clwdth/25 + .5) + 'px; border-bottom:solid 2px ' + menuorange + ';"></div>';
    s+= '<div id="headln2" style="position:fixed; top:' + Math.round(clwdth/25 + 1.5) + 'px; width:100%; height:' + Math.round(clwdth/20 + .5) + 'px; border-bottom:solid 2px ' + menuorange + ';">';
    s+= '<span style="position:absolute; width:100%; text-align:center; font-weight:bold; top:' + Math.round(clwdth/60 +.5) + 'px; font-size:' + Math.round(clwdth/70 +.5) + 'px;">' + caption + '</span></div></header>';
	s+= '<div id="menublk" style="position:fixed; left:0px; padding-left:0; padding-right:0px; border:none; top:' + Math.round(clwdth * 9/100 + 4.5) + 'px; height:' + Math.round(clwdth/40 + .5) + 'px; width:' + Math.round(clwdth/5 + .5) + 'px;">';
	s+=	'<table style="width:100%; text-align:center; border-collapse:collapse;"><tbody><tr>';
	s+= '<td class="menu" onclick="window.location.href = \'';
	for(var i =0; i<level;i++){s+='../';} s+='default.html\'">Home</td>';
	if(document.URL.indexOf('root') < 0){s+= '<td class="menu" onclick="history.back();">Terug</td>';}
	s+= '</tr></tbody></table>';
	s+= '</div>';
  	document.write(s);
	
	headerheight = Math.round(clwdth * 23/200 + .5);
	bodytopmarge = Math.round(clwdth/50 + .5);
  	bodytp = headerheight + 1; bodyhght = clhght - bodytp;
	fontsize = Math.round(clwdth/100 + .5);
	  
    if(document.createStyleSheet)styleSheet = document.createStyleSheet();
    else{var head = document.getElementsByTagName('head')[0]; styleElt = document.createElement('style'); head.appendChild(styleElt); styleSheet = document.styleSheets[document.styleSheets.length-1];}
	styleString ='.left{top:' + bodytp + 'px; margin-top:' + bodytopmarge + 'px; padding-left:' + (fontsize * 3) + 'px; width:' + (clwdth * (leftwidth - 3) / 100 - fontsize * 3) + 'px; font-size:' + fontsize + 'px;}';
	styleString +='.right, .rightscroll{top:' + bodytp + 'px; margin-top:' + bodytopmarge + 'px; margin-right:' + (fontsize * 10) + 'px; font-size:' + fontsize + 'px; border-bottom:solid 2px ' + menuorange + ';}';
	styleString +='.rightscroll{height:' + (clhght - bodytp - bodytopmarge - 2) + 'px; overflow-y:scroll;}';
	if(styleElt)styleElt.innerHTML = styleString; else styleSheet.cssText = styleString;
  }


//Seizoenpresentatie
	var Maandnaam = new Array("januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
	var Dagnaam = new Array("zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag");

//Class Concert	
	function Concert( dat, naam, kerk, art, elab, foto)
	{
	  this.date = dat;
	  this.name = naam;
	  this.church = kerk == 'h' ? 'Hervormde': kerk == 'r'? 'Remonstrantse' : kerk;
	  this.artist = art;
	  this.elaboration = elab;
	  this.photo = (foto == undefined)? '' : foto;
	}
	Concert.prototype = 
	{
	  datum: function(){return this.date;},
	  datline: function(){return( Dagnaam[this.date.getDay()] + ' ' + this.date.getDate() + " " + Maandnaam[this.date.getMonth()] + " " + this.date.getFullYear());},
	  fileline: function()
	  {
	  var l = 'concerten/';
	  	  if( this.date.getMonth() < 7){ l += (this.date.getFullYear() - 1) + '-' + this.date.getFullYear() + '/'; }
		  else l += this.date.getFullYear() + '-' + (this.date.getFullYear() + 1) + '/';
		  l += this.date.getFullYear();
		  if( this.date.getMonth() < 9 ){ l += '0'; } l += ( this.date.getMonth() + 1 );
		  if( this.date.getDate() < 10 ){ l += '0';} l += this.date.getDate() + '.htm';
	  return( l );
	  },
	  artistline: function()
	  {
	  var l = '';
	    if( this.artist.length )
		{
	  	  for(var i = 0; i < this.artist.length; i++ )
		  {
		    if( i > 0 )l += ', ';
		    l += '<span><strong>' + this.artist[i].naam() + '</strong></span>';
			if(! this.artist[i].instr() == '') l+='<span><em>, ' + this.artist[i].instr() + '</em></span>';
		  }
		}
		else
		{
		  l += '<span><strong>' + this.artist.naam() + '</strong></span>';
		  if(! this.artist.instr() == '') l+='<span><em>, ' + this.artist.instr() + '</em></span>';
		}
	  return(l);
	  },
	  writeItem: function()
	  {
	  var item = '<tr class="scheditem" onclick="window.location.href = \'' + this.fileline() + '?root' + '\';return false;">';
	    item += '<td class="schedfoto"><div style="height:100%;width:100%; padding:0px;"><img id="' + this.name + '" class="foto" src="musici/foto/'
		item += (this.photo == '')? this.name : this.photo; item += '.gif"></div></td>';
	    item += '<td class="schedspec">';
	    item += '<table cellspacing="0px" style="height:100%;"><tbody>';
	    item += '<tr><td class="schedspectxt">' + this.church;
		if( this.church == 'Hervormde' || this.church == 'Remonstrantse' ){ item += ' Kerk'; }
		item += '</td></tr><tr><td class="schedspectxt">' + this.datline() + '</td></tr>';
	    item += '<tr><td class="schedspecart">' + this.artistline() + '</td></tr>';
	    item += '<tr><td class="schedspectxt">' + this.elaboration +'</td></tr></tbody></table>';
	    item += '</td></tr><tr class="schedspace"><td></td><td></td></tr>';
		document.write(item);
	  }
	}

	function writeConcertItems()
	{
	var nu = new Date();
	  document.write('<table cellspacing="0px" style="width:100%;"><tbody>');
	
	  for(var i = 0; i < concerten.length; i++)
	  {
	    if(concerten[i].datum() >= nu ){concerten[i].writeItem();}
	  }
	  for(var i = 0; i < concerten.length; i++)
	  {
	    if(concerten[i].datum() < nu){concerten[i].writeItem(); }
	  }
	  document.write('</tbody></table>');
	}
	

//Class Artist
	
	function Artist( voornaam, achternaam, tussenvoegsel, instrum, webpage, fotocredit )
	{
	  this.fstname = voornaam;
	  this.midname = tussenvoegsel;
	  this.famname = achternaam;
	  this.instrument = instrum;
	  this.URL = webpage;
	  this.photocredit = (fotocredit == undefined)? '' : fotocredit;
	}
	Artist.prototype =
	{
	  naam: function(){return(this.fstname + ' ' + this.famname);},
	  refnaam: function(){return(this.famname + this.fstname);},
	  instr: function(){return(this.instrument);},
	  introline: function()
	  {
	  var	l = '<span><strong>' + this.naam() + '</strong></span>';
	    if(! this.instrument == '') l+='<span><em>, ' + this.instrument + '</em></span>';
		return( l );
	  },
	  introlink: function()
	  {
	  var l='';
	  if(document.URL.indexOf(this.famname.replace(/ /g, '') + this.fstname) > 0){ l+= '<span style="background-color:' + highlightgreen + ';">';}
	  else
	  { l += '<a id="' + this.refnaam() + 'lnk" href="../../musici/infopages/' + this.refnaam() + '.htm?' + document.title + ';">';
	  }
	  l += this.introline();
	  if(document.URL.indexOf(this.famname.replace(/ /g, '') + this.fstname) > 0){ l+='</span>';} else l+='</a>';
		return( l );
	  },
	  block: function()
	  {
	  var l = '';
	    l += '<tr><td>';
		l += '<table ';
		if( document.URL.indexOf(this.famname.replace(/ /g,'') + this.fstname) < 0 )
		{
		  l += 'class="contentbutton" onclick="window.location.href = \'../../musici/infopages/' + this.famname + this.fstname + '.htm?' + document.title + '\';return(false);"';
		}
		l += '><tbody><tr><td><img id="' + this.famname + 'img" src="../../musici/foto/' + this.famname + this.fstname + '.gif" class="foto" /></td></tr><tr><td ';
		if(document.URL.indexOf(this.famname.replace(/ /g, '') + this.fstname) > 0){ l+= 'style="background-color:' + highlightgreen + ';"';}
		l += '><strong>' + this.fstname; if(! this.midname == '' )l+= ' ' + this.midname; l+=' ' + this.famname + '</strong>';
	    if(! this.instrument == '') l+='<br/><em>' + this.instrument + '</em>';
		l+= '</td></tr></tbody></table>';
		l += '</td></tr>';
	  	document.write(l);
		document.images[this.famname + "img"].width = fotosize; document.images[this.famname + "img"].height = fotosize;
	  },
	  foto: function()
	  {
	    document.write('<figure style="margin-left:-1px; margin-top:-1px;"><img id="' + this.famname + 'img" src="../../musici/foto/' + this.famname + this.fstname + '.gif" width="' + fotosize + 'px"');
		document.write('height="' + fotosize + 'px" class="foto" />');
		if(! this.photocredit == ''){document.write('<figcaption><span style="color:#999999; font-size:' + fontsize * .6 + 'px;">Foto:' + this.photocredit + '</span></figcaption>');}
		document.write('</figure>');
	  },
	  fotolink: function()
	  {
	    var l = '<tr><td ';
		if( document.URL.indexOf(this.famname.replace(/ /g,'') + this.fstname) < 0 )
		{
		  l += 'class="contentbutton" onclick="window.location.href = \'../../musici/infopages/' + this.famname + this.fstname + '.htm?' + document.title + '\';return(false);"';
		  l += 'onmouseover="document.getElementById(\'' + this.refnaam() + 'lnk\').style.backgroundColor = \'' + schedulehoverorange + '\';"';
		  l += 'onmouseout="document.getElementById(\'' + this.refnaam() + 'lnk\').style.backgroundColor = \'' + bgcontent + '\';"';
		}
		l += '><img id="' + this.famname + 'img" src="../../musici/foto/' + this.famname + this.fstname + '.gif" class="foto" width="' + fotosize + 'px" height="' + fotosize + '" />';
		l += '</td></tr>';
	  	document.write(l);
		document.images[this.famname + "img"].width = fotosize; document.images[this.famname + "img"].height = fotosize;
	  }
	}


