// Base
var My = {

	id : function(id) { return document.getElementById(id); },

	setHomepage : function () {
        try {
                document.body.style.behavior='url(#default#homepage)';
				document.body.setHomePage(document.URL);
        } catch(e) {
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        } catch(e)  {
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入\"about:config\"并回车\n然后将 [signed.applets.codebase_principal_support]设置为'true'");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',document.URL);
                 }
        }
	},

	addFavorite : function() {
		try {
			window.external.addFavorite(document.URL, document.title);
		}
		catch(e) {
			try {
				window.sidebar.addPanel(document.title, document.URL, "");
			} catch(e) {
				alert("加入收藏失败，请使用Ctrl+D进行添加");
			}
		}
	},

	swf : function(body, swf, width, height, quality, wmode) {
		if(swf == '') {
			return false;
		}
		var width = width || 320;
		var height = height || 200;
		var quality = quality || 'high';
		var wmode = wmode || 'opaque';
		var content = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width +'" height="' + height + '">' + 
			'<param name="allowScriptAccess" value="sameDomain">' + 
			'<param name="movie" value="' + swf + '">' + 
			'<param name="quality" value="' + quality + '">' + 
			'<param name="bgcolor" value="#FFFFFF">' + 
			'<param name="menu" value="false">' + 
			'<param name=wmode value="' + wmode + '">' + 
			'<embed src="' + swf + '" wmode="' + wmode + '" menu="false" bgcolor="#FFFFFF" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' + 
			'</object>';
		var swfBody = document.getElementById(body);
		if(swfBody) {
			swfBody.innerHTML = content;
		} else {
			alert('找不到SWF容器: [ ' + body + ' ]!');
		}
	},
	
	focusTo : function(body, data, width, height, txtHeight, borderWidth, borderHeight, swf) {
		var swf = swf || "fla/focus.swf";
		var width = width || 400;
		var height = height || 300;
		var txtHeight = txtHeight || 0;
		var swfHeight = height + txtHeight;
		var borderWidth = borderWidth || width;
		var borderHeight = borderHeight || height;
		var content = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width +'" height="' + swfHeight + '">' + 
			'<param name="allowScriptAccess" value="sameDomain">' + 
			'<param name="movie" value="' + swf + '">' + 
			'<param name="quality" value="high">' + 
			'<param name="bgcolor" value="#FFFFFF">' + 
			'<param name="menu" value="false">' + 
			'<param name=wmode value="opaque">' + 
			'<param name="FlashVars" value="pics=' + data[0] + '&links=' + data[1] + '&texts=' + data[2] + '&borderwidth=' + borderWidth + '&borderheight=' + borderHeight + '&textheight=' + txtHeight + '">' + 
			'<embed src="' + swf + '" wmode="opaque" FlashVars="pics=' + data[0] + '&links=' + data[1] + '&texts=' + data[2] + '&borderwidth=' + borderWidth + '&borderheight=' + borderHeight + '&textheight=' + txtHeight + '" menu="false" bgcolor="#FFFFFF" quality="high" width="'+ width +'" height="'+ swfHeight +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' + 
			'</object>';
		var swfBody = document.getElementById(body);
		if(swfBody) {
			swfBody.innerHTML = content;
		} else {
			alert('找不到SWF容器: [ ' + body + ' ]!');
		}
	}

}



