function addTextnode()
{
var div=document.getElementById("divCreate");
deleteprior(div)
var textnode=document.createTextNode("This is the new node");
div.appendChild(textnode);
}

function changeStyle()
{
var div=document.getElementById("divChange");
div.style.fontFamily="lucida console"
div.style.fontStyle="italic"
div.style.fontSize="25px"
div.style.color="#f00"
div.style.padding="0.5em"
}

function changeTextnode(tekstas,divas,vir)
{
var div=document.getElementById(divas);
//var newText=document.getElementById("newtext").value;
var newText=tekstas;
var newNode=document.createTextNode(newText);
div.replaceChild(newNode,div.childNodes[0]);

if(vir>0){
  div.style.color="#f00"
 }

}

function createHyperlink()
{
var div=document.getElementById("divHyper")
deleteprior(div)
var title=document.getElementById("linktitle").value
var text=document.getElementById("linktext").value
var href=document.getElementById("linkhref").value
var textNode=document.createTextNode(text)
var link=document.createElement("a")
link.setAttribute("title",title)
link.setAttribute("href",href)
link.className="dark"
link.appendChild(textNode)
div.appendChild(link)
}


function createTable()
{
var div=document.getElementById("divTable");
deleteprior(div)
var rows=document.getElementById("rows").value
var columns=document.getElementById("columns").value
var tbl=document.createElement("table");
tbl.setAttribute("id","dynamic")
tbl.style.borderWidth="1px"
tbl.style.borderStyle="solid"
tbl.style.borderColor="#ccc"
var tb=document.createElement("tbody");
for (var i=0;i<rows;i++)
    {
    tr=document.createElement("tr");

    for (var j=0;j<columns;j++)
        {
        var td=document.createElement("td");
        var contents="cell"
        var contentsNode=document.createTextNode(contents)
        td.appendChild(contentsNode)
        td.style.borderWidth="1px"
        td.style.borderStyle="solid"
        td.style.borderColor="#ccc"
        td.style.backgroundColor="#fff"
        td.style.padding="3px"
        tr.appendChild(td)
        }
    tb.appendChild(tr)
    }
tbl.appendChild(tb)
div.appendChild(tbl)
}

function deleteprior(div)
{
if(div.childNodes[0])
    {
    div.removeChild(div.childNodes[0])
    }
}




