//<!--  style="background: #ffffd3;" -->
infotags = {

  init : function() {
    for (key in _INFO_TAGS) {
      if (key == '_') continue;
      infotags.init_node( key );
    }
  },

  init_node : function( key, forceOpen ) {
    try {
      var widget_out = infotag_widgets_init[ key ]( key, _INFO_TAGS[ key ] );
    } catch ( e ) {
      // console.log( e );
      var widget_out = infotag_widgets_init[ 'unknown' ]( key, _INFO_TAGS[ key ] );
    }
    if (!widget_out) return; //disable widget
    if (forceOpen) { widget_out['collapsed'] = false; }
    infotags.build_html('infotags' + ( _INFO_TAGS['_']['pri'][ key ] > -1 ? _INFO_TAGS['_']['pri'][ key ] : 9), widget_out, 1, ( _INFO_TAGS['_']['prv'][ key ] > -1 ? _INFO_TAGS['_']['prv'][ key ] : 1) );
    if (widget_out['post_exec']) { widget_out['post_exec'](); }
  },

  add : function ( key ) {
    var add_container = $('it_' + key + '_ac');
    try {
      infotag_widgets_add[ key ]( key, add_container );
    } catch ( e ) {
      //console.log( e );
      infotag_widgets_add[ 'default' ]( key, add_container );
    }
  },

  save : function ( key ) {
    var add_container = $('it_' + key + '_ac');
    try {
      infotag_widgets_save[ key ]( key, add_container );
    } catch ( e ) {
      // console.log( e );
      infotag_widgets_save[ 'default' ]( key, add_container );
    }
  },

  save_edit : function ( cl, di ) {
    var add_container = $('it_' + cl + '_' + di + '_content');
    try {
      infotag_widgets_save_edit[ cl ]( cl, di, add_container );
    } catch ( e ) {
      // console.log( e );
      infotag_widgets_save_edit[ 'default' ]( cl, di, add_container );
    }
  },


  edit : function ( cl, di ) {
    var add_container = $('it_' + cl + '_' + di + '_content');
    try {
      infotag_widgets_edit[ cl ]( cl, di, add_container );
    } catch ( e ) {
      // console.log( e );
      infotag_widgets_edit[ 'default' ]( cl, di, add_container );
    }
  },

  remove : function( cl, di, force_remove ) {
    // console.log( tag );
    if ( force_remove || confirm(gettext("Are you sure that you would like to delete the InfoTag") + "'" + cl + ':' + di + "'?") ) {
      var nav = $('it_' + cl + '_' + di + '_nav');
      var content = $('it_' + cl + '_' + di + '_content');
      try {
        infotag_widgets_remove[ cl ]( cl, di, nav, content );
      } catch ( e ) {
        // console.log( e );
        infotag_widgets_remove[ 'default' ]( cl, di, nav, content );
      }
    }

  },

  remove_node : function ( cl ) {
    $('it_' + cl + '_hdr').remove();
    $('it_' + cl + '_content').remove();
    delete _INFO_TAGS[ cl ];
  },

  refresh_node : function( key, forceOpen, refreshNew ) {
    //console.log([key, forceOpen, refreshNew]);
    if (forceOpen === undefined) { forceOpen = true; }
    if (refreshNew === undefined) { refreshNew = 0; }
    var success = function(t) {
      var it_data = json_parse( t.responseText )['tags']['tag'];
      _INFO_TAGS[ key ] = {};
      var update_keys = [key];
      for (var j=0;j<it_data.length; j++) {
        if (refreshNew && !(it_data[j].rc in _INFO_TAGS)) {
          update_keys.push( it_data[j].rc );
          _INFO_TAGS[ it_data[j].rc ] = {};
        }
        _INFO_TAGS[ it_data[j].rc ][ it_data[j].rdi ] = {owner: it_data[j].author, id: it_data[j].id, alvl: it_data[j].alvl, vlvl: it_data[j].vlvl, classtype: it_data[j].rc, distinction: it_data[j].rdi, data: it_data[j].rda};
      }
      for (var i=0;i<update_keys.length;i++) {
        infotags.init_node( update_keys[i], forceOpen );
      }
    };

    var call_options = {photo_id: _INFO_TAGS['_']['cnx']['pid']};
    if (!refreshNew) call_options['ctype'] = key;

    ZAPI.callMethodJSON( 'zooomr.photos.getinfotags', call_options, {'onSuccess':success} );
  },

  build_html : function(element, data, mode, prv) {
    if (mode === undefined) mode = 0;
    if (data['content'] == '') data['collapsed'] = true;
    if (data['add_allow'] === undefined) data['add_allow'] = true;

    var it_hdr = $('it_' + data['id'] + '_hdr');

    if (it_hdr) {
      it_hdr.remove(); delete it_hdr;
      $('it_' + data['id'] + '_content').remove();
    }

    var out  = '<table class="itghdr" id="it_' + data['id'] + '_hdr"><tr><td width="100%" class="hinge" colspan="2"><span style="float:right;"><a href="javascript:void(0);" onclick="this.blur();infotags.toggle_display(\'' + data['id'] + '\');" class="iconlink" ' + (data['content'] == '' ? 'style="display: none;"' : '') + '><img id="it_toggle_' + data['id'] + '" src="http://assets2.zooomr.com/images/silk/bullet_toggle_' + (data['collapsed'] ? 'plus' : 'minus') + '.png" alt="" /></a>' + ( prv && data['add_allow'] ? ' <a href="javascript:void(0);" id="it_' + data['id'] + '_addbutt" onclick="infotags.add(\'' + data['id'] + '\');" class="iconlink"><img src="http://assets2.zooomr.com/images/silk/add.png" alt="" /></a>' : '' ) + '<!-- <img src="http://assets2.zooomr.com/images/silk/magnifier.png" alt="" /><img src="http://assets2.zooomr.com/images/silk/pencil.png" alt="" /> <img src="http://assets2.zooomr.com/images/silk/cross.png" alt="" /> --></span>';
        out += '<h4><a href="javascript:void(0);" onclick="this.blur();' + (data['content'] == '' ? (prv && data['add_allow'] ? 'infotags.add(\'' + data['id'] + '\');' : '') : 'infotags.toggle_display(\'' + data['id'] + '\');') + '" class="smalllink_ltgrey"><img src="' + (data['icon'].indexOf( '/' ) > -1 ? data['icon'] : 'http://assets2.zooomr.com/images/silk/' + data['icon'] + '.png') + '" alt="" /> ' + data['title'] + '</a></h4></td><td width="2" class="itshadow" valign="top"><img width="2" height="3" align="top" src="http://assets2.zooomr.com/images/infotags/itag-panel-shadow-tr-wh.png"/></td></tr>';

        out += '<tr class="itshadow"><td height="2" class="its_b"><img width="2" height="2" src="http://assets2.zooomr.com/images/infotags/itag-panel-shadow-bl-wh.png"/></td><td height="2" align="right" class="its_b"/><td height="2" class="its_br"/></tr></table>';
        out += '<table class="itgcontent" id="it_' + data['id'] + '_content" ' + (data['collapsed'] ? 'style="display:none;"' : '') + '><tbody><tr><td><div id="it_' + data['id'] + '_ac" class="itgadd" style="display: none;"></div>' + data['content'] + '</td></tr></tbody></table>';
    if (mode == 0) {
      $(element).innerHTML = out;

    } else if (mode == 1) {
      $(element).innerHTML = $(element).innerHTML + out;
    } else {
      return out;
    }
    delete out;
  },

  build_sub : function( data, content, options ) {

    var props = {
      title : data.distinction,
      linkalt : gettext("Find more shots like this one from everyone!"),
      canEdit : false,
      canRemove : false,
      canSearch : true,
      extras : false
    };
    var search_str = data.classtype + ':' + data.distinction +  '=' + data.data;
    if ((data.classtype+'').indexOf(' ') > 0 ||
        (data.distinction+'').indexOf(' ') > 0 ||
        (data.data+'').indexOf(' ') > 0) {
      search_str = '%22' + search_str + '%22';
    }
    props['linkurl']= '/search/photos/?q='+search_str;

    for (var p in props) {
        props[p] = (!options || typeof options[p] == 'undefined') ? props[p] : options[p];
    }
    var out = '<div class="it_snav" id="it_' + data.classtype + '_' + data.distinction + '_nav"><span style="float:right;">' + (props['canSearch'] ? '<a href="/search/photos/?w=' + _INFO_TAGS['_']['cnx'][ 'onsid' ] + '&amp;q=%22' + data.classtype + ':' + data.distinction +  '=' + data.data  + '%22" title="' + gettext("Find more shots like this one from %(owner_displayname)s").replace('%(owner_displayname)s', _ZGLOBAL[_INFO_TAGS['_']['cnx'][ 'pid' ]]['owner']['name'] ) + '" class="iconlink"><img src="http://assets2.zooomr.com/images/silk/user.png" alt="" /></a>' : '') + ( props['canEdit'] ? ' <a href="javascript:void(0);" onclick="infotags.edit(\'' + data.classtype + '\',\'' + data.distinction + '\');" class="iconlink"><img src="http://assets2.zooomr.com/images/silk/pencil.png" alt="" /></a>' : '') + (props['extras'] ? props['extras'] : '') + (props['canRemove'] ? ' <a href="javascript:void(0);" onclick="infotags.remove(\'' + data.classtype + '\',\'' + data.distinction + '\');" class="iconlink"><img src="http://assets2.zooomr.com/images/silk/cross.png" alt="" /></a>' : '') + '</span><a href="' + props['linkurl'] + '" title="' + props['linkalt'] + '">' + props.title + '</a></div>';
        out = out + '<div class="it_scontent" id="it_' + data.classtype + '_' + data.distinction + '_content">' + content + '</div>';
    return out;
  },

  toggle_display : function( id ) {
    if ( $( 'it_' + id + '_content' ).style.display == 'none' ) {
      infotags.open_content( id );
    } else {
      infotags.close_content( id );
    }
  },

  open_content : function( id ) {
    $( 'it_' + id + '_content' ).style.display = '';
    $( 'it_toggle_' + id ).src = "http://assets2.zooomr.com/images/silk/bullet_toggle_minus.png";
  },

  close_content : function( id ) {
    $( 'it_' + id + '_content' ).style.display = 'none';
    $( 'it_toggle_' + id ).src = "http://assets2.zooomr.com/images/silk/bullet_toggle_plus.png";
  },

  add_prep : function( id ) {
    $('it_' + id + '_ac').style.display = '';
    try { $('it_' + id + '_addbutt').hide() } catch (e) { }
    infotags.open_content( id );
  },

  edit_prep : function( cl, di ) {
    $('it_' + cl + '_' + di + '_content').addClassName( 'itgadd' );
    try { $('it_' + cl + '_addbutt').hide() } catch (e) { }
  },

  saving_prep : function( id ) {
    $('it_' + id + '_ac').update('<img src="http://assets2.zooomr.com/images/tidbits/progress.gif"/> <em>' + gettext("Saving...") + "</em>");
  },

  editing_prep : function( cl, di ) {
    $('it_' + cl + '_' + di + '_content').update('<img src="http://assets2.zooomr.com/images/tidbits/progress.gif"/> <em>' + gettext("Saving...") + "</em>");
  }


};

