function popWin (url, width, height) {			
	//center the pop-up	
	if (parseInt(navigator.appVersion) >= 4 ) {
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;}

	args = "width=" + width + ","
	+ "height=" + height + ","
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=1,"
	+ "status=1," 
	+ "titlebar=1,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + ","  //NN Only
	+ "screeny=" + yposition + ","  //NN Only
	+ "left=" + xposition + ","     //IE Only
	+ "top=" + yposition;           //IE Only
	
	window.open(url,'popup', args);
}

function addArea() {
	var newArea = addElement();
	//var area = document.getElementById('area').innerHTML;
	var area = "<hr size='0' style='border-top: 1px solid #CCCCCC;'/>file:<br /><input type='file' name='attachment" + ((document.getElementById('intVal').value * 1) + 1) + "' style='width: 200px;' size='50' />";
	document.getElementById(newArea).innerHTML = area;
}

function addElement() {
  var ni = document.getElementById('area');
  var numi = document.getElementById('intVal');
  var num = ((document.getElementById('intVal').value) * 1) + 1;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  ni.appendChild(newdiv);
  return divIdName;
}

function MultiSelector( list_target, max ){

	this.list_target = list_target;
	this.count = 0;
	this.id = 0;
	if( max ){
		this.max = max;
	} else {
		this.max = -1;
	};
	
	this.addElement = function( element ){

		if( element.tagName == 'INPUT' && element.type == 'file' ){

			element.name = 'file_' + this.id++;
			element.multi_selector = this;
			element.onchange = function(){

				var new_element = document.createElement( 'input' );
				new_element.type = 'file';
				this.parentNode.insertBefore( new_element, this );
				this.multi_selector.addElement( new_element );
				this.multi_selector.addListRow( this );
				this.style.position = 'absolute';
				this.style.left = '-1000px';

			};

			if( this.max != -1 && this.count >= this.max ){
				element.disabled = true;
			};

			this.count++;
			this.current_element = element;
			
		} else {
			alert( 'Error: not a file input element' );
		};

	};

	this.addListRow = function( element ){

		var new_row = document.createElement( 'div' );

		var new_row_button = document.createElement( 'input' );
		new_row_button.type = 'button';
		new_row_button.value = 'Remove';

		new_row.element = element;

		new_row_button.onclick= function(){

			this.parentNode.element.parentNode.removeChild( this.parentNode.element );
			this.parentNode.parentNode.removeChild( this.parentNode );
			this.parentNode.element.multi_selector.count--;
			this.parentNode.element.multi_selector.current_element.disabled = false;

			return false;
		};

		new_row.innerHTML = element.value;
		new_row.appendChild( new_row_button );
		this.list_target.appendChild( new_row );		
	};

};


function targetopener(blah, closeme, closeonly) {
	
	if (!(window.focus && window.opener))return true;
	window.opener.focus();
	if (!closeonly)window.opener.document.getElementById('postbody').value += blah;
	window.close();
	return false;
	
}