// JavaScript Document
function appendText(node,txt)
      {
        node.appendChild(document.createTextNode(txt));
      }

function appendElement(node,tag,id,htm){
		  //alert("control ");
        var ne = document.createElement(tag);
        //alert(ne);
        if(id) ne.id = id;
        
        if(htm) ne.innerHTML = htm;
        if((node) || node != ""){  
            node.appendChild(ne);
        }
        else{
            var theBody = document.getElementsByTagName('body')[0];
            theBody.appendChild(ne); 
        }
		 return true;
}
function disableForm(theform) {
        if (document.all || document.getElementById) {
            for (i = 0; i < document.getElementById(theform).length; i++) {
            var formElement = document.getElementById(theform).elements[i];
                if (true) {
                    formElement.disabled = true;
                }
            }
        }
    }
function enableForm(theform) {
        if (document.all || document.getElementById) {
            for (i = 0; i < document.getElementById(theform).length; i++) {
            var formElement = document.getElementById(theform).elements[i];
                if (true) {
                    formElement.disabled = false;
                }
            }
        }
    }
function displayLoadingMessage(divID,msg){
    $(divID).innerHTML = msg;
    ///set make it appear
    $(divID).style.display = 'block';
    /// change the class name
    $(divID).addClassName('loading');

}
function hideLoadingMessage(divID){
    $(divID).setStyle({display: 'none'});

}
function toggleTextBoxValue(fieldID,defaultValue){
    //alert('called');
    if($(fieldID).value == defaultValue){
        $(fieldID).value = "";
        return true;
    }
    if($(fieldID).value == ""){
        $(fieldID).value = defaultValue
        return true;
    }
    
}
function randomPassword(length)
{
  chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  pass = "";
  for(x=0;x<length;x++)
  {
    i = Math.floor(Math.random() * 62);
    pass += chars.charAt(i);
  }
  return pass;
}
function showHelp(id,msg){
    //alert(id);
    new Tip(id,msg, {
                title: "Itestify Help",
                hideAfter: 5,
                showOn: 'click',
                hideOn: 'click',
                
                stem: 'topMiddle',
                hook: { target: 'topRight', tip: 'bottomLeft' },
                offset: { x: -6, y: 0 }
            });


}