// ***************** COPYRIGHT (c) 2008 STEFAN WANER ******************
// *********************** ALL RIGHTS RESERVED ************************

// * language
// This is a global called theLanguage that must be speicifed 
// on the page before this is loaded.


// * book names

var booknamefiniteen = "Finite Mathematics";
var booknamecomboen = "Finite Mathematics and Applied Calculus";
var booknamecalcen = "Applied Calculus";
var booknamefinitees = "Matem&aacute;ticas finitas";
var booknamecomboes = "Matem&aacute;ticas finitas y c&aacute;lcula aplicado";
var booknamecalces = "C&aacute;lcula aplicado";



// * book tag

var bookopenTagcomboen = "<a href = 'http:FiniteAndCalc.org' target = '_top'>";
var bookopenTagcalcen = "<a href = 'http:AppliedCalc.org' target = '_top'>";
var bookopenTagfiniteen = "<a href = 'http:FiniteMath.org' target = '_top'>";

var bookopenTagcomboes = "<a href = 'http://www.mnlibros.com.ar/DespLibro.asp?Libro=9706861351' target = '_top'>";
var bookopenTagcalces = "<a href = 'http://www.mnlibros.com.ar/DespLibro.asp?Libro=9706861351' target = '_top'>";
var bookopenTagfinitees = "<a href = 'http://www.mnlibros.com.ar/DespLibro.asp?Libro=9706861351' target = '_top'>";

function writeBookTag(whichBook,theLinkName,lang,hexColor) {
// whichBook = "finite". "calc" or "combo"
var theColor = "009933"; // default green
try{ theColor = hexColor}
catch(error){}
var theCommand = "openTag = bookopenTag" + whichBook + lang;
var doIt = eval(theCommand);
if (theLinkName == "") {
	theCommand = "theLinkName = " + 'bookname'  + whichBook + lang;
	var doIt = eval(theCommand);		
	}
theLinkName = "<i><font color = " + theColor  + ">" + theLinkName + "</font></i>";
document.writeln(openTag + theLinkName + '</a>');
}



// * email tag

function writeEMailtag(theLinkName,theSubject) {
var theAddress = "mailto:zweigmedia@gmail.com?Subject="+theSubject;
var theTag = "<a href = '" + theAddress + "'>" + theLinkName + "</a>";
document.writeln(theTag);
} // writeMailtag



// * js Math note

var jsMathNoteEn = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">Note:</i> The mathematics in this page has been typeset using <a href = "http://www.math.union.edu/~dpvc/jsMath/"><i>jsMath</i></a>. To see the <i>jsMath </i> typesetting at its best you should install the <i>jsMath </i> TeX fonts. Click on the <i>jsMath </i> button at the bottom right corner of this page for more details.'

var jsMathNoteEs = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">Nota:</i> Las matem&aacute;ticas en esta p&aacute;gina han sido mecanografiadas por <a href = "http://www.math.union.edu/~dpvc/jsMath/"><i>jsMath</i></a>. Para ver  <i>jsMath </i> a su mejor expresi&oacute;n, debe instalar las fuentes <i>jsMath </i> TeX. Haga clic en el bot&oacute;n de <i>jsMath </i> en la parte inferior derecha de la pagina para ver m&aacute;s detalles.';

function writeJsMathNote(lang) {
if (lang == "en") document.writeln(jsMathNoteEn);
else if (lang == "es") document.writeln(jsMathNoteEs);
}


// * Even-numbered Exercises Notice

var evenNumNoteEn = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">Note:</i> The even-numbered exercises (except for the "Communication and Reasoning" exercises) are randomized: You might see differences every time you load the page. The odd-numbered exercises are the same for everyone.</p>';

var evenNumNoteEs = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">Nota:</i> Los ejercicios pares (salvo los ejercicios de "comunicaci&oacute;n y razonamiento") son aleatorios: Puede ver diferencias cada vez que recarga la p&aacute;gina. Los ejercicios impares son lo mismo para todos.</p>';

function writeEvenNumNote(lang) {
if (lang == "en") document.writeln(evenNumNoteEn);
else if (lang == "es") document.writeln(evenNumNoteEs);
}


// * Tutorial Book Reference

