// ************************************************************************************************************************************************************************
// © 2006 Public Domain (20061018,20060101)
// ************************************************************************************************************************************************************************

var Log = function (logElementId, logType, logPlace) { 
 this.completionStatus = 0;
 
 this.logType = logType;
 if(!this.logType) {this.logType = this.SYMPLE_TEXT_LOG_TYPE;}; 
 
 this.logPlace = logPlace;
 if(!this.logPlace) {this.logPlace = this.INTRO_ELEMENT_LOG_PLACE;}; 
 
 if(!logElementId) {return -1;}
 this.logElementId = logElementId;
 this.createLogElement(); 
}
Log.prototype = new Root();

Log.prototype.SYMPLE_TEXT_LOG_TYPE = (Log.SYMPLE_TEXT_LOG_TYPE = 100);

Log.prototype.BOTTOM_DOCUMENT_LOG_PLACE = (Log.BOTTOM_DOCUMENT_LOG_PLACE  = 3);
Log.prototype.HIDDEN_LOG_PLACE = (Log.HIDDEN_LOG_PLACE = 0);
Log.prototype.INTRO_ELEMENT_LOG_PLACE = (Log.INTRO_ELEMENT_LOG_PLACE = 1);
Log.prototype.TOP_DOCUMENT_LOG_PLACE = (Log.TOP_DOCUMENT_LOG_PLACE = 2);

Log.prototype.className = "Log"; 
Log.prototype.created = "20060101"; 
Log.prototype.logElemen;
 Log.prototype.getLogElemen = function () {return this.logElemen;};
 Log.prototype.setLogElemen = function (logElemen) {this.logElemen = logElemen; return 1;};
Log.prototype.logElemenId;
 Log.prototype.getLogElemenId = function () {return this.logElemenId;};
 Log.prototype.setLogElemenId = function (logElemenId) {this.logElemenId = logElemenId; return 1;};
Log.prototype.version = "20061024"; 

Log.prototype.println = function(text) {	
 if(!text) {return -1;};
 if(!this.logElement) {return -1;};
 if(!this.logElement.appendChild) {return -1;}; 
 var textNode = document.createTextNode(text);
 var divElement = document.createElement("div");
 divElement.appendChild(textNode);
 this.logElement.appendChild(divElement); 
 return 1;
}

Log.prototype.createLogElement = function() {
 if (this.logPlace == this.TOP_DOCUMENT_LOG_PLACE) {
  this.completionStatus =  this.createLogElementTop();
 } else if (this.logPlace == this.BOTTOM_DOCUMENT_LOG_PLACE) {
  this.completionStatus = this.createLogElementBottom();
 } else if (this.logPlace == this.INTRO_ELEMENT_LOG_PLACE) {
  this.completionStatus = this.createLogElementIntro();
 } else {
  return -1;
 };  
 this.logElement = document.getElementById(logElementId); 
 return 1; 
}

Log.prototype.createLogElementBottom = function() {
 var divElement = document.createElement("div");
 divElement.id = this.logElementID;
 divElement.style.textAlign = "left"
 var bodyElement = document.body;
 if(!bodyElement) {return -1;};
 bodyElement.appendChild(divElement);
 return 1;
}

Log.prototype.createLogElementIntro = function() {
 return 1;
}

Log.prototype.createLogElementTop = function() {
 var divElement = document.createElement("div");
 divElement.id = this.logElementID;
 var bodyElement = document.body;
 if(!bodyElement) {return -1;};
 var bodyFirstChild = bodyElement.firstChild;
 if(!bodyFirstChild) {
  bodyElement.appendChild(divElement);
 } else {
  bodyElement.insertBefore (divElement, bodyFirstChild);
 };
 return 1;
}
