function RLSearchWidget(PartnerID, AffiliateID) {

    //function RLSearchWidget(PartnerID,AffiliateID,WidgetID) {
    //in javascript classes are made by creating functions.
    // seems like a hack to me
    //but it works 
    //RLSearchWidget is a class basically
    //create a new one in your page by using the new operator

    var BASE_URL = 'http://www.rocketlawyer.com/';
    var STYLESHEET = BASE_URL + "Default.css";
    
    var RocketLawyerPartnerID = PartnerID;

    var WidgetID = generateGuid();

    //need to get the protocol used, it should either be http: or https:
    //replace all occurances below of http: with '+protocol+'
    
    
    var protocol = location.protocol;

    //in case someone is testing on a local file, not a web server
    if (protocol == 'file:')
        protocol = 'http:';
    //alert(protocol);
    
    this.show = function(){
        WriteControl();
    }
    this.hide = function() {       
        //alert("hide");
        //var div = document.getElementById(WidgetID);
        //if (div != null)
        //    div.style.visibility = "hidden";
    }
    //is the below code ever called now?
    this.serverResponse = function(data) {
    if (!data) return;
        var div = document.getElementById(WidgetID);
        var txt = '';
        for (var i = 0; i < data.length; i++) {
            if (txt.length > 0) { txt += ", "; }
            txt += data[i];
        }
        div.innerHTML = "<strong>Names:</strong> " + txt;  // assign new HTML into #ROOT
        div.style.display = 'block'; // make element visible
    }

    function generateGuid() {
        var result, i, j;
        result = '';
        for (j = 0; j < 32; j++) {
            //if (j == 8 || j == 12 || j == 16 || j == 20)
            //    result = result + '-';
            i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
            result = result + i;
        }
        return result
    } 
    
/////////////////////////////////////

//keep these functions here for reference. they are not used, the actual functions called by the widget object are written in writecontrol()
    function RocketLawyerSearch(searchBoxID) {
        try {
            var textBox = document.getElementById(searchBoxID);
            var searchQuery = textBox.value.replace(/^\s+|\s+$/g, '');
            var url = 'http://' + RocketLawyerDomain + '/search.aspx?partner=' + RocketLawyerPartnerID;
            url += '&searchArea=' + RocketLawyerSearchArea + '&query=' + escape(searchQuery);
            if (searchQuery.length <= 0) textBox.focus();
            else window.location.href = url;
        } catch (e) {
            alert(e.message);
        } finally {
            return false;
        }
    }

    function CheckEnterKey(textBox, evt) {
        try {
            evt = evt ? evt : window.event;
            if (evt.keyCode == 13) return RocketLawyerSearch(textBox.id);
        } catch (e) { ; }
    }
///////////////////
    function WriteControl() {
        document.write("<div id='" + WidgetID + "' style='display: none'></div>");
        //write vars
        document.write('<script>\r\nvar RocketLawyerPartnerID' + WidgetID + ' = \'' + PartnerID + '\';\r\nvar RocketLawyerAffiliateID' + WidgetID + ' = \'' + AffiliateID + '\';\r\nvar RocketLawyerSearchArea = 0;\r\nvar RocketLawyerDomain = \'www.rocketlawyer.com\';\r\n');
        //write search function
        if ((PartnerID != null) && (PartnerID != "")) {
            document.write('function RocketLawyerSearch' + WidgetID + '(searchBoxID) {\r\ntry {\r\nvar textBox = document.getElementById(searchBoxID);\r\nvar searchQuery = textBox.value.replace(/^\\s+|\\s+$/g, \'\');\r\nvar url = \'http://\' + RocketLawyerDomain + \'/search.aspx?partner=\' + RocketLawyerPartnerID' + WidgetID + ';\r\nurl += \'&searchArea=\' + RocketLawyerSearchArea + \'&query=\' + escape(searchQuery)+\'&affiliate=\'+RocketLawyerAffiliateID' + WidgetID + ';\r\nif (searchQuery.length <= 0) textBox.focus();\r\nelse window.location.href = url;\r\n} catch (e) { \r\nalert(e.message);\r\n}\r\n finally {\r\nreturn false;\r\n}\r\n}');
            // write checkenterkeyfunction
            document.write('function CheckEnterKey' + WidgetID + '(textBox, evt) {\r\ntry {\r\nevt = evt ? evt : window.event;\r\nif (evt.keyCode == 13) return RocketLawyerSearch' + WidgetID + '(textBox.id);\r\n} catch (e) { ; }\r\n}</script>');
            //write html
            document.write('<TABLE borderColor=#003399 height=250 cellSpacing=0 cellPadding=0 width=250 align=center bgColor=#ffffff border=1>\r\n<TBODY>\r\n<TR>\r\n<TD>\r\n<TABLE cellPadding=1 width="100%" border=0>\r\n<TBODY>\r\n<TR>\r\n<TD>\r\n<DIV align=center><FONT face="Arial, Helvetica, sans-serif" color=#003399 size=4><STRONG>Expert Legal<BR>Document Service</STRONG></FONT></DIV></TD></TR>\r\n<TR>\r\n<TD vAlign=top align=right background=' + protocol + '//www.rocketlawyer.com/images/search_forms_widget_BG.jpg height=163>\r\n<DIV align=right>\r\n<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>\r\n<TBODY>\r\n<TR>\r\n<TD align=left><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#009933 size=2>Create your own legal <BR>documents online.<BR><BR>Plus, expert legal<BR>help </FONT></STRONG><FONT size=2><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#009933>when you <BR>need it.</FONT></STRONG></FONT><STRONG><FONT face="Arial, Helvetica, sans-serif" size=3><BR><BR></FONT></STRONG><FONT size=2><A title="Browse Personal Legal Documents" href="http://www.rocketlawyer.com/legal-forms-personal.aspx?&Partner=' + PartnerID + '&Affiliate=' + AffiliateID + '"><FONT face="Arial, Helvetica, sans-serif" color=#0000ff><STRONG>Personal Legal Forms </STRONG></FONT></A><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#0000ff><BR><A title="Browse Business Legal Documents" href="http://www.rocketlawyer.com/legal-forms-business.aspx?&Partner=' + PartnerID + '&Affiliate=' + AffiliateID + '">Business Legal Forms</A></FONT></STRONG></FONT>\r\n<P></P></TD></TR></TBODY></TABLE></DIV></TD></TR>\r\n<TR>\r\n<TD vAlign=center height=26>\r\n<TABLE cellSpacing=0 cellPadding=0 width=234 align=center border=0>\r\n<TBODY>\r\n<TR>\r\n<TD><FONT face="Arial, Helvetica, sans-serif" color=#009933 size=2>Search:</FONT>&nbsp;</TD>\r\n<TD><INPUT onkeypress="return CheckEnterKey' + WidgetID + '(this, event);" id=' + WidgetID + 'SearchWidgetBox size=22 name=text></TD>\r\n<TD class=btn vAlign=center align=middle style="vertical-align: middle;"><A onclick="return RocketLawyerSearch' + WidgetID + '(\'' + WidgetID + 'SearchWidgetBox\');" href="#"><IMG id=' + WidgetID + 'Image8 title="Search legal documents" height=24 alt="Search legal documents" src="' + protocol + '//www.rocketlawyer.com/images/search_forms_widget_btn_GO.gif" width=23 vAlign=center align=middle style="vertical-align: middle;" border=0 name=' + WidgetID + 'Image8></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>\r\n\r\n\r\n');
        }
        else {
            document.write('function RocketLawyerSearch' + WidgetID + '(searchBoxID) {\r\ntry {\r\nvar textBox = document.getElementById(searchBoxID);\r\nvar searchQuery = textBox.value.replace(/^\\s+|\\s+$/g, \'\');\r\nvar url = \'http://\' + RocketLawyerDomain + \'/search.aspx?\';\r\nurl += \'&searchArea=\' + RocketLawyerSearchArea + \'&query=\' + escape(searchQuery)+\'&affiliate=\'+RocketLawyerAffiliateID' + WidgetID + ';\r\nif (searchQuery.length <= 0) textBox.focus();\r\nelse window.location.href = url;\r\n} catch (e) { \r\nalert(e.message);\r\n}\r\n finally {\r\nreturn false;\r\n}\r\n}');
            // write checkenterkeyfunction
            document.write('function CheckEnterKey' + WidgetID + '(textBox, evt) {\r\ntry {\r\nevt = evt ? evt : window.event;\r\nif (evt.keyCode == 13) return RocketLawyerSearch' + WidgetID + '(textBox.id);\r\n} catch (e) { ; }\r\n}</script>');
            //write html
            document.write('<TABLE borderColor=#003399 height=250 cellSpacing=0 cellPadding=0 width=250 align=center bgColor=#ffffff border=1>\r\n<TBODY>\r\n<TR>\r\n<TD>\r\n<TABLE cellPadding=1 width="100%" border=0>\r\n<TBODY>\r\n<TR>\r\n<TD>\r\n<DIV align=center><FONT face="Arial, Helvetica, sans-serif" color=#003399 size=4><STRONG>Expert Legal<BR>Document Service</STRONG></FONT></DIV></TD></TR>\r\n<TR>\r\n<TD vAlign=top align=right background=' + protocol + '//www.rocketlawyer.com/images/search_forms_widget_BG.jpg height=163>\r\n<DIV align=right>\r\n<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>\r\n<TBODY>\r\n<TR>\r\n<TD align=left><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#009933 size=2>Create your own legal <BR>documents online.<BR><BR>Plus, expert legal<BR>help </FONT></STRONG><FONT size=2><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#009933>when you <BR>need it.</FONT></STRONG></FONT><STRONG><FONT face="Arial, Helvetica, sans-serif" size=3><BR><BR></FONT></STRONG><FONT size=2><A title="Browse Personal Legal Documents" href="http://www.rocketlawyer.com/legal-forms-personal.aspx?&Affiliate=' + AffiliateID + '"><FONT face="Arial, Helvetica, sans-serif" color=#0000ff><STRONG>Personal Legal Forms </STRONG></FONT></A><STRONG><FONT face="Arial, Helvetica, sans-serif" color=#0000ff><BR><A title="Browse Business Legal Documents" href="http://www.rocketlawyer.com/legal-forms-business.aspx?&Affiliate=' + AffiliateID + '">Business Legal Forms</A></FONT></STRONG></FONT>\r\n<P></P></TD></TR></TBODY></TABLE></DIV></TD></TR>\r\n<TR>\r\n<TD vAlign=center height=26>\r\n<TABLE cellSpacing=0 cellPadding=0 width=234 align=center border=0>\r\n<TBODY>\r\n<TR>\r\n<TD><FONT face="Arial, Helvetica, sans-serif" color=#009933 size=2>Search:</FONT>&nbsp;</TD>\r\n<TD><INPUT onkeypress="return CheckEnterKey' + WidgetID + '(this, event);" id=' + WidgetID + 'SearchWidgetBox size=22 name=text></TD>\r\n<TD class=btn vAlign=center align=middle style="vertical-align: middle;"><A onclick="return RocketLawyerSearch' + WidgetID + '(\'' + WidgetID + 'SearchWidgetBox\');" href="#"><IMG id=' + WidgetID + 'Image8 title="Search legal documents" height=24 alt="Search legal documents" src="' + protocol + '//www.rocketlawyer.com/images/search_forms_widget_btn_GO.gif" width=23 vAlign=center align=middle style="vertical-align: middle;" border=0 name=' + WidgetID + 'Image8></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>\r\n\r\n\r\n');
        }
        
    }
    //moved WriteControl to the show public method.
    //WriteControl();
}
