//Element ID 불러쓰기
function dEI(elementID){
	return document.getElementById(elementID);
}

// roundBox Layout
function initLayout(layoutEl,childEl) {
	var layoutId = dEI(layoutEl);
	var contentsId = dEI(childEl);
		
	//create and build div structure
	var bodyTH = document.createElement('div');
	var bodyLV = document.createElement('div');
	var bodyRV = document.createElement('div');
	var bodyBH = document.createElement('div');
	var bodyTL = document.createElement('div');
	var bodyTR = document.createElement('div');
	var bodyBL = document.createElement('div');
	var bodyBR = document.createElement('div');
	bodyTH.className = "bodyTH";
	bodyLV.className = "bodyLV";
	bodyRV.className = "bodyRV";
	bodyBH.className = "bodyBH";
	bodyTL.className = "bodyTL";
	bodyTR.className = "bodyTR";
	bodyBL.className = "bodyBL";
	bodyBR.className = "bodyBR";
	layoutId.appendChild(bodyTH);
	bodyTH.appendChild(bodyLV);
	bodyLV.appendChild(bodyRV);
	bodyRV.appendChild(bodyBH);
	bodyBH.appendChild(bodyTL);
	bodyTL.appendChild(bodyTR);
	bodyTR.appendChild(bodyBL);
	bodyBL.appendChild(bodyBR);
	bodyBR.appendChild(contentsId);
}

//Images Btn_KSS
function BtnOn(imgEl){
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function BtnOut(imgEl){
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

// first 예외처리 firstChild(블럭Id, 태그네임, 처리할 아이템 번호) // 아이템번호는 0번부터 반환
function firstChild(Elid, Etn, Num){
	if(Num==""){Num=0;}
	liEl = dEI(Elid).getElementsByTagName(Etn);
	if (liEl.item(Num)) {
		liEl.item(Num).className += " first-child";
	}
}

// first 예외처리 listFirst(블럭Id, 태그네임, 처리할 아이템 갯수) // 아이템번호는 0번부터 반환
function listFirst(Elid, Etn, Num){
	liEl = dEI(Elid).getElementsByTagName(Etn);
	for(i=0; liEl.length>i; i=i+Num){
		liEl.item(i) .className += " first";
	}
}

// first line 예외처리 firstLine(블럭Id, 태그네임, 처리할 아이템 갯수) // 아이템번호는 0번부터 반환
function firstLine(Elid, Etn, Num){
	liEl = dEI(Elid).getElementsByTagName(Etn);
	var checkNum = Num;
	if(liEl.length<Num){
		liEl.length = checkNum;
	}
	for(i=0; i<checkNum; i++){
	liEl.item(i) .className += " firstLine";
	}
}

//이메일 유효성 체크
function email_chk(email) {
  var invalidChars = "\"|&;<>!*\'\\"   ;
  for (var i = 0; i < invalidChars.length; i++) {
	if (email.indexOf(invalidChars.charAt ) != -1) {
	   return false;
	}
  }
  if (email.indexOf(" ") != -1){
	return false;
  }
  if (window.RegExp) {
	var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
	var reg1 = new RegExp (reg1str);
	var reg2 = new RegExp (reg2str);
 
	if (reg1.test(email) || !reg2.test(email)) {
	   return false;
	}
  }
  return true;
} 

//프린트 영어 출력
   var win=null;
  function printIt(printThis)  {
    win = window.open();
    self.focus();
    win.document.open();
    win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
    win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');
    win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
    win.document.write(printThis);
    win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
    win.document.close();
    win.print();
    win.close();
  }
 
