function _private_trim()
{
  var tmpStr, atChar;
  tmpStr = this;
 
  if (tmpStr.length > 0) atChar = tmpStr.charAt(0);
  while (_private_stringvb_isSpace(atChar)) {
    tmpStr = tmpStr.substring(1, tmpStr.length);
    atChar = tmpStr.charAt(0);
  }
  if (tmpStr.length > 0) atChar = tmpStr.charAt(tmpStr.length-1);
  while (_private_stringvb_isSpace(atChar)) {
    tmpStr = tmpStr.substring(0,( tmpStr.length-1));
    atChar = tmpStr.charAt(tmpStr.length-1);
  }
  return tmpStr;
}

function _private_stringvb_isSpace(inChar) {
  return (inChar == ' ' || inChar == '\t' || inChar == '\n' || inChar == '%');
}
String.prototype.trim     = _private_trim;

var search_sursor=-1;
var search_visible=false;
var search_focus=false;
var max_item;

function show_search(){
	search_visible=true;
	document.getElementById("auto_search").style.display="block";
    frmsearch.search_check.value = "1";
}

function hide_search(){
	search_visible=false;
	document.getElementById("auto_search").style.display="none";
	document.getElementById("search_scroll").scrollTop=0;
	search_cursor=-1;
    frmsearch.search_check.value = "0";
	search_item_all_hide();
}

function change_search_text(){
    
	//if(frmsearch.search_text.value == ""){
    //  frmsearch.search_check.value = "0";
    //}

	//if(frmsearch.search_check.value == "0"){

	if(window.event.keyCode != 40 && window.event.keyCode != 38){
	  var chk = isearch.keyword_check(frmsearch.search_text.value);
	  if(chk == true)
	  { show_search();
	  }else{
  	    hide_search();
	  }
    }
	//}
}

window.document.onmouseup = function()
{
	if(status)status=false;
	if(document.getElementById("auto_search")){
		document.getElementById("auto_search").style.display="none";
		
		hide_search();
	}

}

window.document.onkeydown = function (){
	var keycode = window.event.keyCode;
	if(keycode == 40 && search_visible && max_item>search_cursor){
		focus_search(search_cursor+1);
	}
	if(keycode == 38 && search_visible && search_cursor>0){
		focus_search(search_cursor-1);
	}
	if(keycode == 13 && search_visible ){
		search_click(search_cursor);
	}
}

function focus_search(num){
	
	if(document.all.search_item[num]){
		search_item_all_hide();
		
		if(document.all.search_item[num]){
		  document.all.search_item[num].style.background="#DDEFFC";
		  document.getElementById("search_text").value=document.all.search_item[num].innerText;
		  
		}
		search_cursor=num;
	}else{
		search_item_all_hide();
		
		if(document.all.search_item){
		  document.all.search_item.style.background="#DDEFFC";
		  document.getElementById("search_text").value=document.all.search_item.innerText;
		}
		search_cursor=num;
	}

	if(search_cursor*20-document.all.search_scroll.scrollTop>60)document.all.search_scroll.scrollTop+=18;
	if(search_cursor*20-document.all.search_scroll.scrollTop<0)document.all.search_scroll.scrollTop-=18;

}

function search_item_all_hide(){
	for(k=0;k<50;k++)
	{
		if(document.all.search_item[k]){
			document.all.search_item[k].style.background="#FFFFFF";
			max_item=k;
		}
	}
}

function get_item_amount(){
	for(k=0;k<50;k++)
	{
		if(document.all.search_item[k]){
			max_item=k;
		}
	}

	return k;
}

function search_click(url){
	document.getElementById("search_text").value=document.all.search_item[search_cursor].innerText;
	document.location.href= url;

}

function ConfirmSearch(form)
{


	if(!check_special(form.search_text.value)){
		alert("Æ¯¼ö¹®ÀÚ´Â »ç¿ëÇÏ½Ç¼ö ¾ø½À´Ï´Ù.");
		return false;
	}

  if (form.search_text.value.trim() == ""){
	alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
	return false
  } else {
	form.action = "/other/quicksearch.asp";
	return true;
  }

}

//·Î±×ÀÎ½Ã ¾ÆÀÌµð Ã¢¿¡ Æ÷Ä¿½º ÁÖ±â ÇÔ¼ö
function focus_id()
{
	document.getElementById("login_id").focus();
}

