//¸µÅ© Á¡¼± hidden
function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

//ie6 mouseover ÀÌ¹ÌÁö ±ôºýÀÓ ÇØ°á
try {document.execCommand('BackgroundImageCache', false, true); } catch(e) {} 

function swapImage(imgId, value){
	var img = document.getElementById(imgId);

	if(value == "on"){
		img.src = img.src.replace(".png","_on.png");
	}else{
		img.src = img.src.replace("_on.png",".png");
	}
}

$(document).ready(function (){
	$(".img_dw").hover(
		function(){
			$(this).attr("src", $(this).attr("src").replace(".png","_on.png"));
		},
		function(){
			$(this).attr("src", $(this).attr("src").replace("_on.png",".png"));
	});

	$(".down_img").hover(function(){
		$(this).attr("src", $(this).attr("src").replace(".png","_on.png"));
	},function(){
		$(this).attr("src", $(this).attr("src").replace("_on.png",".png"));
	});


	/* ÆäÀÌÂ¡ ÀÌ¹ÌÁö over */
	if($(".setcolor01")){
		$(".setcolor01 .first01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("first","first01"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("first01","first"));});

		$(".setcolor01 .prev01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("prev","prev01"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("prev01","prev"));});

		$(".setcolor01 .next01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("next","next01"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("next01","next"));});

		$(".setcolor01 .end01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("end","end01"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("end01","end"));});
	}
	if($(".setcolor02")){
		$(".setcolor02 .first01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("first","first02"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("first02","first"));});

		$(".setcolor02 .prev01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("prev","prev02"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("prev02","prev"));});

		$(".setcolor02 .next01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("next","next02"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("next02","next"));});

		$(".setcolor02 .end01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("end","end02"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("end02","end"));});
	}
	if($(".setcolor03")){
		$(".setcolor03 .first01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("first","first03"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("first03","first"));});

		$(".setcolor03 .prev01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("prev","prev03"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("prev03","prev"));});

		$(".setcolor03 .next01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("next","next03"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("next03","next"));});

		$(".setcolor03 .end01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("end","end03"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("end03","end"));});
	}
	if($(".setcolor04")){
		$(".setcolor04 .first01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("first","first04"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("first04","first"));});

		$(".setcolor04 .prev01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("prev","prev04"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("prev04","prev"));});

		$(".setcolor04 .next01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("next","next04"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("next04","next"));});

		$(".setcolor04 .end01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("end","end04"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("end04","end"));});
	}
	if($(".setcolor05")){
		$(".setcolor05 .first01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("first","first05"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("first05","first"));});

		$(".setcolor05 .prev01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("prev","prev05"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("prev05","prev"));});

		$(".setcolor05 .next01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("next","next05"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("next05","next"));});

		$(".setcolor05 .end01").hover(function(){	$(this).attr("src", $(this).attr("src").replace("end","end05"));
		},function(){	$(this).attr("src", $(this).attr("src").replace("end05","end"));});
	}
});


// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");

	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		if (thismenu.imgEl) {
			thismenu.onclick = function () {
				//this.onmouseover();
				this.onclick();
			}
			thismenu.onfocus = function () {
				this.onfocus();
			}
		}
		thismenu.onclick = tabMenuClick;
		thismenu.onfocus = tabMenuClick;

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	tabContainer.first.onclick();
	tabContainer.first.onfocus();
}

function tabMenuClick() {
	currentmenu = this.container.current;

	if (currentmenu != this) {
		if (currentmenu) {
			currentmenu.targetEl.style.display = "none";
			if (currentmenu.imgEl) {
				currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif","_off.gif");
			} else {
				currentmenu.className = currentmenu.className.replace(" on", "");
			}
		}
		this.targetEl.style.display = "block";
		if (this.imgEl) {
			this.imgEl.src = this.imgEl.src.replace("_off.gif","_on.gif");
		} else {
			this.className += " on";
		}
		this.container.current = this;
	}
	return false;
}

function eleshow(ele) { /* º¸ÀÌ±â */
	if(typeof ele == "string") ele = document.getElementById(ele);
	ele.style.display = 'block';
	return false;
}
function elehidden(ele) { /* °¨Ãß±â */
	if(typeof ele == "string") ele = document.getElementById(ele);
	ele.style.display = 'none';
	return false;
}

function eleshow02(ele){
	if(typeof ele == "string") ele = document.getElementById(ele);

	if(ele.style.display == "block"){
		ele.style.display ="none";
	}else{
		ele.style.display ="block";
	}
}

$(document).ready(function(){
	$("#lan_div").css('z-index','1000');
	$(".sch").css('z-index','10');

	$("body").click(function(){
		if(document.getElementById('lan_div').style.display == "block"){
			$(".tbg02").removeClass("active");
			$("#lan_div").slideUp('fast');
		}
	})

	$(".tbg02 a").toggle(function(){
		if(document.getElementById('lan_div').style.display == "block"){
			$(".tbg02").removeClass("active");
			$("#lan_div").slideUp('fast');
		}else{
			$(".tbg02").addClass("active");
			$("#lan_div").slideDown('fast');
		}
	},function(){
		if(document.getElementById('lan_div').style.display == "block"){
			$(".tbg02").removeClass("active");
			$("#lan_div").slideUp('fast');
		}else{
			$(".tbg02").addClass("active");
			$("#lan_div").slideDown('fast');
		}
	})
})


function alink(arg){
	document.location.href= arg;
}

/*
function pop(url, width, height){
	window.open(url,"","width="+width+"px, height="+height+"px ");
}

function open_pop(url){
	scr_width = screen.availWidth;
	scr_height = screen.availHeight;
	//window.open("../swf/movie.html", "", "width="+scr_width+", height="+scr_height+", scrollbars=no, menubar=no, toolbar=no, status=no, location=no,resizable=yes");
	window.open(url, "", "width="+scr_width+", height="+scr_height+", scrollbars=no, menubar=no, toolbar=no, status=no, location=no,resizable=yes");
}
*/

/*
$(document).ready(function (){
	//$(".tbl_list02 tr:first-child").addClass('fir');
});
*/
// MSDS ·¹ÀÌ¾îÆË¾÷ Å×ÀÌºí hover
$(document).ready(function (){
	$(".tbl_result01 tr").hover(
		function(){
			$(this).addClass("on");
		},
		function(){
			$(this).removeClass("on");
	});
});

function hasClass(element,value) {
	var re = new RegExp("(^|\\s)" + value + "(\\s|$)");
	return re.test(element.className);
}

function addClass(element,value) {
	if (!element.className) {
			element.className = value;
	}else{
		var new_class_name = element.className;
		if (!hasClass(element,value)) {
			element.className += " " + value;
		}
	}
}

function removeClass(element,value) {
	if (element.className && hasClass(element,value)) {
		var re = new RegExp("(^|\\s)" + value);
		element.className = element.className.replace(re,"");
	}
}

function tblTrHover(obj){
	var obj = document.getElementById(obj);
	var objTr = obj.getElementsByTagName("TR");
	
	for(i=0; i<objTr.length; i++){
		if(objTr[i].parentNode.nodeName == "TBODY"){
			objTr[i].onmouseover = function(){
				addClass(this, "fir");
			}
			objTr[i].onmouseout = function(){
				removeClass(this, "fir");
			}
		}
	}
}

function tblTrHover02(obj){
	var obj = document.getElementById(obj);
	var objTr = obj.getElementsByTagName("TR");
	
	for(i=0; i<objTr.length; i++){
		if(objTr[i].parentNode.nodeName == "TBODY"){
			objTr[i].onmouseover = function(){
				addClass(this, "fir");
				$(".down img",this).attr("src",$(".down img",this).attr("src").replace(".png","_on.png"));
			}
			objTr[i].onmouseout = function(){
				removeClass(this, "fir");
				$(".down img",this).attr("src",$(".down img",this).attr("src").replace("_on.png",".png"));
			}
		}
	}
}

/* GNB select box */
/*
$(document).ready(function() {
	$('form#firstExample select').styledSelect();
	//$('form#firstExample02 select').styledSelect();
	//$('.sele_map select').styledSelect();
	$('form#firstExample03 select').styledSelect();
	$('form#firstExample04 select').styledSelect();
	$('form#firstExample05 select').styledSelect();
	$('form#firstExample06 select').styledSelect();
	$('form#firstExample07 select').styledSelect();
	$('form#firstExample08 select').styledSelect();
	$('form#firstExample09 select').styledSelect();

	$('form#firstExample10 select').styledSelect();
	$('form#firstExample11 select').styledSelect();
	$('form#firstExample12 select').styledSelect();

	//$('.styledSelect').append("<p class='sel_btn'><img src='../../img/common/bullet/img_select01.png' alt='' /></p>");

	$(".styledSelect").css({'background-image':'url("../../img/common/bullet/img_select03.png")', 'background-position':'right center', 'background-repeat':'no-repeat', 'background-color':'white'});

	if($('form#firstExample08 select')){
		$('form#firstExample08 .styledSelect:eq(0)').css({'z-index':'25'});
		$('form#firstExample08 .styledSelect:eq(1)').css({'z-index':'20'});
		$('form#firstExample08 .styledSelect:eq(2)').css({'z-index':'15'});
	}

	if($('form#firstExample04 select')){
		len = $("form#firstExample04 .styledSelect").length;

		if(len == 2){
			$('form#firstExample04 .styledSelect:eq(1)').css({'width':'64px'});
			$('form#firstExample04 .styledSelect:eq(1) ul').css({'width':'62px'});
		}else if(len == 3){
			$('form#firstExample04 .styledSelect:eq(1)').css({'width':'64px'});
			$('form#firstExample04 .styledSelect:eq(1) ul').css({'width':'62px'});

			$('form#firstExample04 .styledSelect:eq(2)').css({'width':'64px'});
			$('form#firstExample04 .styledSelect:eq(2) ul').css({'width':'62px'});			
		}
	}


	if($('form#firstExample10 select')){
		var num = 15;
		len = $("form#firstExample10 .styledSelect").length;
		for(i = 0; i < len; i++, num--){
			$('form#firstExample10 .styledSelect:eq('+i+')').css({'z-index':num});
			if(i == 0){
				$('form#firstExample10 .styledSelect:eq('+i+')').css({'width':'172px'});
				$('form#firstExample10 .styledSelect:eq('+i+') ul').css({'width':'170px'});
			}else if(i == 3){
				$('form#firstExample10 .styledSelect:eq('+i+')').css({'width':'132px'});
				$('form#firstExample10 .styledSelect:eq('+i+') ul').css({'width':'130px'});
			}else if(i == 4){
				$('form#firstExample10 .styledSelect:eq('+i+')').css({'width':'119px'});
				$('form#firstExample10 .styledSelect:eq('+i+') ul').css({'width':'117px'});
			}else if(i == 5){
				$('form#firstExample10 .styledSelect:eq('+i+')').css({'width':'105px'});
				$('form#firstExample10 .styledSelect:eq('+i+') ul').css({'width':'103px'});
			}else if(i == 6){
				$('form#firstExample10 .styledSelect:eq('+i+')').css({'width':'191px'});
				$('form#firstExample10 .styledSelect:eq('+i+') ul').css({'width':'189px'});
			}
		}
	}

	if($('form#firstExample11 select')){
		var num = 15;
		len = $("form#firstExample11 .styledSelect").length;
		for(i = 0; i < len; i++, num--){
			$('form#firstExample11 .styledSelect:eq('+i+')').css({'z-index':num});
			if(i == 0){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'80px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'80px'});
			}else if(i == 1){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'132px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'132px'});
			}else if(i == 3){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'170px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'170px'});
			}else if(i == 6){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'132px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'130px'});
			}else if(i == 7){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'119px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'117px'});
			}else if(i == 8){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'105px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'103px'});
			}else if(i == 9){
				$('form#firstExample11 .styledSelect:eq('+i+')').css({'width':'191px'});
				$('form#firstExample11 .styledSelect:eq('+i+') ul').css({'width':'191px'});
			}
		}
	}
});
*/
function open_pop(url, scr_width, scr_height){
	window.open(url, "", "width="+scr_width+", height="+scr_height+", scrollbars=no, menubar=no, toolbar=no, status=no, location=no,resizable=yes");
}

function open_pop1(url, scr_width, scr_height){
	window.open(url, "", "width="+scr_width+", height="+scr_height+", scrollbars=yes, menubar=no, toolbar=no, status=no, location=no,resizable=yes");
}



/**
 * °ø¹éÁ¦°Å
 */
function trimstr(str){
	var tmp = str;
	tmp = tmp.replace(/\s/g,"");   
	return tmp;
}

//¼ýÀÚ¿©ºÎ ¹Ù·Î Ã¼Å©
function ValidNumChk3(p_SelectEle) {	 
    var i_KeyValue = event.keyCode;		
    if ( (i_KeyValue >= 48 && i_KeyValue <= 57) || (i_KeyValue >= 96 && i_KeyValue <= 105) || (i_KeyValue == 9) || (i_KeyValue == 8)  || (i_KeyValue == 46) || (i_KeyValue == 37)  || (i_KeyValue == 39) )
	{
	}else{
		 event.returnValue=false;
    }
}




/**
ÇÔ¼ö¸í : isValidPassword
¼³   ¸í : ºñ¹Ð¹øÈ£ ¿¬¼Ó¼ýÀÚ¹× ¹®ÀÚ,¼ýÀÚ °Ë»ç
ÀÎ   ÀÚ : 
¸®   ÅÏ : 
»ç¿ë¹ý : 
*/
function isValidPassword(pwd){
    var alpaBig= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var alpaSmall= "abcdefghijklmnopqrstuvwxyz";
    var num = "01234567890";    
    
    if(pwd.length<4 || pwd.length > 16 ){
    	alert("ºñ¹Ð¹øÈ£´Â ¹Ýµå½Ã 4ÀÚ ÀÌ»ó 15ÀÚÀÌ³»·Î ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù");
        return false;
    }
    
    for(var i=0;i < num.length - pwd.length+1;i++){
        if(num.substring(i,i+pwd.length) == pwd)
        {
            alert("12345Ã³·³ ¿¬¼ÓµÈ ¼ýÀÚ´Â »ç¿ëÇÒ ¼ö °¡ ¾ø½À´Ï´Ù");
            return false;
        }
    }
    
    for(var i=0;i < alpaBig.length - pwd.length+1;i++){
        if(alpaBig.substring(i,i+pwd.length) == pwd)
        {
            alert("ABCDEFÃ³·³ ¿¬¼ÓµÈ ¹®ÀÚ´Â »ç¿ëÇÒ ¼ö °¡ ¾ø½À´Ï´Ù.");
            return false;
        }
    }
    
    for(i=0;i < alpaSmall.length - pwd.length+1;i++){
        if(alpaSmall.substring(i,i+pwd.length) == pwd)
        {
            alert("abcdefÃ³·³ ¿¬¼ÓµÈ ¹®ÀÚ´Â »ç¿ëÇÒ ¼ö °¡ ¾ø½À´Ï´Ù");
            return false;
        }
    }
    
    for(i=1;i < pwd.length;i++){
        if(pwd.substring(0,1) != pwd.substring(i,i+1) )
            return true;
    }
    alert("ºñ¹Ð¹øÈ£´Â °°Àº ¹®ÀÚ¸¸ ¿¬¼ÓÇØ¼­ ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù");    
    return false;
}


/**
 * ÁÖ¹Îµî·Ï¹øÈ£ À¯È¿¼º Ã¼Å©
 * @param str ÁÖ¹Îµî·Ï¹øÈ£
 * @return true/false
 */
function isJuminRegNumberUtl(str) {
    if(str != null && (str.length == 13 || str.length == 14)) {
        var num = '';

        if(str.length == 13) {
            num = str;
        } else {
            num = str.substring(0, 6) + str.substring(7, 14);
        }

        var sum = 0;
        var last = num.charCodeAt(12) - 0x30;
        var bases = "234567892345";

        for(var i=0; i<12; i++) {
            if (isNaN(num.substring(i,i+1))) return false;
            sum += (num.charCodeAt(i) - 0x30) * (bases.charCodeAt(i) - 0x30);
        }

        var mod = sum % 11;

        return ((11 - mod) % 10 == last) ? true : false;
    } else {
        return false;
    }
}
