
//-- BEGIN: object fwpObject
function fwpObject()
{
	// type to look for mwsToolbar or HtmlMenu
	this.type = "";
	// the DOM object created by the embed or object tags
	this.ctlObj = null;
	this.tagHTML = "";
	// activeX support?
	this.activeX	  = false;
	// is the toolbar presnt
	this.present 	  = false;
	this.installedMWS = false;
	this.installedFWB = false;
	// attributes for object or embed tags
	this.tagID          = "";
	this.classid        = "";
	this.mimeType       = "";
	this.activeXobjName = "";
	this.progID         = "";
	
	// info returned from request
	this.UID        = "";
	this.partner    = "";
	this.versionStr = "";
	this.parent     = "";
	this.child      = "";
	this.bucket     = "";
	this.partnerStr = "";
}
//end function fwpObject

//-- BEGIN: methods for fwpObject
fwpObject.prototype = {
	initialize: function(type){
		this.type = type;
		if ( type == "HtmlMenu" ){
			this.tagID          = "HtmlMenuCtl";
			this.classid        = "3DC201FB-E9C9-499C-A11F-23C360D7C3F8";
			this.mimeType       = "application/x-mws-mywebsearchplugin";
			this.activeXobjName = "FunWebProducts.HTMLMenu";
			this.progID         = "FunWebProducts.HTMLMenu";
		} else {
			this.tagID          = "ToolbarCtlMWS";
			this.classid        = "07B18EAB-A523-4961-B6BB-170DE4475CCA";
			this.mimeType       = "application/x-mws-mywebsearchplugin";
			this.activeXobjName = "MyWebSearchToolBar.SettingsPlugin";
			this.progID         = "MyWebSearchToolBar.SettingsPlugin";
		}//end if
	},
	
	infoToString: function(){
		var infoStr = "HOST: " + window.location.hostname + "<br>\n" +
					  "type = " + this.type + "<br>\n" +
					  "activeXObjName = " + this.activeXobjName + "<br>\n" +
					  "versionStr = " + this.versionStr + "<br>\n" +
					  "UID = " + this.UID + "<br>\n" +
					  "partner = " + this.partner + "<br>\n" +
					  "parent = " + this.parent + "<br>\n" +
					  "child = " + this.child + "<br>\n" +
					  "bucket = " + this.bucket + "<br>\n" +
					  "partnerStr = " + this.partnerStr + "<br>\n" +
					  "present = " + this.present + "<br>\n" +
					  "ctlObj = " + this.ctlObj + "<br>\n" +
					  "activeX = " + this.activeX + "<br>\n" +
					  "installedMWS = " + this.installedMWS + "<br>\n" +
					  "installedFWB = " + this.installedFWB + "<br>\n";
		return(infoStr);
	},
	
	getInfo: function(){
		this.getVersion();
		this.getPartner();
		this.getUID();
		this.getParentChild();
		this.bucket = ( typeof(this.partner) == "string" && this.partner.length > 9 ) ? this.partner.substr(8,2) : "";
	},
	
	getVersion: function(){
		try {
			this.versionStr = this.ctlObj.GetVersion('');
		} catch(e) {}
	},
	
	getPartner: function(){
		try {
			if ( this.ctlObj.P ){
				this.partner = this.ctlObj.P;
			}//end if
		} catch(e) {}
	},
	
	getParentChild: function(){
		if ( typeof(this.partner) == "string" ){
			if ( this.partner.indexOf("_") > -1 ){
				this.child  = this.partner.split("_")[0];
				this.parent = this.partner.split("_")[1];
			} else {
				this.child  = "";
				this.parent = this.partner;
			}//end if
		}//end if
	},
	
	getUID: function(){
		if ( this.type == "HtmlMenu" ){
			try {
				this.UID = this.ctlObj.GetUID('http://www.funwebproducts.com/');
			} catch(e) {}
		} else {
			try {
				this.UID = this.ctlObj.I;
			} catch(e) {}
		}//end if
	},
	
	createPartnerStr: function(zebValue){
		if ( !zebValue ){ return; }
		if ( this.parent.length < 1 ){
			this.partnerStr = zebValue;
		} else {
			this.partnerStr = zebValue + "_" + this.parent;
		}//end if
	},
	
	detect: function(){
		//are we in IE or something else??
		if ( window.ActiveXObject ){
			this.findActiveX();
			this.getObjTag();
			document.write(this.tagHTML);
			this.activeX = true;
			this.installedMWS = true;
		} else {
			this.findPlugin();
			this.getEmbedTag();
			document.write(this.tagHTML);
			this.activeX = false;
		}//end if
		
		this.ctlObj = document.getElementById(this.tagID);
		
		if ( this.installedMWS ){
			if ( this.ctlObj.Type != 1 ) {
				this.installedFWB = true;
			}//end if
		}//end if
		
		if ( this.installedMWS || this.installedFWB ){
			this.present = true;
		}//end if
	},
	
	findActiveX: function(){
		new ActiveXObject(this.activeXobjName);
	},
	
	findPlugin: function(){
		var pMimeType = this.mimeType;
		navigator.plugins.refresh(false);
		var numPlugins = navigator.plugins.length;
		for (var i = 0; i < numPlugins; i++) {
			var plugin = navigator.plugins[i];
			var numTypes = plugin.length;
	        var mType;
	        var enabled;
	        var enabledPlugin;
	        for (var j = 0; j < numTypes; j++) {
	            mType = plugin[j];
	            if ( mType ) {
	                if ( mType.type == pMimeType ) {
	                	this.installedMWS = true;
						return;
	                }//end if
	            }//end if
	        }//end for
		}//end for
		//this.installedMWS = true;
	},
	
	getEmbedTag: function(){
		var html = "<embed id=\"" + this.tagID + "\"" +
				   " type=\"" + this.mimeType + "\"" +
				   " ProgId=\"" + this.activeXobjName + "\"" +
				   " width=\"1\"" +
				   " height=\"1\"" +
				   " >&nbsp;</embed>";
		this.tagHTML = html;
	},

	getObjTag: function(){
		var html = "<object id=\"" + this.tagID + "\"" +
				   " classid=\"clsid:" + this.classid + "\"" +
				   " width=\"1\"" +
				   " height=\"1\"" +
				   " >&nbsp;</object>";
		this.tagHTML = html;
	}
	
};
//-- END: method for fwpObject