//Áñ°ÜÃ£±â Ãß°¡ÇÏ´Â ÇÔ¼ö 
function add_bookmark()
{
	url = "http://www.homecgv.com/";
	title = "Home CGV ¿µÈ­ÀÇ ¸ðµç°Í";
	window.external.AddFavorite(url, title);
}

//FILE search input form ¿¡¼­ search¹öÆ°À» ÀÌ¹ÌÁö·Î ±³Ã¼ÇÑ 
//dummy form °ú ½ÇÁ¦ form À» ¿¬°á½ÃÄÑÁÖ±â À§ÇÑ ÇÔ¼ö
function click_search()
{
	document.getElementById("file_upload").click();
	document.getElementById("file_view").value = document.getElementById("file_upload").value;
}

//µ¡±Û form Æ÷Ä¿½Ì,ºí·¯¸µ ÇÔ¼ö
function modify_input(target, content)
{
	
	if (target.value == content)
	{
		target.value = "";
		return true;
	}

	if (target.value=="")
	{
		target.value = content;
		return true;
	}
}

//ÆË¾÷Ã¢ ¿ÀÇÂ ÇÔ¼ö
function open_pop(url)
{
	var newWin = window.open(url, 'hcgv_pop', 'scrollbars=no, toolbars=no, menubars=no, left=100, top=100,width=50,height=50');
	newWin.focus();
}

function open_pop2(url)
{
	var newWin = window.open(url, 'hcgv_pop', 'scrollbars=auto, toolbars=no, menubars=no, left=100, top=100');
	newWin.focus();
}

//ÆË¾÷Ã¢ Å©±â Á¶ÀýÇÔ¼ö
function resize_pop()
{
	window.resizeTo(document.getElementById("pop_size").clientWidth + 10, document.getElementById("pop_size").clientHeight + 49);

}

function resize_pop2()
{
	window.resizeTo(document.getElementById("pop_size").clientWidth + 10, document.getElementById("pop_size").clientHeight + 49);
	alert(screen.availWidth);
	alert(screen.availHeight);
	alert(window.width);
}


//ÃßÃµ°Ë»ö¾î Ã¢ ¼¼·ÎÀ§Ä¡ Á¶Àý
function locate_search(){
	document.all.auto_search.style.top=document.all.submenu_table.clientHeight+303;
}

function onlyNumber(){
if(((event.keyCode>=48)&&(event.keyCode<=57))||((event.keyCode>=96)&&(event.keyCode<=105))||(event.keyCode==8||event.keyCode==9||event.keyCode==37||event.keyCode==39||event.keyCode==46||event.keyCode==13)){
	event.returnValue=true;
	}else{
	event.returnValue=false;
	 }
}

//¼ýÀÚ ÀÌ¿ÜÀÇ ¹®ÀÚ °É·¯³»±â
function removeNoneNum(val){    
    var reg=/[^\d]/;
    while(reg.test(val)){
        val=val.replace(reg,"");
    }    
    return val;
}

//¹®ÀÚ°¡ ÀÖ³ª È®ÀÎÇÏ±â
function check_eng(val){
	var reg=/^[A-Za-z]/
	if(!reg.test(val)){
		return false;
	}else{return true;}
}

function check_engnum(val){
	var reg=/^[A-Za-z0-9]/
	if(!reg.test(val)){
		return false;
	}else{return true;}
}

function check_search_text(val){

}

//PNG  ÆÄÀÏ Ã³¸®
function fixPNG(obj)
{
	var blankImg = "/images/common/blank.gif";
	var Src, Width, Height;

	if ( !(typeof obj.style.filter == 'string' && obj.src.substr(obj.src.lastIndexOf(".")+1).toLowerCase() == 'png') ) return;

	Src = obj.src;
	Width = obj.width;
	Height = obj.height;

	obj.src = blankImg;
	obj.width = Width;
	obj.height = Height;
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+Src+"', sizingMethod='scale')";
}

//ÀÌ¹ÌÁö Ãà¼ÒÇÏ±â
function smalling_img(img,width_size)
{
	if(img.width>width_size){
		img.width=width_size;
	}
}

//Æ¯¼ö¹®ÀÚ Ã¼Å©ÇÏ±â
function check_special(id){
	var ccc = "~`@#$%^&*|\+=-_;\"<>/";
	for(a=0;a<id.length;a++){
		var sid=id.charAt(a);
			for ( j = 0 ; j < ccc.length ; j++) {
				if (sid == ccc.charAt(j)) { 
					return false;
				}
			}
	}
	return true;
}