function tool_buildTechnoratiExtra( tag, name ) {
  return ' <a href="http://technorati.com/tags/' + encodeURIComponent( tag ) + '" title="View everything tagged &quot;' + name + '&quot; on Technorati" class="iconlink" rel="tag"><img src="http://assets2.zooomr.com/images/tidbits/technorati-bubble12.png" /></a>';
}

infotag_widgets_add = {

  "default" : function( key, add_container ) {
    infotags.add_prep( key );
    add_container.update('This InfoTag either does not have a default Add Pane or is experiencing problems.');
  },

  "geo" : function( key, add_container ) {
    infotags.add_prep( key );

    /* FUTURE var nscript = document.createElement('script');
    nscript.setAttribute('src', 'http://www.placeengine.com/javascripts/pengine.js');
    nscript.setAttribute('type', 'text/javascript');
    document.childNodes[1].childNodes[1].appendChild(nscript);

    window.pe = 0; */

    add_container.update( '<strong>' + gettext("Welcome:") + '</strong> ' + gettext("Geotagging allows you to place your photograph onto our World Map. Geotagging also allows you and others to find other neat photos nearby! <em>How cool is that?</em>") + '<br /><br /><strong style="font-size:14px;"><a href="/world/?pids=' + _INFO_TAGS['_']['cnx'][ 'pid' ] + '"><img src="http://assets2.zooomr.com/images/silk/world_add.png" width="12" height="12" alt="" /> ' + gettext("Would you like to start geotagging now?") + '</a></strong>'); /* FUTURE + '<script type="text/javascript">pe = new PEngine({onGetLocation: function(x, y, r, info) {console.log( info );if ($("pestatus")!=null) { $("pestatus").innerHTML = info.addr; }}, idstatus:"pestatus", appkey:"qUa6RRMUCPaxCR87Ps6B0pcBq-MVuc8dVvSKUmMQ6TVuN95Zs9c9ZJJP7sfXRpI07WZjN4R0oSlPhjxyBc9EBSWi9Djn5S2YV7YAsK4y0axX7Ff4LVHkzaWpkK3poe5.8nKiQNqF7S-iT4CoO54HOxETlI6MAVOlmjbaZY3P3bHyYtaeir6BsaDWC6551g1AowCccbBZuiV16juahDVMVF86yPQxqbttYy5C0Fb0NonFVKdxDjzaNjNc1cZF0LQ0qWAPRePOsJTt-5aJW6qjKBrNV42Sfv1MOwS0.0Q18FQBFveKfgWh3aZB3pKLkgw77rBEK3La94Rs4LChYFKTAg__,aHR0cDovL3d3dy56b29vbXIuY29tLw__,Wm9vb21y"});</script><div class="peui"><input alt="" src="http://www.placeengine.com/images/wide_bt2.png" type="image" onclick=\'pe.registerLocation()\' /><input alt="" src="http://www.placeengine.com/images/wide_bt1.png" type="image" onclick=\'pe.getLocation()\' /><div id="pestatus"></div></div>'); */
  },

  "people" : function( key, add_container ) {
    znotes.AddNote(_INFO_TAGS['_']['cnx'][ 'pid' ], note_container, 1);
    infotags.add_prep( key );
    add_container.update( '<strong>' + gettext("Tip:") + '</strong> ' + gettext("Select the person using the note outline, type the name of the Zooomr User or enter the person's email address and name. When you're all finished, click save.") );
  },

  "labels" : function( key, add_container ) {
    infotags.add_prep( key );
    add_container.update('<form onsubmit="infotags.save(\'labels\')" action="javascript:void(0);"><input id="it_labels_ac_input" type="text" style="font-size: 12px;" value="" size="30" /> <input class="sm_button" type="submit" value="' + gettext("ADD") + '"/></form><br /><strong>' + gettext("Tip:") + '</strong> ' + gettext("Separate each label with a space: <em>tokyo train station</em>. Join two words together in one label using double quotes: <em>&quot;daily commute&quot;</em>.") );
    $('it_labels_ac_input').focus();
  },

  "marketplace" : function( key, add_container ) {
    infotags.add_prep( key );
    add_container.update('<form onsubmit="infotags.save(\'marketplace\')" action="javascript:void(0);" style="margin-bottom: 5px;"><input id="it_marketplace_ac_input" type="hidden" value=""/><h2><span id="debug3" style="color:#00396E;">$0.0 USD</span> <input id="it_marketplace_ac_button" class="reg_button" style="display: none;vertical-align:bottom;" type="submit" value="' + gettext("Put it on the Market!") + '" /></h2></form><div id="pricetrack" style="width:275px;background-color:#ccc;height:7px;margin-bottom: 10px;"><div id="pricetrackhandle" style="width:7px;height:12px;background-color:#00396E;cursor:move;"> </div></div><em>' + gettext("Please use the above slider to select a price.") + '</em><br /><br /><p><strong style="color: #f00;">' + gettext("Notice:") + '</strong> ' + gettext("Only license photos that you hold the copyright to; If you license photos that are not yours, you become liable to account deletion under the <a href='%(tos_url)s'>Zooomr Terms of Service</a>!").replace('%(tos_url)s', '/about/tos/') + '</p><br /><p><em>' + gettext("For more information, please see our <a href='%(help_url)s'>Help FAQ</a>.").replace('%(help_url)s', '/help/') + '</em></p>'  );

    var price_values = []

    for (var s=0;s<=200; s++) {
      price_values[price_values.length] = s * 5;
    }

    new Control.Slider('pricetrackhandle','pricetrack',{axis:'horizontal', sliderValue: 0,
        onSlide:function(v){$('debug3').innerHTML = '$' + v + '.00 USD';},
        onChange:function(v){$('debug3').innerHTML = '$' + v + '.00 USD'; $('it_marketplace_ac_input').value = v; $('it_marketplace_ac_button').show(); },
        minimum: 0,
        maximum: 1000,
        range: $R(0,1000),
        values: price_values });


  },

  "color" : function( key, add_container ) {
    return infotag_widgets_add['marketplace']( key, add_container );
  }

};

