/**********************************************************************
   Copyright 2006, Bookmarkit.org
   It is pointless to steal what is already free...
 *********************************************************************/

// initialize the UI, including forms, parsing the URL, and using CSS to round corners
function org_bookmarkit_initUI(pageName)
{
    if(NiftyCheck())
    {
        Rounded("div#header", "#ffffff", "#000099");  
    }
    if (pageName == 'settings')
    {
        // dynamically draw the settings form options
        org_bookmarkit_drawSettingsForm();

        // set checkboxes by the currently selected items
        org_bookmarkit_initSettingsPage();
    }
    else if (pageName == 'mark')
    {
        org_bookmarkit_doBookmark();
    }
    else if (pageName == 'how-it-works')
    {
        org_bookmarkit_drawListOfSupportedSites();
    }
}
 
 
// The function to call when creating a bookmark. It will analyze the
// URL for required parameters parameters
function org_bookmarkit_doBookmark(bookmarkType)
{   
    var marker = org_bookmarkit_createBookmarker();
    if (marker.url == "")
    {
        org_bookmarkit_makeOverlayVisible();
        var message = org_bookmarkit_renderResource("no_url_error_message");
        org_bookmarkit_displayStatusMessage(message);
    }
    else
    {
        if (bookmarkType == null)
            bookmarkType = org_bookmarkit_determineBookmarkType(marker);
        
        // multiple bookmark types may be possible
        var typeArray = bookmarkType.split(",");
        
        // bookmark using just one bookmark site
        if (typeArray.length == 1)
        {
            var redirectUrl = org_bookmarkit_determineBookmarkUrl(marker, bookmarkType);
            var message = org_bookmarkit_renderResource("redirect_progress_bar", 
                    bookmarkType, 
                    org_bookmarkit_encode(marker.title, 1, -1), 
                    org_bookmarkit_encode(marker.url, 1, -1), 
                    org_bookmarkit_encode(marker.tags, 1, -1),
                    org_bookmarkit_encode(marker.description, 1, -1));
            org_bookmarkit_displayStatusMessage(message);
            location.replace(redirectUrl);
        }
        else
        {
            org_bookmarkit_makeOverlayVisible();
            // present a form so the user must pick just one site
            var message = org_bookmarkit_renderResource("please_select_bookmark_site_from_list",
                org_bookmarkit_encode(marker.url, 1, 1), 
                org_bookmarkit_encode(marker.title, 1, 1), 
                org_bookmarkit_encode(marker.description, 1, 1), 
                org_bookmarkit_encode(marker.tags, 1, 1), 
                org_bookmarkit_encode(marker.xml, 1, 1));
            org_bookmarkit_displayStatusMessage(message);
            org_bookmarkit_drawDetermineBookmarkSiteForm(typeArray);                
        }        
    }
}

// make the overlay visible if needed
function org_bookmarkit_makeOverlayVisible()
{
    var overlay = document.getElementById("overlay");
    if (overlay != null)
    {
        overlay.style.display = "block";
    }
}

// this displays a 'please wait' message to the user
function org_bookmarkit_displayStatusMessage(message, isAppend)
{
    var elem = document.getElementById("status-message");
    if (elem == null)
        return;

    if (isAppend)
        message = elem.innerHTML + message;

    elem.innerHTML = message;
}


// This object will hold all of the information needed to create a
// social bookmark: the url, a title, a description, some tags,
// and a free-form XML string reserved for future use
function org_bookmarkit_bookmarker(bookmarkType, url, title, 
        description, tags, xml)
{
    this.bookmarkType = (bookmarkType) ? bookmarkType : "";
    this.url = (url) ? url : "";
    this.title = (title) ? title : "";
    this.description = (description) ? description : "";
    this.tags = (tags) ? tags : "";
    this.xml = (xml) ? xml : "";
    
    this.redirectUrl = null;
    this.errorString = null;
}


// create a bookmarker object for doing the redirects
function org_bookmarkit_createBookmarker()
{
    var bookmarker = new org_bookmarkit_bookmarker();
    var urlParams = org_bookmarkit_parseUrlParameters();
    
    bookMarker = new org_bookmarkit_bookmarker(
            urlParams["bookmarkType"], urlParams["url"], 
            urlParams["title"], urlParams["description"], 
            urlParams["tags"], urlParams["xml"]);

    // todo: have a PHP page do a dump of the HTTP environment variables into
    //   JavaScript, so the bookmarker can also store gateway server settings

    return bookMarker;
}


