function htmlEncode(s)
{s=s.replace(/&(?!\w+([;\s]|$))/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&amp;#39;/g,"'");return s.replace(/&lt;br \/&gt;/g,"<br />");}
function poplatex(formula,wd,ht)
{formula=htmlEncode(formula);L_CODE="Codice";L_LATEX_POPUP_TITLE="ScienzeMatematiche.it LaTeX popup";L_CLOSE_WINDOW="Chiudi la finestra";L_SELECT_ALL="Seleziona tutto";if(!wd){wd=500;}
if(!ht){ht=200;}
if(navigator.userAgent.indexOf('MSIE')!=-1){L_LATEX_POPUP_TITLE=L_CODE;}
var w=window.open('',L_LATEX_POPUP_TITLE,'width='+wd+', height='+ht+', resizable=yes, scrollbars=yes, menubar=no, toolbar=no, location=no, status=yes');w.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');w.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>'+L_LATEX_POPUP_TITLE+'</title>');w.document.write('<link rel="stylesheet" href="./codebox.css" />');w.document.write('<script type="text/javascript"> /* <![CDATA[ */ function selectCode(a) { var e = a.parentNode.parentNode.getElementsByTagName(\'code\')[0]; if (document.selection) { var r = document.body.createTextRange(); r.moveToElementText(e); r.select(); } else { var s = window.getSelection(); var r = document.createRange(); r.setStartBefore(e); r.setEndAfter(e); s.addRange(r); } } /* ]]> */</script>');w.document.write('</head><body style=\'background-color: #E5E5E5;\'>');w.document.write('<div style="width: 95%; padding: 5px; text-align: left;"><dl class="codebox" style="width: 95%;"><dt>'+L_CODE+': <a href="#" onclick="selectCode(this); return false;">'+L_SELECT_ALL+'</a></dt><dd><code>'+formula+'</code></dd></dl></div>');w.document.write('<div style="padding-top: 10px; text-align: center; margin: 0px auto; width: 95%;"><form><button onclick="window.close();" class="liteoption">'+L_CLOSE_WINDOW+'</button></form></div></div>');w.document.write('</body></html>');w.document.close();w.focus();}
function ajaxRating(xml)
{var x=xml.responseXML;var xmlRating=x.getElementsByTagName('value');var rating=xmlRating[0].firstChild.nodeValue;var xmlPostId=x.getElementsByTagName('id');var post_id=xmlPostId[0].firstChild.nodeValue;var xmlErrorBit=x.getElementsByTagName('errorbit');var errorbit=xmlErrorBit[0].firstChild.nodeValue;var xmlMsg=x.getElementsByTagName('msg');var msg=xmlMsg[0].firstChild.nodeValue;document.getElementById('mp_rating_infobox_'+post_id).innerHTML=msg;s.locked=true;}
function addSearchPlugin(name,cat){if((typeof window.sidebar=="object")&&(typeof window.sidebar.addSearchEngine=="function"))
window.sidebar.addSearchEngine("http://www.scienzematematiche.it/forum/"+name+".src","http://www.scienzematematiche.it/forum/favicon.ico",'ScienzeMatematiche.it',cat);else
alert("Netscape 6, Mozilla or Firefox are needed to install a sherlock plugin.");}