function writeBookRefCalc(lang,secCalc,secComb,hexColor) {
var theColor = "009933"; // default green
try{ theColor = hexColor}
catch(error){}
if (lang == "en") document.writeln('<center><p> (This topic is also in Section ' + secCalc + ' in <i><a href = "http://www.AppliedCalc.org" target = "_top"><font color = ' + theColor  + '>Applied Calculus</font></a></i> and Section ' + secComb + ' in <i><a href = "http://www.FiniteAndCalc.org" target = "_top"><font color = ' + theColor  + '>Finite Mathematics and Applied Calculus</font></a></i>)</center>');
else document.writeln('<center><p> (Se puede encontrar este tema en la Secci&oacute;n ' + secCalc + ' del libro <i><a href = "http://www.AppliedCalc.org" target = "_top"><font color = ' + theColor  + '>Applied Calculus</font></a></i> o la Secci&oacute;n ' + secComb + ' de <i><a href = "http://www.FiniteAndCalc.org" target = "_top"><font color = ' + theColor  + '>Finite Mathematics and Applied Calculus</font></a></i>)</center>');
}

function writeBookRefFinite(lang,secFinite,secComb) {
var theColor = "009933"; // default green
try{ theColor = hexColor}
catch(error){}
if (lang == "en") document.writeln('<center><p> (This topic is also in Section ' + secFinite + ' in <i><a href = "http://www.FiniteMath.org" target = "_top"><font color = ' + theColor  + '>Finite Mathematics</font></a></i> and Section ' + secComb + ' in <i><a href = "http://www.FiniteAndCalc.org" target = "_top"><font color = ' + theColor  + '>Finite Mathematics and Applied Calculus</font></a></i>)</center>');
else document.writeln('<center><p> (Se puede encontrar esta tema en la Secci&oacute;n ' + secFinite + ' del libro <i><a href = "http://www.FiniteMath.org" target = "_top"><font color = ' + theColor  + '>Matem&aacute;ticas finitas</font></a></i> o la Secci&oacute;n ' + secComb + ' de <i><a href = "http://www.FiniteAndCalc.org" target = "_top"><font color = ' + theColor  + '> Matem&aacute;ticas finitas y c&aacute;lculo aplicado</font></a></i>)</center>');
}


// * Game Tutorials Notice

var gameTutNoteEn = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">This is a game version of the tutorial, and a little more challenging than the non-game version. If this is your first time studying the material, you might try the non-game version first (press "non-game version" on the sidebar).  To complete the game you must answer all the questions correctly. The questions are randomized: You might see differences every time you load the page. Warning: Pressing "Help" or "Peek" decreases your scores. Clicking on the little pictures that may appear on the left can have unexpected consequences!</i></p>';

var gameTutNoteEs = '<p><i style = "font-family: Arial, Verdana, Helvetica, sans-serif; color: C93344;">Esta es una versi&oacute;n juego del tutorial, y es un poco m&aacute;s exigente que la versi&oacute;n no juego. Si est&eacute; es la primera vez que estudie el material, sugerimos que pruebe primero la versi&oacute;n no juego (pulse "versi&oacute;n no juego" al lado izquierda). Para completar el juego, tiene que contestar correctamente cada pregunta. Las preguntas son aleatorias: Puede ver diferencias cada vez que recarge la p&aacute;gina. Aviso: &iexcl;Pulsando "Ayuda" o "Vistazo" bajar&aacute; sus resultados. Hacienco clic en cualquier dibujo peque&ntilde;o que aparezca a la izquierda puede resultar en consecuencias inesperadas!</i></p>';

function writeTutNote(lang) {
if (lang == "en") document.writeln(gameTutNoteEn);
else if (lang == "es") document.writeln(gameTutNoteEs);
}


// * Game Alert (to slow Mozilla down when jsMath is running)

var theGameAlert = "Note: Reloading the page will cause the game to start over with different questions.";
if (theLanguage == "es") theGameAlert = "Nota: Recargar la pagina hara que el juego se reinicia con preguntas diferentes.";


// * IEwarning
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->

var IEWarningStrEn = '<p><font color = red><b>Note: </b>You are using Microsoft Internet Explorer, which lacks native support for the widely used Javascript graphics method <a href = "http://en.wikipedia.org/wiki/Canvas_%28HTML_element%29"><i>Canvas</i></a>. One consequence of this is that the interactive graphs on this page will be very slow and sluggish. To remedy this, and to experience a browser with superior <a href = "http://en.wikipedia.org/wiki/Standards-compliant">standards compliance</a>, try switching to <a href = " http://www.mozilla.com">Mozilla Firefox</a> or <a href = "http://www.apple.com/safari/download/">Safari</a> for both Mac and PC platforms. You will see a <i>dramatic </i> improvement.</font></p>';