infotag_widgets_save_edit = {
  "default" : function( cl, di, add_container ) {
    add_container.update('If you are seeing this message, something went wrong. :(')
  }
}

infotag_widgets_edit = {

  "default" : function( cl, di, add_container ) {
        infotags.add_prep( cl );
    add_container.update('So You wanna edit, huh?')
  },

  "marketplace" : function( cl, di, add_container ) {
    infotags.edit_prep( cl, di );
    add_container.update('<form onsubmit="infotags.save(\'marketplace\')" action="javascript:void(0);" style="margin-bottom: 5px;"><input id="it_marketplace_ac_input" type="hidden" value=""/><h2><span id="debug3" style="color:#00396E;">$' + _INFO_TAGS[ cl ][ di ]['data'] + ' USD</span> <input id="it_marketplace_ac_button" class="reg_button" style="display: none;vertical-align:bottom;" type="submit" value="' + gettext("Change Price") + '" /></h2></form><div id="pricetrack" style="width:275px;background-color:#ccc;height:7px;margin-bottom: 10px;"><div id="pricetrackhandle" style="width:7px;height:12px;background-color:#00396E;cursor:move;"> </div></div><em>' + gettext("Please use the above slider to select a price.") + '</em>');

    var price_values = []

    for (var s=0;s<=200; s++) {
      price_values[price_values.length] = s * 5;
    }

    new Control.Slider('pricetrackhandle','pricetrack',{axis:'horizontal', sliderValue: parseInt( _INFO_TAGS[ cl ][ di ]['data'] ),
        onSlide:function(v){$('debug3').innerHTML = '$' + v + '.0 USD';},
        onChange:function(v){$('debug3').innerHTML = '$' + v + '.0 USD'; $('it_marketplace_ac_input').value = v; $('it_marketplace_ac_button').show(); },
        minimum: 0,
        maximum: 1000,
        range: $R(0,1000),
        values: price_values });


  },

  "color" : function( cl, di, add_container ) {
    return infotag_widgets_edit['marketplace']( cl, di, add_container );
  }



};

