//-------------------------------------------------------------------------------------------------
//	These functions are for the content editor
//-------------------------------------------------------------------------------------------------

function InsertImageWindow()
{
	ShowMedia('image');
}
function InsertAudioWindow()
{
	ShowMedia('audio');
}





function ToolBar(toolbarId,textboxId)
{
	
	/*
		This is adapted from Wikipedia.org
		Made into a class
	*/
	
	var buttons = new Array();
	
	// this function generates the actual toolbar buttons with localized text
	// we use it to avoid creating the toolbar where javascript is not enabled
	this.addButton = function(imageFile, speedTip, tagOpen, tagClose, sampleText, attachFunction) {
		// Don't generate buttons for browsers which don't fully
		// support it.
		if (!attachFunction) var attachFunction = false;
		buttons[buttons.length] =
			{"imageFile": imageFile,
			 "speedTip": speedTip,
			 "tagOpen": tagOpen,
			 "tagClose": tagClose,
			 "sampleText": sampleText,
			 "attachFunction": attachFunction};
	}
	
	// this function generates the actual toolbar buttons with localized text
	// we use it to avoid creating the toolbar where javascript is not enabled
	mwInsertEditButton = function(parent, item) {
		var image = document.createElement('IMG');
		image.width = 16;
		image.height = 16;
		image.src = item.imageFile;
		image.border = 0;
		image.alt = item.speedTip;
		image.title = item.speedTip;
		image.style.cursor = "pointer";
		if (item.attachFunction != false) {
			image.onclick = item.attachFunction;	
		}
		else {
			image.onclick = function() {
				insertTags(item.tagOpen, item.tagClose, item.sampleText, textboxId);
				return false;
			}
		}
		parent.appendChild(image);
	}
	
	this.mwSetupToolbar = function() {
		var toolbar = xGetElementById(toolbarId);
		if (!toolbar) return false;
	
		var textbox = xGetElementById(textboxId);
		if (!textbox) return false;
		
		// Don't generate buttons for browsers which don't fully
		// support it.
		if (!document.selection && textbox.selectionStart == null)
			return false;
		
		for (var i=0;i<buttons.length;i++) {
			mwInsertEditButton(toolbar, buttons[i]);
		}
	}
	
}