var IEWarningStrEs = '<p><font color = red><b>Nota: </b>Est&aacute; usando Microsoft Internet Explorer, que <a href = "http://en.wikipedia.org/wiki/Standards-compliant">no soporta los est&aacute;ndares de Internet</a> como soporte para el m&eacute;todo <a href = "http://en.wikipedia.org/wiki/Canvas_%28HTML_element%29"><i>Canvas</i></a> de javascript. Una consequencia es que las gr&aacute;ficas interactivas en este p&aacute;gina sera muy lentas y inertas. Para remediarla, y para experimentar un navegador con soporta superior de est&aacute;ndares, cambie a <a href = " http://www.mozilla-europe.org/es/">Mozilla Firefox</a> o <a href = "http://www.apple.com/es/safari/download/">Safari</a> para todos los plataformas Mac, PC, y Unix. Mirar&aacute; una mejora <i>dram&aacute;tica.</i></font></p>';

var IEWarningStr2En = '<p><font color = red><b>Note: </b>You are using Microsoft Internet Explorer, which lacks native support for the widely used Javascript graphics method <a href = "http://en.wikipedia.org/wiki/Canvas_%28HTML_element%29"><i>Canvas</i></a>. One consequence of this is that the graphing of functions on this page will be very slow and sluggish, and the trace feature is disabled. To experience a browser with native canvas support, try switching to <a href = " http://www.mozilla.com">Mozilla Firefox</a> or <a href = "http://www.apple.com/safari/download/">Safari</a> for both Mac and PC platforms. You will see a <i>dramatic </i> improvement.</font></p>';

var IEWarningStr2Es = '<p><font color = red><b>Nota: </b>Est&aacute; usando Microsoft Internet Explorer, que <a href = "http://en.wikipedia.org/wiki/Standards-compliant"> falta soporte para el m&eacute;todo extensamente utilizado <a href = "http://en.wikipedia.org/wiki/Canvas_%28HTML_element%29"><i>Canvas</i></a> de javascript. Una consequencia es que el graficador en este p&aacute;gina sera muy lento y inerto, y la herramienta trazador ha sido desactivada. Para experimentar un navegador con soporta nativa para Canvas, cambie a <a href = " http://www.mozilla-europe.org/es/">Mozilla Firefox</a> o <a href = "http://www.apple.com/es/safari/download/">Safari</a> para todos dos plataformas Mac y PC. Mirar&aacute; una mejora <i>dram&aacute;tica.</i> </font></p>';

function writeIEWarning (lang, num) {

if (num == 2) {
	if (lang == "en") document.writeln(IEWarningStr2En);
	else if (lang == "es") document.writeln(IEWarningStr2Es);
	}
else {
	if (lang == "en") document.writeln(IEWarningStrEn);
	else if (lang == "es") document.writeln(IEWarningStrEs);
	}
}


// * vertical skip

function vSkip(num_points) {
var theStr = '<br><span style = "line-height: ' + num_points.toString() + 'px">&nbsp;</span><br>';
document.writeln(theStr);
} // vSkip

// * utilities
// * Javascript loaders **
// * These are due to
// http://www.phpied.com/javascript-include/
function include(script_filename) {
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}
// writedoc loader

function include_dom(script_filename) {
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
    return false;
}

// * Now one that includes new JS only if already included

var included_files = new Array();

function include_once(script_filename) {
    if (!in_array(script_filename, included_files)) {
        included_files[included_files.length] = script_filename;
        include_dom(script_filename);
    }
}

function in_array(needle, haystack) {
    for (var i = 0; i < haystack.length; i++) {
        if (haystack[i] == needle) {
            return true;
        }
    }
    return false;

}

// * end of on-the-fly javascript includers


// * Format Table