// Determines the bookmark type for this user by analyzing their cookies.
// If no cookie exists, it redirects to the 'settings' page so they can
// choose a bookmarking method
function org_bookmarkit_determineBookmarkType(bookMarker)
{
    var bookmarkType = "UserInitialization";

    // extract the user preferred type from the cookie
    var userType = org_bookmarkit_getCookie("bookmarkType");
    
    // extract the site preferred type from the URL
    var suggestedType = bookMarker.bookmarkType;
    
    // determine if the user does not want suggestions
    var allowSuggestions = org_bookmarkit_getCookie("allowSuggestions");

    // set the bookmark type for the redirect
    if (allowSuggestions != null && allowSuggestions == 1 && suggestedType != null && suggestedType != "")
    {
        bookmarkType = suggestedType;
    }
    else if (userType != null)
    {
        bookmarkType = userType;
    }

    return bookmarkType;
}


/**********************************************************************
                          BOOKMARK SETTINGS
 *********************************************************************/


// initializes the settings page
function org_bookmarkit_initSettingsPage()
{
    var frm = document.getElementById("settings-form");
    if (frm == null)
        return;
    
    var bookmarkType = org_bookmarkit_getCookie("bookmarkType");
    if (bookmarkType != null)
    {
        var typeArray = bookmarkType.split(",");
        for (var i=0; i<typeArray.length; i++)
        {
            var fieldName = typeArray[i];
            if (fieldName != null && fieldName != "")
            {
                var elem = frm.elements[typeArray[i]];
                if (elem != null)
                    elem.checked = true;
            }
        }
    }
    
    var allowSuggestions = org_bookmarkit_getCookie("allowSuggestions");
    if (allowSuggestions == 0)
    {
        var elem = document.getElementById("sug-no");
        if (elem != null)
            elem.checked = true;
    }
}

// update the settings for this user, and redirect if possible
function org_bookmarkit_updateSettings()
{
    var frm = document.getElementById("settings-form");
    if (frm == null)
        return;

    // the cookies wont expire for 100 years. Ha!
    var expireDate = new Date();
    expireDate.setYear(2100);
    
    // determine the user configured bookmark type
    var bookmarkType = "";
    for (var i=0; i<frm.elements.length; i++)
    {
        var field = frm.elements[i];
        if (field.type == "checkbox" &&  field.checked)
        {
            if (bookmarkType != "")
                bookmarkType += ",";
            bookmarkType = bookmarkType + field.name;            
        }
    }
    org_bookmarkit_setCookie("bookmarkType", bookmarkType, expireDate);

    // determine if the user wants to allow a site to make suggestions
    var allowSuggestions = 1;
    for (var i=0; i<frm.allowSuggestions.length; i++)
    {
        if (frm.allowSuggestions[i].checked)
        {
            allowSuggestions = frm.allowSuggestions[i].value;
            break;
        }
    }
    org_bookmarkit_setCookie("allowSuggestions", allowSuggestions, expireDate);
    
    // redirect if possible, otherwise just notify the user
    var urlParams = org_bookmarkit_parseUrlParameters();
    var doRedirect = urlParams["doRedirect"];
    if (doRedirect == 1)
    {
        var marker = org_bookmarkit_createBookmarker();
        var redirectUrl = org_bookmarkit_determineBookmarkUrl(
            marker, "Bookmarkit");
        document.location.replace(redirectUrl);
    }
    else
    {
        var box = document.getElementById("message-box");
        var message = org_bookmarkit_renderResource(
                "settings_update_msg", bookmarkType);
        var url = urlParams["url"];
        if (url != null)
        {
            message += org_bookmarkit_renderResource(
                    "settings_update_back_url", url, url);
        }
        box.innerHTML = message;
        box.className = "new-message";
    }
}



/**********************************************************************
                        REDIRECT FUNCTIONS
 *********************************************************************/


