function displayMocastDialog(div, mouse_x, mouse_y){
	//var div = document.getElementById(id);	
	//showDiv(id);//need to show div for the ElementDimensions function to work
	document.body.appendChild(div);
	div.style.position = "absolute"; //needs to go before ElementDimension for some reason.
	pos = new ElementDimensions(div);	

	var x = 0;
	if(mouse_x != null){
		x = mouse_x - (pos.outer.width/2);
		div.style.left = x+'px';
	}
	var y = 0;
	if(mouse_y != null){
		y = mouse_y - (pos.outer.height/2);
		div.style.top = y+'px';	
	}	
}


function textDialog(content){
	var div = createIEElement('div', new Array(), new Array( ));
	div.addText(content);
	showDialog(div, true, true);
}

/*
	showMocastDialog
	This displays the dialog fromt he output class in the system.
	Uses a fade in animation and has a light box effect
	
	@param string id: the id of the dialog
	@param boolean animate: a toggle to use the display animation or not.
	The display animation is quite intensive when used with other javascript processes.
	Defaults to true
	
*/
function showDialog(content, animate, close_button){
		var sizes = getCentreOfClientView();
		if(blank(animate)){
			animate = true;	
		}
		
		if(blank(animate)){
			close_button = true;	
		}
		
		//hide all select inputs if IE6
		if(dickyBrowser( )){
			var sels = document.getElementsByTagName('select');
			alert(sels.length);
			for(i=0; i<sels.length; i++){
				sels[i].style.display = "none";
			}
		}
		
		var gg = getGuid( );
		
		var div_holder = createIEElement('div', new Array('class', 'id'), new Array('dialog_holder', gg));
		var div = createIEElement('div', new Array('class'), new Array('dialog'));
		var title = createIEElement('div', new Array('class'), new Array('title'));
		title.addText('Kirra Holidays');
		div.appendChild(title);
		var inner_div = createIEElement('div', new Array('class'), new Array('dialog_inner')); 
		inner_div.appendChild(content);
		if(close_button){
			var but = createIEElement('input', new Array('type', 'value', 'onclick', 'class'), new Array('button', 'close', 'closeDialog(document.getElementById(\''+gg+'\'));', 'button'));
			inner_div.appendChild(but);
		}
		//div.addText(content);
		//div.innerHTML = content;
		div.appendChild(inner_div);	
		div_holder.appendChild(div);
		
		displayMocastDialog(div_holder, sizes[0],sizes[1], animate);
		div_holder.style.zIndex = 1000;
		displayLightBox(div_holder.style.zIndex - 1);
		//lightBox.style.zIndex = document.getElementById(id).style.zIndex - 1; //need to do it after it is displayed
}

function closeDialog(div){
	document.body.removeChild(div);
	document.body.removeChild(getEl('_lightbox_div'));
	
	//show all selects
	if(dickyBrowser( )){
			var sels = document.getElementsByTagName('select');
			for(i=0; i<sels.length; i++){
				sels[i].style.display = "block";
			}
		}
}

function displayLightBox(z_index){
	if(blank(z_index)){
		z_index = 1000;	
	}
	var full = getPageSizeWithScroll( );
	var lightBox = document.createElement("div");
		lightBox.setAttribute('id', '_lightbox_div');
		lightBox.className = 'lightBox'; //required dali.css
		lightBox.style.display="block";
		
		lightBox.style.position = "absolute";
		lightBox.style.width = full[0]+'px';
		//lightBox.style.height = full[1]+'px';
		lightBox.style.height = $(document).height()+'px'; //using jquery;
		lightBox.style.top = '0px';
		lightBox.style.left = '0px';
		lightBox.style.backgroundColor = "#ffffff";
		lightBox.style.opacity = 0.7;
		lightBox.style.filter = 'alpha(opacity = 70)';
		document.body.appendChild(lightBox);
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}

function getCentreOfClientView(){
	var x = '';
	var y = '';
	x = f_scrollLeft( ) + (f_clientWidth( )/2);
	y = f_scrollTop( ) + (f_clientHeight( )/2);
	return new Array(x, y);
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
