/**
* @author gerardo.lopez
* @author rodrigo.bartels
* @author wendy.espinoza
*/

/*
Ext.ux.clv2.SimpleSearchPanelLO = function(config) {
	// call parent constructor
	Ext.ux.clv2.SimpleSearchPanelLO.superclass.constructor.call(this, config);
}; // end of Ext.ux.clv2.SimpleSearchPanelContainer constructor
Ext.extend(Ext.ux.clv2.SimpleSearchPanelLO, Ext.Panel, {
	bodyStyle: 'padding:15px',
	width:530,
	height:400,
	autoScroll:true,
	defaults: {
		// applied to each contained panel
		border: false
	}
});
*/

var showContentPreview = function(typeLO, titleLO, objectId){
	var previewPanel;
	//------------------------------------------------------------
	// Card selector & card panel
	//------------------------------------------------------------
	
	switch(typeLO){
		case 'HTML_XHTML':/*
			previewPanel = new Ext.Panel({
				border: false,
				items: {
					border: false,
					xtype: 'iframepanel',
					defaultSrc: 'content.spr?learningObjectId='+objectId
					//,height: Ext.isIE6 ? 401 : 400
				}
			});*/
			previewPanel = {
				border: false,
				xtype: 'iframepanel',
				defaultSrc: 'content.spr?learningObjectId='+objectId
				//,height: 387
			};
		break;
		case 'SHOWCKWAVE_FLASH': case 'FLASH_VIDEO':
			previewPanel = new Ext.Panel({
				border: false,
				autoLoad: {url: 'getBinaryLOContent.spr', params: {id: objectId, editMode:false, type:'multimediaLOContent',
					versionNumber:-1
				}}
			});
		break;
		case 'JPEG': case 'GIF': case 'BMP': case 'PNG':
			previewPanel = new Ext.Panel({
				border: false,
				autoLoad: {url: 'getBinaryLOContent.spr', params: {id: objectId, editMode:false, type:'imageLOContent',
					width:'', height:'', versionNumber:-1, draft:false
				}}
			});
		break;
		default:
			previewPanel = new Ext.Panel({
				border: false,
				autoLoad: {url: 'getBinaryLOContent.spr', params: {id: objectId, editMode:false, type:'binaryLOContent',
					versionNumber:-1
				}}
			});
		break;
	}
	
	var cardPanel = new Ext.Panel({
		items: [previewPanel]
	});
	
	//------------------------------------------------------------
	// Toolbar
	//------------------------------------------------------------
	var ttbLO = new Ext.ux.clv2.LOSimpleSToolbarView({
		titleText: 'View'
	});
	
	//------------------------------------------------------------
	// WINDOW
	//------------------------------------------------------------
	if (winLO = Ext.getCmp('content-preview-window')) winLO.close();
	var windowLO = new Ext.Window({
		id: 'content-preview-window',
		title: titleLO,
		tbar: ttbLO,
		items: [previewPanel],
		cls: 'clv2-window',
		//height: 440,
		//width: 560,
		constrainHeader: true,
		hideSpotlight: hideSpotlight,
		showSpotlight: showSpotlight,
		afterShowWindow: function(win){
			this.setSize(560,440);
		},
		afterResizeWindow: function(win, width, height){
			this.items.items[0].setHeight(this.getSize().height-this.getFrameHeight());
			return;
		}
	});
	windowLO.on("show", windowLO.afterShowWindow, windowLO);
	windowLO.on('beforeclose', windowLO.hideSpotlight, windowLO);
	windowLO.on('beforehide', windowLO.hideSpotlight, windowLO);
	windowLO.on('beforeshow', windowLO.showSpotlight, windowLO);
	windowLO.on('collapse', windowLO.showSpotlight, windowLO);
	windowLO.on('move', windowLO.showSpotlight, windowLO);
	windowLO.on('resize', windowLO.showSpotlight, windowLO);
	windowLO.on('resize', windowLO.afterResizeWindow, windowLO);
	if(Ext.isIE) windowLO.show(); else windowLO.show(this);
};

/*
// Horizontal ToolBar: Used for image buttons
Ext.ux.clv2.HorizontalToolbar = function(config) {
	Ext.ux.clv2.HorizontalToolbar.superclass.constructor.call(this, config);
};
(function(){
	var HT = Ext.ux.clv2.HorizontalToolbar;
	Ext.extend(HT, Ext.Toolbar, {

		changeItemPressed : function(item){
			if(this.currentPressed){
				if(this.currentPressed != item){
					this.currentPressed.el.removeClass("x-btn-pressed");
					this.currentPressed.pressed = false;
				}
			}else{
				if(this.items && this.items.items){
					for(var i=0; i < this.items.items.length; i++){
						if(this.items.items[i].pressed && this.items.items[i] != item){
							this.items.items[i].el.removeClass("x-btn-pressed");
							this.items.items[i].pressed = false;
						}
					}
				}
			}
			this.currentPressed = item;
		},

		togglePressState : function(item){
			if(!item.pressed){
				item.el.addClass("x-btn-pressed");
				item.pressed = true;
			}else{
				item.el.removeClass("x-btn-pressed");
				item.pressed = false;
			}
		}
	});
	Ext.reg('HorizontalToolbar', Ext.ux.clv2.HorizontalToolbar);
})();
*/

Ext.ux.clv2.LOSimpleSToolbarView = function(config) {
	// call parent constructor
	Ext.ux.clv2.LOSimpleSToolbarView.superclass.constructor.call(this, config);
}; // end of Ext.ux.clv2.LOToolbarView constructor
(function(){var LOTTB = Ext.ux.clv2.LOSimpleSToolbarView;
Ext.extend(LOTTB, Ext.Toolbar, {
	cls: 'lo-preview-panel-simple-search',
	titleText: 'TITLE',
	height: 26,
	listeners: {
		render: function(tb){
			tb.initializeItems();
		}
	},
	initializeItems: function(){
        this.titleLb = new Ext.form.Label({
			text: this.titleText //'VIEW'
		});

		var rating = new Ext.Panel({
			cls: 'star-panel',
			border: false,
			header: false,
			height: 12
		});
		
		this.addFillTitle();
		this.add(rating);
		this.setTitle();
	},
	addFillTitle: function(){
		return this.addItem(new LOTTB.FillTitle());
	},
	getTitle: function(){
		return this.titleText;
	},
	setTitle: function(title){
		if(typeof title == 'string') this.titleText = title;
		LOTTB.Title.prototype.setTitle(this.titleText);
	}
});
LOTTB.Title = function(){
	this.constructor.superclass.id = 'lo-ttbar-title';
	var s = document.createElement("div");
	s.id = this.constructor.superclass.id;
	s.className = 'ttbar-title-text';
	s.innerHTML = LOTTB.prototype.getTitle();
	LOTTB.Title.superclass.constructor.call(this, s);
};

Ext.extend(LOTTB.Title, Ext.Toolbar.Item, {
	enable:Ext.emptyFn,
	disable:Ext.emptyFn,
	focus:Ext.emptyFn,
	setTitle: function(title){
		var s = Ext.getDom(this.id);
		s.innerHTML = title;
	}
});
Ext.reg('lottbtitleLO', LOTTB.Title);

LOTTB.FillTitle = Ext.extend(LOTTB.Title, {
	render : function(td){
		td.style.width = '100%';
		LOTTB.FillTitle.superclass.render.call(this, td);
	}
});
Ext.reg('lottbfilltitleLO', LOTTB.FillTitle);
})();
