var backgroundColor_ime_off = "#99ccff";
var backgroundColor_ime_on = "pink";
var foregroundColor_ime_off = "black";
var foregroundColor_ime_on = "black";

//SUILEN_setSWFFile();

//window.alert(SUILEN_getIMEStatus());
init();




function init(){
  var inputObj = document.getElementsByTagName("input");
  for(var n=0; n < inputObj.length ; n++){
    if((inputObj[n].type = "text") || (inputObj[n].type = "textarea")){
      if(!document.all){
        inputObj[n].addEventListener('focus',suilen_Core,true);
        inputObj[n].addEventListener('keypress',suilen_Core,true);
        inputObj[n].addEventListener('blur',returnBGColor,true);
      }else{
        inputObj[n].onfocus = function () {
          this.style.backgroundColor = SUILEN_getBackGroundColor();
          this.style.color = SUILEN_getColor();
        }
        inputObj[n].onkeydown = function () {
          this.style.backgroundColor = SUILEN_getBackGroundColor();
          this.style.color = SUILEN_getColor();
        }
        inputObj[n].onkeyup = function () {
          this.style.backgroundColor = SUILEN_getBackGroundColor();
          this.style.color = SUILEN_getColor();
        }
        inputObj[n].onblur = function(){
          this.style.backgroundColor = "#fff";
        }
      }
    }
  }
}

function suilen_Core(){
  if(SUILEN_getIMEStatus()){
    this.style.backgroundColor = backgroundColor_ime_on;
    this.style.color = foregroundColor_ime_on;
  }else{
    this.style.backgroundColor = backgroundColor_ime_off;
    this.style.color = foregroundColor_ime_off;
  }
}

function returnBGColor(){
  this.style.backgroundColor = null;
  this.style.color = null;
}

function SUILEN_getBackGroundColor(){
  if(SUILEN_getIMEStatus()){
    return backgroundColor_ime_on;
  }else{
    return backgroundColor_ime_off;
  }
}

function SUILEN_getColor(){
  if(SUILEN_getIMEStatus()){
    return foregroundColor_ime_on;
  }else{
    return foregroundColor_ime_off;
  }
}

function SUILEN_getIMEStatus(){
  return document.getElementById("suilen").getIMEStatus();
}


function SUILEN_setSWFFile(){
  var objectElement = document.createElement("object");
  objectElement.data = "getIMEStatus.swf";
  objectElement.id = "suilen";
  objectElement.width = "1";
  objectElement.height = "1";
  objectElement.type = "application/x-shockwave-flash";
  var bodyElement = document.getElementsByTagName("body");
  bodyElement[0].appendChild(objectElement);
}

