function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.0
  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 fixLayers() {
	if (navigator.appName == "Netscape") {
		if (parseFloat(navigator.appVersion) >= 4.5) {
			document.location.reload();
		} // End Check AppVersion
	}// End Check AppName
} // End fixLayers

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function resetLists(whichList) {
    if ( whichList == 1 ) {
	    document.browseComponent.title.selectedIndex = 0;
		document.browseComponent.isbn.selectedIndex = 0;
	}
	if ( whichList == 2 ) {
	    document.browseComponent.subject.selectedIndex = 0;
		document.browseComponent.isbn.selectedIndex = 0;
	}
	if ( whichList == 3 ) {
	    document.browseComponent.subject.selectedIndex = 0;
		document.browseComponent.title.selectedIndex = 0;
	}
	if ( whichList == 4 ) {
		document.browseComponent.isbn.selectedIndex = 0;
	}
	if ( whichList == 5 ) {
		document.browseComponent.title.selectedIndex = 0;
	}
	if ( whichList == 6 ) {
	    document.addcomponent.newdiscipline.value = '';
	}
	if ( whichList == 7 ) {
	    document.addcomponent.userdiscipline.selectedIndex = 0;
	}
}

function open_window(url) {
	    win = window.open(url, "newWindow", "width=500,height=300,toolbar=no,scrollbars=no,resizable=yes,menubar=no");
}

function verify_form() {
    var msg = '';
	if (( document.addcomponent.userdiscipline.value == '' )&&
	    ( document.addcomponent.newdiscipline.value == '' )) msg = "Subject Area\n"; 
	if ( document.addcomponent.title.value == '' ) msg += "Title\n"; 
	if ( document.addcomponent.isbn.value == '' ) msg += "ISBN\n"; 
	if ( document.addcomponent.copyright.value == '' ) msg += "Copyright\n"; 
	if ( msg > '' ) {
	    msg = "The following information is required:\n" + msg; 
	    alert(msg);
	    return false;
	}
}

var newWindow;

function preview_errata() {
    if (( !newWindow )||(newWindow.closed )) {
	    newWindow = window.open("","newWindow","width=700,height=300,toolbar=no,scrollbars=no,resizable=yes,nemubar=no");
		newWindow.document.write('<head>');
		writeLine = '<link rel=\"stylesheet\" href=\"/css-bin/errata.css\" type=\"text/css\">';
		newWindow.document.write(writeLine);
		newWindow.document.write('</head>');
		newWindow.document.write('<html>');
		newWindow.document.write('<body>');
		newWindow.document.write('<span class=bodyText3>Errata Preview</span><br><br><br>');
		newWindow.document.write('<table width=100% cellspacing=20 cellpadding=0 border=0 bgcolor=ffffc6>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=100% bgcolor=ffffc6>');
		newWindow.document.write('<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor=ffffc6>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right class=bodyText1>');
		newWindow.document.write('<img src=\"/errata/images/spacer.gif\" height=1 width=75><br>');
		newWindow.document.write('Page:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.page.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right class=bodyText1>Location:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.location.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>Original:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.current.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>Revision:&nbsp;&nbsp;&nbsp;</td>');
	    writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.replacement.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		
		if ( document.adderrata.userfile.value > '' ) {
		    newWindow.document.write('<tr>');
		    newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>&nbsp;</td>');
	    	writeLine = "<td width=100% align=left class=bodyText1><a href=\"JavaScript:alert('The Image file will be available for preview when this errata is published.')\">Preview Replacement</a></td>";
	   	    newWindow.document.write(writeLine);
		    newWindow.document.write('</tr>');
		}
		if ( document.adderrata.image.value > '' ) {
		    newWindow.document.write('<tr>');
		    newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>&nbsp;</td>');
	    	writeLine = "<td width=100% align=left class=bodyText1><a href=\"/download/"+document.adderrata.divisionID.value+"/"+document.adderrata.disciplineID.value+"/"+document.adderrata.image.value+"\">Preview File</a></td>";
	   	    newWindow.document.write(writeLine);
		    newWindow.document.write('</tr>');
		}
		
		newWindow.document.write('</table>');
		newWindow.document.write('</td>');
		newWindow.document.write('</tr>');
		newWindow.document.write('</table>');
		newWindow.document.write('<table width=100% cellspacing=0 cellpadding=0 border=0>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td align=center><img src=\"/errata/images/spacer.gif\" height=100 width=1>');
		newWindow.document.write('<input type=\"button\" name=\"close\" value=\"Close Window\" onClick=\"javascript:window.close()\"></td>');
		newWindow.document.write('</tr>');
		newWindow.document.write('</table>');
		newWindow.document.write('</body>');
		newWindow.document.write('</html>');
	} else {
	    newWindow.focus();
	}
}