infotag_widgets_save = {

  "default" : function( key, add_container ) {
    infotags.add_prep( key );
    add_container.update('This InfoTag either does not have a default Add Pane or is experiencing problems.')
  },

  "labels" : function( key, add_container ) {
    var tag_data = $F('it_labels_ac_input');
    infotags.saving_prep( key );
    var success = function(t) {
      try {
        infotags.refresh_node(key, 1, 1);
      } catch (e) {
        //console.log( e );
      }
    };
    ZAPI.callMethodJSON( 'zooomr.photos.addtags', {photo_id: _INFO_TAGS['_']['cnx'][ 'pid' ], tags: tag_data}, {'onSuccess':success});
  },

  "marketplace" : function( key, add_container ) {
    var price = $F('it_marketplace_ac_input');
    infotags.saving_prep( key );
    var success = function(t) {
      // console.log( t.responseText );
      infotags.refresh_node( key );
    };
    ZAPI.callMethodJSON( 'zooomr.marketplace.setprice', {photo_id: _INFO_TAGS['_']['cnx'][ 'pid' ], price: price}, {'onSuccess':success});
  },

  "color" : function( key, add_container ) {
    return infotag_widgets_save['marketplace']( key, add_container );
  }


};

infotag_widgets_init = {

  "unknown" : function ( key, data ) {
    var content = '';
    var canRemove = true;
    if (_ZGLOBAL[ _INFO_TAGS['_']['cnx'][ 'pid' ] ]['owner']['nsid'] != global_nsid) {
      canRemove = false;
    }

    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', {canRemove: canRemove} );
    }

    return {"id" : key, "icon": "help", "title" : key, "content" : content, "collapsed" : true, "add_allow":false };
  },
  "photowalk" : function ( key, data ) {
    var content = '';
    var canRemove = true;
    if (_ZGLOBAL[ _INFO_TAGS['_']['cnx'][ 'pid' ] ]['owner']['nsid'] != global_nsid) {
      canRemove = false;
    }
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', {canRemove: canRemove} );
    }
    return {"id" : key, "icon": "group", "title" : key, 'content' : content, 'collapsed' : false };
  },
  "geo" : function ( key, data ) {
    var content = '';
    if (data['loc']) {
      content = infotags.build_sub( data[ 'loc' ], '', { title: gettext("Geo Location: %(latitude_longitude)s").replace('%(latitude_longitude)s', data[ 'loc' ].data.replace(' ', ', ')), linkalt: gettext("Find more photos taken nearby!"), extras : ' <a href="/world/?ll=' + data[ 'loc' ].data.replace(' ', ',') + '&amp;z=' +  (data['zoom'] ? parseInt( data['zoom'].data ) : 15 ) + '" title="' + gettext("View this photo on the World Map") + '" class="iconlink"><img src="http://assets2.zooomr.com/images/silk/world_nearby.png" /></a>' } );

      var lat_lon = data[ 'loc' ].data.split(' ');
      var post_exec = function() {
        var photo_map = new ZMap($('it_geo_loc_content'),ZM_MICRODIV_TYPE,[parseFloat( lat_lon[0] ), parseFloat( lat_lon[1] ), (data['zoom'] ? parseInt( data['zoom'].data ) : 15 ) - 2],{"height":225,"width":284,"cripple":true,"limitList":[931670]});
            photo_map.init();
        infotags.close_content( key );
      }

      addLoadEvent( post_exec ); //add to onload, maybe this will help IE??

    } else {
      var post_exec = 0;
    }

    return {"id" : key, "icon": "world", "title" : gettext("Geo"), 'content' : content, collapsed: false, 'add_allow': !('loc' in data) }; // 'post_exec': post_exec
  },

  "event" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '' );
    }

    return {"id" : key, "icon": "date", "title" : gettext("Event"), 'content' : content };
  },

  "marketplace" : function ( key, data ) {
    var content = '';
    var order = ['price', 'primarycolor', 'secondarycolor'];
    for (var j=0;j<order.length;j++) {
      var dk = order[j];
      if (!data[ dk ]) { continue; }
      if (dk == 'price') {
        content = content + infotags.build_sub( data[ dk ], '<h2>$' + data[ dk ].data + ' USD</h2>', { title: gettext("Price"), linkalt: gettext("Find more photos listed at $%(list_price_usd)s USD.").replace('%(list_price_usd)s', data[ dk ].data), canEdit : true, canRemove : true } );
      } else {
        if (String(data[ dk ].data).charAt(0) == '#') { data[ dk ].data = data[ dk ].data.substring(1,7) }
        data[ dk ].classtype = 'color';
        data[ dk ].distinction = 'hex';
        content = content + infotags.build_sub( data[ dk ], '<h2 style="background-color:#' + data[ dk ].data + ';color:#' + (parseInt(data[ dk ].data, 16) >= 13421772 ? '333' : 'fff') + ';padding:0 4px;">#' + data[ dk ].data + '</h2>', { title: ( dk == 'primarycolor' ? gettext("Primary Color") : gettext("Secondary Color") ), canEdit : false, canRemove : false } );
      }
    }
    return {"id" : key, "icon": "money", "title" : gettext("Marketplace"), 'content' : content, 'collapsed' : true, 'add_allow': !('price' in data) };
  },

  "color" : function ( key, data ) {
    var output = infotag_widgets_init['marketplace']( key, data );
    output['icon'] = 'color_wheel';
    output['title'] = gettext("Color Space");
    return output;
  },

  "labels" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', { title : data[ dk ].data, linkalt: gettext("Find more shots labeled '%(label_name)s' from everyone!").replace('%(label_name)s', data[ dk ].data), linkurl: '/search/photos/?q=' + data[ dk ].data, canRemove : true, extras : ' <a href="http://en.wikipedia.com/wiki/' + encodeURIComponent( data[ dk ].data ) + '" title="" class="iconlink"><img src="http://assets2.zooomr.com/images/tidbits/wikipedia.gif" /></a>' + tool_buildTechnoratiExtra('"'+data[ dk ].data+'"', data[ dk ].data) } );
    }
    return {"id" : key, "icon": "tag_green", "title" : gettext("Labels"), 'content' : content };
  },

  "people" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      var isUser = String(data[ dk ].distinction).indexOf('@') > -1;
      var title_html = '<img src="' + ( isUser ? _icon_root + data[ dk ].distinction + '.jpg' : 'http://assets2.zooomr.com/images/avatarmaker/default.png' ) + '" style="vertical-align:bottom;" width="20" alt="" border="0" height="20" /> ' + (data[ dk ].extra ? data[ dk ].extra.dn : data[ dk ].data);
      if (isUser) {
        content = content + infotags.build_sub( data[ dk ], '', { title : title_html, linkalt: gettext("Find more photos of %(person_name)s!").replace('%(person_name)s', data[ dk ].data), linkurl : '/people/' + (data[ dk ].extra ? data[ dk ].data : data[ dk ].distinction) + '/', extras : tool_buildTechnoratiExtra(data[ dk ].data, data[ dk ].data) } );
      } else {
        content = content + infotags.build_sub( data[ dk ], '', { title : title_html, linkalt: gettext("Find more photos of %(person_name)s!").replace('%(person_name)s', data[ dk ].data), extras : tool_buildTechnoratiExtra(data[ dk ].data, data[ dk ].data) } );
      }
    }
    return {"id" : key, "icon": "user", "title" : gettext("People"), 'content' : content };
  },

  "groups" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', { title : data[ dk ].data, linkalt: gettext("Find more shots labeled '%(label_name)s' from everyone!").replace('%(label_name)s', data[ dk ].data), linkurl: '/search/photos/?q=' + data[ dk ].data, canRemove : true, extras : ' <a href="http://en.wikipedia.com/wiki/' + encodeURIComponent( data[ dk ].data ) + '" title="" class="iconlink"><img src="http://assets2.zooomr.com/images/tidbits/wikipedia.gif" /></a>' + tool_buildTechnoratiExtra('"'+data[ dk ].data+'"', data[ dk ].data) } );
    }
    return {"id" : key, "icon": "group", "title" : gettext("Groups"), 'content' : content };
  },

  "camera" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', { title : data[ dk ].distinction + ' = ' + data[ dk ].data } );
    }
    return {"id" : key, "icon": "camera", "title" : gettext("Camera Information"), 'content' : content, 'collapsed' : true };
  },

  "exif" : function ( key, data ) { //ALIAS FOR CAMERA
    return infotag_widgets_init['camera'](key, data);
  },

  "awards" : function ( key, data ) {
    var content = '';
    for (dk in data) {
      content = content + infotags.build_sub( data[ dk ], '', { title : 'Fave' + data[ dk ].data } );
    }
    return {"id" : key, "icon": "award_star_gold_3", "title" : gettext("Awards") + " (" + Object.keys(data).length + ")", 'content' : content, 'collapsed' : true, 'add_allow': false };
  },

  "upcoming" : function ( key, data ) {
    var content = '';

    if (data[ 'event' ]) {
      content = infotags.build_sub( data[ 'event' ], '<ul><li class="Go"><a href="http://upcoming.yahoo.com/event/' + data[ 'event' ].data + '/">' + gettext("View the Upcoming event page") + '</a></li>', { title : gettext("Event #%(event_id)s").replace('%(event_id)s', data[ 'event' ].data), canRemove : true } );
    }

    return {"id" : key, "icon": "http://assets2.zooomr.com/images/tidbits/icon_upcoming_over.gif", "title" : "Upcoming", 'content' : content, 'add_allow': false };
  },

  "vimeo" : function ( key, data ) {
    var content = '';

    if (data[ 'clip' ]) {
      content = infotags.build_sub( data[ 'clip' ], '<object type="application/x-shockwave-flash" width="280" height="200" data="http://vimeo.com/moogaloop.swf?clip_id=' + data[ 'clip' ].data + '&amp;server=vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF"> <param name="quality" value="best" />   <param name="allowfullscreen" value="true" />   <param name="scale" value="showAll" />  <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' + data[ 'clip' ].data + '&amp;server=vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF" /></object><ul><li class="Go"><a href="http://www.vimeo.com/clip:' + data[ 'clip' ].data + '">' + gettext("View the Vimeo Video page") + '</a></li>', { title : gettext("Vimeo Video #%(vid_id)s").replace('%(vid_id)s', data[ 'clip' ].data), canRemove : true } );
    }

    return {"id" : key, "icon": "http://www.vimeo.com/favicon.ico", "title" : "Vimeo", 'content' : content, 'add_allow': false };
  },

  "youtube" : function ( key, data ) {
    var content = '';

    if (data[ 'clip' ]) {
      content = infotags.build_sub( data[ 'clip' ], '<object width="280" height="210"><param name="movie" value="http://www.youtube.com/v/' + data[ 'clip' ].data + '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' + data[ 'clip' ].data + '" type="application/x-shockwave-flash" wmode="transparent" width="280" height="210"></embed></object><ul><li class="Go"><a href="http://www.youtube.com/watch?v=' + data[ 'clip' ].data + '">' + gettext("View the YouTube Video page") + '</a></li>', { title : gettext("YouTube Video #%(vid_id)s").replace('%(vid_id)s', data[ 'clip' ].data), canRemove : true } );
    }

    return {"id" : key, "icon": "http://www.youtube.com/favicon.ico", "title" : "YouTube", 'content' : content, 'add_allow': false };
  }



};


