function incrementCurrent() {
    current = parseInt(document.forms["noteForm"].total.value);
    document.forms["noteForm"].total.value = current + 1;
}

function getCurrentNumber() {
    formElement = document.getElementById("noteForm");
    return formElement.childNodes.item(1).value;
}

function makeNewNote() {
    mainDivElement = document.getElementById("mainDiv");
    newNote = document.createElement("TEXTAREA");
    newNote.setAttribute("id", "note" + getCurrentNumber());
    newNote.style.width = "150px";
    newNote.style.height = "100px";
    newNote.style.border = "1px solid blue";
    newNote.style.backgroundColor = "yellow";
    newNote.style.color = "black";
    newNote.style.position = "absolute";
    newNote.style.bottom = "39px";
    var lefter = (125 + 160 * getCurrentNumber());
    newNote.style.left = (lefter + "px");
    editLink = getEditLink("note" + getCurrentNumber());
    newNote.appendChild(editLink);
    newNote.appendChild(document.createElement("br"));
    noteText = document.createTextNode("Notat: ");
    newNote.appendChild(noteText);
    mainDivElement.appendChild(newNote);
    incrementCurrent();
}

function getEditLink(thisId) {
    editLink = document.createElement("a");
    linkText = document.createTextNode("Kast");

	editLink.setAttribute("id","small_info");
    editLink.setAttribute("href", "javascript:editNote('" + thisId + "')");
    editLink.appendChild(linkText);
    return editLink;
}

function editNote(editLink) {
    theDiv = document.getElementById(editLink);
    newText = prompt("Change your note:");
    oldNode = theDiv.firstChild.nextSibling.nextSibling;
    newNode = document.createTextNode(newText);
    theDiv.replaceChild(newNode, oldNode);
}

function deleteNote(editLink){
        theDiv = document.getElementById(editLink);
        oldNode = theDiv.firstChild.nextSibling.nextSibling;
        theDiv.removeChild(oldNode);
}


var xmlHttp = null;

function showHint(str)
 {
    if (str.length == 0)
    {
        document.getElementById("txtHint").innerHTML = "";
        return;
    }
    try
    {
        // Firefox, Opera 8.0+, Safari, IE7
        xmlHttp = new XMLHttpRequest();
		
		
    }
    catch(e)
    {
        // Old IE
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
            alert("Your browser does not support XMLHTTP!");
            return;
        }
    }
    var url = "gethint.php?q=" + str;
    xmlHttp.open("GET", url, false);
    xmlHttp.send(null);
    document.getElementById("txtHint").innerHTML = xmlHttp.responseText;
}

function insert_date(str, id)
 {
    if (str.length == 0)
    {
        document.getElementById("answer").innerHTML = "";
        return;
    }
    try
    {
        // Firefox, Opera 8.0+, Safari, IE7
        xmlHttp = new XMLHttpRequest();
		
		
    }
    catch(e)
    {
        // Old IE
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
            alert("Your browser does not support XMLHTTP!");
            return;
        }
    }
    var url = "insert_follow_up.php?time=" + str + "&ID="+id;
    xmlHttp.open("GET", url, false);
    xmlHttp.send(null);
	 document.getElementById("answer").innerHTML = xmlHttp.responseText;
	
	go();



}