// in the event of a serious error, redirect ro an error page
function org_bookmarkit_redirectToErrorPage(marker)
{
    var msg = marker.errorString;
    if (msg == "")
        msg = "Unknown error.";
    
    // todo: add the ability for custom overloading of the error page
    
    location.replace("/error.html?msg=" + encodeURIComponent(msg));
}


// based on the data in the table above, generate the redirect URL
// for this bookmarkType
function org_bookmarkit_determineBookmarkUrl(marker, bookmarkType)
{   
    // default to the user initialization page
    var redirectData = org_bookmarkit_getBookmarkTypeData(bookmarkType);
    if (redirectData == null)
        redirectData = org_bookmarkit_bookmarkTypeData[0];
        
    // use regex to determine the full URL
    var bookmarkUrl = redirectData[3];
        
    bookmarkUrl = bookmarkUrl.replace(/URL/, 
        org_bookmarkit_encode(marker.url, 0, 1));
    bookmarkUrl = bookmarkUrl.replace(/TITLE/, 
        org_bookmarkit_encode(marker.title, 0, 1));
    bookmarkUrl = bookmarkUrl.replace(/TAGS/, 
        org_bookmarkit_encode(marker.tags, 0, 1));
    bookmarkUrl = bookmarkUrl.replace(/DESCRIPTION/, 
        org_bookmarkit_encode(marker.description, 0, 1));
    bookmarkUrl = bookmarkUrl.replace(/XML/, 
        org_bookmarkit_encode(marker.xml, 0, 1));
    return bookmarkUrl;
}


// extract the bookmark type data from the array
function org_bookmarkit_getBookmarkTypeData(bookmarkType)
{
    var typeArray = org_bookmarkit_bookmarkTypeData;
    var length = typeArray.length;
    var typeData = null;
    
    for (var i=0; i<length; i++)
    {
        if (typeArray[i][0] == bookmarkType)
        {
            typeData = typeArray[i];
            break;
        }
    }
    
    return typeData;
}


/**********************************************************************
                     PAGE DRAWING FUNCTIONS
 *********************************************************************/

// draw a list of supported sites on the 'how it works' page
function org_bookmarkit_drawListOfSupportedSites()
{
    var container = document.getElementById("social-bookmark-sites-container");
    var html = "";

    // loop over known bookmarks, display the data
    var types = org_bookmarkit_bookmarkTypeData;
    var formGroup = null;
    for (var i=0; i<types.length; i++)
    {
        var thisGroup = types[i][4];
        var doSubGroupWrapper = false;
        if (thisGroup != "internal" && thisGroup != formGroup)
        {
            if (thisGroup != "internal")
                html += org_bookmarkit_renderResource("how_works_page_subgroup_end");

            html += org_bookmarkit_renderResource("how_works_page_subgroup_begin", thisGroup);
            doSubGroupWrapper = true;
            formGroup = thisGroup;
        }

        if (thisGroup != "internal")
        {
            var url = types[i][3];
            url = url.substring(0, url.indexOf("/", 8));
            html += org_bookmarkit_renderResource("how_works_page_subgroup_single_entry",
                    url, types[i][2], types[i][1]);
        }
    }

    container.innerHTML = html;
}

// draw the settings form, display all known sites, and the user's preferences
function org_bookmarkit_drawSettingsForm()
{
    // prepare to display the settings page
    var formContainer = document.getElementById("settings-form-container");
    var html = org_bookmarkit_renderResource("settings_page_bookmark_group_begin");

    // loop over known bookmarks, display the data
    var types = org_bookmarkit_bookmarkTypeData;
    var formGroup = null;
    for (var i=0; i<types.length; i++)
    {
        var thisGroup = types[i][4];
        var doSubGroupWrapper = false;
        if (thisGroup != "internal" && thisGroup != formGroup)
        {
            if (thisGroup != "internal")
                html += org_bookmarkit_renderResource("settings_page_bookmark_subgroup_end");

            html += org_bookmarkit_renderResource("settings_page_bookmark_subgroup_begin", thisGroup);
            doSubGroupWrapper = true;
            formGroup = thisGroup;
        }

        if (thisGroup != "internal")
            html += org_bookmarkit_renderResource("settings_page_bookmark_subgroup_single_entry",
                    types[i][0], types[i][2], types[i][1]);
    }    

    // finish the form
    html += org_bookmarkit_renderResource("settings_page_bookmark_subgroup_end");
    html += org_bookmarkit_renderResource("settings_page_bookmark_group_end");
    html += org_bookmarkit_renderResource("settings_page_form_inputs_allow_suggest");
    html += org_bookmarkit_renderResource("settings_page_form_inputs_save_settings");

    // display the html
    formContainer.innerHTML = html;
}


