/*
   Cyberz_ERIKO

   Source License & Copyright:
     Cyberz Inc. 2006
       http://www.cyberz.co.jp/
       manager@cyberz.co.jp

*/
var ERIKO_Root_URL = "http://eriko.cyberz.co.jp/";
var ERIKO_Image_URL = "http://srv.cyberz.co.jp/eriko.cyberz.co.jp/";
function rssPreLoader (xFileurl,target_div,bar_id,cnt_id,predata_id,Direct) {
  if(Direct!=false) Direct = true;
  document.getElementById(target_div).innerHTML
    = '<img src="'+ERIKO_Image_URL+'load.gif" height="15px" width="150px" style="border-width:1px;border-style: solid;"/>';
  var xml = new JKL.ParseXML(xFileurl);
  var func = function(predata_id) {
    onLoadedXML(predata_id,target_div,bar_id,Direct);
  }
  xml.async(func);
  xml.parse();
}
function onLoadedXML(xml,tdiv_id,bar_var,Direct) {
  var i,j,tdiv,ttable,tbody,tr,td,div,val,img,aelem;
  var tdline;
  var csize, many;
  var ermsg;
  var filter;
  var pat;
  tdiv = document.getElementById(tdiv_id);
  if((xml.root != undefined)&&(xml.root.links != undefined)&&(xml.root.links.row != undefined)) {
    tdiv.innerHTML = '<table border="0px" cellpadding="0px" cellspacing="0px" ></table>';
    ttable = tdiv.getElementsByTagName("table")[0];
    if (xml.root.msg != undefined) {
      tcaption = document.createElement("caption");
      if(document.all&&!(window.opera)) {
        tcaption.style.cssText = "font-size:12px;text-align: center;";
      } else {
        tcaption.setAttribute("style","font-size:12px;text-align: center;");
      }
      tcaption.innerHTML = xml.root.msg;
      ttable.appendChild(tcaption);
    }
    tbody = document.createElement('tbody');
    csize = xml.root.property.csize;
    many = xml.root.property.many;
    for(i=0;i<xml.root.links.row.length;i++) {
      oneRow = xml.root.links.row[i];
      //tr = tbody.insertRow(tbody.rows.length);
      tr = document.createElement('tr');   // Saf
      for(j=0;j<oneRow.item.length;j++) {
        oneItem = oneRow.item[j];
        //td = tr.insertCell(tr.cells.length);
        td = document.createElement('td');  // Saf
        div = document.createElement("div");
        if(oneItem.color != undefined ) {
          if(document.all&&!(window.opera)) {
            div.style.cssText = "background-color:"+oneItem.color+";";
          } else {
            div.setAttribute("style","background-color:"+oneItem.color+";");
          }
        }
        if(oneItem.bgimg != undefined) {
          val = oneItem.bgimg;
        } else {
          val = ERIKO_Image_URL+"img_bord.gif";
        }
        filter = "";
        aelem = document.createElement("a");
        if(Direct==true) aelem.setAttribute("target","_blank"); else aelem.setAttribute("target","_self");
        if(oneItem.href != undefined ) {
          if(Direct==true) 
            aelem.setAttribute("href",oneItem.href);
          else
            aelem.setAttribute("href",ERIKO_Root_URL+'?idenc='+oneItem.hrefenc);
          pat = /\.jpg$|\.jpeg$|\.gif$|\.png$/gi;
          if(oneItem.href.match(pat)) {
            val = oneItem.href;
            filter = ' style="filter: alpha(style=0, opacity=40);" ';
          }
          if(oneItem.title != undefined ) {
            aelem.setAttribute("title",oneItem.title);
          } else {
            aelem.setAttribute("title",oneItem.href);
          }
          aelem.innerHTML = '<img src="'+val+'" width="'+csize+'px" height="'+csize+'px" border="0px" '+filter+'/>';
          div.appendChild(aelem);
        } else {
          if(oneItem.bgimg != undefined) {
            if(xml.root.current.url == undefined) {
              xml.root.current.url = '';
            }
            if(xml.root.current.url.match(/^http:/g)) {
              aelem.setAttribute("href",xml.root.current.url);
            }
            if(xml.root.current.title != undefined){
              aelem.setAttribute("title",xml.root.current.title);
            } else {
              aelem.setAttribute("title",xml.root.current.url);
            }
            aelem.innerHTML = '<img src="'+val+'" width="'+csize+'px" height="'+csize+'px" border="0px" />';
            div.appendChild(aelem);
          } else {
            div.innerHTML = '<img src="'+val+'" width="'+csize+'px" height="'+csize+'px" border="0px" />';
          }
        }
        td.appendChild(div);
        tr.appendChild(td);  // Saf
      }
      tbody.appendChild(tr); // Saf
    }
    ttable.appendChild(tbody);
    if(xml.root.adv != undefined) {
      div = document.createElement("div");
      if(document.all&&!(window.opera)) {
        div.style.cssText = "width:"+(csize*many)+"px;height: 30px;"
              +"font-size:10px;text-align: center;background-color:#ccccff;";
      } else {
        div.setAttribute("style","width:"+(csize*many)+"px;height: 30px;"
              +"font-size:10px;text-align: center;background-color:#ccccff;");
      }
      div.innerHTML = xml.root.adv;
      tdiv.appendChild(div);
    }
    div = document.createElement("div");
    if(document.all&&!(window.opera)) {
      div.style.cssText = "width:"+(csize*many)+"px;font-size:10px;text-align: right;";
    } else {
      div.setAttribute("style","width:"+(csize*many)+"px;font-size:10px;text-align: right;");
    }
    div.innerHTML = xml.root.cyberz;
    tdiv.appendChild(div);
    clearInterval(bar_var);
  } else {
    clearInterval(bar_var);
    tdiv.innerHTML = '<table border="0px" cellpadding="0px" cellspacing="0px" ></table>';
    ttable = tdiv.getElementsByTagName("table")[0];
    tbody = document.createElement('tbody');
    if(xml.root == undefined) {
      tcaption = document.createElement("caption");
      if(document.all&&!(window.opera)) {
        tcaption.style.cssText = "width: 150px;font-size:12px;text-align: center; background-color:#ffcccc";
      } else {
        tcaption.setAttribute("style","width: 150px;font-size:12px;text-align: center; background-color:#ffcccc");
      }
      ermsg = "%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AE%E5%8F%96%E5%BE%97%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82"
      tcaption.innerHTML = decodeURIComponent(ermsg);
      ttable.appendChild(tcaption);
    } else if (xml.root.msg != undefined) {
      tcaption = document.createElement("caption");
      if(document.all&&!(window.opera)) {
        if (xml.root.current != undefined) {
          tcaption.style.cssText = "width: 150px; font-size:11px;text-align: center;background-color:#ffffcc";
        } else {
          tcaption.style.cssText = "width: 150px; font-size:11px;text-align: center;background-color:#ffcccc";
        }
      } else {
        if (xml.root.current != undefined) {
          tcaption.setAttribute("style","width: 150px;font-size:11px;text-align: center;background-color:#ffffcc");
        } else {
          tcaption.setAttribute("style","width: 150px;font-size:11px;text-align: center;background-color:#ffcccc");
        }
      }
      tcaption.innerHTML = xml.root.msg;
      ttable.appendChild(tcaption);
    }
    if(xml.root == undefined) {
      
    } else if(xml.root.adv != undefined) {
      div = document.createElement("div");
      if(document.all&&!(window.opera)) {
        div.style.cssText = "width:150px;height: 30px;"
            +"font-size:10px;text-align: center;background-color:#ccccff;";
      } else {
        div.setAttribute("style","width:150px;height: 30px;"
            +"font-size:10px;text-align: center;background-color:#ccccff;");
      }
      div.innerHTML = xml.root.adv;
      tdiv.appendChild(div);
    }
    div = document.createElement("div");
    if(document.all&&!(window.opera)) {
      div.style.cssText = "width:150px;font-size:10px;text-align: right;";
    } else {
      div.setAttribute("style","width:150px;font-size:10px;text-align: right;");
    }
    div.innerHTML = "Powered by Cyberz Inc";
    tdiv.appendChild(div);
  }
    
  return xml;
}
function progressbar(table_id,bar_var,cnt) {
  if(cnt>100) {
    clearInterval(bar_var);
    document.getElementById(table_id).innerHTML = 'Data fetch False';
  }
  cnt ++;
}
