window.onload=function(){
    var system=0;                  //platform (OS system) number
    var browser=0;                 //browser number
                                        //string definitions
    var msfont = 
        '{font-family: "Arial", "Times New Roman", "Book Antiqua", serif;}';
    var macfont = 
        '{font-family: BiauKai, AppleMyungjo, "Lucida Grande", serif;}';
    var linuxfont = 
        '{font-family: UnBatang, FreeSerif, Nimbus, Dejavu, serif;}';
//    var msfont3 = 
//        '{font-family: STIXGeneral, "Times New Roman", "Book Antiqua", serif;}';
//    var macfont3 = 
//        '{font-family: STIXGeneral, BiauKai, AppleMyungjo, "Lucida Grande", serif;}';
//    var linuxfont3 = 
//        '{font-family: STIXGeneral, UnBatang, FreeSerif, Nimbus, Dejavu, serif;}';
    var wrphi = "#wrphi {display:none;}";
    var crphi = "#crphi {display:none;}";
    var csstring = ""; 

    if(navigator.platform == "Win32"){
        system=1;
//alert("system = "+system);
        if(navigator.appName == "Microsoft Internet Explorer") browser=1;
//alert("browse = "+browser);
        else getbrowser();
    }
    else {
        if (navigator.platform == "MacIntel"){
            system=2;
            if(navigator.userAgent.indexOf("Safari") != -1) {
                browser=5;
//alert("Safari does not support yet MathML");
            }
            else getbrowser();
        }
        else {
            if (navigator.platform == "Linux i686"){
                system=3;
                getbrowser();
            }
            else {
                if ((navigator.platform.indexOf("Solaris") != -1)||
                    (navigator.platform.indexOf("Unix") != -1)) getbrowser();
//else alert("Your platform does not support MathML");
            }                       
        }
    }

    if(system==0){
        csstring=wrphi;
        csstyle();                             
        return;
    }
    if(system==1){
//alert("browser is "+browser);
        switch(browser) {
            case 1:
                var phi=document.all("crphi");
                if(phi == null)return;
                var phis=phi.length;            
                for(var n=0; phis>n; n++){
                    phi[n].style.display="none";
                }
                return;
            case 2:
                csstring="p,li"+msfont+" "+crphi;
                break;
             case 3:
                csstring="p,li"+msfont+" "+wrphi;
                break;
             case 4:
                csstring="p,li"+msfont+" "+wrphi;
        }      
        csstyle(); 
        return;
    }
    if(system==2){
        switch(browser) {
            case 2:
            case 4: 
        
        csstring="p,li"+macfont+" "+crphi;
                break; 
            case 3:

                csstring="p,li"+macfont+" "+wrphi;
                break;
            case 5:               
                csstring="p,li"+macfont+" "+wrphi;
        }
        csstyle(); 
        return;
    }
    if(system==3){
        if(browser==2)csstring="p,li"+linuxfont+" "+crphi; 
        else csstring="p,li"+linuxfont+" "+wrphi;
        csstyle(); 
        return;
    }
    if(system==4){
        csstring="p,li"+macfont+" "+crphi; 
        csstyle(); 
        return;
    }
    csstring=wrphi;
    csstyle();
    return;
                                
function getbrowser(){
    if (navigator.userAgent.indexOf("Firefox/2") != -1) browser=2;
    else {
// next 2 lines are the original
//        if ((navigator.userAgent.indexOf("Firefox/3") != -1)||
//            (navigator.userAgent.indexOf("Minefield/3") != -1)) browser=3;
// next line is the new one 28/11/2011
          if (navigator.userAgent.indexOf("Firefox/") != -1) browser=3;
        else {
            if (navigator.userAgent.indexOf("Opera") != -1) {
                browser=4;
//alert("Opera does not support yet MathML");
            }
//alert("You don't have any MathML support");
        }
    }
}

function csstyle(){
    var csstyle = document.createTextNode(csstring);
//    alert("csstyle is "+csstyle);
    var newstyle = 
        document.createElementNS
        ('http://www.w3.org/1999/xhtml','style');
    newstyle.setAttribute('type','text/css');
    newstyle.appendChild(csstyle);
    if (document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml','head').length>0){
        var parent = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml','head')[0];
    }
    else {
        var parent = document.documentElement;
    }
    parent.insertBefore(newstyle,parent.firstChild);
}
}







