// JavaScript Document

//document.oncontextmenu = function() {return false};
//document.ondragstart = function() {return false};
//document.onselectstart = function() {return false};

//flash Script
function CHHDFlash(Url,Width,Height){                 
  document.writeln("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + Width + "' height='" + Height + "'>"); 
  document.writeln("<param name='movie' value='" + Url + "'>"); 
  document.writeln("<param name='quality' value='high' />");     
  document.writeln("<param name='wmode' value='transparent'>");
  document.writeln("<param name='menu' value='false'>"); 
  document.writeln("<param name='FlashVars' value='<?=$num_f?>'>"); 
  document.writeln("<embed src='" + Url + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + Width + "'  height='" + Height + "'>"); 
  document.writeln("</object>");     
}

//Focus Blur
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring; 

//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//online faq menu
function premier(n) {
    for(var i = 1; i <= 4; i++) {
        obj = document.getElementById('premier'+i);
        img = document.getElementById('premier_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
			img.height = 31;
            img.src = "../img/sub/online/faq/tab01"+i+".gif";    
        } else {
            obj.style.display = "none";
			img.height = 31;
            img.src = "../img/sub/online/faq/tab01_over"+i+".gif";
        }
    }
}
// CheckStrlen ÀÔ·ÂÆûÀÇ ¹ÙÀÌÆ®¸¦ °è»êÇÏ¿© Á¤ÇØÁø ¹ÙÀÌÆ® º¸´Ù Å¬°æ¿ì ÀÌÀüÀÛ¼º±Û ±îÁö¸¸ ÀÔ·ÂµÊ
function CheckLen(tmpValue) {
	var hex_char;
	var all_length = 0;
		for(var i = 0; i < tmpValue.length; i++) {
			hex_char = escape( tmpValue.charAt(i) );
			 
			if(hex_char.length >= 4) all_length += 2;
			else all_length++;
		}
	return all_length;
}

function CheckStrLen(tmpObject, tmpSize) {
	if( CheckLen(tmpObject.value) > tmpSize ) {
		alert(tmpSize+" ¹ÙÀÌÆ®°¡ ³Ñ°Ô ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
		tmpObject.value = temp_textarea;
	} else {
		temp_textarea = tmpObject.value;
	}
}

//checkboxÅ¸ÀÔÀÌ ÁöÁ¤µÈ °¹¼ö¸¸Å­¸¸ ¼±ÅÃ °¡´ÉÇÏ°ÔÇÏ´Â ÇÔ¼ö
function CheckBoxCount(tmpName, tmpObject, tmpSize){
	var i=0, k=0;
	while(document.all[tmpName][i]){
		if(document.all[tmpName][i].checked==true){
			k++;
			if(k>tmpSize){
				alert(tmpSize+"±îÁö¸¸ ¼±ÅÃÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
				tmpObject.checked=false;
			}
		}
		i++;
	}

}

//////////////////////////////Ã¼Å©¹Ú½º´ÙÁß¼±ÅÃ///////////////////////////
function aCheck(form_name, allCheck_name, field_name){
	var i=0;
	while(document[form_name][field_name][i]){
		if (document[form_name][allCheck_name].checked){
			document[form_name][field_name][i].checked = true;
		}else{
			document[form_name][field_name][i].checked = false;
		}
	i++;
	} 
}

function bCheck(form_name, field_name, mode, action, Etc_Field, Etc_Field1){
    var str = "";
    var s = 0;
	var i=0;
	while(document[form_name][field_name][i]){
		if(document[form_name][field_name][i].checked){
			if(document[form_name][field_name][i].value){
				if(s != 0) str += "|";
				str  = str + document[form_name][field_name][i].value;
				s++;
			}
		}
	i++;
	} 

    if(s == 0){
        alert ("Àû¾îµµ ÇÏ³ª ÀÌ»ó ¼±ÅÃÀ» ÇÏ¼Å¾ß ÇÕ´Ï´Ù."); 
        return false;
    }else{
        document[form_name].bb.value = str;
		document[form_name].mode.value = mode;
		if(document[form_name].ProcessValue) document[form_name].ProcessValue.value = mode;
		if(action) document[form_name].action = action;
		if(Etc_Field) document[form_name].etcfield.value = Etc_Field;
		if(Etc_Field1) document[form_name].etcfield1.value = Etc_Field1;
        document[form_name].submit();
    }
}


//////////////////////////////ÀÎÇ²¹Ú½ºÃß°¡»èÁ¦///////////////////////////
/*		
<?
$ShowFile=$row[cate_goods];
$File=explode("|",$ShowFile);

if($ShowFile)$FileNo=count($File)-1;
else $FileNo="1";
$TotalFileNo="30";	
?>

<img src="/_admin/img/btn/AddFile.gif" align="absmiddle" onclick="File_show('add','Fileshow','FileName','<?=$FileNo?>','<?=$TotalFileNo?>','1');" style="cursor:hand">
<img src="/_admin/img/btn/DelFile.gif" align="absmiddle"  onclick="File_show('del','Fileshow','FileName','<?=$FileNo?>','','1')" style="cursor:hand">

<?
for($i=1; $i<=$TotalFileNo; $i++){
?>
<tr id="Fileshow[<?=$i?>]" <?if(!$File[$i]){?>style="display:none"<?}?>>
	<td>»óÇ°ÀÌ¸§</td>
	<td>
		<input name="FileName[<?=$i?>]" type="text" class="input" size="40" style="width:340;" value="<?=$File[$i]?>">
		<input type="image" src="../img/btn/btn_search.gif" border="0" align="absmiddle" style="cursor:hand">
	</td>
</tr>
<?}?>
*/
// --------------------------------------------------------
var HisView_Num1;
var HisDel_Num1;
var HisView_Num2;
var HisDel_Num2;
var HisView_Num3;
var HisDel_Num3;
var HisView_Num4;
var HisDel_Num4;
var HisView_Num5;
var HisDel_Num5;

function File_show(Type, TaName, FieldName, FileNo, TotalFileNo, OptionNo, Etc_Field){
	if(OptionNo==1){
		var HisView_Num = HisView_Num1;
		var HisDel_Num = HisDel_Num1;
	}else if(OptionNo==2){
		var HisView_Num = HisView_Num2;
		var HisDel_Num = HisDel_Num2;
	}else if(OptionNo==3){
		var HisView_Num = HisView_Num3;
		var HisDel_Num = HisDel_Num3;
	}else if(OptionNo==4){
		var HisView_Num = HisView_Num4;
		var HisDel_Num = HisDel_Num4;
	}else if(OptionNo==5){
		var HisView_Num = HisView_Num5;
		var HisDel_Num = HisDel_Num5;
	}

	if(Type == 'add'){
		if(HisView_Num){
			if(HisDel_Num){
				HisDel_Num='';
			}else{
				if(HisView_Num < TotalFileNo){
					HisView_Num = parseInt(HisView_Num) + 1;
				}else{
					alert('´õÀÌ»ó Ãß°¡ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù');
				}
			}
		}else{
			HisView_Num = parseInt(FileNo);
			if(HisView_Num == TotalFileNo) alert('´õÀÌ»ó Ãß°¡ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù');
		}	
		if(HisView_Num <= TotalFileNo){
			document.all[TaName+"["+HisView_Num+"]"].style.display='';
		}

	}else if(Type == 'del'){
		if(HisDel_Num){
			if(HisView_Num > 1) HisView_Num = parseInt(HisView_Num) - 1;		
		}else{
			HisDel_Num = "Y";	
			if(!HisView_Num && FileNo !=1){
				HisView_Num = parseInt(FileNo);
			}else{
				HisView_Num = parseInt(HisView_Num);
			}
		}
		
		if(HisView_Num > 0){
			document.all[FieldName+"["+HisView_Num+"]"].value='';
			if(Etc_Field) document.all[Etc_Field+"["+HisView_Num+"]"].value='';
			document.all[TaName+"["+HisView_Num+"]"].style.display='none';
		}
	}

	if(OptionNo==1){
		HisView_Num1 = HisView_Num;
		HisDel_Num1 = HisDel_Num;
	}else if(OptionNo==2){
		HisView_Num2 = HisView_Num;
		HisDel_Num2 = HisDel_Num;
	}else if(OptionNo==3){
		HisView_Num3 = HisView_Num;
		HisDel_Num3 = HisDel_Num;
	}else if(OptionNo==4){
		HisView_Num4 = HisView_Num;
		HisDel_Num4 = HisDel_Num;
	}else if(OptionNo==5){
		HisView_Num5 = HisView_Num;
		HisDel_Num5 = HisDel_Num;
	}
}

//////¼ýÀÚ¸¦ °¡°ÝÀ¸·Î(,) º¯È¯
function check_cost(cost){
    var tmpCost;
    var tmpintCost;
    var j;
    var k;

    tmpintCost=new String(cost.value);
    for(i=0;i<tmpintCost.length;i++) {
        tmpintCost = tmpintCost.replace(/,/,"");
    }

    j=0;
    k=tmpintCost.length % 3;
    for(i=0; i<=tmpintCost.length/3; i++){
        if(tmpCost){
            tmpCost = tmpCost+","+tmpintCost.substring(j, k);
        }else{
            tmpCost = tmpintCost.substring(j, k);
        }
        j=k;
        k+=3;
    }

    cost.value=tmpCost;
    cost.focus();
}

////// È­ÀÏÃ·ºÎ (Ã£¾Æº¸±â) ½ºÅ©¸³Æ®

function file_browse() 
{ 
document.form.file.click(); 
document.form.text1.value=document.form.file.value; 
} 

///// in_array
function in_array(str,arr){
	var i=0;
	for(i=0; i<arr.length;i++){if(arr[i]==str) return true;}
	return false;
}

///// selectÀÌµ¿
function select_move(fbox, tbox, select_value, not_move) {
     var arrFtext = new Array();
     var arrTtext = new Array();
     var arrFValue = new Array();
	 var arrTValue = new Array();
     var i;
     for(i=0; i<tbox.options.length; i++) {
          if(!in_array(tbox.options[i].text, arrTtext)){
			  arrTtext[i] = tbox.options[i].text;
			  arrTValue[tbox.options[i].text] = tbox.options[i].value;
		  }
     }
     var fLength = 0;
     var tLength = arrTtext.length
     for(i=0; i<fbox.options.length; i++) {
          arrFValue[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               if(!in_array(fbox.options[i].text, arrTtext)){
				   arrTtext[tLength] = fbox.options[i].text;
				   arrTValue[arrTtext[tLength]] = fbox.options[i].value;
			   }
               tLength++;
          } else {
               arrFtext[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     arrFtext.sort(function() { return '0'; });
     arrTtext.sort(function() { return '0'; });
     tbox.length = 0;
     var c;
	 var chk_value;

	 if(fbox.name != not_move){
		 fbox.length = 0;
		 for(c=0; c<arrFtext.length; c++) {
			  var no = new Option();
			  if(fbox.name == select_value){
				 if(chk_value) chk_value = chk_value+"|"+arrFValue[arrFtext[c]];
				 else chk_value = arrFValue[arrFtext[c]];
			 }
			  no.value = arrFValue[arrFtext[c]];
			  no.text = arrFtext[c];
			  fbox[c] = no;
		 }
	 }else{
		 for(c=0; c<fbox.options.length; c++) {
			  var no = new Option();
			  no.value = arrFValue[fbox.options[c].text];
			  no.text = fbox.options[c].text;
			  fbox[c] = no;
		 }
	 }
     for(c=0; c<arrTtext.length; c++) {
         var no = new Option();	 
		 if(arrTtext[c]){
			 if(fbox.name == not_move){
				 if(chk_value) chk_value = chk_value+"|"+arrTValue[arrTtext[c]];
				 else chk_value = arrTValue[arrTtext[c]];
			 }
			 no.value = arrTValue[arrTtext[c]];
			 no.text = arrTtext[c];
			 tbox[c] = no;
		 }
     }
	 if(chk_value) document.all.select_value.value=chk_value;
}


///// select¼ø¼­ÀÌµ¿(¸ÇÀ§·Î, ¸Ç¾Æ·¡·Î, À§·Î, ¾Æ·¡·Î)
function swap(combo,index1, index2){
    var savedValue=combo.options[index1].value;
    var savedText=combo.options[index1].text;

    combo.options[index1].value=combo.options[index2].value;
    combo.options[index1].text=combo.options[index2].text;

    combo.options[index2].value=savedValue;
    combo.options[index2].text=savedText;
}
function OptAll(combo, option_value){
	document.all[option_value].value="";
	for (var i=0;i<combo.options.length;i++){
		document.all[option_value].value+=combo.options[i].value+"|";
	}
}

function MoveUp(combo_name, option_value){
    var combo=document.getElementById(combo_name);
    i=combo.selectedIndex;
    if (i>0){
        swap(combo,i,i-1);
        combo.options[i-1].selected=true;
        combo.options[i].selected=false;
		OptAll(combo, option_value);
    }
}
function MoveDown(combo_name, option_value){
    var combo=document.getElementById(combo_name);
    i=combo.selectedIndex;

    if (i<combo.length-1 && i>-1){
        swap(combo,i+1,i);
        combo.options[i+1].selected=true;
        combo.options[i].selected=false;
		OptAll(combo, option_value);
    }
}
function MoveToTop(combo_name, option_value){
    var combo=document.getElementById(combo_name);
    i=combo.selectedIndex;
    
    for (;i>0;i--){
        swap(combo,i,i-1);
        combo.options[i-1].selected=true;
        combo.options[i].selected=false;
    }
	OptAll(combo, option_value);
}

function MoveToBottom(combo_name, option_value){
    var combo=document.getElementById(combo_name);
    i=combo.selectedIndex;
    
    if (i>-1){
        for (;i<combo.length-1;i++)
        {
            swap(combo,i+1,i);
            combo.options[i+1].selected=true;
            combo.options[i].selected=false;
        }
		OptAll(combo, option_value);
    }
}

/////////////////////////////ÇÏ´Ü·¹ÀÌ¾î º¸¿´´Ù ¾Èº¸¿´´Ù
var old='';
function menu(name){
    downmenu=eval(name+".style");
    if(old!=downmenu)
    {
        if(old!='')
        {
            old.display='none';
        }
        downmenu.display='block';
        old=downmenu;
    }
    else
    {
        downmenu.display='none';
        old='';
    }
}