var quoteMark = unescape( '%22' );
var formatTable;
if (theLanguage == "en") formatTable = '<center><table border = 1 width = 90% cellspacing = 0 cellpadding = 7 noshade border = 0 bordercolor = #009933 STYLE=' + quoteMark + 'background-color: FFE9EE; border-collapse: collapse' + quoteMark + '><tr><td align = center><font class = smtableHeading>Some Examples:<br>Expression</font></td><td align = center><font class = smtableHeading>Format (spaces are ignored)</font></td></tr><tr><td align = center> 2<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>2*x-4 </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 2x-4</font></td></tr><tr><td align = center>3<sup>2</sup></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 3^2 </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> pow(3,2)</font></td></tr><tr><td align = center> 3<font class = math>x</font><sup>2</sup> + 4<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 5</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>3*x^2+4*x-5 </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 3x^2+4x-5</font></td></tr><tr><td align = center> 3,000e<sup>2<font class = math>x</font><font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font>1</sup></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>3000*e^(2*x-1) </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>   3000*exp(2x-1)</font></td></tr><tr><td align = center><table><tr><td nowrap><center>2<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 1<br><img src = ' + quoteMark + 'SYMB/FR.GIF' + quoteMark + ' height = 1 width =100%><br>3<font class = math>x</font><sup>2</sup> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4<font class = math>x</font> </center></td></tr></table></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> (2x-1)/(3x^2-4x)</font></td></tr><tr><td align = center>|2x <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> e<sup>x</sup>|</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>abs(2x-exp(x)) </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> abs(2x-e^x)</font></td></tr><tr><TD align = center><TABLE><TR><img src = ' + quoteMark + pathPrefix + 'RealWorld/gf/shortsqrtline.gif' + quoteMark + '><br><img src = ' + quoteMark + pathPrefix + 'RealWorld/gf/sqrt.gif' + quoteMark + '>2x+1</td></TR></TABLE></TD></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> (2x+1)^0.5 </font>or<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> sqrt(2x+1)</font></td></tr><tr><td align = center>ln | 4<font class = math>x</font><sup>3</sup><font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font>5<font class = math>x</font> | + log(10<sup><font class = math>x</font></sup><img src =' + quoteMark + 'gf/thinspace.gif' + quoteMark + ' width = 2>)</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>ln(abs(4x^3-5x))+log(10^x)</font></td></tr><tr><td align = center>sin(&pi;<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4)</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>sin(pi*x-4) </font>NOT<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> sin(pix-4) </font></td></tr></table></center>';

else formatTable = '<center><table border = 1 width = 90% cellspacing = 0 cellpadding = 7 noshade border = 0 bordercolor = #009933 STYLE=' + quoteMark + 'background-color: FFE9EE; border-collapse: collapse' + quoteMark + '><tr><td align = center><font class = smtableHeading>Unos Ejemplos:<br>Expresi&oacute;n</font></td><td align = center><font class = smtableHeading>Formato (espacios son ignorados)</font></td></tr><tr><td align = center> 2<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>2*x-4 </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 2x-4</font></td></tr><tr><td align = center>3<sup>2</sup></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 3^2 </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> pow(3,2)</font></td></tr><tr><td align = center> 3<font class = math>x</font><sup>2</sup> + 4<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 5</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>3*x^2+4*x-5 </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> 3x^2+4x-5</font></td></tr><tr><td align = center> 3,000e<sup>2<font class = math>x</font><font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font>1</sup></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>3000*e^(2*x-1) </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>   3000*exp(2x-1)</font></td></tr><tr><td align = center><table><tr><td nowrap><center>2<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 1<br><img src = ' + quoteMark + 'SYMB/FR.GIF' + quoteMark + ' height = 1 width =100%><br>3<font class = math>x</font><sup>2</sup> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4<font class = math>x</font> </center></td></tr></table></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> (2x-1)/(3x^2-4x)</font></td></tr><tr><td align = center>|2x <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> e<sup>x</sup>|</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>abs(2x-exp(x)) </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> abs(2x-e^x)</font></td></tr><tr><TD align = center><TABLE><TR><img src = ' + quoteMark + pathPrefix + 'RealWorld/gf/shortsqrtline.gif' + quoteMark + '><br><img src = ' + quoteMark +  pathPrefix + 'RealWorld/gf/sqrt.gif' + quoteMark + '>2x+1</td></TR></TABLE></TD></td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> (2x+1)^0.5 </font>o<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> sqrt(2x+1)</font></td></tr><tr><td align = center>ln | 4<font class = math>x</font><sup>3</sup><font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font>5<font class = math>x</font> | + log(10<sup><font class = math>x</font></sup><img src =' + quoteMark + 'gf/thinspace.gif' + quoteMark + ' width = 2>)</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>ln(abs(4x^3-5x))+log(10^x)</font></td></tr><tr><td align = center>sin(&pi;<font class = math>x</font> <font face = ' + quoteMark + 'Courier' + quoteMark + '>-</font> 4)</td><td align = center><font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta>sin(pi*x-4) </font>PERO NO<font face = ' + quoteMark + 'Courier' + quoteMark + ' class = magenta> sin(pix-4) </font></td></tr></table></center>';

// * End Format Table
