
// -----------------------------------------------
// This is designed to be a very easy to implement
// generic window popper function to fit all
// foreseeable requirements of a popup window 
// using just one single javascript function call
// ------------------------------------------------
function popwin( path, target, w, h, extras, align ){
	// error check and set defualt values
	if( !path ){
		alert('path - not defined');
		return;
	}
	if( !target ){
		target = '_blank';
	}
	if( !w || !h ){
		w = 400;
		h = 300;
	}
	if( !extras ){
		extras = 'none';
	}
	if( !align ){
		align = 'MC';
	}
	
	// set window size
	var settings = 'width=' +w+ ',height=' +h;
	// set window position
	align = align.toUpperCase();
		
	// compensate for window chrome
	var real_w = w + 15;
	var real_h = h + 30;
  
	// set x position
	if( align.indexOf('L',0) != -1 ){
		x = 0;
	} else if( align.indexOf('C',0) != -1 ){
		x = (screen.availWidth * 0.5) - (real_w * 0.5);
	} else if( align.indexOf('R',0) != -1 ){
		x = screen.availWidth-real_w;
	}
	
	// set y position
	if( align.indexOf('T',0) != -1 ){
		y = 0;
	} else if( align.indexOf('M',0) != -1 ){
		y = (screen.availHeight * 0.5) - (real_h * 0.5);
	} else if( align.indexOf('B',0) != -1 ){
		y = screen.availHeight-real_h;
	}
	
	settings += ',left=' +x+ ',top=' +y;
	// set the window properties
	var props = '';
	props += ',scrollbars=' + ((extras.indexOf('scroll',0)==-1)?'no':'yes');
	props += ',resizable=' + ((extras.indexOf('resiz',0)==-1)?'no':'yes');
	props += ',menubar=' + ((extras.indexOf('menu',0)==-1)?'no':'yes');
	props += ',toolbar=' + ((extras.indexOf('tool',0)==-1)?'no':'yes');
	props += ',status=' + ((extras.indexOf('status',0)==-1)?'no':'yes');
	props += ',location=' + ((extras.indexOf('url',0)==-1)?'no':'yes');
	props += ',directories=' + ((extras.indexOf('links',0)==-1)?'no':'yes');
	// open up the window 
	var popwin = null;
	popwin = window.open('', target, settings+props);
	popwin.document.location = path;
	
	
	// bring new window to the front
	popwin.focus();
}