
function newWindow(url, title, w, h, scroll){
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings;
	if ( document.layers ){
		settings = 'height='+h+',width='+w+',screenY='+TopPosition
					+',screenX='+LeftPosition+',scrollbars='+scroll;
	} else {
		settings = 'height='+h+',width='+w+',top='+TopPosition
					+',left='+LeftPosition+',scrollbars='+scroll;
	}
	var win = window.open(url, title, settings)
	if( win.window.focus ){
		win.window.focus();
	}
}



// dest is the url that should be loaded after the entry is complete.
function enterNewCreditCard(dest){
	newWindow('/accounting/cc/get_cc_info?destType=J&destination='+escape(dest),
			'Enter_Credit_Card_Info', 400, 300, false);

}



function selectItem(args){
	// set args by position or name
	if ( window.opener.destForm && window.opener.destFormType ){
		var dests = window.opener.destFormDests;
		for (var i=0; i < dests.length ; i++){
			if ( dests[i] && i < args.length  ){
				dests[i].value = args[i].value;
			}

		}

	} else if ( window.opener.destForm ){
		for (var i=0; i < args.length ; i++) {
			var dest = window.opener.destForm.elements[args[i].table+'_'+args[i].column];
			if ( ! dest ){
				dest = window.opener.destForm.elements[args[i].column];
			}
			if ( dest ){
				dest.value = args[i].value;
//window.alert("Setting "+args[i].column+"to "+args[i].value);
			}
		}
	} 
	window.opener.destForm = null;
	window.opener.destFormType = null;
	close();
}

