﻿// Written by Will Fastie, 19 Aug 2005
// Rewritten for Global Abatement 07 Jul 2008
// Revised for generality 10 Jul 2008

/*global WF */
WF = {};

WF.constructaddr = function (ename, edomain) {
    var atsign = "@";
    var addr = ename + atsign + edomain;
    return addr;
};

WF.nb = function (ename, edomaincode, edisplay, esubj) {
    var subj = "?subject=";
    var addr = WF.constructaddr(ename, WF.myd(edomaincode));
    var display = addr;
    var atag;
    if (((arguments.length === 4) || (arguments.length === 3)) && (edisplay !== "")) {
        display = edisplay;
    }
    if ((arguments.length === 4) && (esubj !== "")) {
        addr = addr + subj + esubj;
    }
    atag = "<a " +  " href=\"mailto:" + addr + "\">" + display + "</a>";
    document.write(atag);
    return null;
};

// If the code does not match, return the code as the domain name.
WF.myd = function (mycode) {
    var dn = 'fastie';
    var tldc = '.com';
    var d;
    switch (mycode) {
    case "fc":
        d = dn + tldc;
        break;
    case "gm":
        d = 'gmail' + tldc;
        break;
    case "ao":
        d = 'aol' + tldc;
        break;
    case "yh":
        d = 'yahoo' + tldc;
        break;
    default:
        d = mycode;
        break;
    }
    return d;
};

/* Function to populate the options for the Bing search box */
WF.getBingOptions = function () {
	var WLSearchBoxConfiguration =
	{
		"global":{
			"serverDNS":"www.bing.com",
			"market":"en-US"
		},
		"appearance":{
			"autoHideTopControl":false,
			"width":700,
			"height":600,
			"theme":"Green"
		},
		"scopes":[
			{
				"type":"web",
				"caption":"&#x46;&#x61;&#x73;&#x74;&#x69;&#x65;&#x20;&#x53;&#x79;&#x73;&#x74;&#x65;&#x6d;&#x73;",
				"searchParam":"site:www.fastie.com"
			}
			,
			{
				"type":"web",
				"caption":"&#x57;&#x65;&#x62;",
				"searchParam":""
			}
		]
	};
	return WLSearchBoxConfiguration;
}
