﻿//div mouse drag control
	var bdown = false;
	var x, y;
	var sElem;
	
	function mdown() {
		if(event.srcElement.className == "drag") {
			bdown = true;
			sElem = event.srcElement;
			x = event.clientX;
			y = event.clientY;
		}
	}
	
	function mup() {
		bdown = false;
	}
	
	function moveimg() {
		if(bdown) {
			var distX = event.clientX - x;
			var distY = event.clientY - y;
			sElem.style.pixelLeft += distX;
			sElem.style.pixelTop += distY;
			x = event.clientX;
			y = event.clientY;
			return false;
		}
	}
	document.onmousedown = mdown;
	document.onmouseup = mup;
	document.onmousemove = moveimg;
//=========================================================================================================	

function EnterKey(){
	if (event.keyCode == 13){
		onSubmit();
	}
}
	
//frame left auto control
function switchSysBarl(){ 
	var imgsrc; 
	imgsrc=document.all("makeleft").src; 
	if (imgsrc.indexOf("pic23")>1)	{ 
		 parent.left.cols='0,13,20, *';
		document.all("makeleft").src="/timeadmin/images/pic24.gif"; 
	} 
	else{ 
		parent.left.cols='200,13,20, *';
		document.all("makeleft").src="/timeadmin/images/pic23.gif"; 
	} 
}
//견적서 보기(doc_account view Estimate)
function reView(estNum)	{
	window.open('/timeAdmin/estimate/review.asp?estimateNum='+estNum,'', 'width=750, height=650,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=yes, copyhistory=no')
}

