var loadedOverlays=new Array();
var createdOverlays=new Array();


function closeDialog(){}


function createWebOverlay(id,title,url){

	if(!createdOverlays[id]){
		//alert('APPEND DIV dialog_'+id);
		$("body").append('<div id="dialog_'+id+'"></div>');
		createdOverlays[id]=1;
	} 
	cntnt='<iframe width="100%" height="100%" FRAMEBORDER=0 SCROLLING=auto src="'+url+'">';
	showOverlayContent(id,title,'static',cntnt);
}

function createOverlay(id,title,ctype,content,ox,oy,ow,oh,reload){
	
	if(!createdOverlays[id]){
		//alert('APPEND DIV dialog_'+id);
		$("body").append('<div id="dialog_'+id+'"></div>');
		createdOverlays[id]=1;
	} 

	showOverlayContent(id,title,ctype,content,ox,oy,ow,oh,reload);
}

function showOverlayContent(id,title,ctype,content,ox,oy,ow,oh,reload){
	
	if(!reload){reload=false;}
	
	if(loadedOverlays[id]==1 && !reload){
		//alert('JUST SHOW dialog_'+id);
		$("div#dialog_"+id).dialog("open");
		return true;
	}

	if(ctype=='static'){
		$("div#dialog_"+id).html(content);
	} 
	else if(ctype=='ajax'){
		$("div#dialog_"+id).load(content);
	}

	if(!ox){ox='center';}
	else{ox=parseInt(ox);}
	if(!oy){oy='top';} 
	else{oy=parseInt(oy);}
	if(!ow){ow='600';} 
	if(!oh){oh='500';}


	if(loadedOverlays[id]==1){
		$("div#dialog_"+id).dialog("open");
	}  
	else {
		//Create Dialog
		$("div#dialog_"+id).dialog(
			{ 
				title: title,
				autoOpen: true,
				position:[ox,oy],
				width: parseInt(ow),
				height: parseInt(oh),
				maxWidth: 970,
				maxHeight: 620,
				resizable: true,
				draggable: true
			}
		);		
	}  
						
	loadedOverlays[id]=1;
	
}


function showWebInOverlay(id,title,url){
	cntnt='<iframe width="100%" height="100%" FRAMEBORDER=0 SCROLLING=auto src="'+url+'">';
	showOverlayContent(id,title,'static',cntnt);
}



/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.

function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var value = arr[item];

if(typeof(value) == 'object') { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += dump(value,level+1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Stings/Chars/Numbers etc.
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
alert(dumped_text);
} 
*/

