﻿// ALWAYS EXECUTES

//check for items in the query string
var urlArray = new Array();
var bareUrl;
var qString = new Array();
urlArray = document.location.href.split('?');
if (urlArray[1]) {
bareUrl = urlArray[0];
qString = urlArray[1].split('&');
    for (i = 0; i<qString.length; i++) {
    var key = qString[i].split('=')[0];
    var value = qString[i].split('=')[1];
        //scroll?
        if (key == "scroll") {
        location.href = bareUrl + "#" + value;
        }
    }
}


// FUNCTIONS

//a wrapper function for the 'onload' event of the <body> tag in chief.master
function chiefMasterInit() {
initSocialToolbarHrefs();
}

//initialize the "social toolbar" links for the current page
function initSocialToolbarHrefs() {
    var here = escape(location.href);
    var title = escape(document.title);
    $("st_link_del").href = "http://del.icio.us/post?url=" + here + "&title=" + title;
    $("st_link_dig").href = "http://digg.com/submit?phase=2&URL=" + here;
    $("st_link_tec").href = "http://technorati.com/cosmos/search.html?url=" + here;
    $("st_link_bli").href = "http://blinklist.com/index.php?Action=Blink/addblink.php&URL=" + here + "&Title=" + title;
    $("st_link_fur").href = "http://furl.net/storeIt.jsp?t=" + title + "&u=" + here;
    $("st_link_red").href = "http://reddit.com/submit?url=" + here + "&title=" + title;
}

//email obfuscator
function writeEmailLink(u, d) {
var link = u + "@" + d;

if(u == "ads") {
document.write("<a hre" + "f=ma" + "ilto:" + u + "@" + d + "?cc=sa" + "les" + "@" + "struct" + "uremag.org>" + link + "</a>");
}
else{
document.write("<a hre" + "f=ma" + "ilto:" + u + "@" + d + ">" + link + "</a>");
}
}
