function iManager() {	
}
iManager.prototype.openWindow=function(width,height,hPath){
	if (width==null) width=screen.width/2.0;
	if (height==null) height=screen.height/2.0;
	x=parseInt(screen.width/2.0)-(width/2.0);
	y=parseInt(screen.height/2.0)-(height/2.0);
	
	if (hPath==null) { hPath = '../../../'; }
	
	var win=window.open(''+hPath+'hydrogen/hydrogen.php',"imanager","top="+y+",left="+x+"width="+width+",height="+height+",scrollbars=yes,dialog=yes,minimizable=no,modal=yes,resizable=yes");
	win.focus();
}

iManager.prototype.filebrowser=function(field_id, type,win) {
	this.win = win;
	this.fieldId= field_id;
	this.field=null;
	this.value=this.win.document.getElementById(this.fieldId).value;	
	this.openWindow(630,510,'includes/');
}

iManager.prototype.filebrowserCallBack = function(field_name,url,type,win) {
	this.win = win;
	this.field = field_name;
	this.url=url;
	this.field_id=null;
	this.value=this.win.document.forms[0].elements[this.field].value;	
	this.openWindow(630,510);
}

iManager.prototype.insertImage = function(url) {
	var formField;
	if(this.field!=null){
		formField=this.win.document.forms[0].elements[this.field];		
	}
	else {
		formField=this.win.document.getElementById(this.fieldId);
	}
	formField.value=url;
	try {
			formField.onchange();
		} catch (e) {}
}


var imanager = new iManager();
