function round(val) {
                // zaokrąglanie do 0.5
                number = parseInt(val);
                rest = val % 1;
                if (rest <= 0.25) add=0;
                if (rest > 0.25 && rest <= 0.75) add=0.5;
                if (rest > 0.75) add=1;
                return number+add;
            }
			

function ilinia() {
                // obliczanie interlinii
                
                unit=getUnit(document.getElementById('fs').value);
                
                if (unit!='em') { 
                    stopien=toUnit(document.getElementById('fs').value, 'pt');
                    kolumna=toUnit(document.getElementById('elwidth').value, 'pc');
                } else { 
                    stopien=toUnit(document.getElementById('fs').value, 'pt', toUnit(document.getElementById('fs').value,'em'));
                kolumna=toUnit(document.getElementById('elwidth').value, 'pc', toUnit(document.getElementById('fs').value,'em'));
                    }
                //kolumna=toUnit(document.getElementById('elwidth').value, 'pc');
                //interlinia=document.getElementById('interlinia');
                interlinia2=document.getElementById('olheight');
                
                dodatkowo=round(kolumna/stopien);
                //interlinia.value=dodatkowo.toString()+'pt';
                //if (unit!='pt')
                v=toUnit(parseFloat(dodatkowo)+parseFloat(stopien)+'pt', unit);
                interlinia2.value=v.toPrecision(3)+unit;
                
                    //else interlinia2.value=parseFloat(dodatkowo)+parseFloat(stopien)+'pt';
            }
            
             function getUnit(val) {
                if (val.substr(val.length-1,1)=='%') return '%';
                if (val.substr(val.length-2,2)=='em') return 'em';
                if (val.substr(val.length-2,2)=='pt') return 'pt';
                if (val.substr(val.length-2,2)=='px') return 'px';
                if (val.substr(val.length-2,2)=='pc') return 'pc';
                if (val.substr(val.length-2,2)=='cm') return 'cm';
                if (val.substr(val.length-2,2)=='in') return 'in';
                if (val.substr(val.length-2,2)=='mm') return 'mm';
                return '';
            }

