if (typeof USEFUL == "undefined") {
    alert("(BLINKER) USEFUL include missing");
}

//tobbszoros include:
if (typeof BLINKER != "undefined") {
    alert("BLINKER  multiple insert!");
}
BLINKER=true;


/** egy villogtato cuccos
  */
function Blinker() {
}

/** inicializalo fuggveny
  * @param config parameterek objektuma
  */
Blinker.prototype.init=function(config) {
  this.node=null;

  this.setDefaults();
  this.readConfig(config);

  if (null == this.node) {
    throw new Error("blinker: node undefined");
  }

  /*
  this.colors={
     top: getStyle(node,'top-border-color'),
     bottom: getStyle(node,'bottom-border-color'),
     left: getStyle(node,'left-border-color'),
     right: getStyle(node,'right-border-color')   
  };
  */

  this.mode=0;
//  this.border=getStyle(this.node,"border-top");

  var blinker=this;
  this.timerId=window.setInterval(function() {
      blinker.blink();
      },this.time);
}

/** ez a fuggveny beallitja a default ertekeket, amiket at lehet definialni
  */
Blinker.prototype.setDefaults=function() {
  this.count=15;
  this.className="blinker_error";
  this.time=200;
}

/** E fuggveny vegigmegy a config objektumon es ervenyes ertekek eseten atirja a megfelelo parametert
  * @param config parameterek objektuma
  */
Blinker.prototype.readConfig=function(config) {
  if (typeof config.node == "object" && null != config.node) {
    this.node=config.node;
  }
  if (typeof config.count == 'number' && 0 < config.count) {
    this.count=config.count;
  }
  if (typeof config.className == "string" && "" != config.className) {
    this.className=config.className;
  }
  if (typeof config.time == 'number' && 0 < config.time) {
    this.time=config.time;
  }

}

/** Ez vegzi a villogtatast
  */
Blinker.prototype.blink=function() {
  if (0 == this.mode) {
    //be kell kapcsolni
//    this.node.style.borderColor=this.color;
//    this.node.style.borderWidth="2px";
//    this.node.style.border=this.color+" solid "+this.width+"px";
    addClass(this.node,this.className);

    this.mode=1;
  } else {
    //ki kell kapcsolni
//    this.node.style.borderColor="";
//    alert(this.border);
//    this.node.style.border=this.border;
    removeClass(this.node,this.className);

    --this.count;

    if (0 == this.count) {
      //vege a mokanak
      window.clearInterval(this.timerId);
    }

    this.mode=0;
  }
}