function org_bookmarkit_drawDetermineBookmarkSiteForm(typeArray)
{
    var formContainer = document.getElementById("multiple-bookmark-form-container");
    if (formContainer == null)
        return;

    var formHtml = org_bookmarkit_renderResource("multiple_bookmark_form_begin");
    
    // for each item in the array, draw a form element
    for (var i=0; i<typeArray.length; i++)
    {
        var type = typeArray[i];
        var typeData = org_bookmarkit_getBookmarkTypeData(type);
        if (typeData == null)
            continue; // should not happen
        formHtml += org_bookmarkit_renderResource("multiple_bookmark_form_single_entry",
                type, typeData[2], typeData[1]);
    }
    
    formHtml += org_bookmarkit_renderResource("multiple_bookmark_form_end");
        
    // set focus to the 'submit' button
    formContainer.innerHTML = formHtml;
}


/**********************************************************************
                        UTILITY FUNCTIONS
 *********************************************************************/

// A convenience function allowing people to bookmark the current page.
// This can be used in a URL like so:
// <a href="javascript:org_bookmarkit_bookmarkCurrentPage()">bookmark it!</a>
function org_bookmarkit_bookmarkCurrentPage()
{
    // redirect to bookmarkit.org with the current page's URL and title
    var url = encodeURIComponent(document.location);
    var title = encodeURIComponent(document.title);
    var redirectUrl = "http://bookmarkit.org/mark.htm?url=" + url + 
        "&title=" + title;
    document.location.replace(redirectUrl);
}


// Parses the URL for parameters, such as "http://example.com?foo=1&bar=2",
// and returns an associative array of the values. 
function org_bookmarkit_parseUrlParameters()
{
    var urlParams = new Array();
    var fullUrl = location.href;
    var qLoc = fullUrl.indexOf('?');
    if (qLoc > -1)
    {
        var queryString = fullUrl.substring(qLoc+1);
        var paramTokens = queryString.split('&');
        var urlParams = new Array();
        for (var i=0; i<paramTokens.length; i++)
        {           
            var nameValuePairStr = paramTokens[i];
            if (nameValuePairStr.indexOf('=') > -1)
            {
                var nameValuePair = nameValuePairStr.split('=');
                urlParams[decodeURIComponent(nameValuePair[0])] = 
                        decodeURIComponent(nameValuePair[1]);
            }
        }
    }
    return urlParams;
}

// sets a cookie with the specified name, value, and expiration date object
function org_bookmarkit_setCookie(name, value, expires)
{
    var cookieStr = name + "=" + encodeURIComponent(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        "; path=/";
    document.cookie = cookieStr;
}

// returns the value for the specified cookie
function org_bookmarkit_getCookie(name)
{
    var cookie = document.cookie;
    var prefix = name + "=";
    var begin = cookie.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = cookie.indexOf(prefix);
        if (begin != 0)
            return null;
    }
    else
    {
        begin += 2;
    }
    
    var end = cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = cookie.length;
    }
    
    return decodeURIComponent(cookie.substring(begin + prefix.length, end));
}

