//* This file: javascript/genSciacHeaders.js :   writes header for Acadaff scientific activities site with   parameters, link to previous, next year and current index year 
/* writeLinkPriv(privurl)  writeLinkNext(nexturl)  writeSciacHeader(indexyear, indexurl)*/
// The assumption is that if priv year or next does not exist , even though we passed the time, then call will not be there 


//function writeSciacHeader( indexyear, privurl, nexturl){
function writeSciacHeader( indexyear,privurl, nexturl){
	var indexurl = "/acadaff/Scientific_Activities/" + indexyear;
	//var privyear =  indexyear -1;
	var nextyear =  parseInt(indexyear) +1;
	var privyear =  nextyear-2;
	writeBaseHeader(indexyear);
	document.write('<a href="' +indexurl +'"><img src="/acadaff/Scientific_Activities/images/index.gif" width="229" height="36" border=0></a></td>');
	document.write('<td width="23" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif">');
  // handle priv:  NOTE - for priv year is decided before being called so at the file the call is made for ON with link, or for OFF
  //alert("privurl:"+privurl);
 	var thePurl = "/acadaff/Scientific_Activities/"  + privyear + "/" +  privurl;
  //alert("priv-url:"+thePurl);
  /**/
  if ( parseInt(privurl)!= 0){ // no priv disp off
			document.write('<a href="' +thePurl +'"><img src="/acadaff/Scientific_Activities/images/prev_year.gif" width="23" height="21" border=0></a>');
	}
	else{
			document.write('<img src="/acadaff/Scientific_Activities/images/prev_year_off.gif" width="23" height="21">');
	}
	document.write('</td><td width="33" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif">');
	document.write('<img src="/acadaff/Scientific_Activities/images/nav_year.gif" width="33" height="21" /></td>');
  //handel next, For NEXT YEAR we make the decfiion to have it OFF or ON here by testing the currnt year
 	var curdate = new Date();
	var thisyear = curdate.getFullYear();
	var theurl = "/acadaff/Scientific_Activities/"  + nextyear + "/" +  nexturl;
  //alert("this year: "+thisyear+" index year:"+ indexyear);
	if ( nextyear < thisyear){  		// we are after the index year+1 so we should have already next
			document.write('<td width="23" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif"> <a href="' +theurl +'"><img src="/acadaff/Scientific_Activities/images/next_year.gif" width="23" height="21" border=0 >'+ '</a>'+'</td>');
	}
	else{														// off link grayed off arrow
			document.write('<td width="23" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif"><img src="/acadaff/Scientific_Activities/images/next_year_off.gif" width="23" height="21" /></td>');
  }	
	writeEndHeader();  
}

function writeSciacIndex(indexyear){
	var nextyear =  parseInt(indexyear) +1;
	var privyear =  nextyear-2;
	var indexurl = "/acadaff/Scientific_Activities/" + indexyear;
	//writeBaseHeader(indexyear);
	//document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" height="47">'); 
	document.write('<table  border="0" cellspacing="0" cellpadding="0" height="47">'); 
	document.write('<tr>');   
	document.write('<td width="23" align="left" valign="top" >');  //background="/acadaff/Scientific_Activities/images/bc_nav.gif"
	//document.write('<td width="226" height="47"><img src="/acadaff/Scientific_Activities/images/logo_bot.jpg" width="226" height="47" /></td>');
	//document.write('<td width="229" height="47" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_index.gif" >');

	
	//document.write('<img src="/acadaff/Scientific_Activities/images/index_on.gif" width="229" height="36"></td>');
	//document.write('<td width="23" align="left" valign="top" >');
  // handle priv:  till back 2000
 	var thePurl = "/acadaff/Scientific_Activities/"  + privyear + "/" ;
  //alert("privurl:"+thePurl);
  if ( privyear < 2000){ // no priv disp off
			document.write('<img src="/acadaff/Scientific_Activities/images/prev_year_off.gif" width="23" height="21">');
	}
	else{
			document.write('<a href="' +thePurl +'"><img src="/acadaff/Scientific_Activities/images/prev_year.gif" width="23" height="21" border=0></a>');
	}
	document.write('</td><td width="33" align="left" valign="top" >');
	document.write('<img src="/acadaff/Scientific_Activities/images/nav_year.gif" width="33" height="21" /></td>');
 //handel next, For NEXT YEAR we make the decfiion to have it OFF or ON here by testing the currnt year
 	var curdate = new Date();
	var thisyear = curdate.getFullYear();
	var theurl = "/acadaff/Scientific_Activities/"  + nextyear + "/" ;
	if (nextyear < thisyear){  		// we are after the index year so we should have already next
			document.write('<td width="23" align="left" valign="top" > <a href="' +theurl +'"><img src="/acadaff/Scientific_Activities/images/next_year.gif" width="23" height="21" border=0 >'+ '</a>'+'</td>');
	}
	else{														// off link grayed off arrow
	document.write('<td width="23" align="left" valign="top" ><img src="/acadaff/Scientific_Activities/images/next_year_off.gif" width="23" height="21" /></td>');
  }	
  	document.write('</td></tr></table>');	

	//writeEndHeader();  
}

