nl='';        /* a new line character for testing esthetics. no value when not testing */
zoomButton='';
about_sono='';
anyScripts='';
key='';


function writeConsole(content,w,h,title,zoom,content2) {

	birdname=title.substring(title.indexOf('-')-1);	/* bird name without file description */
	zoom_1X=sonoImgDir+content+'_Z.jpg';		/*  image name for single level zoom */
	zoom_2X=sonoImgDir+content+'_Z2.jpg';	/*  image name for double level zoom */
	no_zoom=sonoImgDir+content+'_L.jpg';		/*  image name for large unzoomed image */
	mp3=songDir+content+'.mp3';			/* birdsong name */
	sono_color_bar=imgDir+'sonogram_color_key.jpg'	/* color key for sonogram files */
	window_name=content;			/* dynamic naming of windows */

	/* general window properties with dynamic width and height*/
	windowProps="'left=5,top=5,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+"'";

	/* close button html */
	closeButton='<input type="button" value="Close" onClick="window.close()">';


/* greater than zero ? then create sonogram image window with the specified data */

if(zoom > 0){ /* Allow you to zoom into images */

	/* only sonogram images will have a zoom button */
	zoomButton='<center><input type="button" name="biggerPic" value="Zoom In" onClick="zoomMe('+zoom+')"></center>';
	
	// scripts written to window


		if(document.all || document.getElementById){
		about_sono='<a href="'+scriptDir+'about.html" style="text-decoration: none; color: white; font-family: sans-serif">About Sonograms</a>'
		}

		else{
		about_sono='<font color="gray" face="sans-serif">Birdsong Project</font>'
		}
		
	bottom_bar=''
	+'    <td width="33%" align="center" bgcolor="#000080">'+nl
	+about_sono+nl
	+'</td>'+nl
	+'    <td width="33%" align="center" bgcolor="#000080">'+nl
	+zoomButton
	+'</td>'+nl
	+'    <td width="33%" align="center" bgcolor="#000080">'+nl
	+closeButton

	key='<p style="font-family: arial, sans-serif">&nbsp;&nbsp;Low Volume &gt;&nbsp;&nbsp;'
	+'<img border="0" src="'+sono_color_bar+'" width="213" height="20" align="middle">&nbsp;&nbsp;&lt; High Volume</p><p></p>'

	insert_main_content='<img border="0" name="sono" src="'+no_zoom+'">'+key

	}

/* if zoom is specified at zero or less do the following */
else{ 
	zoomButton='';
	about_sono='';
	
	/* zoom is -1 ? then create a window with sonogram images and sound files - with a static width and height */
	if(zoom==-1){
		windowProps="'left=5,top=5,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=450'";
		window.open("../birdsongs_mp3/song.html?"+"'"+content+'\','+w+','+h+','+"'Bird Songs"+birdname+"'"+',1,\''+content2+"'","sound_window",windowProps)
//		window.open(sono_img+content+'\','+w+','+h+','+"'Bird Songs"+birdname+"'"+',1,\''+content2+"'","sound_window",windowProps)
		return;
		}

	/* zoom is -2 ? then create a window with single sound files width and height can be adjusted but will probably be static*/
	if(zoom==-2){
			window_name='song_file'+content;
			window.open("birdsongs_mp3/song.html?"+"'"+content+'\','+w+','+h+','+"'"+title+"'"+',-2,\''+''+"'",window_name,windowProps)
			return;

		}
	
	/* zoom is 0 ? then create a window for a larger map file*/
	if(zoom==0) {

		key=''
		+'<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="400" id="AutoNumber1">'
		+' <tr>'
		+'    <td width="61">'
		+'   <p align="right"><font face="Arial">Summer</font></td>'
		+'    <td width="40" bgcolor="#FFCE00">&nbsp;</td>'
		+'    <td width="72">'
		+'    <p align="right">'
		+'    <font face="Arial">Winter</font></td>'
	 	+'   <td width="40" bgcolor="#01CFFF">'
	 	+'   <p align="right">&nbsp;'
		+'    </td>'
		+'    <td width="93">'
		+'    <p align="right"><font face="Arial">Year Round</font></td>'
		+'    <td width="40" bgcolor="#CE67FF">&nbsp;</td>'
		+'  </tr>'
		+'</table><br>';

		insert_main_content='<img border="0" name="sono" src="'+mapDir+content+'.gif"><br><br>'+key /* main window contents */
		window_name='map'
		}

bottom_bar=''
+'    <td width="33%" align="center" bgcolor="#000080">'+nl
+'&nbsp;'
+'</td>'+nl
+'    <td width="33%" align="center" bgcolor="#000080">'+nl
+closeButton
+'</td>'+nl
+'    <td width="33%" align="center" bgcolor="#000080">'+nl
+'&nbsp;'		

}	

	
top.consoleRef=window.open('',window_name,windowProps);


/* this html will write to the new window, inserting dynamic content depending on whether it is a sonogram, map or sound file */

 consoleContent=''
+ '<html><head><TITLE>ASU-Ask A Biologist'+birdname+'</TITLE>'+nl

+'</head>'+nl
+'<BODY BGCOLOR="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" onload="self.focus();">'+nl
+'<CENTER>'+nl
+'<table border="0" width="100%">'+nl
+'  <tr>'+nl
+'    <td bgcolor="#000080" width="100%">'+nl
+'      <p align="center"><font color="#FFFFFF" face="Arial"><b>'+title+'</b></font></td>'+nl
+'  </tr>'+nl
+'  <tr>'+nl
+'    <td width="100%" align="center">'

+insert_main_content 

/* dynamic content of generated window */

+'</td>'
+'  </tr>'+nl
+'  <tr>'+nl
+'<td bgcolor="#000080" width="100%">'

+'<table border="0" width="100%" cellpadding="0" cellspacing="0"><tr><td>'+nl
+'<form name="form_1">'

+bottom_bar  /* determines bottom bar esthetics ie whether close button is in the middle or on the right */

+'    </td>'+nl
+'</tr></table>'+nl
+'    </td>'+nl
+'  </tr>'+nl
+'</table>'+nl
+'</center></form>'+nl
+'</body>'+nl
+'</html>';+nl

anyScripts=''
	+'<script'+' language="javascript">'+nl

	/* function written to window that controls the zoom level */

	+'function zoomMe(zoom){'+nl

	+'if(document.form_1.biggerPic.value=="Zoom In"){'
	+'zoom==1 ? document.form_1.biggerPic.value="Zoom Out" : document.form_1.biggerPic.value="Zoom More";'+nl
	+'document.sono.src="'+zoom_1X+'";'+nl
	+'return;'+nl
	+'}'+nl

	+'if(document.form_1.biggerPic.value=="Zoom More"){'+nl
	+'document.form_1.biggerPic.value="Zoom Out";'+nl
	+'document.sono.src="'+zoom_2X+'";'+nl
	+'return;'+nl
	+'}'+nl

	+'if(document.form_1.biggerPic.value=="Zoom Out"){'+nl
	+'document.form_1.biggerPic.value="Zoom In";'+nl
	+'document.sono.src="'+no_zoom+'";'+nl
	+'return;'+nl
	+'}'+nl
 +'}'
 
+'</'+'script>'



 top.consoleRef.document.writeln(consoleContent)
 top.consoleRef.document.writeln(anyScripts)
 top.consoleRef.document.close()
 
 
 
}