infotag_widgets_remove = {

  "default" : function( cl, di, nav, content ) {
    var success = function(t) {
      // console.log( t.responseText );
      nav.remove();
      content.remove();
      delete _INFO_TAGS[ cl ][ di ];

      var reinit_node = 0;
      if (cl in _INFO_TAGS['_']['pri']) {
        reinit_node = 1;
      } else {
        for (k in _INFO_TAGS[ cl ]) {
          reinit_node = 1;break;
        }
      }

      if (reinit_node) {
        infotags.init_node( cl, true ); //Re-Init!
      } else {
        infotags.remove_node( cl );
      }
    };
    ZAPI.callMethodJSON( 'zooomr.photos.removetag', {tag_id: _INFO_TAGS[ cl ][ di ]['id']}, {'onSuccess':success});
  },

  "marketplace" : function( cl, di, nav, content ) {
    var success = function(t) {
      // console.log( t.responseText );
      nav.remove();
      content.remove();
      delete _INFO_TAGS[ cl ][ di ];
      infotags.init_node( cl ); //Re-Init!
    };
    ZAPI.callMethodJSON( 'zooomr.marketplace.removeprice', {photo_id: _INFO_TAGS['_']['cnx']['pid']}, {'onSuccess':success});
  }


};



// RECENT ADDITIONS! ZOOOMR 2008