function writeBaseHeader(indexyear){
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>');
	document.write('<td width="226" height="77" align="left" valign="top">');
	document.write('<img src="/acadaff/Scientific_Activities/images/logo_top.jpg" width="226" height="77"></td>');
	document.write('<td width="300" align="left" valign="top"><img src="/acadaff/Scientific_Activities/images/title.jpg" width="313" height="77"></td>');
	document.write('<td width="76" height="77" background="/acadaff/Scientific_Activities/images/bc_blue.jpg">');
	document.write('&nbsp;<span class="year_style">' + indexyear + '</span></td>');
	document.write('<td width="100%" rowspan="2" align="right" valign="top" background="/acadaff/Scientific_Activities/images/bc_blue.jpg">');
	document.write('<a href="/"><img src="/acadaff/Scientific_Activities/images/wis.gif" width="253" height="77" border="0"></a></td>');    
	document.write('</tr></table>');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" height="47">'); 
	document.write('<tr>');   
	document.write('<td width="226" height="47"><img src="/acadaff/Scientific_Activities/images/logo_bot.jpg" width="226" height="47" /></td>');
	document.write('<td width="229" height="47" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_index.gif" >');

}
function writeEndHeader(){
document.write('<td align="left" valign="top"><img src="/acadaff/Scientific_Activities/images/nav_end.gif" width="71" height="47" />');
	document.write('</td></tr></table>');	
}

//--------------------------------------------------------------
// NOTE NOT IN USE OUT!!!

// NOTE - for priv year is decided before being called so at the file the call is made for ON with link, or for OFF
function writeLinkPriv(privurl){
	thePurl= "/acadaff/Scientific_Activities/"  + privurl;   //var theurl 
	document.write( '<a href="' +thePurl +'">'+ 'Privious' + '</a>');	
}
function writeLinkPrivOff(){
	document.write(  'Privious' );	
}
// For NEXT YEAR we make the decfiion to have it OFF or ON here by testing the currnt year
function writeLinkNext(nexturl, indexyear){
	var curdate = new Date();
	var thisyear = curdate.getFullYear();
	var theurl = "/acadaff/Scientific_Activities/"  + nexturl;
	if (indexyear < thisyear){  // we are after the index year so we should have already next
			//document.write( '<a href="' +theurl +'">'+ 'Next' + '</a>');	  //on link
			document.write('<td width="23" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif"> <a href="' +theurl +'"><img src="/acadaff/Scientific_Activities/images/next_year.gif" width="23" height="21" border=0 >'+ '</a>'+'</td>');
	}
	else{
			// off link grayed off arrow
	document.write('<td width="23" align="left" valign="top" background="/acadaff/Scientific_Activities/images/bc_nav.gif"><img src="/acadaff/Scientific_Activities/images/next_year.gif" width="23" height="21" /></td>');
  }	

}
