
//############################################################
function modal( url, w, h )
	{
	if( !w ) w = 400;
	if( !h ) h = 400;
	url = HOMEDIR +'/'+ url;
	var w = W.showModelessDialog( url, top.window, 'dialogHeight: '+h+'px; dialogWidth: '+w+'px; center: yes; dialogHide: no; edge: sunken; help: off; resizable: on; status: no; unordered: off;' );
	}
	
//############################################################
function perm_modal( url, w, h )
	{
	if( !w ) w = 400;
	if( !h ) h = 400;
	url = HOMEDIR +'/'+ url;
	var w = W.showModelessDialog( url, top.window, 'dialogHeight: '+h+'px; dialogWidth: '+w+'px; center: yes; dialogHide: no; edge: sunken; help: off; resizable: on; status: no; unordered: off; scroll: no;' );
	}
//############################################################

function dsize( w, h )
	{
	if( !w || !h ) return;
	W.dialogWidth = w+'px';
	W.dialogHeight = h+'px';
	}
	
function wsize( w, h ){
	if( !w || !h ) return;
	W.resizeTo( w, h );
	wcenter( w, h );
}

function wcenter( w, h ){
	if( !w || !h ) return;
	var aw = screen.availWidth;
	var ah = screen.availHeight;
	if( w > aw ) w = aw;
	if( h > ah ) h = ah;
	var l = ( aw - w ) / 2;
	var t = ( ah - h ) / 2
	W.moveTo( l, t );
}

//#############################################################

function wait( key )
	{
	if( key )
		{
		W.D.wait_div.style.display = "none";
		return;
		}
	W.D.wait_div.style.display = "block";

	}

//#####################################################################

function wopen( url, target, w, h, asize, title, res )
	{
	if( !url )
		{
		event.cancelBubble = true;
		event.returnValue = false;
		return;
		}
	if( !target ) target = '_blank';
	if( !w ) w = 500;
	if( !h ) h = 400
	if( !title ) title = '';
	
	w = parseInt( w, 10 );
	h = parseInt( h, 10 );
	if( asize ) asize = true;
	else asize = false;

	var aw = screen.availWidth;
	var ah = screen.availHeight;
	if( w > aw ) w = aw;
	if( h > ah ) h = ah;
	
	if( res )r = 0; else r = 1;

	var left = Math.round( ( aw - w ) / 2 );
	var top = Math.round( ( ah - h ) / 2 );

	var wd = window.open( url, target, 'channelmode= 0, directories=0, fullscreen=0, height='+h+'px, width='+w+'px, location=0, menubar=0, resizable='+r+', scrollbars=1, status=0, toolbar=0, top='+top+'px, left='+left+'px' );
	if ( !asize ) { return; }

	if( url.indexOf( window.location.host ) != -1 || url.indexOf( 'http://' ) == -1  ) wd.attachEvent( "onload", function() {resize_new_win( wd, asize, title )	} );

	}

function resize_new_win( win, asize, title )
	{
	if( win.document.body == null )
		{
		win.document.createElement( "body" );
		}
		var wb = win.document.body;

		wb.style.padding = "0px";
		wb.style.margin = "0px";
		wb.style.overflow="auto";


		if( asize )
			{

			var ofw = wb.scrollWidth - wb.clientWidth;
			var ofh = wb.scrollHeight - wb.clientHeight;

				var eflag = false;

			if( ( wb.clientWidth + ofw ) > ( screen.availWidth - 40 ) )
				{
				ofw =  screen.availWidth - wb.clientWidth - 50 ;
				eflag = true;
				}
			if( wb.clientHeight + ofh > screen.availHeight - 60 )
				{
				ofh = screen.availHeight - wb.clientHeight - 60;
				eflag = true;
				}

			win.resizeBy( ofw , ofh  );

			var left = 2;
			if( eflag == false )
				{
				win.resizeBy( wb.scrollWidth - wb.clientWidth,  wb.scrollHeight - wb.clientHeight );
				left = Math.round( ( screen.availWidth - wb.clientWidth+20 ) / 2 );
				}


			win.moveTo( left, 10 );
			if( title )
				{
				win.document.title = title;
				}
			}

	}

function winfull( url, target ) {
	if ( !url ) { return false; }

	if ( !target ) { target = '_blank'; }

    var wd = window.open( url, target, 'fullscreen=1, scrollbars=0, toolbar=0' );
}


function contextfalse(  )
	{
	if( event ) 
		{
		event.cancelBubble = true;
		event.returnValue = false;
		}
	return false;	
	}