infotag_widgets_init["privacy"] = function (key, data) {
    var content = '';
    var icon = '';
    var title = '';
    var title_sub = '';
    var is_owner = (_ZGLOBAL[ _INFO_TAGS['_']['cnx'][ 'pid' ] ]['owner']['nsid'] == global_nsid || (typeof _ZGLOBAL['is_superuser'] != 'undefined' && _ZGLOBAL['is_superuser']));
    for (dk in data) {
      title = gettext("Privacy")
      switch (data[ dk ].data) {
        case 1:
          title_sub = ' (' + gettext("Public") + ')';
          break;
        case 2:
          title_sub = ' (' + gettext("Private") + ')';
          break;
        case 6:
          title_sub = ' (' + gettext("Friends Only") + ')';
          break;
        case 10:
          title_sub = ' (' + gettext("Family Only") + ')';
          break;
        case 14:
          title_sub = ' (' + gettext("Friends and Family Only") + ')';
          break;
      }
      title = title + title_sub;

      icon = data[ dk ].data == 1 ? 'lock_open' : data[ dk ].data == 2 ? 'lock' : 'shield' ; // Set Icon name from the InfoTag Data

      if (is_owner) {
        content = infotags.build_sub(data[dk], '',
                                     { title : '<img src="http://assets2.zooomr.com/images/silk/' + icon + '.png" style="vertical-align:bottom;" border="0" /> ' + gettext("Photo Viewing") + title_sub, //Title of the Node
                                       canRemove: false, //Can we remove this Node?
                                       canEdit: true // Can we edit this node?
                                     });
      }
    }
    var titlebar = {"id" : key, // The InfoTag s class/key (mood)
                   "icon": icon, // The Icon we wish to use
                   "title" : title, // The Title we wish to use
                   'content' : content, // Our Widget s Content
                   'collapsed' : true, // Does this widget start collapsed?
                   'add_allow': false}; // Don't allow users to add anything if we already have data
    return titlebar;
};

infotag_widgets_edit['privacy'] = function( cl, di, add_container ) {
  infotags.edit_prep( cl, di );

  var obj_split = [1, _INFO_TAGS['_']['cnx'][ 'pid' ] ];

  var editarea = '<div id="'+cl+'_'+di+'_editor">';

  editarea += '<input type="radio" name="is_public_' + obj_split[1]+'" id="is_private_' + obj_split[1]+'" value="0" '+(_ZGLOBAL[obj_split[1]].privacy & 2 ?'checked':'')+' onchange="_change_privacy_form(0, '+obj_split[1]+');" onclick="_change_privacy_form(0, '+obj_split[1]+');" />';
   editarea += '<label for="is_private_' + obj_split[1]+'"><img src="http://assets2.zooomr.com/images/silk/lock.png" border="0" alt="lock" style="vertical-align:middle;" /> ' + gettext("Mark as Private") + '</label><br />';
  editarea += '<div style="padding-left: 20px;">';
  editarea += '    <input type="checkbox" name="is_friend_' + obj_split[1]+'" id="is_friend_' + obj_split[1]+'" value="1" '+(_ZGLOBAL[obj_split[1]].privacy & 4 ?'checked':'')+' />';
  editarea += '    <label for="is_friend_' + obj_split[1]+'"><img src="http://assets2.zooomr.com/images/silk/key_add.png" border="0" alt="key" style="vertical-align:middle;" /> ' + gettext("Visible to Friends") + '</label><br />';
  editarea += '    <input type="checkbox" name="is_family_' + obj_split[1]+'" id="is_family_' + obj_split[1]+'" value="1" '+(_ZGLOBAL[obj_split[1]].privacy & 8 ?'checked':'')+' />';
  editarea += '    <label for="is_family_' + obj_split[1]+'"><img src="http://assets2.zooomr.com/images/silk/key_add.png" border="0" alt="key" style="vertical-align:middle;" /> ' + gettext("Visible to Family") + '</label><br />';
  editarea += '</div>';
  editarea += '<input type="radio" name="is_public_' + obj_split[1]+'" id="is_public_' + obj_split[1]+'" '+(_ZGLOBAL[obj_split[1]].privacy & 1 ?'checked':'')+' value="1" onchange="_change_privacy_form(1, '+obj_split[1]+');" onclick="_change_privacy_form(1, '+obj_split[1]+');" />';
  editarea += '<label for="is_public_' + obj_split[1]+'"><img src="http://assets2.zooomr.com/images/silk/lock_open.png" border="0" alt="open lock" style="vertical-align:middle;" /> ' + gettext("Mark as Public") + '</label><br />';

  editarea += '<input id="'+cl+'_'+di+'_save" type="button" class="sm_button" value="'+gettext("SAVE")+'" /> OR <input id="'+cl+'_'+di+'_cancel" type="button" value="'+gettext("CANCEL")+'" class="sm_cancel_button" /></div>';

  add_container.update('<div style="text-align:left;"'+editarea+'</div>');

  function _change_privacy_form( setting, pid ) {
      $( 'is_friend' + (pid ? '_'+pid : '') ).disabled = setting
      $( 'is_family' + (pid ? '_'+pid : '') ).disabled = setting
      if (setting == 1) {
          $( 'is_friend' + (pid ? '_'+pid : '') ).checked = false
          $( 'is_family' + (pid ? '_'+pid : '') ).checked = false
      }
  }

  _change_privacy_form(Boolean(parseInt( _INFO_TAGS[cl][di].data ) & 1), obj_split[1]);

  Event.observe(cl+'_'+di+'_save', 'click', function(){ infotags.save_edit(cl, di); }, false);
  Event.observe(cl+'_'+di+'_cancel', 'click', function(){ infotags.init_node(cl); }, false);
};

