
var supportedSites = null;


function populateSupportedSites()
{
    //format is pure json with named variables
    // m_Site - domain of website
    // m_InputCtlAttribValue - attribute value for input element
    // m_InputCtlAttrib - attribute name for input element
    // m_ActionCtlAttribValue - attribute value for action element(form, button..)
    // m_ActionCtlAttrib - attribute name for action element
    // m_XPathExpression - optional: an xpath expression that returns a set of anchors
    // m_ReachHighlightNode - optional: anonymous full function string to reach highlight node from xpath node
    //Note:
    // - Each entry is indexed by its domain
    // - Attrib name can be either id, name, value, or formid where
    //      id is for the element id
    //      name is for the element name
    //      value is for an unnamed attribute value, i.e. search all #attributes
    //      formid is a special case where you pass in the id of the enclosing form element
    //

    if(supportedSites != null)
    {
        //second window precaution
        return;
    }

    supportedSites = {
        //#Begin Misc sites
    	"www.live.com": {
	    	"m_Site": "www.live.com",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "id",
		    "m_ActionCtlAttribValue": "go",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": "//div[@id='results']/ul/li/h3/a",
            "m_ReachHighlightNode": "function(p_Node){return p_Node.parentNode.parentNode;}"
    	},
	    "search.live.com": {
    		"m_Site": "search.live.com",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "go",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": "//div[@id='results']/ul/li/h3/a",
            "m_ReachHighlightNode": "function(p_Node){return p_Node.parentNode.parentNode;}"
    	},
	    "www.excite.com": {
    		"m_Site": "www.excite.com",
	    	"m_InputCtlAttribValue": "qkw",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "Search",
    		"m_ActionCtlAttrib": "value"
    	},
	    "msxml.excite.com": {
		    "m_Site": "msxml.excite.com",
    		"m_InputCtlAttribValue": "qkw",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "Search",
    		"m_ActionCtlAttrib": "value",
	    	"m_XPathExpression": ""
    	},
	    "www.altavista.com": {
    		"m_Site": "www.altavista.com",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "FIND",
	    	"m_ActionCtlAttrib": "value",
		    "m_XPathExpression": ""
    	},
        //#End Misc sites
        //#Begin Yahoo
    	"www.yahoo.com": {
	    	"m_Site": "www.yahoo.com",
    		"m_InputCtlAttribValue": "p",
    		"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "searchsubmit",
    		"m_ActionCtlAttrib": "id",
    		"m_XPathExpression": "//div[@class='res']/div/h3/a",
            "m_ReachHighlightNode": "function(p_Node){return p_Node.parentNode.parentNode.parentNode;}",
            "m_SpecialUrlComparison": "function(p_First, p_Second){ return p_First.split('**')[1] == p_Second.split('**')[1]; }"
	    },
    	"search.yahoo.com": {
    		"m_Site": "search.yahoo.com",
	    	"m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": "//div[@class='res']/div/h3/a",
            "m_ReachHighlightNode": "function(p_Node){return p_Node.parentNode.parentNode.parentNode;}",
            "m_SpecialUrlComparison": "function(p_First, p_Second){ return p_First.split('**')[1] == p_Second.split('**')[1]; }"
	    },
    	"de.search.yahoo.com": {
	    	"m_Site": "de.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
		    "m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
	    },
    	"search.yahoo.co.jp": {
    		"m_Site": "search.yahoo.co.jp",
	    	"m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
	    },
    	"fr.search.yahoo.com": {
    		"m_Site": "fr.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
    	"www.yahoo.cn": {
    		"m_Site": "www.yahoo.cn",
	    	"m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
	    },
    	"it.search.yahoo.com": {
	    	"m_Site": "it.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"ca.search.yahoo.com": {
	    	"m_Site": "ca.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"au.search.yahoo.com": {
	    	"m_Site": "au.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
	    "br.search.yahoo.com": {
    		"m_Site": "br.search.yahoo.com",
	    	"m_InputCtlAttribValue": "yschsp",
		    "m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"dk.search.yahoo.com": {
	    	"m_Site": "dk.search.yahoo.com",
		    "m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "es.search.yahoo.com": {
    		"m_Site": "es.search.yahoo.com",
	    	"m_InputCtlAttribValue": "yschsp",
		    "m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"hk.search.yahoo.com": {
	    	"m_Site": "hk.search.yahoo.com",
		    "m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"uk.search.yahoo.com": {
	    	"m_Site": "uk.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
		    "m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"in.search.yahoo.com": {
	    	"m_Site": "in.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
		    "m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"kr.search.yahoo.com": {
	    	"m_Site": "kr.search.yahoo.com",
    		"m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
		    "m_ActionCtlAttribValue": "y",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "se.search.yahoo.com": {
    		"m_Site": "se.search.yahoo.com",
	    	"m_InputCtlAttribValue": "yschsp",
		    "m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"ru.search.yahoo.com": {
	    	"m_Site": "ru.search.yahoo.com",
		    "m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
    	    "m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "nl.search.yahoo.com": {
    		"m_Site": "nl.search.yahoo.com",
		    "m_InputCtlAttribValue": "yschsp",
	    	"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "y",
		    "m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"fi.search.yahoo.com": {
	    	"m_Site": "fi.search.yahoo.com",
		    "m_InputCtlAttribValue": "yschsp",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "y",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
        //#End Yahoo
        //#Begin MSN
    	"www.msn.com": {
	    	"m_Site": "www.msn.com",
    		"m_InputCtlAttribValue": "f1",
	    	"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "srchfrm",
	    	"m_ActionCtlAttrib": "formid",
		    "m_XPathExpression": ""
    	},
	    "search.arabia.msn.com": {
    		"m_Site": "search.arabia.msn.com",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "go",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"search.msn.com": {
    		"m_Site": "search.msn.com",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "id",
    		"m_ActionCtlAttribValue": "go",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"search.msn.co.jp": {
	    	"m_Site": "search.msn.co.jp",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "id",
	    	"m_ActionCtlAttribValue": "go",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
        //#End MSN
        //#Begin Google
    	"www.google.com": {
	    	"m_Site": "www.google.com",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": "//div[@class='g']/h2[@class='r']/a",
            "m_ReachHighlightNode": "function(p_Node){return p_Node.parentNode.parentNode;}"
    	},
	    "www.google.de": {
    		"m_Site": "www.google.de",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
	    "www.google.it": {
    		"m_Site": "www.google.it",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
	    "www.google.fr": {
    		"m_Site": "www.google.fr",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.ru": {
    		"m_Site": "www.google.ru",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
       	},
    	"www.google.no": {
    		"m_Site": "www.google.no",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.se": {
    		"m_Site": "www.google.se",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.nl": {
    		"m_Site": "www.google.nl",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.jp": {
    		"m_Site": "www.google.jp",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.cn": {
    		"m_Site": "www.google.cn",
    		"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
       	},
    	"www.google.tw": {
	    	"m_Site": "www.google.tw",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
    	},
    	"www.google.ca": {
	    	"m_Site": "www.google.ca",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.kz": {
	    	"m_Site": "www.google.kz",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.fi": {
    		"m_Site": "www.google.fi",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"www.google.com.tw": {
	    	"m_Site": "www.google.com.tw",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.co.jp": {
    		"m_Site": "www.google.co.jp",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
	    "www.google.ac": {
    		"m_Site": "www.google.ac",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"www.google.co.uk": {
	    	"m_Site": "www.google.co.uk",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.ad": {
	    	"m_Site": "www.google.ad",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.ae": {
	    	"m_Site": "www.google.ae",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.af": {
	    	"m_Site": "www.google.com.af",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.ag": {
	    	"m_Site": "www.google.com.ag",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.ai": {
	    	"m_Site": "www.google.com.ai",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.am": {
	    	"m_Site": "www.google.am",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.com.ar": {
    		"m_Site": "www.google.com.ar",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.as": {
	    	"m_Site": "www.google.as",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.at": {
    		"m_Site": "www.google.at",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
	    "www.google.com.au": {
    		"m_Site": "www.google.com.au",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"www.google.az": {
	    	"m_Site": "www.google.az",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.ba": {
	    	"m_Site": "www.google.ba",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.com.bd": {
    		"m_Site": "www.google.com.bd",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.be": {
	    	"m_Site": "www.google.be",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.bg": {
	    	"m_Site": "www.google.bg",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.bi": {
	    	"m_Site": "www.google.bi",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.bn": {
	    	"m_Site": "www.google.com.bn",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.bo": {
	    	"m_Site": "www.google.bo",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.com.br": {
		    "m_Site": "www.google.com.br",
    		"m_InputCtlAttribValue": "q",
	    	"m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
    	"www.google.bs": {
	    	"m_Site": "www.google.bs",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.by": {
    		"m_Site": "www.google.by",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
    	"www.google.com.bz": {
	    	"m_Site": "www.google.com.bz",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.cd": {
	    	"m_Site": "www.google.cd",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.cg": {
	    	"m_Site": "www.google.cg",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.ch": {
	    	"m_Site": "www.google.ch",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.ci": {
	    	"m_Site": "www.google.ci",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.co": {
	    	"m_Site": "www.google.com.co",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.com.cu": {
	    	"m_Site": "www.google.com.cu",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.cz": {
	    	"m_Site": "www.google.cz",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
    	"www.google.dj": {
	    	"m_Site": "www.google.dj",
		    "m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
	    "www.google.dk": {
    		"m_Site": "www.google.dk",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
    	},
	    "www.google.dm": {
    		"m_Site": "www.google.dm",
	    	"m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
    		"m_ActionCtlAttribValue": "btnG",
	    	"m_ActionCtlAttrib": "name",
    		"m_XPathExpression": ""
	    },
	    "www.google.com.do": {
		    "m_Site": "www.google.com.do",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.ec": {
		    "m_Site": "www.google.com.ec",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ee": {
		    "m_Site": "www.google.ee",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.eg": {
		    "m_Site": "www.google.com.eg",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.es": {
		    "m_Site": "www.google.es",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.et": {
		    "m_Site": "www.google.com.et",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.fj": {
		    "m_Site": "www.google.com.fj",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.fm": {
		    "m_Site": "www.google.fm",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gd": {
		    "m_Site": "www.google.gd",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ge": {
		    "m_Site": "www.google.ge",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gf": {
		    "m_Site": "www.google.gf",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gg": {
		    "m_Site": "www.google.gg",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.gh": {
		    "m_Site": "www.google.com.gh",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.gi": {
		    "m_Site": "www.google.com.gi",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gl": {
		    "m_Site": "www.google.gl",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gm": {
		    "m_Site": "www.google.gm",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gp": {
		    "m_Site": "www.google.gp",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gr": {
		    "m_Site": "www.google.gr",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.gt": {
		    "m_Site": "www.google.com.gt",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.gy": {
		    "m_Site": "www.google.gy",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.hk": {
		    "m_Site": "www.google.com.hk",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.hn": {
		    "m_Site": "www.google.hn",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.hr": {
		    "m_Site": "www.google.hr",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ht": {
		    "m_Site": "www.google.ht",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.hu": {
		    "m_Site": "www.google.hu",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ie": {
		    "m_Site": "www.google.ie",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.im": {
		    "m_Site": "www.google.im",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.co.in": {
		    "m_Site": "www.google.co.in",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.is": {
		    "m_Site": "www.google.is",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.je": {
		    "m_Site": "www.google.je",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.jm": {
		    "m_Site": "www.google.com.jm",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.jo": {
		    "m_Site": "www.google.jo",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.co.jp": {
		    "m_Site": "www.google.co.jp",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.kg": {
		    "m_Site": "www.google.kg",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.com.kh": {
		    "m_Site": "www.google.com.kh",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ki": {
		    "m_Site": "www.google.ki",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.kr": {
		    "m_Site": "www.google.kr",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.la": {
		    "m_Site": "www.google.la",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.li": {
		    "m_Site": "www.google.li",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.lk": {
		    "m_Site": "www.google.lk",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.lt": {
		    "m_Site": "www.google.lt",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.lu": {
		    "m_Site": "www.google.lu",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.lv": {
		    "m_Site": "www.google.lv",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ly": {
		    "m_Site": "www.google.ly",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.ma": {
		    "m_Site": "www.google.ma",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.md": {
		    "m_Site": "www.google.md",
		    "m_InputCtlAttribValue": "q",
		    "m_InputCtlAttrib": "name",
		    "m_ActionCtlAttribValue": "btnG",
		    "m_ActionCtlAttrib": "name",
		    "m_XPathExpression": ""
	    },
	    "www.google.mn": {
    		"m_Site": "www.google.mn",
	    	"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
		"www.google.ro": {
    		"m_Site": "www.google.ro",
	    	"m_InputCtlAttribValue": "q",
    		"m_InputCtlAttrib": "name",
	    	"m_ActionCtlAttribValue": "btnG",
    		"m_ActionCtlAttrib": "name",
	    	"m_XPathExpression": ""
    	},
		"www.baidu.com": {
		"m_Site": "www.baidu.com",
		"m_InputCtlAttribValue": "wd",
		"m_InputCtlAttrib": "name",
		"m_ActionCtlAttribValue": "%u767E%u5EA6%u4E00%u4E0B",
		"m_ActionCtlAttrib": "value"
	}
//#End Google
    };


}

function getSearchObjectFromLocation(doc)
{

	var locationHref = null;
	var searchObject = null;

	try
    {
        locationHref = doc.location.host;
    }
    catch(error)
    {
        //when host cannot be retrieved...happens when adding a tab
        return null;
    }

    if(locationHref == null)
    {
    	return null;
	}

	searchObject = supportedSites[locationHref];


	return searchObject;

}

function getInputAndButton(p_SearchObject)
{
	var ctls = null;

	if(p_SearchObject == null)
	{
		return;
	}

	ctls = findSearchControls(p_SearchObject.m_ActionCtlAttribValue, p_SearchObject.m_ActionCtlAttrib, p_SearchObject.m_InputCtlAttribValue, p_SearchObject.m_InputCtlAttrib);

  	return ctls;
}

function findSearchControls(p_SearchButtonAttrib, p_SearchButtonType, p_SearchInputAttrib, p_SearchInputType)
{
	var searchButton = null;
	var searchInput = null;
	var evaldCode = null;
	var ctls = null;

	if(p_SearchButtonType == "name")
	{
		var searchButtons = null;

		searchButtons = window.document.getElementsByName(p_SearchButtonAttrib);

		if(searchButtons == null || searchButtons.length < 1)
		{
			searchButton = null;
		}
		else
		{
			searchButton = searchButtons.item(0);
		}
	}
	else if(p_SearchButtonType == "id")
	{
		searchButton = window.document.getElementById(p_SearchButtonAttrib);

	}
	else if(p_SearchButtonType == "value")
	{
		searchButton = getElementByAttribute(p_SearchButtonAttrib);
	}
	else if(p_SearchButtonType == "formid")
	{
		var formElement = window.document.getElementById(p_SearchButtonAttrib);

		if(formElement == null)
		{
			searchButton = null;
			evaldCode = null;
		}
		else
		{
			searchButton = null;
			/* id of form and submit method call so frm.submit()...really ugly but necessary
			for those engines that are just too nasty and do some weird voodoo with js */
			evaldCode = "window.document.getElementById('" + p_SearchButtonAttrib + "').submit()";
		}
	}

	if(p_SearchInputType == "name")
	{
		var searchInputs = null;
		searchInputs = window.document.getElementsByName(p_SearchInputAttrib);

		if(searchInputs == null || searchInputs.length < 1)
		{
			searchInput = null;
		}
		else
		{
			searchInput = searchInputs.item(0);
		}
	}
	else if(p_SearchInputType == "id")
	{
		searchInput = window.document.getElementById(p_SearchInputAttrib);
	}
	else if(p_SearchInputType == "value")
	{
		searchButton = getElementByAttribute(p_SearchInputAttrib);
	}


	if(searchInput == null)
	{
		return null;
	}

	ctls = new Array();
	ctls[p_SearchButtonAttrib] = searchButton;
	ctls[p_SearchInputAttrib] = searchInput;

	if(evaldCode != null)
	{
		ctls[2] = evaldCode;
	}

	return ctls;

}

function getElementByAttribute(p_AttributeValue)
{
	var elementsList = null;
	var inputNode = null;
	var nodeAttributes = null;
	var attributeNode = null;

	/*for now, only search for input elements */
	elementsList = window.document.getElementsByTagName("input");

	if(elementsList == null || elementsList.length < 1)
	{
		return null;
	}

	for(i = 0; i < elementsList.length ; i++)
	{
		inputNode = elementsList.item(i);
		nodeAttributes = inputNode.attributes;

		for(j = 0; j < nodeAttributes.length; j++)
		{
			attributeNode = nodeAttributes.item(j);

			if(attributeNode.nodeValue != null && (attributeNode.nodeValue == p_AttributeValue || escape(attributeNode.nodeValue) == p_AttributeValue))
			{
				return inputNode;
			}
		}

	}

	return null;


}


function addToSearchBox(text1)
{
	var searchObject = null;
  	var ctls = null;


  	searchObject = getSearchObjectFromLocation(window.document);

  	ctls = getInputAndButton(searchObject);

  	if(ctls == null)
  	{
  		return;
	}


	var ctlInput = ctls[searchObject.m_InputCtlAttribValue];
  	var ctlButton = ctls[searchObject.m_ActionCtlAttribValue];

  	if(ctlInput != null)
  	{
  		ctlInput.value += text1;
  	}

	if(ctlButton != null)
	{
		setTimeout(function() {ctlButton.click();},250);
	}
	else if(ctls.length == 3)
	{
		//If there are 3 params, and the second param is null, then the third is an eval expression that
  		// contains the code needed to perform the search
  		//alaa note..this is current not used
		eval(ctls[2]);
	}
}

function lessParams()
{
  addToSearchBox(' -"' + window.getSelection().toString() + '"');
}

function moreParams()
{
  addToSearchBox(' "' + window.getSelection().toString() + '"');
}


function onDOMContentLoaded(p_Event)
{
    var searchObject = null;
    var doc = null;


    doc = document;

    //Make sure the current site is in the supported site list
    searchObject = getSearchObjectFromLocation(doc);


    if(searchObject != null)
    {
    	var myStylesString = "a.xippeeadslink:link {\
    							color: #0000ff;\
    							}\
    							a.xippeeadslink:visited {\
    							color: #ff0000;\
    							}\
    							a.xippeeadslink:hover {\
    							color: #00bc00;\
    							}\
    							"
		var mystyleElement = doc.createElement("style");
		var mystyleelementContent = doc.createTextNode(myStylesString);
		mystyleElement.appendChild(mystyleelementContent);

		var documentHead = doc.getElementsByTagName('head').item(0);
		documentHead.appendChild(mystyleElement);

        doc.addEventListener("mouseup", mouseUp, false);

        //insert main xippee div
        var mydivElement = doc.createElement("div");
        doc.body.insertBefore(mydivElement, doc.body.lastChild);




        mydivElement.setAttribute("id", "mydiv");
        mydivElement.setAttribute("align", "center");
        mydivElement.setAttribute("style", "background:url(http://www.xippee.com/classic/top.png) no-repeat 0px 0px;  position: absolute;z-index:9999; width:243px; border:solid 0px black; padding:0px; visibility: hidden");


        var innerdivElement = doc.createElement("div");
        innerdivElement.setAttribute("id", "inner");


        var closeImageElement = doc.createElement("img");
        closeImageElement.setAttribute("id", "closeimg");
        closeImageElement.setAttribute("class", "none");
        closeImageElement.setAttribute("src", "http://www.xippee.com/classic/close.png");
        closeImageElement.setAttribute("style", "float: right; margin-right: 10px; margin-top: 12px;");
        closeImageElement.setAttribute("alt", "close");
        closeImageElement.setAttribute("title", "Close this window");
        closeImageElement.setAttribute("onmouseup", "this.parentNode.parentNode.style.visibility=\"hidden\";return false;");


        var tableElement = doc.createElement("table");
        tableElement.setAttribute("cellpadding", "0px");
        tableElement.setAttribute("cellspacing", "0px");
        tableElement.setAttribute("align", "left");
        //some websites mess with the global table style
        tableElement.setAttribute("style", "width: 0px");

        var trElement = doc.createElement("tr");

        var tdPlusElement = doc.createElement("td");

        var tdMinusElement = doc.createElement("td");

        var tdLogoElement = doc.createElement("td");


        var anchorMoreElement = doc.createElement("a");
        anchorMoreElement.setAttribute("href", "#");
        anchorMoreElement.addEventListener("mousedown", moreParams, false);


        var moreImageElement = doc.createElement("img");
        moreImageElement.setAttribute("id", "hotimg");
        moreImageElement.setAttribute("style", "border: 0px none; padding-left: 0px; margin-left: 9px; margin-top: 10px; margin-right: 5px");
        moreImageElement.setAttribute("src", "http://www.xippee.com/classic/add-up.png");
        moreImageElement.setAttribute("onmouseover", "this.src = 'http://www.xippee.com/classic/add-down.png'");
        moreImageElement.setAttribute("onmouseout", "this.src = 'http://www.xippee.com/classic/add-up.png'");
        moreImageElement.setAttribute("alt", "See more results like this");



        var anchorLessElement = doc.createElement("a");
        anchorLessElement.setAttribute("href", "#");
        anchorLessElement.addEventListener("mousedown", lessParams, false);


        var lessImageElement = doc.createElement("img");
        lessImageElement.setAttribute("id", "coldimg");
        lessImageElement.setAttribute("style", "border: 0px none ; padding-left: 0px; margin-top: 10px;");
        lessImageElement.setAttribute("src", "http://www.xippee.com/classic/subtract-up.png");
        lessImageElement.setAttribute("onmouseover", "this.src = 'http://www.xippee.com/classic/subtract-down.png'");
        lessImageElement.setAttribute("onmouseout", "this.src = 'http://www.xippee.com/classic/subtract-up.png'");
        lessImageElement.setAttribute("alt", "See fewer of these kinds of results");

        var anchorLogoElement = doc.createElement("a");
        anchorLogoElement.setAttribute("href", "http://www.xippee.com");
        anchorLogoElement.setAttribute("target", "_blank");

        var logoImageElement = doc.createElement("img");
        logoImageElement.setAttribute("id", "xippeelogo");
        logoImageElement.setAttribute("src", "http://www.xippee.com/classic/logo.png");
        logoImageElement.setAttribute("onmouseover", "this.src = 'http://www.xippee.com/classic/logoRollover.png'");
        logoImageElement.setAttribute("onmouseout", "this.src = 'http://www.xippee.com/classic/logo.png'");
        logoImageElement.setAttribute("style", "border: 0px none; margin-left: 20px;");
        logoImageElement.setAttribute("alt", "Xipee Logo");



        mydivElement.appendChild(innerdivElement);
        innerdivElement.appendChild(closeImageElement);
        innerdivElement.appendChild(tableElement);

        tableElement.appendChild(trElement);

        trElement.appendChild(tdPlusElement);
        trElement.appendChild(tdMinusElement);
        trElement.appendChild(tdLogoElement);

        tdPlusElement.appendChild(anchorMoreElement);
        anchorMoreElement.appendChild(moreImageElement);

        tdMinusElement.appendChild(anchorLessElement);
        anchorLessElement.appendChild(lessImageElement);


        //add logo
        tdLogoElement.appendChild(anchorLogoElement);
        tdLogoElement.appendChild(doc.createElement("br"));
        anchorLogoElement.appendChild(logoImageElement);




var addthisRemoteJS = null;
            var addthisLocalJS = null;
            var addthisAnchor = null;
            var addthisImage = null;

            addthisRemoteJS = doc.createElement("script");
            addthisRemoteJS.src = "http://s7.addthis.com/js/152/addthis_widget.js";


            addthisAnchor = doc.createElement("a");
            addthisAnchor.setAttribute("href", "http://www.addthis.com/bookmark.php");
            addthisAnchor.setAttribute("onMouseOver", "return addthis_open(this, '', 'http://www.xippee.com', 'Xippee')");
            addthisAnchor.setAttribute("onMouseOut", "addthis_close()");
            addthisAnchor.setAttribute("onClick", "return addthis_sendto()");


            addthisImage = doc.createElement("img");
            addthisImage.setAttribute("id", "addthisthumb");
            addthisImage.setAttribute("src", "http://s9.addthis.com/button1-share.gif");
            addthisImage.setAttribute("width", "121");
            addthisImage.setAttribute("height", "16");
            addthisImage.setAttribute("border", "0");

            addthisLocalJS = doc.createElement("script");
            addthisLocalJS.text = "addthis_pub = 'rbunn83815'; addthis_logo_background = 'EFEFFF'; addthis_logo_color = '666699'; addthis_brand = 'Xippee'; addthis_options = 'email, digg, delicious, technorati, twitter, reddit';";

            addthisAnchor.appendChild(addthisImage);

            tdLogoElement.appendChild(addthisLocalJS);
            tdLogoElement.appendChild(addthisRemoteJS);
            tdLogoElement.appendChild(addthisAnchor);        var adsdivElement = doc.createElement("div");
        adsdivElement.setAttribute("id", "ads");
        adsdivElement.setAttribute("onmouseover", "var dlElement = document.getElementById(\"DL\"); if(dlElement != null){ dlElement.style.position=\"\"; dlElement.style.visibility=\"visible\"}");
        adsdivElement.setAttribute("onmouseout", "var dlElement = document.getElementById(\"DL\"); if(dlElement != null){ dlElement.style.position=\"absolute\"; dlElement.style.visibility=\"hidden\"}");
        adsdivElement.setAttribute("style", "background:url(\"http://www.xippee.com/classic/middle.png\"); border: 0px;display: block; font-size: 10pt; font-family: Arial; margin-top: 59px; padding-top: 10px; padding-bottom: 0px; padding-left: 25px; padding-right: 20px; text-align: justify;");


        var adsImageElement = doc.createElement("img");
        adsImageElement.setAttribute("id", "adsImg");
        adsImageElement.setAttribute("src", "");
        adsImageElement.setAttribute("style", "width:10px;height:0px;");

        var fontElement = doc.createElement("font");
        fontElement.setAttribute("id", "adsFont");
        fontElement.setAttribute("size", "1");
        fontElement.setAttribute("color", "gray");
        fontElement.innerHTML = "";

        var bottomdivElement = doc.createElement("div");
        bottomdivElement.setAttribute("style", "background:url(\"http://www.xippee.com/classic/bottom.png\"); border: 0px;display: block; font-size: 10pt; padding-bottom:7px;padding-top: 20px;padding-right: 15px;padding-left:10px");

        mydivElement.appendChild(adsdivElement);
        adsdivElement.appendChild(adsImageElement);
        adsdivElement.appendChild(fontElement);

        mydivElement.appendChild(bottomdivElement);

    } //end found supported site
}


function mouseUp(e)
{

    /*if(sgg==null)
    {
        sgg=setInterval("disabler()", 250);
    }*/

    var mydivElement = document.getElementById("mydiv");

    if(mydivElement != null)
    {
        mydivElement.style.visibility="hidden";
        var dlDivElement = document.getElementById("DL");
        if(dlDivElement != null)
        {
            dlDivElement.style.visibility = "hidden";
        }
    }

    //if we're pressing on a special image, just skip all this
    if(e.target instanceof HTMLImageElement)
    {
        var pressedImg = e.target;

        if(pressedImg.id == "hotimg" || pressedImg.id == "coldimg" || pressedImg.id == "closeimg" || pressedImg.id == "xippeelogo")
        {
            return;
        }

    }

    var selectedText = window.getSelection().toString();



    if(selectedText!="")
    {
        var mydivElement = document.getElementById("mydiv");
        if(mydivElement != null)
        {
			resetAds();

            mydivElement.style.position="absolute";


            var tempX = 0;
            var tempY = 0;
            var offset = 15;
            var myPageX=0;
            var myPageY=0;

            if(document.documentElement.scrollTop>0)
            {
                myPageX=document.documentElement.scrollLeft;
                myPageY=document.documentElement.scrollTop;
            }
            else if(document.body.scrollTop>0)
            {
                myPageX=document.body.scrollLeft;
                myPageY=document.body.scrollTop;
            }
            else if(window.pageYOffset>0)
            {
                myPageX=window.pageXOffset;
                myPageY=window.pageYOffset;
            }

            tempX = e.clientX + myPageX;
            tempY = e.clientY + myPageY;

            // step 4
            if (tempX < 0){tempX = 0}
            if (tempY < 0){tempY = 0}


            mydivElement.style.position = 'absolute';
            mydivElement.style.top = (tempY + offset) + 'px';

            mydivElement.style.left = (tempX + offset) + 'px';
            mydivElement.style.visibility = "visible";
			mydivElement.style.display = "block";

            var xippeeNotifyDiv = document.getElementById("xippeenotify");

            if(xippeeNotifyDiv != null)
            {
                xippeeNotifyDiv.style.display = "none";
            }

            var searchObject = getSearchObjectFromLocation(document);

            var ctls = getInputAndButton(searchObject);

            if(ctls == null)
            {
            	return;
			}

            var ctlInput = ctls[searchObject.m_InputCtlAttribValue];
            var ctlButton = ctls[searchObject.m_ActionCtlAttribValue];


            include_ads("http://opera.xippee.com/Default.aspx?searchCriteria=" + escape(ctlInput.value + " " + selectedText) + "&minCount=1&maxCount=4");


        } //end if mydiv not null

    } //end if selected

} //end mouseup


function include_ads(url)
{

    var adsScript = null;
    
    adsScript = document.createElement("script");
    adsScript.src = url;
    
    document.getElementsByTagName("head")[0].appendChild(adsScript);

}


function resetAds()
{
	var adsElement = document.getElementById("ads");

	if(adsElement == null)
	{
            //ads not displayed..return
            return;
        }

	var numChildren = adsElement.childNodes.length;

	for(i = 0; i < numChildren; i++)
	{
		adsElement.removeChild(adsElement.childNodes.item(0));
	}


    var fontElement = document.createElement("font");
    fontElement.setAttribute("id", "adsFont");
    fontElement.setAttribute("size", "1");
    fontElement.setAttribute("color", "gray");
    fontElement.innerHTML = "";

	adsElement.appendChild(fontElement);


}











populateSupportedSites();
window.addEventListener("DOMContentLoaded", onDOMContentLoaded, false);