function em2px(em) {return parseFloat(em)*16;}
            function em2percent(em) {return parseFloat(em)*100;}
            function em2pt(em) {return parseFloat(em)*12;}
            function em2pc(em) {return parseFloat(em)}
            function em2inch(em) {return parseFloat(em)/6}
            function em2mm(em) {return (parseFloat(em)/6)*25.4}
            function em2cm(em) {return (parseFloat(em)/6)*2.54}
            
            function px2em(px) {return parseFloat(px)/16;}
            function px2pc(px) {return parseFloat(px)/16;}
            function px2pt(px) {return (parseFloat(px)*12)/16;}
            function px2percent(px) {return (parseFloat(px)*100)/16;}
            function px2cm(px) {return em2cm(parseFloat(px)/16)}
            function px2mm(px) {return em2mm(parseFloat(px)/16)}
            function px2inch(px) {return em2inch(parseFloat(px)/16)}
            
            function pt2em(pt) {return parseFloat(pt)/12;}
            function pt2pc(pt) {return parseFloat(pt)/12;}
            function pt2px(pt) {return (parseFloat(pt)*16)/12;}
            function pt2percent(pt) {return (parseFloat(pt)*100)/12;}
            function pt2cm(pt) {return em2cm(parseFloat(pt)/12)}
            function pt2mm(pt) {return em2mm(parseFloat(pt)/12)}
            function pt2inch(pt) {return em2inch(parseFloat(pt)/12)}
            
            function percent2em(percent) {return parseFloat(percent)/100;}
            function percent2pc(percent) {return parseFloat(percent)/100;}
            function percent2px(percent) {return (parseFloat(percent)/100)*16;}
            function percent2pt(percent) {return (parseFloat(percent)/100)*12;}
            function percent2cm(pt) {return em2cm(parseFloat(percent)/100)}
            function percent2mm(pt) {return em2mm(parseFloat(percent)/100)}
            function percent2inch(pt) {return em2inch(parseFloat(percent)/100)}
            
            function pc2inch(pc) {return parseFloat(pc)/6}
            function pc2mm(pc) {return (parseFloat(pc)/6)*25.4}
            function pc2cm(pc) {return (parseFloat(pc)/6)*2.54}
            function pc2px(pc) {return parseFloat(pc)*16;}
            function pc2em(pc) {return parseFloat(pc);}
            function pc2percent(pc) {return parseFloat(pc)*100;}
            function pc2pt(em) {return parseFloat(em)*12;}
            
            function inch2pc(inch) {return parseFloat(inch)*6}
            function inch2cm(inch) {return parseInt(inch)*2.54}
            function inch2mm(inch) {return parseInt(inch)*25.4}
            function inch2percent(inch) {return (parseFloat(inch)*6)*100}
            function inch2em(inch) {return parseFloat(inch)*6}
            function inch2pt(inch) {return parseFloat(inch)*6*12}
            function inch2px(inch) {return parseFloat(inch)*6*16}
            
            //function pc2mm(pc) {1 PostScript pica = 4.23333333 millimeters}
            function cm2inch(cm) {return parseInt(cm)/2.54}
            function cm2mm(cm) {return parseInt(cm)*10}
            function cm2pc(cm) {return (parseInt(cm)/25.4)*6}
            function cm2pt(cm) {return (parseInt(cm)/25.4)*6*12}
            function cm2px(cm) {return (parseInt(cm)/25.4)*6*16}
            function cm2em(cm) {return (parseInt(cm)/25.4)*6}
            function cm2percent(cm) {return (parseInt(cm)/25.4)*6*100}
            
            function mm2inch(mm) {return parseInt(mm)/0.254}
            function mm2cm(mm) {return parseInt(mm)/10}
            function mm2pc(mm) {return (parseInt(mm)/2.54)*6}
            function mm2pt(mm) {return (parseInt(mm)/2.54)*6*12}
            function mm2px(mm) {return (parseInt(mm)/2.54)*6*16}
            function mm2em(mm) {return (parseInt(mm)/2.54)*6}
            function mm2percent(cm) {return (parseInt(cm)/2.54)*6*100}
            
            function toUnit(val, unit, base) {
                if (base==undefined) base=1;
                else  base=parseFloat(1/base);
                switch (unit) {
                    case '%':
                         if (val.substr(val.length-1, 1)=='%') return parseFloat(val.substr(0, val.length-1));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2percent(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2percent(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2percent(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2percent(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='cm') return px2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return px2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='in') return px2inch(val.substr(0, val.length-2));
                         
                    break;
                    
                    case 'px':
                         if (val.substr(val.length-2, 2)=='px') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2px(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2px(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2px(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2px(val.substr(0, val.length-1));
                         
                         if (val.substr(val.length-2, 2)=='in') return inch2px(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='cm') return cm2px(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return mm2px(val.substr(0, val.length-2));
                         
                    break;
                    
                    case 'pt':
                         if (val.substr(val.length-2, 2)=='pt') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2pt(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2pt(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2pt(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2pt(val.substr(0, val.length-1));
                         
                         if (val.substr(val.length-2, 2)=='cm') return cm2pt(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return mm2pt(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='in') return inch2pt(val.substr(0, val.length-2));
                         
                    break;
                    
                    case 'pc':
                    case 'em':
                         if (val.substr(val.length-2, 2)=='pc') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return parseFloat(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2pc(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2pc(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2pc(val.substr(0, val.length-1));
                         
                         if (val.substr(val.length-2, 2)=='cm') return cm2pc(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return mm2pc(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='in') return inch2pc(val.substr(0, val.length-2));
                         
                    break;
                    
                    case 'cm':
                         if (val.substr(val.length-2, 2)=='cm') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='in') return inch2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return mm2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2cm(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2cm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2cm(val.substr(0, val.length-1));
                         
                    break;
                    
                    case 'mm':
                         if (val.substr(val.length-2, 2)=='mm') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='in') return inch2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='cm') return mm2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2mm(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2mm(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2mm(val.substr(0, val.length-1));
                         
                    break;
                    
                    case 'in':
                         if (val.substr(val.length-2, 2)=='in') return parseFloat(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='cm') return inch2inch(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='mm') return mm2inch(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='em') return em2inch(val.substr(0, val.length-2))*base;
                         
                         if (val.substr(val.length-2, 2)=='pc') return pc2inch(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='pt') return pt2inch(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-2, 2)=='px') return px2inch(val.substr(0, val.length-2));
                         
                         if (val.substr(val.length-1, 1)=='%') return percent2inch(val.substr(0, val.length-1));
                         
                    break;
                    
                    
                    
                }
                    return parseFloat(val);
            }
            
            

function csizeUpdate() {
    sheet=document.getElementById('sheet');
    //csize=toUnit(document.getElementById('csize').value, 'em');
    csize=document.getElementById('csize').value;
    sheet.style.fontSize=csize;
}

// in array function
        Object.prototype.in_array = function(datum, strict) {
            if (strict) function equals(a,b) { return a === b }
            else function equals(a,b) { return a == b }

            for (var i in this) {
                if (equals(this[i], datum)) return true;
            }
            return false;
        }
        
        // define element properties to get
        var css_prop = new Array ('font-face', 'font-size', 'line-height', 'margin-top', 'margin-bottom', 'text-transform', 'font-width', 'letter-spacing', 'word-spacing', 'color');
        
        // editable elements array
        var editable=new Array("h1", "p1" , 'h2', 'p2', 'h3', 'p3', 'h4', 'p4', 'h5', 'p5', 'h6', 'p6', 'abbr', 'link');

        function toggleGrid(type, me){
            switch (type){
            case 'local':
                elv=document.getElementById('el').innerHTML;
                el=document.getElementById(elv);
                if (me.checked) {
                    //. size=parseInt(getValue('llh')[2]);
                    size=Math.round(toUnit(document.getElementById('llh').value, 'px'));
                    // el.style.background="url(grid.php?llh="+size.toString()+"&color=1) repeat";
                    el.style.backgroundImage="url(grid.php?llh="+size.toString()+"&color=1)";
                    el.style.backgroundRepeat="repeat";
                    el.style.borderLeft="1px solid #b43abc";
                    el.style.borderRight="1px solid #b43abc";
                } else {
                    //el.style.background="transparent";
                    el.style.borderLeft="none";
                    el.style.borderRight="none";
                    el.style.backgroundImage="";
                    el.style.backgroundRepeat="";
                }
            break;
            default:
                el=document.getElementById('page');
                if (me.checked) {
                    //. size=getValue('llh')[2];
                    size=Math.round(toUnit(document.getElementById('llh').value, 'px'));
                    el.style.background="url(grid.php?llh="+size.toString()+") repeat";
                } else {
                    el.style.background="transparent";
                }
            }            
        }
        
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
   targ = targ.parentNode
var tname
tid=targ.id

    if (editable.in_array(tid.toString())) {
        document.getElementById('el').innerHTML=tid;
        updateFields(tid);
    }
}

function updateFields(id){
    // read element style properties and update form fields
    if (document.getElementById){
        var s=document.getElementById(id).style;
        
        ffo=document.getElementById('ffamily')
        for (i=0;i<ffo.length;i++){
            if (ffo.options[i].value==s.fontFamily) ffo.selectedIndex=i; 
        }
        
        tt=document.getElementById('tt')
        for (i=0;i<tt.length;i++){
            if (tt.options[i].value==s.textTransform) tt.selectedIndex=i; 
        }
        
        fw=document.getElementById('fw')
        for (i=0;i<fw.length;i++){
            if (fw.options[i].value==s.fontWeight) fw.selectedIndex=i; 
        }
        
        found=false;
        ta=document.getElementById('ta')
        for (i=0;i<ta.length;i++){
            if (ta.options[i].value==s.textAlign) { 
                found=true;
                ta.selectedIndex=i;
            }
        }
        
        document.getElementById('fs').value=s.fontSize;
        document.getElementById('elwidth').value=s.width;
        document.getElementById('lh').value=s.lineHeight;
        document.getElementById('mt').value=s.marginTop;
        document.getElementById('mb').value=s.marginBottom;
        document.getElementById('ls').value=s.letterSpacing;
        document.getElementById('ws').value=s.wordSpacing;
        var c=s.color;
        
        if (c.substring(0,4)=='rgb(') {
                c=c.substring(4, c.length-1);
                c=c.split(',');
                c[0]=parseInt(c[0]);
                c[1]=parseInt(c[1]);
                c[2]=parseInt(c[2]);
                c='#'+rgb2hex(c);
        }
        
        document.getElementById('clr').value=c;
        // local grid checkbox
        if(s.backgroundImage=='none' || s.backgroundImage=='') document.getElementById('grid-local').checked=false;
        else document.getElementById('grid-local').checked=true;
        updateSuggested(true);
    }
    ilinia();
}

function toggleVis(id, me){
    el=document.getElementById(id);
    if (me.checked) el.style.display="";
    else el.style.display="none";
}

function updateStyle(checksmart){
    //read values from form fields and update element style
    if (document.getElementById){
        
         // suggested line height
        updateSuggested(true);
            
        id=document.getElementById('el').innerHTML
        var s=document.getElementById(id).style;
        s.fontFamily=document.getElementById('ffamily').value;
        s.fontSize=document.getElementById('fs').value;
        s.lineHeight=document.getElementById('lh').value;
        s.marginTop=document.getElementById('mt').value;
        s.marginBottom=document.getElementById('mb').value;
        s.letterSpacing=document.getElementById('ls').value;
        s.wordSpacing=document.getElementById('ws').value;
        s.color=document.getElementById('clr').value;
        s.textTransform=document.getElementById('tt').value;
        s.textAlign=document.getElementById('ta').value;
        s.fontWeight=document.getElementById('fw').value;
        s.width=document.getElementById('elwidth').value;
    }
    ilinia();
}


function updateSuggested(checksmart){
//llh=getValue('llh')[2];
llv=document.getElementById('lh').value
llh=toUnit(llv, 'em');
        //fs=getValue('fs')[2];
        fs=toUnit(document.getElementById('fs').value, 'em');
        if (fs<llh) prop=llh/fs;
            else prop=fs/llh;

unit=getUnit(llv);

//if (unit!='em') 
    v=toUnit(prop.toString()+'em',unit);
v=v.toPrecision(3)+unit;
            
if (document.getElementById('smart').checked && checksmart) { 
            document.getElementById('lh').value=v;
            document.getElementById('slh').value=v;
            }
        else document.getElementById('slh').value=v;
}

function getElementCSS(id){
    // generate css properties by element
    if (document.getElementById){
        var s=document.getElementById(id).style;
        code='#'+id.toString()+ " {";
        code+="\nwidth: "+s.width+";";
        code+="\nfont-family: "+s.fontFamily+";";
        code+="\nfont-size: "+s.fontSize+";";
        code+="\nline-height: "+s.lineHeight+";";
        code+="\nletter-spacing: "+s.letterSpacing+";";
        code+="\nword-spacing: "+s.wordSpacing+";";
        code+="\nline-height: "+s.lineHeight+";";
        code+="\ntext-transform: "+s.textTransform+";";
        code+="\ntext-align: "+s.textAlign+";";
        code+="\nfont-weight: "+s.fontWeight+";";
        code+="\ncolor: "+s.color+";";
        code+="\nmargin-top: "+s.marginTop+";";
        code+="\nmargin-bottom: "+s.marginTop+";";
        code+="\n}\n\n";
    }
    
    return code;
}

function generateCSS(){
    str='';
    for (i=0;i<editable.length;i++) {
        str+=getElementCSS(editable[i]);
    }
    
    document.getElementById('codebox').innerHTML=str;
}

function getValue(id){
// retuns array:
// [1] string before number
// [2] number
// [3] string after number
    var field=document.getElementById(id);
    ex = field.value;
         parts=new Array(3)
         // float regex test
         re=/([^\d^\-]*)(\-?\d*\.\d+)(\D*)/;
         s=re.exec(ex);
         if (s!=null) parts=s;
         else {
            // integer regex test
            re=/([^\d^\-]*)(\-?\d*)(\D*)/;
            s=re.exec(ex);
            parts=s;
         }
         parts[2]=parseFloat(parts[2]);
         return parts;
}

function update_field(id, v){

    var field=document.getElementById(id);

         values=getValue(id);
         value=values[2];
         
         //value=document.getElementById(id).value, '');
         
         if (!isNaN(value)) {
            value+=v;
            field.value=values[1]+value.toFixed(3)+values[3];// nie jest liczbą
         }
         
    
    if (id=='llh') {
        update_background();
        updateStyle(false);
    }
    else updateStyle(true);
    // generateCSS(); // CSS auto-update
}

function update_background()
{
    //var size=toUnit(document.getElementById('llh').value, 'px');
    var size=document.getElementById('llh').value;
    size=parseInt(size);
    if (size>500) {
        size=500;
        document.getElementById('llh').value=size;
        alert('Największa dopuszczalna wartość to 500 pikseli.');
    }
    s=document.getElementById('sheet');
    s.style.background="url(grid.php?llh="+size.toString()+") repeat";
}


function inspectStyle(elm){
  if (elm.style){
    var str = "";
    for (var i in elm.style){
	  str += i + ": " + elm.style[i] + " ";
	}
	alert(str);
  }
}



function setup(){
         
    var s = document.getElementById("h1").style;
            s.fontFamily="Georgia";
            s.fontSize='2.5em';
            s.lineHeight='1em';
            s.marginTop='0.5em';
            s.marginBottom='0.5em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="12em";
            
            s = document.getElementById("p1").style;
            // s.background="url(grid.php?llh=16&color=1) repeat";
            s.fontFamily="Georgia";
            s.fontSize='0.8125em';
            s.lineHeight='1.23em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="39em";
            
            
            s = document.getElementById("abbr").style;
            // s.background="url(grid.php?llh=16&color=1) repeat";
            s.fontFamily="Georgia";
            s.fontSize='1em';
            s.lineHeight='1.23em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            
            s = document.getElementById("link").style;
            // s.background="url(grid.php?llh=16&color=1) repeat";
            s.fontFamily="Georgia";
            s.fontSize='1em';
            s.lineHeight='1.23em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#00f";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textDecoration="underline";
            s.cursor="crosshair";
            
            s = document.getElementById("h2").style;
            s.fontFamily="Trebuchet MS";
            s.fontSize='2em';
            s.lineHeight='1em';
            s.marginTop='0.5em';
            s.marginBottom='0.5em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="14em";
            
            s = document.getElementById("p2").style;
            s.fontFamily="Times New Roman";
            s.fontSize='0.6875em';
            s.lineHeight='1.45em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="39em";
            
            s = document.getElementById("h3").style;
            s.fontFamily="Arial Black";
            s.fontSize='2em';
            s.lineHeight='1em';
            s.marginTop='0.5em';
            s.marginBottom='0.5em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="12em";
            
            s = document.getElementById("p3").style;
            s.fontFamily="Courier New";
            s.fontSize='0.625em';
            s.lineHeight='1.60em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="39em";
            
            s = document.getElementById("h4").style;
            s.fontFamily="Trebuchet MS";
            s.fontSize='1.5em';
            s.lineHeight='1.5em';
            s.marginTop='1.13em';
            s.marginBottom='0.03em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="15em";
            
            s = document.getElementById("p4").style;
            s.fontFamily="Times New Roman";
            s.fontSize='1em';
            s.lineHeight='1em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="30em";
            
            s = document.getElementById("h5").style;
            s.fontFamily="Trebuchet MS";
            s.fontSize='2em';
            s.lineHeight='1em';
            s.marginTop='0.5em';
            s.marginBottom='0.5em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="12em";
            
            s = document.getElementById("p5").style;
            s.fontFamily="Times New Roman";
            s.fontSize='1em';
            s.lineHeight='1em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="30em";
            
            s = document.getElementById("h6").style;
            s.fontFamily="Trebuchet MS";
            s.fontSize='2em';
            s.lineHeight='1em';
            s.marginTop='0.5em';
            s.marginBottom='0.5em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="bold";
            s.textTransform="none";
            s.textAlign="left";
            s.width="12em";
            
            s = document.getElementById("p6").style;
            s.fontFamily="Times New Roman";
            s.fontSize='1em';
            s.lineHeight='1em';
            s.marginTop='0em';
            s.marginBottom='0em';
            s.letterSpacing="0em";
            s.wordSpacing="0em";
            s.color="#000";
            s.fontWeight="normal";
            s.textTransform="none";
            s.textAlign="left";
            s.width="30em";
    generateCSS();
}

function editor(){
    controls = document.getElementById('menu');
    sheet = document.getElementById('sheet');
    //sheet = document.getElementById('sheet');

    if (controls.style.display=='none') {
        controls.style.display='';
        sheet.style.height='100%';
        sheet.style.overflow='auto';
      //  sheet.style.border='1px solid #ccc;';
    } else {
        controls.style.display='none';
        sheet.style.height='auto';
        sheet.style.overflow='hidden';
        //sheet.style.border=''
    }
    
}

