/*
*
* Ferret PLUS Base JavaScripts
*
*/
var g_proxyurl = "/ticket";
var g_page_mgr = null;


/***************************************/
/*** Ferret PLUS java object manager ***/
/***************************************/
g_page_mgr = new ftppm();

/*** LAPPER ftppm::findObj ***/
function findObj(fid) {
 return g_page_mgr.findObj(fid);
}
/*** LAPPER ftppm::addObject ***/
function addObject(did, ftype) {
 g_page_mgr.addObject(did, ftype);
}
/*** LAPPER ftppm::addObjectByObj ***/
function addObjectByObj(nfo) {
 g_page_mgr.addObjectByObj(nfo);
}
/*** LAPPER ftppm::getAllObj ***/
function getAllObj() {
 return g_page_mgr.getAllObj();
}
/*** AJAX LAPPER ***/
function axRequest(reqid, act, params) {
 var ps = "?fid=" + reqid;
 ps += "&act=" + act;
 if (params != null) {
  var i = 0;
  for (i = 0; i < params.length; i++) {
   ps += "&" + params[i];
  }
 }
 var dm = new Date();
 ps += "&actm=" + dm.getTime();
 var ax = new Ajax.Request(
                  g_proxyurl,
                  {
                   method: "post",
                   parameters: ps,
                   onComplete: axResult
                  });
}
/*** AJAX Result Parser ***/
function axResult(or) {
 var oj = eval('(' + or.responseText + ')');
 if(oj.status<1){
  new Lightbox.base("popup");
  var dob = $('popup');
  if (dob != null) {
   dob.innerHTML = oj.msg;
  }
 }
 /*
 var dump = findObj("bi-fkw-resultlist");
 dump.html = "<div class='mainobj-detail'>" + or.responseText + "</div>";
 dump.update();
 */
}

/*** CLASS ****/
function ftppm() {
 /*** ftpso list by managed this pm ***/
 this.objs = null;
 this.ftppm = function () {
 }
 
 /*** addObject(): add ftpso object(by text) ***/
 this.addObject = function (did, ftype) {
  if (this.objs == null) {
   this.objs = new Array();
  }
  if (this.objs != null) {
   var nfo = null;
   if (ftype == "member-reg-flow") {
    nfo = new ftnbso(did, ftype);
   }
   else if (ftype == "member-reg-form") {
    nfo = new ftnbso(did, ftype);
   }
   else {
    nfo = new ftpso(did, ftype);
   }
   if (nfo != null) {
    this.objs.push(nfo);
    nfo.update();
   }
  }
 }
 
 /*** addObjectByObj(): add ftpso object (by Object) ***/
 this.addObjectByObj = function (nfo) {
  if (this.objs == null) {
   this.objs = new Array();
  }
  if (this.objs != null) {
   this.objs.push(nfo);
  }
 }
 
 /*** find objct in managed list ***/
 this.findObj = function (fid) {
  if (this.objs != null) {
   var num = this.objs.length;
   for (var i = 0; i < num; i++) {
    var otmp = this.objs[i];
    if (otmp.myid == fid) {
     return this.objs[i];
    }
   }
  }
  /*
  var o = document.getElementById(fid);
  if (o != null) {
   return o;
  }
  */
  return null;
 }
 
 /*** getAllObj(): get all object list ***/
 this.getAllObj = function () {
  if (this.objs != null) {
   var str = "";
   var num = this.objs.length;
   for (var i = 0; i < num; i++) {
    var otmp = this.objs[i];
    str += otmp.myid + ":" + otmp.mytp + ";";
   }
   return str;
  }
  return "";
 }
}

/*****************************************/
/*** Ferret PLUS standard object class ***/
/*****************************************/
function ftpso (did, ftype) {
 /*** MY div-id name ***/
 this.myid = did;
 /*** INSTANCE ***/
 this.instance = document.getElementById(did);
 /*** TYPE ***/
 this.mytp = ftype;
 /*** DISPLAY HTML ***/
 this.html_load = "<div class='ftpso-loading'>";
 // this.html_load += "<div class='ftpso-title'><div style='padding-left:8px; padding-top:4px; color:#ddf'>Now Loading ... </div></div>";
 this.html_load += "<div class='ftpso-detail'>";
 /*
 this.html_load += "<img style='padding-left:2px;' src='imgs/axload.gif' width='6px' height='6px' />";
 this.html_load += "<img style='padding-left:2px;' src='imgs/axload.gif' width='12px' height='12px' />";
 */
 this.html_load += "<img style='padding-left:4px; padding-top:4px;' src='imgs/ajax-loader2.gif' />";
 this.html_load += "</div></div>";
 this.html = this.html_load;
 /*
 this.html_load = "<div class='ftpso-loading'>";
 this.html_load += "";
 this.html_load += "</div>";
 this.html = this.html_load;
 */
 
 /*** init():initialize ***/
 this.init = function (did, ftype) {
  this.myid = did;
  this.mytp = ftype;
  this.update();
 }
 
 /*** update():update document ***/
 this.update = function () {
  var po = document.getElementById(this.myid);
  if (po != null) {
   po.innerHTML = this.html;
  }
 }
 
 /*** setload() */
 this.setload = function () {
  var po = document.getElementById(this.myid);
  if (po != null) {
   po.innerHTML = this.html_load;
  }
 }
 
}

/*****************************************/
/*** Ferret PLUS no-bar object class ***/
/*****************************************/
function ftnbso (did, ftype) {
 /*** MY div-id name ***/
 this.myid = did;
 /*** INSTANCE ***/
 this.instance = document.getElementById(did);
 /*** TYPE ***/
 this.mytp = ftype;
 /*** DISPLAY HTML ***/
 this.html_load = "<div class='ftnbso-loading'>";
 this.html_load += "<div class='ftnbso-detail'>";
 this.html_load += "<img style='padding-left:4px; padding-top:4px;' src='imgs/axload.gif' />";
 this.html_load += "</div></div>";
 this.html = this.html_load;
 
 
 /*** init():initialize ***/
 this.init = function (did, ftype) {
  this.myid = did;
  this.mytp = ftype;
  this.update();
 }
 
 /*** update():update document ***/
 this.update = function () {
  var po = document.getElementById(this.myid);
  if (po != null) {
   po.innerHTML = this.html;
  }
 }
 
}

/*****************************************/
/*** Ferret PLUS site Catalist ***/
/*****************************************/
function siteCatalyst (id) {
  var s=s_gi('basicferret');
  s.linkTrackVars='events,prop8';
  s.linkTrackEvents='event1';
  s.prop8=id;
  s.events='event1';
  s.tl(this,'o',id);
}