// delets a specific cookie by expiring it
function org_bookmarkit_expireCookie(name)
{
    if (getCookie(name))
    {
        document.cookie = name + "=; " + 
            "expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

// render a HTML resorce
function org_bookmarkit_renderResource(resName)
{
    var argValues = org_bookmarkit_renderResource.arguments;
    var argCount = argValues.length;
    var resource = org_bookmarkit_htmlResources[resName];
    if (resource == null)
        return resName;

    for (var i=1; i<argCount; i++)
    {
        var regexp = eval("/{" + i + "[.!}]*}/g");
        resource = resource.replace(regexp, argValues[i]);
    }
    return resource;
}

// allows for encoding / decoding of items for display on HTML, or
// usage in a URL
function org_bookmarkit_encode(str, doXmlEncode, doUrlEncode, doJsEncode)
{
    if (doUrlEncode == -1)
    {
        str = decodeURIComponent(str);
    }
    if (doUrlEncode == 1)
    {
        str = encodeURIComponent(str);
    }
    if (doXmlEncode)
    {
        str = str.replace(/&/g, "&amp;");
        str = str.replace(/</g, "&lt;");
        str = str.replace(/>/g, "&gt;");
        str = str.replace(/\'/g, "&quot;");
    }
    if (doJsEncode)
    {
        str = str.replace(/'/g, "\\'");
        str = str.replace(/"/g, "\\\"");
    }
    return str;
}

/**********************************************************************
                NIFTY JAVASCRIPT LIBRARY FOR ROUND CORNERS
 *********************************************************************/
 
function NiftyCheck()
{
    if(!document.getElementById || !document.createElement)
        return(false);
    var b=navigator.userAgent.toLowerCase();
    if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
        return(false);
    return(true);
}


function Rounded(selector,bk,color,size)
{
    var i;
    var v=getElementsBySelector(selector);
    var l=v.length;
    for(i=0;i<l;i++)
    {
        AddTop(v[i],bk,color,size);
        AddBottom(v[i],bk,color,size);
    }
}


function RoundedTop(selector,bk,color,size)
{
    var i;
    var v=getElementsBySelector(selector);
    for(i=0;i<v.length;i++)
        AddTop(v[i],bk,color,size);
}


function RoundedBottom(selector,bk,color,size)
{
    var i;
    var v=getElementsBySelector(selector);
    for(i=0;i<v.length;i++)
        AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size)
{
    var i;
    var d=document.createElement("b");
    var cn="r";
    var lim=4;
    if(size && size=="small"){ cn="rs"; lim=2}
    d.className="rtop";
    d.style.backgroundColor=bk;
    for(i=1;i<=lim;i++)
    {
        var x=document.createElement("b");
        x.className=cn + i;
        x.style.backgroundColor=color;
        d.appendChild(x);
    }
    el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size)
{
    var i;
    var d=document.createElement("b");
    var cn="r";
    var lim=4;
    if(size && size=="small"){ cn="rs"; lim=2}
    d.className="rbottom";
    d.style.backgroundColor=bk;
    for(i=lim;i>0;i--)
    {
        var x=document.createElement("b");
        x.className=cn + i;
        x.style.backgroundColor=color;
        d.appendChild(x);
    }
    el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector)
{
    var i;
    var s=[];
    var selid="";
    var selclass="";
    var tag=selector;
    var objlist=[];
    if(selector.indexOf(" ")>0)
    {  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
    if(selector.indexOf("#")>0)
    { //id selector like "tag#id"
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
    }
    if(selid!="")
    {
        objlist.push(document.getElementById(selid));
        return(objlist);
    }
    if(selector.indexOf(".")>0)
    {  //class selector like "tag.class"
        s=selector.split(".");
        tag=s[0];
        selclass=s[1];
    }
    var v=document.getElementsByTagName(tag);  // tag selector like "tag"
    if(selclass=="")
        return(v);
    for(i=0;i<v.length;i++)
    {
        if(v[i].className==selclass)
            objlist.push(v[i]);
    }
    return(objlist);
}

/**********************************************************************
                           RESOURCE DATA
 *********************************************************************/

// this array contains all the known bookmark types, and their order.
// The second dimension of the array contains information about each
// social bookmarking site: id, caption, image, redirectUrl, type
// The 'redirectUrl' contains tokens (URL, TITLE, TAGS) which are replaced 
// with regular expression before being rendered
var org_bookmarkit_bookmarkTypeData = new Array
(
    new Array ("UserInitialization", "", "",
        "http://bookmarkit.org/settings.htm?doRedirect=1&url=URL&title=TITLE&description=DESCRIPTION&tags=TAGS&xml=XML",
        "internal"),

    new Array ("Bookmarkit", "", "",
        "http://bookmarkit.org/mark.htm?url=URL&title=TITLE&description=DESCRIPTION&tags=TAGS&xml=XML",
        "internal"),

    new Array ("Delicious", "Del.icio.us", "/img/delicious.png", 
        "http://del.icio.us/post?v=4;url=URL;title=TITLE",
        "one"),

    new Array ("Digg", "Digg", "/img/digg.png",
        "http://digg.com/submit?phase=2&url=URL",
        "one"),  

    new Array ("Blinklist", "Blinklist", "/img/blinklist.png",
        "http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=DESCRIPTION&Url=URL&Title=TITLE&Tag=TAGS",
        "one"),  

    new Array ("Tailrank", "Tailrank", "/img/tailrank.png",
        "http://tailrank.com/share/?title=TITLE&link_href=URL",
        "one"),  

    new Array ("Simpy", "Simpy", "/img/simpy.png",
        "http://simpy.com/simpy/LinkAdd.do?title=TITLE&href=URL&_doneURI=URL", 
        "one"),

    new Array ("YahooMyWeb", "Yahoo! My Web", "/img/yahoomyweb.png",
        "http://myweb2.search.yahoo.com/myresults/bookmarklet?t=TITLE&u=URL&tag=TAGS",
        "one"),

    new Array ("Furl", "Furl", "/img/furl.png",
        "http://www.furl.net/storeIt.jsp?u=URL&t=TITLE",
        "one"),

    new Array ("Newsvine", "Newsvine", "/img/newsvine.png",
        "http://www.newsvine.com/_tools/seed&save?u=URL&h=TITLE",
        "one"),

    new Array ("RawSugar", "Raw Sugar", "/img/rawsugar.png",
	"http://www.rawsugar.com/tagger/?turl=URL&tttl=TITLE",
        "one"),

    new Array ("Scuttle", "Scuttle", "/img/scuttle.png",
	"http://scuttle.org/bookmarks?action=add&address=URL&title=TITLE&description=DESCRIPTION",
        "one"),

    new Array ("Fark", "Fark", "/img/fark.png",
        "http://cgi.fark.com/cgi/fark/edit.pl?new_url=URL&new_comment=TITLE",
        "one"),

    new Array ("Spurl", "Spurl", "/img/spurl.png",
        "http://www.spurl.net/spurl.php?url=URL&title=TITLE",
        "one"),

    new Array ("Magnolia", "Ma.gnolia", "/img/magnolia.png",
        "http://ma.gnolia.com/beta/bookmarklet/add?url=URL&title=TITLE&description=DESCRIPTION",
        "one"),

    new Array ("Blogmarks", "Blogmarks", "/img/blogmarks.png",
        "http://blogmarks.net/my/new.php?mini=1&simple=1&url=URL&title=TITLE",
        "two"),

    new Array ("Comments", "Co.Mments", "/img/co.mments.png",
        "http://co.mments.com/track?url=URL&title=TITLE",
        "two"),

    new Array ("Netvouz", "Netvouz", "/img/netvouz.png",
	"http://www.netvouz.com/action/submitBookmark?url=URL&title=TITLE&description=DESCRIPTION",
        "two"),

    new Array ("Reddit", "Reddit", "/img/reddit.png",
        "http://reddit.com/submit?url=URL&title=TITLE",
        "two"),

    new Array ("BlinkBits", "Blink Bits", "/img/blinkbits.png",
	"http://www.blinkbits.com/bookmarklets/save.php?v=1&source_url=URL&title=TITLE&body=DESCRIPTION",
        "two"),

    new Array ("Shadows", "Shadows", "/img/shadows.png",
	"http://www.shadows.com/bookmark/saveLink.rails?page=URL&title=TITLE",
        "two"),

    new Array ("Wists", "Wists", "/img/wists.png",
        "http://wists.com/r.php?c=null&u=&title=TITLE&r=URL",
        "two"),

    new Array ("LinkAGoGo", "Link a Go Go", "/img/linkagogo.png",
        "http://www.linkagogo.com/go/AddNoPopup?url=URL&title=TITLE&keywords=TAGS&comments=DESCRIPTION",
        "two"),

    new Array ("Connotea", "Connotea", "/img/connotea.png",
        "http://www.connotea.org/addpopup?continue=confirm&uri=URL&title=TITLE&description=DESCRIPTION&tags=TAGS",
        "two"),

    new Array ("Feedmelinks", "Feed Me Links", "/img/feedmelinks.png",
        "http://feedmelinks.com/categorize?from=toolbar&op=submit&url=URL&name=TITLE",
        "two"),

    new Array ("Smarking", "Smarking", "/img/smarking.png",
        "http://smarking.com/editbookmark/?url=URL&description=TITLE",
        "two"),

    new Array ("Tipd", "Tip'd", "/img/tipd.gif",
        "http://tipd.com/submit.php?url=URL",
        "two")

);


// a list of HTML resources
var org_bookmarkit_htmlResources = new Array();
var r = org_bookmarkit_htmlResources;
r["settings_update_msg"] = "<p>Sucessfully updated your settings to include: <b>{1}</b>.</p>";
r["settings_update_back_url"] = "<p><a href='{1}'>Back to {2}</a>";
r["no_url_error_message"] = "<p>Nothing to bookmark. You must pass the parameter 'url' to this page in order to bookmark a page. For example:</p><ul><li><a href='http://bookmarkit.org/mark.htm?title=Google&url=http://google.com'>http://bookmarkit.org/mark.htm?title=Google&url=http://google.com</a></ul><p>Please read the <a href='index.htm'>main page</a> about how to bookmark a site.";
r["redirect_progress_bar"] = "<p>Submitting the following data to {1}:</p><ul><li>Title: <b>{2}</b></li><li>URL: <a href='{3}'>{3}</a></li><li>Tags: <b>{4}</b></li><li>Description: <b>{5}</b></li></ul>";
r["multiple_bookmark_form_begin"] = "<form name='multiple-bookmark-form' action='null'>\n<ul style='list-style-type: none;'>";
r["multiple_bookmark_form_single_entry"] = "<li><input type='radio' id='mark-{1}' onClick='org_bookmarkit_doBookmark(\"{1}\")'><label for='mark-{1}'><img src='{2}'>{3}</label></li>\n";
r["multiple_bookmark_form_end"] = "</ul>\n</form>";
r["please_select_bookmark_site_from_list"] = "<p>Please select which site to use from the list below. To avoid this message, <a href='settings.htm?doRedirect=1&url={1}&title={2}&description={3}&tags={4}&xml={5}'>change your settings</a> to use only one bookmark server.</p>";
r["settings_page_bookmark_group_begin"] = "<div class='form-group'>\n<p>Which bookmarking server would you like to use?</p>\n";
r["settings_page_bookmark_group_end"] = "</div>\n\n";
r["settings_page_bookmark_subgroup_begin"] = "<div id='form-group-{1}' class='form-group-left'>\n<ul style='list-style-type: none;'>";
r["settings_page_bookmark_subgroup_end"] = "</ul>\n</div>\n\n";
r["settings_page_bookmark_subgroup_single_entry"] = "<li><input type='checkbox' name='{1}' id='type-{1}'>\n<label for='type-{1}'><img src='{2}' alt='{1}'>&nbsp;&nbsp;{3}</label></li>\n";
r["settings_page_form_inputs_allow_suggest"] = "<div class='form-group'>\n<p>Would you like to allow sites to suggest a bookmark server to you?</p>\n<ul style='list-style-type: none;'>\n<li><input type='radio' name='allowSuggestions' value='1' checked id='sug-yes'>\n<label for='sug-yes'>Yes</label></li>\n<li><input type='radio' name='allowSuggestions' value='0' id='sug-no'>\n<label for='sug-no'>No<label></li>\n</ul>\n</div>\n\n";
r["settings_page_form_inputs_save_settings"] = "<div class='form-group'>\n<p>Save the settings for next time.</p>\n<input type='button' value=' Save Settings ' onClick='org_bookmarkit_updateSettings()'>\n</div>\n\n";
r["how_works_page_subgroup_begin"] = "<div id='form-group-{1}' class='form-group-left'>\n";
r["how_works_page_subgroup_end"] = "</div>\n\n";
r["how_works_page_subgroup_single_entry"] = "<h4><a href='{1}'><img border=0 src='{2}' alt='{3}'> {3}</a></h4>\n";

