// JavaScript Document

	var alert = new Function("m","getAlert(m);");
	var defaultWidth = '300';
	var defaultHeight = '100';
	
	/*
		Possible Message Types: [error,information,help,warning]
	*/
	function getAlert(m) {
		/* Setting up the default values */
		var msgText = '';
		var msgTitle = '';
		var msgWidth = defaultWidth;
		var msgHeight = defaultHeight;
		var msgNoclose = false;
		var msgType = 'information';
		var msgButtons = '<input id="CitboxAlertBtnOk" type="submit" value="OK" onclick="Citbox.close();"/>'
		
		if (typeof(m) == 'object') {
			msgText = m.msgText;
			
			msgTitle = ((m.msgTitle == undefined) || (m.msgTitle == null)) ? msgTitle : m.msgTitle;
			msgWidth = ((m.width == undefined) || (m.width == null)) ? defaultWidth : m.width;
			msgHeight = ((m.height == undefined) || (m.height == null)) ? msgHeight : m.height;
			msgNoclose = ((m.noclose == undefined) || (m.noclose == null)) ? msgNoclose : m.noclose;
			
			/* Configuring the buttons */
			if ((m.buttons != undefined) && (m.buttons != null) && (m.buttons != '')) {
				if ((typeof(m.buttons) == 'object') && (m.buttons.length > 0)) {
					msgButtons = '';
					for (var i=0; i<m.buttons.length; i++ ){
						msgButtons += '<input id="CitboxAlertBtn'+m.buttons[i][0]+'" type="submit" value="'+m.buttons[i][0]+'" onclick="'+m.buttons[i][1]+'"/>';
					}
				} else 
				if (typeof(m.buttons) == 'string') {
					msgButtons = m.buttons;
				}
			}
			
			var msgTypes = /(error|information|warning|help)/g;
			if (String(m.msgType).match(msgTypes)) {
				msgType = m.msgType;
			}
		} else {
			msgText = m;
		}
		
		/* Structuring the div container */
		var divAlert = '<div id="divAlertCitbox" class="'+msgType+'">';
		divAlert += (msgTitle == '') ? '' : '<h2>'+msgTitle+'</h2>';
		divAlert += '<p>'+msgText+'</p>';
		divAlert += (!msgNoclose) ? '' : '<div class="buttons">'+msgButtons+'</div>';
		divAlert += '</div>';
		
		/* Calling the Citbox engine */
		Citbox.show(divAlert,'','width='+msgWidth+', height='+msgHeight+', noclose=true, type=text','alert');
		
//		document.getElementById('ububu').innerHTML = 'Message: '+msgText+'<br />Type: '+msgType;
	}

