
// roundBox Layout
function initLayout(layoutEl,childEl) {
    var layoutId = document.getElementById(layoutEl);
    var contentsId = document.getElementById(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 ¿¹¿ÜÃ³¸®
function firstChild(Elid, Etn, Num){
	if(Num==""){Num=0;}
	liEl = document.getElementById(Elid).getElementsByTagName(Etn);
	if (liEl.item(Num)) {
		liEl.item(Num).className += " first-child";
	}
}


	//LEFT ¸Þ´º ÁÖ¼Ò¸µÅ©ÀÌµ¿
	function gopage(url){
		location.href=url;
	}

//vision open Layer
function opLayer(opID){
	document.getElementById(opID).style.display="block";
}
function closeLayer(clID){
	document.getElementById("vision"+clID).style.display="none";
}

function openPop(url,idn,intWidth,intHeight,scroll) { 
	//alert("pop_scroll");
	window.open(url, idn,"width="+intWidth+", height="+intHeight+",resizable=0,scrollbars="+scroll) ;
}

//±¹¹® »çÀÌÆ® ¹Ù·Î°¡±â
function goKor(){
	 
	var dom = document.domain;
	val = "util";
	var link="http://www.lg.co.kr?section=obj_kor_eng&from="+ val ;	
	
	openwindow(link, 'winKorean','' );
	
}
// openwindow
function openwindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}



function goMainClickView(){
	 
	var dom = document.domain;
	val = "main";
	var link="/common/site_link.jsp?sitelink=http://www.lge.com/products/main.jhtml?section=obj_main_click_view="+ val ;	
	
	openwindow(link, 'winKorean','' );
	
}



function onLink(Viewnum){
	var blockIE = document.getElementById("comp_link");
	var imgIE = blockIE.getElementsByTagName("dt");
	var txtIE = blockIE.getElementsByTagName("dd");
		for(var i=0 ; i<imgIE.length; i++){
			if(i==Viewnum){
				imgIE.item(i).style.display="";
				txtIE.item(i).style.display="";
			}else{
				imgIE.item(i).style.display="none";
				txtIE.item(i).style.display="none";
			}
		}
}



/********************************************************************
*  Function Name		: LocationSetting
*  Description			: uri ·ÎÄÉÀÌ¼Ç ¼ÂÆÃ 
*  Input Data			: tagURL
*  Output Data			: None
*  »ç¿ëµÇ´Â Function 		: None
/********************************************************************/

function LocationSetting(uri,param,val){

 	var Chars = checkSpecialChar(uri);
		
	  if(Chars == true){ // ÆÄ¶ó¹ÌÅÍ °ªÀÌ ÀÖÀ¸¸é 
		location.href=uri.replace(" ","")+"&section="+param+"&from="+val;
	  } else {    // ÆÄ¶ó¹ÌÅÍ °ªÀÌ ¾øÀ¸¸é 
		location.href=uri.replace(" ","")+"?section="+param+"&from="+val;
	 }

}
 


/********************************************************************
*  Function Name		: MainLocationSetting
*  Description			: uri ·ÎÄÉÀÌ¼Ç ¼ÂÆÃ 
*  Input Data			: tagURL
*  Output Data			: None
*  »ç¿ëµÇ´Â Function 		: None
/********************************************************************/

function MainLocationSetting(uri,mainMode,param,val){


 	var Chars = checkSpecialChar(uri);
		
	  if(Chars == true){ // ÆÄ¶ó¹ÌÅÍ °ªÀÌ ÀÖÀ¸¸é 
		location.href=uri.replace(" ","")+"&section="+param+"&from="+val+"&mainMode="+mainMode;
	  } else {    // ÆÄ¶ó¹ÌÅÍ °ªÀÌ ¾øÀ¸¸é 
		location.href=uri.replace(" ","")+"?section="+param+"&from="+val+"&mainMode="+mainMode;
	 }

}




/* --------------------------------------------- 
 * ÇÔ¼ö¸í : checkSpecialChar 
 * ¼³  ¸í : Æ¯¼ö¹®ÀÚ Ã¼Å©  URI·ÎÄÉÀÌ¼Ç ÆÄ¶ó¹ÌÅÍ °ª Ã¼Å© 
 * ¿¹) if(!checkSpecialChar()) return; 
 ---------------------------------------------*/ 
function checkSpecialChar(Chk){ 

    if(Chk.search(/[?]/) >= 0) { 
//      alert("¹®ÀÚ¿­¿¡ Æ¯¼ö¹®ÀÚ( \",  ',  <,  > )°¡ ÀÖ½À´Ï´Ù.\nÆ¯¼ö¹®ÀÚ¸¦ Á¦°ÅÇÏ¿© ÁÖ½Ê½Ã¿À!");         
      return true;
      } else { return false; }
} 



//Á¦Ç°Ã£±â ¹Ù·Î°¡±â(»õÃ¢)
function goProduct(link){
	if (link=="" || link==null) {
	} else {		
		if(link.indexOf("http://") < 0) {
			link = "http://" + link;
		}	
		openwindow(link, 'winProduct','' );
	}
}







 
function checkEmailForm( emailbox ) {
    emailbox.value = alltrim(emailbox.value);

    if (emailbox.value.length == 0) {
		alert("Please insert your e-mail address");
        emailbox.focus();
        return false;
    }

    if (isAllowStr(emailbox.value, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@.-_") == false) {
		alert("Please insert your correct e-mail address");
        return false;
    }

    var atCnt = 0;
    var dotCnt = 0;
    for (i = 0; i < emailbox.value.length ; i++) {
        ch = emailbox.value.charAt(i);
        if (ch == "@")
            atCnt++;
        if (ch == ".") {
            dotCnt++;
        }
    }

    if (atCnt != 1 || dotCnt < 1) {
		alert("Please insert your correct e-mail address");
        emailbox.focus();
        return false;
    }

    var atIndex = 0;
    atIndex = emailbox.value.indexOf("@");

    if (atIndex <= 0) {
		alert("Please insert your correct e-mail address");
        emailbox.focus();
        return false;
    }

    return true;
}
function alltrim(str) {
    var i;
    var ch;
    var retStr = '';
    var retStr1 = '';
    if (str.length == 0)
        return str;
    for (i=0;i<str.length;i++) {
        ch = str.charAt(i);
        if (ch == ' ' || ch == '\r' || ch == '\n')
            continue;
         retStr += ch;
    }
    return retStr;
}

function isAllowStr(str, allowStr) {
    var i;
    var ch;
    for (i=0;i<str.length;i++) {
        ch = str.charAt(i);
        if (allowStr.indexOf(ch) < 0) {
            return false;
        }
    }
    return true;
}




