var remWin = 0;
var infoWin = new Array(10);
var iWin = 2;
function newWin(load,typ)
{
	if ( remWin != 0) {
		if (infoWin[remWin].closed == false){
			infoWin[remWin].close();
		}
	}
	scrx = (screen.width)/8;
	scry = (screen.height)/5;
	if (typ == "1") {
		features ="width=700,height=500,resizable=no,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	}
	if (typ == "2") {
		features ="width=800,height=600,resizable=no,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	}
	if (typ == "3") {
		features ="width=530,height=400,resizable=yes,scrollbars=no,toolbar=no,status=yes,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	}
	if (typ == "4") {
		features ="width=580,height=450,resizable=yes,scrollbars=no,toolbar=no,status=yes,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	}

	infoWin[iWin] = window.open(load,iWin,features);
	if (navigator.appName != 'Netscape')
		infoWin[iWin].moveTo(screen.width/8,screen.height/5);
	infoWin[iWin].focus();
	remWin = iWin;
	if (iWin < 7)
		iWin++;
	else
		iWin = 1;
}


function previewWin(load) {
	if ( remWin != 0) {
		if (infoWin[remWin].closed == false) {
			infoWin[remWin].close();
		}
	}
	scrx = (screen.width)/8;
	scry = (screen.height)/5;
	// features ="width=800,height=560,resizable=yes,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	features ="width=800,height=560,resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no";
	infoWin[iWin] = window.open(load,'preview_main',features)
	// if (navigator.appName != 'Netscape') infoWin[iWin].moveTo(screen.width/8,screen.height/5);
	infoWin[iWin].focus();
	remWin = iWin;
	if (iWin < 7) {
		iWin++;
	} else {
		iWin = 1;
	}
}

function previewSizableWin(load,width,height) {
	if ( remWin != 0) {
		if (infoWin[remWin].closed == false) {
			infoWin[remWin].close();
		}
	}
	scrx = (screen.width)/8;
	scry = (screen.height)/5;
	// features ="width=800,height=560,resizable=yes,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;
	features ="width="+width+",height="+height+",resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no";
	infoWin[iWin] = window.open(load,'preview_main',features)
	// if (navigator.appName != 'Netscape') infoWin[iWin].moveTo(screen.width/8,screen.height/5);
	infoWin[iWin].focus();
	remWin = iWin;
	if (iWin < 7) {
		iWin++;
	} else {
		iWin = 1;
	}
}

function date_popup(label, div_prefix, elem_id) {

	var scrx = (screen.width)/8+20;
	var scry = (screen.height)/5+20;
	var features = "width=300,height=210,resizable=no,scrollbars=no,toolbar=no,status=yes,directories=no,menubar=no,location=no,screenX=" + scrx + ",screenY=" + scry;

	// "encodeURI()" geht bei meinem MSIE 5.0 nicht, daher uskommentiert
	// micha, 25.2.2003
	// 'date_popup.php3?label=' +encodeURI(label)+ '&div_prefix=' +div_prefix+ '&element=' +elem_id+ '&init=' +document.forms[0].elements[elem_id].value,
	var hwin = window.open(
		'date_popup.php?label=' +label+ '&div_prefix=' +div_prefix+ '&element=' +elem_id+ '&init=' +document.forms[0].elements[elem_id].value,
		'date_popup',
		features
	);
	if (navigator.appName != 'Netscape')
		hwin.moveTo(scrx, scry);
	hwin.focus();
}


var checkboxes_set = new Array();
function toggle_checkboxes(form, cb_name)
{
	if (!form.elements[cb_name+'[]'])
		return;

	var do_set;
	var cb_elements = form.elements[cb_name+'[]'];
	var i;

	// 'global'-last-status
	if (checkboxes_set[cb_name])
		do_set = false;
	else
		do_set = true;
	checkboxes_set[cb_name] = do_set;

	// update checkboxes
	if (cb_elements.length) {
		for (i = 0; i < cb_elements.length; i++) {
			cb_elements[i].checked = do_set;
		}
	} else {
		cb_elements.checked = do_set;
	}
}


var te_window = 0;
function open_te(load)
{
	if (te_window) {
		if (te_window.closed == false) {
			te_window.focus();
			return;
		}
	}
	var width  = 700;
	var height = 480;

	// var scrx = 5; // (screen.width) - (width + 15);
	// var scry = 5;	// scry = (screen.height) / 5; scry = screen.height - height;
	var features = "width="+width+",height="+height+",resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no"
	// ,screenX=" + scrx + ",screenY=" + scry;

	te_window = window.open(load, 'w_txt_edit', features);
	te_window.focus();
}


function deliverypreview(load/* , varname*/ ) {
	if ( remWin != 0) {
		if (infoWin[remWin].closed == false) {
			infoWin[remWin].close();
		}
	}
	//	aValue = document.f[varname].options[document.f[varname].selectedIndex].value;
	//	load += aValue;
	scrx = (screen.width)/8;
	scry = (screen.height)/5;
	features ="width=1400,height=500,resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no";
	infoWin[iWin] = window.open(load,'distributionpreview',features)
	infoWin[iWin].focus();
	remWin = iWin;
	if (iWin < 7) {
		iWin++;
	} else {
		iWin = 1;
	}
}

function protocolprocess(load/* , varname*/ ) {
	if ( remWin != 0) {
		if (infoWin[remWin].closed == false) {
			infoWin[remWin].close();
		}
	}
	//	aValue = document.f[varname].options[document.f[varname].selectedIndex].value;
	//	load += aValue;
	scrx = (screen.width)/8;
	scry = (screen.height)/5;
	features ="width=1400,height=600,resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no";
	infoWin[iWin] = window.open(load,'protocolprocess',features)
	infoWin[iWin].focus();
	remWin = iWin;
	if (iWin < 7) {
		iWin++;
	} else {
		iWin = 1;
	}
}

function cb_check(cb_name, mode)
{
	if (!document.f.elements[cb_name+'[]'])
		return;

	var cb_elements  = document.f.elements[cb_name+'[]'];

	// update checkboxes
	if (cb_elements.length) {
		for (i = 0; i < cb_elements.length; i++) {
			if (mode > 0) {
				cb_elements[i].checked = true;
			} else if (mode == 0) {
				cb_elements[i].checked = false;
			} else {
				if (cb_elements[i].checked) {
					cb_elements[i].checked = false;
				} else {
					cb_elements[i].checked = true;
				}
			}
		}
	}
}



