/**
*
* egFile Class
*/
function egFile(id, title, posX, posY, width, height, container, name) {
	 this.objName = 'edit_'+id;
	 this.id = id;
	 this.name = name;
	 this.value = title;
	 this.x = posX;
	 this.y = posY;
	 this.width = 0;
	 this.height = 0;

	 this.getHeight = egWindow_getHeight;
	 this.getWidth  = egWindow_getWidth;

	 this.show = egWindow_show;
	 this.moveTo = egWindow_moveTo;
	 this.displayAt = egWindow_displayAt;

	 this.active = 0;

	 this.getValue = egFile_getValue;
	 this.setValue = egFile_setValue;

	 this.setReadonly = egFile_setReadonly;
	 
	 this.setActive = egFile_setActive;
	 this.setInactive = egFile_setInactive;

	 this.onChange = egFile_onChangeHandler;

   if (!container) {
      container = 'easy-GUI_mainLayer';
   }
	 divRoot = document.getElementById(container);

	 var pos;
	 var value = this.value;
	 var currentValue = '';

	 while((pos = value.indexOf('<br />')) >= 0 ) {
	 		currentValue += value.substring(0, pos) + '\n';
	 		value = value.substring(pos+6, value.length);
	 }

	 this.value = currentValue + value;

	divRoot.innerHTML += '<div id="' + this.id + '" class="egFileFrame"><input type="hidden" name="MAX_FILE_SIZE" value="256000" /><input id="' + this.id + '_value" name="' + this.name + '" class="egFile" size="50" type="file" onChange="egFile_onChange(this.id);" onKeyPress="cancelBubble(arguments[0]); return egFile_preventCRKey(event);" /></div>';


	 div = document.getElementById(this.id);
	 div.style.width = width+'px';
	 div.style.height = (height-3)+'px';
	 div.style.left = posX+'px';
	 div.style.top  = posY+'px';

	 inputItem = document.getElementById(this.id+'_value');
	 if(height > 18) {
		 inputItem.style.height = (height-4)+'px';
	 }
}

function egFile_preventCRKey(e){
	var key = (window.event)? window.event.keyCode : e.which;
	if(key == 13) return false;
	return true;
}

function egFile_getValue(){
	this.value = document.getElementById(this.id+'_value').value;
	return this.value;
}

function egFile_setValue(value){
	this.value = value;
  document.getElementById(this.id+'_value').value = value;
}

function egFile_setReadonly(){
	document.getElementById(this.id+'_value').readOnly = true;
}

function egFile_setActive(){
	if(!this.active) {
    this.active = 1;
    this.setClassName();
	}
}

function egFile_setInactive(){
	if(this.active) {
    this.active = 0;
    this.setClassName();
	}
}

function egFile_onChangeHandler() {
}

function egFile_onChange(id) {
	var append = '_value';
	if(typeof(egObjectsArray['file_'+id.substr(0, id.length-(append.length))].onChange) =='function') {
		egObjectsArray['file_'+id.substr(0, id.length-(append.length))].onChange();
	}
}
