/*  Tag Creator CLASS
 *  (c) 2008 Moises Beltran
 *  Interesting little class, It will create tag/html for you to use.
 *  See parse_opts
/*--------------------------------------------------------------------------*/

var TagCreator = Base.extend({
  //OH! Prototype. Exclude all methods added by Array.Proto
  PrototypeObjectExtensions: function(){
    poe = ''
    for (var i in Array.prototype) poe += i+'|';
    this.poe = new RegExp('('+poe+'null|_)')
  },
  parse_opts: function(orig_opts){
    if(this.poe == false) this.PrototypeObjectExtensions();
    opts = '';
    for (var i in orig_opts) {
      if(i.match(this.poe) == null && orig_opts[i] != null) opts += i+'="'+orig_opts[i]+'"';
    }
    return opts;
  },
  tag: function(tag,tag_options,content){
    return '<'+tag+' '+tag_options+'>'+content+'</'+tag+'>';
  },
  li: function(content,li_opts){
    return '<li '+this.parse_opts(li_opts)+'>'+content+'</li>';
  },
  a: function(content,a_opts){
    return '<a '+this.parse_opts(a_opts)+'>'+content+'</a>';
  },
  /* Generated an image tag can take any number of options*/
  image: function(img_opts) {
    img_opts['border'] = 0;
    if(img_opts['size']) {
      size = img_opts['size'].split("x");
      img_opts['width'] = size[0];
      img_opts['height'] = size[1];
      img_opts['size'] = null;
    }
    return '<img '+this.parse_opts(img_opts)+'>';
  },
  li_a: function(content,a_opts,li_opts) {
    return this.li(this.a(content,a_opts),li_opts);
  },
  li_a_image: function(image_opts,a_opts,li_opts) {
    return this.li_a(this.image(image_opts),a_opts,li_opts);
  },
  poe: false
});
