// JavaScript Document
function makeRounded() {
      /* finds all divs within the document */
     
      var divs=document.getElementsByTagName('div');
      var numDivs=divs.length;
     
      /* defines a new array for storing “rounded” divs */
      var roundedDivs= new Array();
     
      /*  looks for “rounded” divs and stores them in the array */
      for(i=0;i<numDivs;i++) {
        if(/\brounded\b/.test(divs[i].className)) {
          roundedDivs[roundedDivs.length]=divs[i];
        }
      }
      var numRoundedDivs=roundedDivs.length;

      /* appends the three divs needed for rounded corners */
      for(i=0;i<numRoundedDivs;i++) {
        /* access the bottom-right div (original div) */
        var brdiv=roundedDivs[i];

        /* creates top-left div */
        var tldiv=document.createElement('div');

        /* removes class name attribute from bottom-right div (original div)  */
        brdiv.className=brdiv.className.replace('rounded','');

    /* sets class name “rounded” to top-left div */
        tldiv.className='rounded';

        /* swaps bottom-right div (original div) with top-left div */
        brdiv.parentNode.replaceChild(tldiv,brdiv);

        /* creates top-right div inner node */
        trdiv=document.createElement('div');

        /* creates bottom-left div inner node */
        bldiv=document.createElement('div');

        /* appends top-left and top-right inner nodes in the document */
        tldiv.appendChild(trdiv);
        trdiv.appendChild(bldiv);

        /* appends bottom-right div (original div) back in the document */
        bldiv.appendChild(brdiv);
      }
}
    /* calls the function after the page is loaded */
    window.onload=makeRounded;