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;}; 
 
 this.logElementID = logElementID;
 if(!logElementID) {
  this.completionStatus = -1;
 };
 
 this.logElement;
 this.createLogElement(); 
}

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

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.BOTTOM_DOCUMENT_LOG_PLACE = (Log.BOTTOM_DOCUMENT_LOG_PLACE  = 3);

//-------------------------------------------------------------------------------
Log.prototype.completionStatus = 0;
Log.prototype.getCompletionStatus = function () {return this.completionStatus;};
Log.prototype.setCompletionStatus = function (completionStatus) {this.completionStatus = completionStatus;};

Log.prototype.println = function(text) {	
 if(!this.logElementID) {this.completionStatus = -100; return this.completionStatus;};
 if(!this.logElement) {
  this.createLogElement();
  if(!this.logElement) {
   return this.completionStatus;
  }
 };
 if(!this.logElement.appendChild) {this.completionStatus = -300; return this.completionStatus;};

 if(text == "") {text = " "};
 
 var textNode = document.createTextNode(text);
 var divElement = document.createElement("div");
 divElement.appendChild(textNode);
 this.logElement.appendChild(divElement);
 
 this.completionStatus = 1;
 return this.completionStatus;
}

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 {
         ;
        }; 
 
 this.logElement = document.getElementById(this.logElementID);
 if(this.logElement) {this.completionStatus = 1;}
 else {
 };
 
 return this.completionStatus; 
}

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

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