function preview_errata2() {
    if (( !newWindow )||(newWindow.closed )) {
	    newWindow = window.open("","newWindow","width=700,height=300,toolbar=no,scrollbars=no,resizable=yes,nemubar=no");
		newWindow.document.write('<head>');
		writeLine = '<link rel=\"stylesheet\" href=\"/css-bin/errata.css\" type=\"text/css\">';
		newWindow.document.write(writeLine);
		newWindow.document.write('</head>');
		newWindow.document.write('<html>');
		newWindow.document.write('<body>');
		newWindow.document.write('<span class=bodyText3>Errata Preview</span><br><br><br>');
		newWindow.document.write('<table width=100% cellspacing=20 cellpadding=0 border=0 bgcolor=ffffc6>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=100% bgcolor=ffffc6>');
		newWindow.document.write('<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor=ffffc6>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right class=bodyText1>');
		newWindow.document.write('<img src=\"/errata/images/spacer.gif\" height=1 width=75><br>');
		newWindow.document.write('Page:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.page.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right class=bodyText1>Location:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.location.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>Original:&nbsp;&nbsp;&nbsp;</td>');
		writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.current.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>Revision:&nbsp;&nbsp;&nbsp;</td>');
	    writeLine = '<td width=100% align=left class=bodyText1>' + document.adderrata.replacement.value + '</td>';
		newWindow.document.write(writeLine);
		newWindow.document.write('</tr>');
		
		if ( document.adderrata.userfile.value > '' ) {
		    newWindow.document.write('<tr>');
		    newWindow.document.write('<td width=75 align=right valign=top class=bodyText1>&nbsp;</td>');
	    	writeLine = "<td width=100% align=left class=bodyText1><a href=\"JavaScript:alert('The Image file will be available for preview when this errata is published.')\">Preview Replacement</a></td>";
	   	    newWindow.document.write(writeLine);
		    newWindow.document.write('</tr>');
		}
		
		newWindow.document.write('</table>');
		newWindow.document.write('</td>');
		newWindow.document.write('</tr>');
		newWindow.document.write('</table>');
		newWindow.document.write('<table width=100% cellspacing=0 cellpadding=0 border=0>');
		newWindow.document.write('<tr>');
		newWindow.document.write('<td align=center><img src=\"/errata/images/spacer.gif\" height=100 width=1>');
		newWindow.document.write('<input type=\"button\" name=\"close\" value=\"Close Window\" onClick=\"javascript:window.close()\"></td>');
		newWindow.document.write('</tr>');
		newWindow.document.write('</table>');
		newWindow.document.write('</body>');
		newWindow.document.write('</html>');
	} else {
	    newWindow.focus();
	}
}

var previewWindow;

function preview_image(image) {
    if (( !previewWindow )||(previewWindow.closed )) {
	    previewWindow = window.open("","previewWindow","width=500,height=300,toolbar=no,scrollbars=no,resizable=yes,nemubar=no");
		previewWindow.document.write('<html>');
		previewWindow.document.write('<body>');
		previewWindow.document.write('<table width=100% height=100% cellspacing=0 cellpadding=0 border=0>');
		previewWindow.document.write('<tr>');
		previewWindow.document.write('<td valign=middle align=center>');
		writeline = "<img src='" + image + "' border=0>";
		previewWindow.document.write(writeline);
		previewWindow.document.write('</td>');
		previewWindow.document.write('</tr>');
		previewWindow.document.write('</table>');
		previewWindow.document.write('</body>');
		previewWindow.document.write('</html>');
	} else {
	    previewWindow.focus();
	}
}