var widget = {
    __proto__ : widgetbase,    //make this object 'extends' widgetbase
    isMovingContent : false,
    isMovingWindow : false,
    isResizing : false,
    moveStartPos : {x : 0,y : 0},
    defaultView : null,
    reloader : null,
    reloadInterval : 20000,
    titlebarMinWidth : 160,
    width : 300,
    height :325,
    heightIncrement :31,
	overflowTimer : null,
    //heightWithPlaylist :700,
	init : function() {
		var args = window.arguments[0];
		if (args.widgetArgs == null){
			args.widgetArgs = {
				docked: false
			};
		}
		if (args.widgetArgs.docked == null){
			args.widgetArgs.docked = false;
		}
		this.__proto__.init.apply(this);
		document.getElementById("player_browser").setAttribute('src', args.widgetArgs.location);
	},
	
	initBrowser: function(){
		this.__proto__.initBrowser.apply(this);
	},
	
	reportClick : function(link){
		var req = new XMLHttpRequest();  
		req.open('GET', 'http://www.g-fox.cn/livemargins/reportAppLink.html?value='+encodeURIComponent(link), true);   
		req.send(null);  
	},
	
	returnURL : function(ev){
		var browser = document.getElementById("player_browser");
		var frame = browser.contentDocument.getElementById("contentFrame");
		const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                         .getService(Components.interfaces.nsIWindowMediator);
		var mainWin = wm.getMostRecentWindow( "navigator:browser" );
		if (mainWin) {
			mainWin.focus();
			var gBrowser = mainWin.getBrowser();
			if (frame){ // there is a possibility that the webpage break out of the frame
				gBrowser.selectedTab = gBrowser.addTab(frame.getAttribute("src"));
			} else {
				gBrowser.selectedTab = gBrowser.addTab(browser.contentDocument.URL);
			}
		} else {
			window.open(frame.getAttribute("src"));
		}
	},
	
	reload : function() {
		var browser = document.getElementById("player_browser");
		var frame = browser.contentDocument.getElementById("contentFrame");
		if (frame){
			frame.contentDocument.defaultView.location = frame.contentDocument.defaultView.location.toString();
			frame.contentDocument.defaultView.location.reload();
		} else {
			browser.reload();
		}
	},
	
    LOG : function(msg) {
        this.__proto__.LOG.apply(this,["favpart taobao player: "+ msg]);
    },
    
    logger: utils.logger('LM4.Webapp'),
    
    openLinkInTab : function(){
        this.__proto__.openLinkInTab.apply(this,[true]);
    },
    
    getIcon : function(){
        return "chrome://livemargins/skin/taobao-icon.png";
    }
};
    
window.addEventListener("load", function() {
	widget.init();
}, false);