infotag_widgets_save_edit['privacy'] = function ( cl, di, add_container ) {
    var the_split = [1, _INFO_TAGS['_']['cnx'][ 'pid' ] ];
    data = {photo_id:the_split[1], is_public:($( 'is_private_' + the_split[1] ).checked ? 0 : 1), is_friend:($( 'is_friend_' + the_split[1] ).checked ? 1 : 0), is_family:($( 'is_family_' + the_split[1] ).checked ? 1 : 0) };

    infotags.editing_prep(cl, di);

    var success = function(t) {
      infotags.refresh_node( cl, false );
    };

    ZAPI.callMethodJSON( 'zooomr.photos.setperms', data , {onSuccess:success});
};

//infotags.init_node('privacy');


// LICENSES
infotag_widgets_init["license"] = function (key, data) {
    var content = '';
    var icon = '';
    var title = '';
    var title_icons = '';
    var description = '';

    var is_owner = (_ZGLOBAL[ _INFO_TAGS['_']['cnx'][ 'pid' ] ]['owner']['nsid'] == global_nsid);

    for (dk in data) {
      function generate_cc_icon(kind) {
        var attrs = ['http://assets2.zooomr.com/images/cc_icons/cc_icon_attribution_small.gif'];

        if (kind in {3:1,4:1,5:1}) {
          attrs[attrs.length] = 'http://assets2.zooomr.com/images/cc_icons/cc_icon_noncomm_small.gif';
        }

        if (kind in {2:1,3:1}) {
          attrs[attrs.length] = 'http://assets2.zooomr.com/images/cc_icons/cc_icon_noderivs_small.gif';
        }

        if (kind in {5:1,6:1}) {
          attrs[attrs.length] = 'http://assets2.zooomr.com/images/cc_icons/cc_icon_sharealike_small.gif';
        }
        return attrs;
      }

      if (data[ dk ].data == 0) {
        icon = 'copyright';
        title = gettext("All Rights Reserved");

        description = '<p style="background:#eee;"><strong style="color: #f00;">' + gettext("Notice:") + '</strong> ' + gettext('This photo is licensed <a href="http://en.wikipedia.org/wiki/All_rights_reserved"><strong>All Rights Reserved</strong></a>, which means that the copyright holder reserves <em>all rights</em> granted under existing copyright law, including the ability to pursue legal action against infringement.') + (is_owner ? ' <a href="javascript:infotags.edit(\'' + key + '\',\'master\');">' +gettext("Edit") + ' &raquo;</a>' : '') + ' </p>';

      } else {
        var _cc_icons = generate_cc_icon(parseInt(data[ dk ].data));
        icon = _cc_icons[0];

        if (_cc_icons.length > 1) {
          for (var i=1;i<_cc_icons.length;i++) {
            title_icons = title_icons + '<img src="' + _cc_icons[i] + '" alt="" /> ';
          }
        }

        title = gettext("Some Rights Reserved");

        description = '<div style="background:#eee;"><strong style="color: #f00;">' + gettext("Notice:") + '</strong> ' + gettext('This photo is <a href="http://en.wikipedia.org/wiki/Creative_Commons"><strong>Creative Commons licensed</strong></a>, which enables the copyright holder to grant some or all of their rights to the public.') + (is_owner ? ' <a href="javascript:infotags.edit(\'' + key + '\',\'master\');">' +gettext("Edit") + ' &raquo;</a>' : '') + '<br /><br />';

        switch (data[ dk ].data) {
          case 1:
            description = description + '<center><a href="http://creativecommons.org/licenses/by/3.0/"><img src="http://i.creativecommons.org/l/by/3.0/88x31.png" alt="' + gettext("Attribution License") + '" title="' + gettext("Attribution License") + '" /></a></center>';
            break;
          case 2:
            description = description + '<center><a href="http://creativecommons.org/licenses/by-nd/3.0/"><img src="http://i.creativecommons.org/l/by-nd/3.0/88x31.png" alt="' + gettext("Attribution-NoDerivs License") + '" title="' + gettext("Attribution-NoDerivs License") + '" /></a></center>';
            break;
          case 3:
            description = description + '<center><a href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img src="http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png" alt="' + gettext("Attribution-NonCommercial-NoDerivs License") + '" title="' + gettext("Attribution-NonCommercial-NoDerivs License") + '" /></a></center>';
            break;
          case 4:
            description = description + '<center><a href="http://creativecommons.org/licenses/by-nc/3.0/"><img src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" alt="' + gettext("Attribution-NonCommercial License") + '" title="' + gettext("Attribution-NonCommercial License") + '" /></a></center>';
            break;
          case 5:
            description = description + '<center><a href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" alt="' + gettext("Attribution-NonCommercial-ShareAlike License") + '" title="' + gettext("Attribution-NonCommercial-ShareAlike License") + '" /></a></center>';
            break;
          case 6:
            description = description + '<center><a href="http://creativecommons.org/licenses/by-sa/3.0/"><img src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" alt="' + gettext("Attribution-ShareAlike License") + '" title="' + gettext("Attribution-ShareAlike License") + '" /></a></center>';
            break;


        }
        description = description + '<br /></div>';

      }

      content = infotags.build_sub(data[dk], description,
                                   { title : gettext("Master License") + ': ' + title, //Title of the Node
                                     canRemove: false, //Can we remove this Node?
                                     canEdit: is_owner // Can we edit this node?
                                   });
    }

    var titlebar = {"id" : key, // The InfoTag s class/key (mood)
                   "icon": icon, // The Icon we wish to use
                   "title" : title_icons + title, // The Title we wish to use
                   'content' : content,
                   'collapsed' : true, // Does this widget start collapsed?
                   'add_allow': false};

    return titlebar;
};

