function writediv(text)
{

//document.getElementById('addbox').innerHTML = text;
replaceHtml(el, text)
}

function CheckKeyword(keyword)
{
var el = document.getElementById("addbox");
if(keyword != '')
{
if(keyword.length<1)
replaceHtml(el,'<div style="background:#fff;height:auto;padding:10px"><span style="color:#cc0000"><b>'+keyword+' :</b> This keyword is too short !</span></div>');
else if(keyword.length>60)
replaceHtml(el,'<div style="background:#fff;height:auto;padding:10px"><span style="color:#cc0000"><b>'+keyword+' :</b> This Keyword is too long !</span></div>');
else if(keystatus = getKeyStatus('http://trends.lessaid.net/checkkeyword.php?v='+escape(keyword)))
{
if(keystatus == 1)
replaceHtml(el,'<div style="background:#fff;height:auto;padding:10px"><span style="color:#cc0000"><b>'+keyword+' :</b> This Keyword is already in the database !</span></div>');
else if(keystatus == 2)
replaceHtml(el,'<div style="background:#fff;height:auto;padding:10px"> <input type="image" src="/images/add.gif" alt="add Keyword" style="vertical-align:middle;padding-left:1px;" /> <span style="color:#1A7917"><b> '+keyword+' :</b> This Keyword is free !</span></div>');
//writediv('<span style="color:#1A7917"><b>'+keyword+' :</b> This Keyword is free !</span>');
else
replaceHtml(el,keystatus);
}
}

}

function getKeyStatus(fichier)
{
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);
if(xhr_object.readyState == 4) return(xhr_object.responseText);
else return(false);
}
function replaceHtml(el, html) {
//code from 
//http://blog.stevenlevithan.com/archives/faster-than-innerhtml
//http://www.bigdumbdev.com/2007/09/replacehtml-remove-insert-put-back-is.html
 var oldEl = el;
 /*@cc_on // Pure innerHTML is slightly faster in IE
 oldEl.innerHTML = html;
 return oldEl;
 @*/
 var newEl = oldEl.cloneNode(false);
 newEl.innerHTML = html;
 oldEl.parentNode.replaceChild(newEl, oldEl);
 /* Since we just removed the old element from the DOM, return a reference
 to the new element, which can be used to restore variable references. */
 return newEl;
}; 