function PopClose(){
	window.close();
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//부킹장부 관련, 정산관련
///////////////////////////////////////////////////////////////////////////////////////////////////////////////	
//견적서정보 찾기
function findEstimate(doc_Chk)	{
	if(doc_Chk=="realCost"){//실비정산인경우는 최종견적만 검색
		window.open('/timeadmin/real_Cost/findEstimate.asp','', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
	}
	else if(doc_Chk=="inform"){
		window.open('/timeadmin/real_Cost/findInform.asp','', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
	}
	else{
		window.open('/timeadmin/booking/findEstimate.asp?doc_Chk='+doc_Chk,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
	}
}

//정산서정보 찾기
function findDocument(doc_Chk, cnt)	{
	var doc_Kind;
	var progress;
	//실비정산인경우는 최종정산서만 검색
	if(doc_Chk=="realCost"){doc_Kind="estimate"; progress=3;}
		window.open('/timeadmin/real_Cost/findDocument.asp?doc_Chk='+doc_Chk+"&doc_Kind="+doc_Kind+"&progress="+progress+"&cnt="+cnt,'', 'width=700, height=680,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
	}
//부서정보 찾기
function findDepartment()	{
	window.open('/timeadmin/booking/findDepartment.asp','', 'width=350, height=450,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}
//데일리 상품정보 찾기
function findDaily(doc_Chk,o,cnt)	{
	window.open('/timeadmin/booking/findDaily.asp?doc_Chk='+doc_Chk+'&findKind='+o+'&cnt='+cnt,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
}
//호텔정보 찾기
function findHotel(doc_Chk,o,cnt)	{
	window.open('/timeadmin/booking/findHotel.asp?doc_Chk='+doc_Chk+'&findKind='+o+'&cnt='+cnt,'', 'width=500, height=650,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
}
//쇼핑기업정보 찾기
function findShop(doc_Chk,o,cnt)	{
	window.open('/timeadmin/booking/findShop.asp?doc_Chk='+doc_Chk+'&findKind='+o+'&cnt='+cnt,'', 'width=500, height=650,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
}
//가이드정보 찾기
function findGuide(doc_Chk)	{
	window.open('/timeadmin/booking/findGuide.asp?doc_Chk='+doc_Chk,'', 'width=505, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//기업정보 관련
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//부서정보 찾기(info_company)
function findDep_InfoCompany()	{
	window.open('/timeadmin/info_company/findDepartment.asp','', 'width=350, height=450,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}
//직급정보 찾기(info_company)
function findPos_InfoCompany()	{
	window.open('/timeadmin/info_company/findPosition.asp','', 'width=350, height=450,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//견적서 관련
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//기업정보 찾기
function findCompany(estLang)	{
	window.open('/timeadmin/estimate/findCompany.asp?estLang='+estLang,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=yes, copyhistory=no')
	}
//개인정보 찾기	
function findIndi(estLang)	{
	window.open('/timeadmin/estimate/findIndi.asp?estLang='+estLang,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=yes, copyhistory=no')
	}
//샘플일정 찾기	
function findSample(estLang,findKeyWord)	{
	window.open('/timeadmin/estimate/findSample.asp?estLang='+estLang+'&findKeyWord='+findKeyWord,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
	}	
//가이드, 차량이미지 찾기
function insertPhoto(o)	{
	var cateKind = document.all.item("category"+o).value;
	window.open('/timeadmin/estimate/findPhoto.asp?photo='+o+'&category='+cateKind,'', 'width=505, height=750,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=yes, copyhistory=no')
}
function selectEstimate(a, b)	{
	window.open('/timeadmin/estimate/selectList.asp?idxNum='+a+'&gubun='+b,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no')
}	

function FormatNumber3(num){
	num=new String(num)
	num=num.replace(/,/gi,"")
	return FormatNumber2(num)
}

function FormatNumber4(num){
	num=new String(num)
	num=num.replace(/,/gi,"")
	return num
}

function FormatNumber2(num){
	fl=""
	if(isNaN(num)) { alert("character type use not ");return 0}
	if(num==0) return num
	if(num<0){ 
			num=num*(-1)
			fl="-"
	}else{
			num=num*1 //처음 입력값이 0부터 시작할때 이것을 제거한다.
	}
	num = new String(num)
	temp=""
	co=3
	num_len=num.length
	
	while (num_len>0){
		num_len=num_len-co
		if(num_len<0){co=num_len+co;num_len=0}
		temp=","+num.substr(num_len,co)+temp
	}
	return fl+temp.substr(1)
}

function CheckNumPax() {
	var f = document.listFrm;
	f.pick_Total.value = FormatNumber2(Number(document.all.pick_Adlt.value) + Number(document.all.pick_Child.value) + Number(document.all.pick_Charge.value));
}
//견적서에서 단독으로 사용됨(부킹, 정산서, 투어일지는 각페이지에서 )
function CheckNum(form) {
	var f = document.listFrm;
	var cnt = f.NumberOfItems.value;
	var totalAmount=0;
	
	document.all.item("amount"+form).value = Number(document.all.item("quantity"+form).value) * Number(document.all.item("price"+form).value);
//		document.all.item("amount"+form).value = String(document.all.item("quantity"+form).value) * String(document.all.item("price"+form).value);
	
	for (i=1;i<=cnt;i++){
		totalAmount = Number(totalAmount) + Number(document.all.item("amount"+i).value);
	}
	f.subAmount.value = FormatNumber3(totalAmount);	

}
//투어정보 도움말
function findTourInfoHelp(estLang)	{
	var f = document.listFrm;
//		var ts = f.tourSchedule.value.replace(/→/gi,"/");
	var a = f.samSchNum.value;
	var b = f.samSchKind.value;
//	var c = f.tourSchedule.value;
//		var c = f.desLanguage.checked;
	if (f.tourSchedule.value != ""){
//			alert(ts);
		window.open('./findTourInfoHelp.asp?estLang='+estLang+'&samSchNum='+a+'&samSchKind='+b,'', 'width=700, height=700,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=yes, copyhistory=no')
	}
	else{
		alert("Caution!! Schedule is null");
		f.tourSchedule.focus();
	}
}

function viewInfoTour(o){
	var f = document.listFrm;
	if (o == "K" || o =="E" || o =="J" || o =="C" ) {
		document.all.infoTour.style.display=""
	}
	else {
		document.all.infoTour.style.display="none";
	}
} 

function Check(keyword) {
	var st_num, key_len;
	st_num = keyword.indexOf(" ");	
	while (st_num != -1){
		keyword = keyword.replace(" ", "");
		st_num  = keyword.indexOf(" ");
	}
	key_len=keyword.length;
	return key_len;
}
	
function addColum(form){
	var f = document.listFrm;
	if(f.NumberOfItems.value >= 100){
		alert("Caution!! Max :100EA");
		return;
	}
	else{
		var i = f.NumberOfItems.value;
		f.NumberOfItems.value = Number(i)+1;
		document.all.item("tblAttachTable"+f.NumberOfItems.value).style.display="";
	}
}

function addColumA(form){
	var f = document.listFrm;
	if(f.NumberOfItemsA.value >= 20){
		alert("Caution!! Max :20 EA");
		return;
	}
	else{
		var i = f.NumberOfItemsA.value;
		f.NumberOfItemsA.value = Number(i)+1;
		document.all.item("tblAttachTableA"+f.NumberOfItemsA.value).style.display="";
	}
}

function delColum(){
	var f = document.listFrm;
	if(f.NumberOfItems.value <= 1){
		alert("default : 1EA");
		return;
	}
	else{
		var i = f.NumberOfItems.value;
		f.NumberOfItems.value = Number(i)-1;
		document.all.item("tblAttachTable"+f.NumberOfItems.value).style.display="none";
	}
}
//타임별 일정 사용유무
function viewDetailTime(o,target_name){
	var target = document.getElementsByName(target_name);
	
	if (o == 2) {
		document.all.detailScheduleTime.style.display=""
	}
	else{
		if (document.all.schMainUseDiv[0].checked==true){
			alert("전체일정이 사용안함으로 설정되어 있기 때문에 \n\n타임별일정을 사용안함으로 설정할 수 없습니다.\n\n전체일정과 타임별일정 모두 사용안함으로 설정할 수 없습니다.");
			target[1].checked = true;
		}
		document.all.detailScheduleTime.style.display="none";
	}
} 
//전체일정과 타임별일정 사용유무 check
function viewTime(target_name){
	var target = document.getElementsByName(target_name);

	if (document.all.schUseDiv[0].checked==true){
		alert("타임별 일정이 사용안함으로 설정되어 있기 때문에 \n\n전체 일정을 사용안함으로 설정할 수 없습니다.\n\n전체일정과 타임별일정 모두 사용안함으로 설정할 수 없습니다.");
		target[1].checked = true;
	}
} 

function numCheck(target){  
  var Digit = '1234567890';
   for (i=0 ;i<=target.length ;i++)
   {  if(Digit.indexOf(target.substring(i,i+1)) < 0) 
      {  
   return true;
      }
   }
   return false;
}

function numCheck1(o){
	if(isNaN(o)==true) {
		alert("숫자만 입력하십시오."); 
		return;
	}
}

var special_char = " `~!@#$%^&*()_-+=|\\[]{}:;,<.>/?'\"";
var temp = "";
function identify(ident) {
	for ( var i = 0 ; i < special_char.length ; i++ ) {
		temp = special_char.substr(i, 1); 
		if ( ident.indexOf(temp) != -1 ) return true ;
	}
	return false;
}

var addr_special_char = "`~!@#$%^&*_+=|\\[]{}:;,<.>/?'\"";
var temp1 = "";
function addr_identify(ident) {
	for ( var i = 0 ; i < addr_special_char.length ; i++ ) {
		temp1 = addr_special_char.substr(i, 1); 
		if ( ident.indexOf(temp1) != -1 ) return true ;
	}
	return false;
}

var email_special_char = " `~!#$%^&*()+=|\\[]{}:;,<>/?'\"";
var temp2 = "";

function email_identify(ident) {
	for ( var i = 0 ; i < email_identify.length-3; i++ ) {
		temp2 = email_special_char.substr(i,1);
		if ( ident.indexOf(temp2) != -1 ) return true;
	}
	return false;
}

function email_chk(t){
	var ValidFlag = false
	var atCount = 0
	var SpecialFlag
	var atLoop
	var atChr
	var BadFlag
	var tAry1
	var UserName
	var DomainName

	if ( t.length > 0 && t.indexOf("@") > 0 && t.indexOf(".") > 0 ) {
		atCount = 0
		SpecialFlag = false

		for( atLoop=1; atLoop<=t.length; atLoop++ ) {
atChr = t.substring( atLoop, atLoop+1 )
if ( atChr == "@" ) atCount = atCount + 1

if ( (atChr >= 32) && (atChr <= 44) ) SpecialFlag = true 
if ( (atChr == 47) || (atChr == 96) || (atChr >= 123) ) SpecialFlag = true 
if ( (atChr >= 58) && (atChr <= 63) ) SpecialFlag = true 
if ( (atChr >= 91) && (atChr <= 94) ) SpecialFlag = true 
		}

		if ( ( atCount == 1 ) && (SpecialFlag == false ) ) {
BadFlag = false
tAry1 = t.split("@")
UserName = tAry1[0]
DomainName = tAry1[1]
if ( (UserName.length <= 0 ) || (DomainName.length <= 0 ) ) BadFlag = true
if ( DomainName.substring( 1, 2 ) == "." ) BadFlag = true
if ( DomainName.substring( DomainName.length-1, DomainName.length) == "." ) BadFlag = true
ValidFlag = true
		}
	}
	if ( BadFlag == true ) ValidFlag = false
	return ValidFlag

}

function check_companynum()
{
	var su1 = mregform.su1.value;
	var su2 = mregform.su2.value;
	var su3 = mregform.su3.value;
	
	var checkID = new Array(1, 3, 7, 1, 3, 7, 1, 3, 5, 1);
	var bizID = ""+ su1 + su2 + su3;
	var i, Sum=0, c2, remander;
	
	for (i=0; i<=7; i++) Sum += checkID[i] * bizID.charAt(i);
	
		c2 = "0" + (checkID[8] * bizID.charAt(8));
		c2 = c2.substring(c2.length - 2, c2.length);
		
		Sum += Math.floor(c2.charAt(0)) + Math.floor(c2.charAt(1));
		
		remander = (10 - (Sum % 10)) % 10 ;
	
	if (Math.floor(bizID.charAt(9)) != remander)
	{
		alert ("사업자등록번호가 잘못되었습니다. \n\n다시 시도해 주십시오.");
		return true;
	}
	return false;
}


function IDCheck(t)
{
	var id = t.value;
    var  id_check = "";
    var temp6 = "";

	if (id.length == "")	{
		t.focus();
		alert("Please, Company Name!!");
	}else{
	    window.open('/timeadmin/intra/id_check.asp?id='+id,'', 'width=398, height=186,left=200,top=200, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, scrollbars=no, copyhistory=no');
	}
}

function Jumin_chk(it) {
	IDtot = 0;
	IDAdd = "234567892345";

	for(i=0; i<12; i++) IDtot = IDtot + parseInt(it.substring(i, i+1)) * parseInt(IDAdd.substring(i, i+1));
	IDtot = 11 - (IDtot%11);
	if (IDtot == 10) IDtot = 0;
	else if (IDtot == 11) IDtot = 1;
	if(parseInt(it.substring(12, 13)) != IDtot) return true;
	else return false
} 


function social_id_check(f) {
	jumin = mregform.jumin1.value+mregform.jumin2.value;

	if(Jumin_chk(jumin)) {
		alert("Error!! Social Number \n\nretry");
		return true
	} 
	return false
}


function getObj(obj) 
{ 
var nscp = (navigator.appName == "Netscape") 
var ismc = (navigator.appVersion.indexOf("Mac") != -1) 
var vers = parseFloat(navigator.appVersion.substring(22,25)) 

   if (nscp) 
   { 
    compLayr = document.layers[obj] 
   }
   else
   { 
    compLayr = eval("document.all." + obj + ".style") 
   } 
    return compLayr 
}

function s_menu_v(name)
{ 
    obj = getObj(name) ;
    obj.visibility = "visible" ;
}

function s_menu_h(name)
{ 

    obj = getObj(name) ;
    obj.visibility = "hidden" ;
}

function menugo(url)
{
	location.href=url;
}

//roll over
function restore_img_src(name, nsdoc){
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	if (name == '')
	return;
	
	if (img && img.altsrc) {
		img.src    = img.altsrc;
		img.altsrc = null;
	} 
}

function preload_img(){ 
	var img_list = preload_img.arguments;
	if (document.preloadlist == null) 
	document.preloadlist = new Array();
	var top = document.preloadlist.length;

	for (var i=0; i < img_list.length; i++) {
		document.preloadlist[top+i]     = new Image;
		document.preloadlist[top+i].src = img_list[i+1];
	} 
}

function change_img_src(name, nsdoc, rpath, preload){ 
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	if (name == '')
	return;

	if (img) {
		img.altsrc = img.src;
		img.src    = rpath;
	} 
}

function enter()
{
    if (event.keyCode == 13){
        if (event.shiftKey == false){
            var sel = document.selection.createRange();
            sel.pasteHTML('<br>');
            event.cancelBubble = true;
            event.returnValue = false;
            sel.select();
            return false;
        } else {
            return event.keyCode = 13;
		}
    }
}

function AutoResize(img){ 
  foto1= new Image(); 
  foto1.src=(img); 
  Controlla(img); 
}

function Controlla(img){ 
  if((foto1.width!=0)&&(foto1.height!=0)){ 
    viewFoto(img); 
  } 
  else{ 
    funzione="Controlla('"+img+"')"; 
    intervallo=setTimeout(funzione,20); 
  } 
}

function viewFoto(img){ 
	largh=foto1.width+20; 
	altez=foto1.height+20; 
	stringa="width="+largh+",height="+altez; 
	finestra=window.open("/include/view_image.asp?image_name=" + img,"view",stringa);
	finestra.focus();
}

function FocusColor(This) { This.style.backgroundColor = "#FFF4DA"; }
function BlurColor(This) { This.style.backgroundColor = "#FFFFFF";}