infotag_widgets_edit['license'] = function( cl, di, add_container ) {
  infotags.edit_prep( cl, di );

  try {

  var obj_split = [_INFO_TAGS[cl][di].data, _INFO_TAGS['_']['cnx'][ 'pid' ] ];

  var editarea = '<div id="'+cl+'_'+di+'_editor"><strong>'+ gettext("Note: You should only license photos you have the copyright to.") + '</strong><br />';
  editarea += '<select id="'+cl+'_'+di+'_edit" name="'+cl+'_'+di+'_edit" style="font-size:x-small;" >';
  editarea += '<option value="0" '+(obj_split[0]==0?'selected':'')+'>'+ gettext("None (All rights reserved)") + '</option>';
  editarea += '<option value="1" '+(obj_split[0]==1?'selected':'')+'>'+ gettext("Attribution License") + '</option>';
  editarea += '<option value="2" '+(obj_split[0]==2?'selected':'')+'>'+ gettext("Attribution-NoDerivs License") + '</option>';
  editarea += '<option value="3" '+(obj_split[0]==3?'selected':'')+'>'+ gettext("Attribution-NonCommercial-NoDerivs License") + '</option>';
  editarea += '<option value="4" '+(obj_split[0]==4?'selected':'')+'>'+ gettext("Attribution-NonCommercial License") + '</option>';
  editarea += '<option value="5" '+(obj_split[0]==5?'selected':'')+'>'+ gettext("Attribution-NonCommercial-ShareAlike License") + '</option>';
  editarea += '<option value="6" '+(obj_split[0]==6?'selected':'')+'>'+ gettext("Attribution-ShareAlike License") + '</option></select><br />';
  editarea += '<input id="'+cl+'_'+di+'_save" type="button" class="sm_button" value="'+ gettext("SAVE") +'" /> OR <input id="'+cl+'_'+di+'_cancel" type="button" value="'+ gettext("CANCEL") +'" class="sm_cancel_button" /></div>';

  add_container.update('<div style="text-align:left;"'+editarea+'</div>');

  } catch (e) {
    // console.log(e);
  }

    Event.observe(cl+'_'+di+'_save', 'click', function(){ infotags.save_edit(cl, di); }, false);
    Event.observe(cl+'_'+di+'_cancel', 'click', function(){ infotags.init_node(cl); }, false);
};

infotag_widgets_save_edit['license'] = function ( cl, di, add_container ) {
    var the_split = [$(cl+'_'+di+'_edit').value, _INFO_TAGS['_']['cnx'][ 'pid' ] ];

    infotags.editing_prep(cl, di); //show saving icon

    // define update event handler
    var success = function(t) {
        //console.log( t.responseText );
        infotags.refresh_node( cl );
    };

    ZAPI.callMethodJSON( 'zooomr.photos.licenses.setlicense', {'photo_id': the_split[1], 'license_id': the_split[0]} , {onSuccess:success});
};

//infotags.init_node('license');

infotag_widgets_init["report"] = function (key, data) {
  var title = gettext("Report this photo");
  var content = '';
  var menubar = {
      "id" : key,
      "icon": 'report',
      "title" : title,
      'content' : content,
      'add_allow': true,
      'collapsed' : true
  };
  return menubar;
}
infotag_widgets_add["report"] = function (key, add_container) {
  infotags.add_prep(key);
  var content = '<style>';
  content += '.report {margin: 0 8px 0 8px; }';
  content += '#report_submit {margin-right: 16px; }';
  content += '#report_description textarea {margin:5px 0;width:240px;height:3em;}';
  content += '</style>';
  content += '<div class="report">';
  content += '<form id="report_form" action="javascript:void(0)" method="POST">';
  content += '<input type="checkbox" name ="type" value="report"/>&nbsp;&nbsp;';
  content += gettext("I want to report this photo.");
  content += '<br/><div id="report_description" style="display: none;">';
  content += '<br/>';
  content += gettext("Please tell us why you are reporting this photo:");
  content += '<textarea name="description"></textarea>';
  content += '<br/>';
  content += '<span style="font-size: small;">';
  content += gettext("For more information about our policies, please read our <a href=\"%(TOS_URL)s\">Terms Of Service</a>.").replace('%(TOS_URL)s','/about/tos/');
  content += '</span>';
  content += '</div>';
  content += '<div id="report_submit">';
  content += '<input type="submit" class="reg_button" disabled="true" value="';
  content += gettext("Report");
  content += '" onclick="infotags.save(\''+key+'\')" />';
  content += '<input type="button" class="cancel_button" value="';
  content += gettext("Cancel");
  content += '" onclick="infotags.init_node(\''+key+'\')" />';
  content += '</div>';
  content += '</form></div>';
  add_container.update(content)
  /* j$('#report_form select[name="type"]').change(function() { j$('#report_description').slideDown(); }); */
  j$('#report_form input[name="type"]').change(function() {
    if (j$('#report_form input[name="type"]').attr('checked')) {
      j$('#report_description').slideDown();
      if (j$('#report_form textarea[name="description"]').val()) {
        j$('#report_form input[type="submit"]').attr('disabled', false);
      }
    } else {
      j$('#report_description').slideUp();
      j$('#report_form input[type="submit"]').attr('disabled', true);
    }
  });
  j$('#report_form textarea[name="description"]').keyup( function() {
    if (j$('#report_form textarea[name="description"]').val()) {
      j$('#report_form input[type="submit"]').attr('disabled', false);
    } else {
      j$('#report_form input[type="submit"]').attr('disabled', true);
    }
  });
}
infotag_widgets_save["report"] = function (key, add_container) {
  //var type = j$('#report_form select[name="type"]').val();
  var type = j$('#report_form input[name="type"]').val();
  var description = j$('#report_form textarea[name="description"]').val();
  var uid = _ZGLOBAL[ _INFO_TAGS['_']['cnx'][ 'pid' ] ]['owner']['url'] ;
  var pid = _INFO_TAGS['_']['cnx']['pid'] + '';
  var method = '/photos/' + uid + '/' + pid + '/report/';
  var call_options = {
    type: type,
    description: description
  };
  if (typeof type == 'undefined' || !type) {
    return;
  }
  var success = function(d) {
    //console.log(d);
    if (typeof d.stat != 'undefined' && d.stat == 'ok') {
      infotags.init_node(key);
    } else {
      var contents = 'update failed!';
      contents += '<br/>';
      contents += '<a href="javascript:void(0);" onclick="infotags.init_node(\''+key+'\')" >close</a>'
      add_container.update(contents);
    }
  }
  //console.log(call_options);
  j$.post(method, call_options, success, 'json');
  infotags.saving_prep(key);
}