function calculateOffsetLeft(field) {
  return calculateOffset(field, "offsetLeft");
}

function calculateOffsetTop(field) {
  return calculateOffset(field, "offsetTop");
}

function calculateOffset(field, attr) {
  var offset = 0;
  while(field) {
    offset += field[attr]; 
    field = field.offsetParent;
   }
  return offset;
}

//ÀÚµ¿¿Ï¼º Ã£±â ¹× ÀÌº¥Æ® Ã¼Å©.
function Tom(){
	this.version="1.0";
	this.name = "AutoComplete Tom";
	this.oForm = null;							//°Ë»ö¾î ÀÔ·Â Form°´Ã¼
	this.sCollection = null; //ÄÝ·¢¼Ç Á¤º¸.		//ÀÚµ¿¿Ï¼º ÇØ´ç ÄÝ·¢¼Ç
	this.oKeyword = null;						//°Ë»öÅ°¿öµå ÀÔ·Â Text°´Ã¼
	this.sOldkwd = "";							//ÀÌÀü°Ë»ö¾î
	this.sNewkwd = "";							//½Å±Ô°Ë»ö¾î
	this.oAc_lyr = null;						//ÀÚµ¿¿Ï¼º ÀüÃ¼·¹ÀÌ¾î°´Ã¼
	this.oAc_ifr = null;						//ÀÚµ¿¿Ï¼ºÃ³¸® ÇÁ·¹ÀÓ°´Ã¼
	this.oImg_Toggle = null;					//°Ë»öÅ°¿öµå ÀÔ·Â Text°´Ã¼ÀÇ ¿ìÃø Åä±ÛÀÌ¹ÌÁö°´Ã¼
	this.sImg_Toggle_on = "http://img.enuri.gscdn.com/images/main_2007/search_arr_off.gif";
	this.sImg_Toggle_off = "http://img.enuri.gscdn.com/images/main_2007/search_arr_on.gif"; 
	this.sSkipWrd = "¤¡¤¤¤§¤©¤±¤²¤µ¤·¤¸¤º¤»¤¼¤½¤¾";	//ÀÚµ¿¿Ï¼º skip´Ü¾î
	this.bSkipTF = false;						//ÀÚµ¿¿Ï¼º skip´Ü¾î ±â´ÉÀ» »ç¿ëÇÒÁö ¿©ºÎ
	this.TimerInterval = 200; 					//ÀÚµ¿¿Ï¼º Ã¼Å©ÁÖ±â1000ÀÌ 1ÃÊ
	this.act =0; 								//ÀÚµ¿¿Ï¼º ½ÇÇàÁßÀÎÁö ¿©ºÎ (0:À¯ÈÞ, 1:½ÇÇà)
	this.sSubmitFunctionName = "";
	this.isExistSkipwrd = function(){
		var ret = false;
		s = arguments[0]; 
		t = arguments[1];
		for(i=0;i<s.length;i++){
			if(t.indexOf(s.substring(i, i+1)) < 0){
				ret = false;
			}else{
				ret = true;
				break;
			}
		}
		return ret;
	};
	
	this.toggle = function(){
		if(this.oAc_ifr!=null){
			obj = document.frames(this.oAc_ifr.name);
			obj.Jerry_on_off();
		}
	};
	this.find = function(){
		/*
		if(this.sOldkwd == this.oKeyword.value.trim()){
			return;
		}else{
			if(this.act){
				return;
			}else{
				if(this.bSkipTF){
					if(this.isExistSkipwrd(this.oKeyword.value.trim(), this.sSkipWrd)){
						return;
					}
				}
				this.act=1;
				this.sNewkwd = this.oKeyword.value.trim();
				obj = document.frames(this.oAc_ifr.name);
				obj.Jerry_AutoSearch( this);
				this.sOldkwd = this.sNewkwd;
				this.act=0;
			}
		}
		*/
		if(this.act){
			return;
		}else{
			if(this.bSkipTF){
				if(this.isExistSkipwrd(this.oKeyword.value.trim(), this.sSkipWrd)){
					return;
				}
			}
			this.act=1;
			this.sNewkwd = this.oKeyword.value.trim();
			obj = document.frames(this.oAc_ifr.name);
			obj.Jerry_AutoSearch( this);
			this.sOldkwd = this.sNewkwd;
			this.act=0;
		}		
	};
}


