var imgserver = "http://image.ahnlab.com/img_upload";


// Flash
function swfprint(objid,furl,fwidth,fheight,transoption,flashvars) {
	var swfString = '<object id="'+ objid +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+ fwidth +'" height="' + fheight +'" >';
	swfString += '<param name="allowScriptAccess" value="always"/>';
	swfString += '<param name="movie" value="'+ furl +'"/>';
	swfString += '<param name="quality" value="high"/>';
	if (flashvars) swfString += '<param name="flashVars" value="'+ flashvars +'" />';
	if (transoption == "t"){
		swfString += '<param name="wmode" value="transparent" />';
	} else if (transoption == "o"){
		swfString += '<param name="wmode" value="opaque" />';
	}
	swfString += '<![if !IE]>';
	swfString +='<embed name="'+objid+'" src="'+ furl +'"quality="high" wmode="transparent" width="'+ fwidth +'" height="'+ fheight +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />';
	swfString += '<![endif]>';
	swfString +='</object>';
	document.write(swfString);
}

//제품카테고리 Print
function pCategoryPrint(url,w,h,vars,bg,win){
	
	var id=url.split("/")[url.split("/").length-1].split(".")[0]; //id는 파일명으로 설정
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';

	// 플래시 코드 정의
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='false' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
	
	
		flashStr+="		<embed src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='false'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";

	// 플래시 코드 출력
	document.write(flashStr);
}

appname = navigator.appName;
useragent = navigator.userAgent;
if(appname == "Microsoft Internet Explorer") appname = "IE";
IE55 = (useragent.indexOf('MSIE 5.5')>0);  //5.5 버전
IE6 = (useragent.indexOf('MSIE 6')>0);     //6.0 버전

function chgSelect() {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		if(selectObj) {
			for (var i=0; i<selectObj.length; i++) {
				selectObj[i].style.visibility ="hidden";
			}
		}
	}
}
function chgSelectDefaut() {
	var selectObj = document.getElementsByTagName("select");
	if(appname=="IE" && IE55 || IE6) {
		if(selectObj) {
			for (var i=0; i<selectObj.length; i++) {
				selectObj[i].style.visibility ="visible";
			}
		}
	}
}

function resizeLNB(h){
	var objLNB = document.getElementById('LNBBox');
	objLNB.style.height= h+"px";
}
function resizeGNB(h){
	document.getElementById('gnbBox').style.height=h+'px';
	var objsBar=document.getElementById('schBar');
	var objsBar2=document.getElementById('schLayer');

	if(h > 135){
		objsBar.style.display='none';
		objsBar2.style.display='none';
	}else{
		objsBar.style.display='block';
	}
}
function resizeMain(h){
	document.getElementById('mFlash').style.height=(h+20)+'px';
}


//제품카테고리
function hideCategory() {
	document.getElementById('productCategory').style.width="0px";
	document.getElementById('productCategory').style.height="0px";
	chgSelectDefaut();
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		if ( navigator.appVersion.indexOf("MSIE 9.0") != -1 ) {
			return document[movieName];
		} else {
			return window[movieName]
		}
	} else {
		return document[movieName];
	}
}
function openCategory() {
	document.getElementById('productCategory').style.width="732px";
	document.getElementById('productCategory').style.height="313px";
	thisMovie("productCategory").openCategory();
	chgSelect();
}



// POP - Q&A
function showQNA(num) {
	var selectObj=document.getElementById('qList').getElementsByTagName("li");

	for (var i=0; i<selectObj.length; i++) {
		if(num==i){
			selectObj.item(num).className = "on";
		}else{
			selectObj.item(i).className = "";
		}
		document.getElementById('q'+i).style.display= (num==i)?"":"none";
		document.getElementById('a'+i).style.display= (num==i)?"":"none";
	}
}


function TabOver(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_over.gif");
}
function TabOut(imgEl) {
	imgEl.src = imgEl.src.replace("_over.gif", ".gif");
}


// 보안 정보 디렉토리 & 상세보기 Box
function viewOpen(){
	img=document.getElementById('viewBtn');
	lay=document.getElementById('viewLayer');

	if(lay.style.display=="none"){
		img.src = imgserver+"/kr/site/images/common/btn/btns_layerclose.gif";
		img.alt="닫기";
		lay.style.display="block";
	}else{
		img.src = imgserver+"/kr/site/images/common/btn/btns_layeropen.gif";
		img.alt="펼치기";
		lay.style.display="none";
	}
}

//의견 달기 Box
function commOpen(btnid,layerid){
	img=document.getElementById(btnid);
	lay=document.getElementById(layerid);

	if(lay){
		if(lay.style.display=="none"){
			img.src = imgserver+"/kr/site/images/common/btn/btnt_commclose.gif";
			lay.style.display="block";
		}else{
			img.src = imgserver+"/kr/site/images/common/btn/btnt_commopen.gif";
			lay.style.display="none";
		}
	}
}

//Footer
function footerOpen(){
	img=document.getElementById('qBtn');
	lay=document.getElementById('qBox');

	if(lay.style.display=="none"){
		img.src = imgserver+"/kr/site/images/common/btn/btns_fclose.gif";
		lay.style.display="block";
	}else{
		img.src = imgserver+"/kr/site/images/common/btn/btns_fopen.gif";
		lay.style.display="none";
	}
}

//Footer - Global Site
function globalSite(){
	btn=document.getElementById('fsbtn');
	lay=document.getElementById('fsBox');

	if(lay.style.display=="none"){
		btn.className = "btn on";
		lay.style.display="block";
	}else{
		btn.className = "btn";
		lay.style.display="none";
	}
}

//고객지원센터 fAQ
function showFaq(id){
	var fb = document.getElementById(id);
	if (fb.style.display == 'block'){
		fb.style.display='none';
	}
	else{
		fb.style.display='block';
	}
}

// Layer Show&Hidden
function showLayer(id){
	var fb = document.getElementById(id);
	if (fb.style.display == 'block'){
		fb.style.display='none';
	}
	else{
		fb.style.display='block';
	}
}
function hiddenLayer(id){
	document.getElementById(id).style.display='none';
}


// PNG
function setPng24(obj) {
	try {
		obj.width=obj.height=1;
		obj.className=obj.className.replace(/\bpng24\b/i,'');
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
		obj.src='';
		return '';
	} catch(e) {}
}


//달력레이어
function getOffsetTop(obj){ return obj ? obj.offsetTop + getOffsetTop(obj.offsetParent) : 0; }
function getOffsetLeft(obj){ return obj ? obj.offsetLeft + getOffsetLeft(obj.offsetParent) : 0; }

function showLayCal( bShow, hook){

	var oPrev = document.getElementById('popCal') ;
	var oBody = ( document.compatMode && document.compatMode!="BackCompat" ) ? document.documentElement : document.body ;

	if(bShow){
		var nLyrWidth = 172 ;
		var nLyrInt = -150 ;
		var nArrowInt = 0 ;
		var nHookLeft = getOffsetLeft(hook) ;
		var nHookTop = getOffsetTop(hook) ;
		if (nHookLeft + nLyrWidth > oBody.scrollWidth)
		{
			nLyrLeft = oBody.scrollWidth - nLyrWidth - 5 ;
			nArrowLeft = nHookLeft-nLyrLeft+nLyrInt+nArrowInt ;
		}else{
			nLyrLeft = nHookLeft+nLyrInt ;
			nArrowLeft = nArrowInt ;
		}
		nLyrTop = nHookTop + hook.clientHeight+5 ;
		oPrev.style.left = nLyrLeft + "px" ;
		oPrev.style.top = nLyrTop + "px" ;
		oPrev.style.display = "block" ;
	}else
		oPrev.style.display = 'none';
}

//말풍선
function showWord(layerId, bShow, hook, lHiehgt){

	var oPrev = document.getElementById(layerId) ;
	var oBody = ( document.compatMode && document.compatMode!="BackCompat" ) ? document.documentElement : document.body ;

	if(bShow){
		var nLyrWidth = 222 ;
		var nLyrInt = -60 ;
		var nArrowInt = 0 ;
		var nHookLeft = getOffsetLeft(hook) ;
		var nHookTop = getOffsetTop(hook) ;
		if (nHookLeft + nLyrWidth > oBody.scrollWidth)
		{
			nLyrLeft = oBody.scrollWidth - nLyrWidth - 5 ;
			nArrowLeft = nHookLeft-nLyrLeft+nLyrInt+nArrowInt ;
		}else{
			nLyrLeft = nHookLeft+nLyrInt ;
			nArrowLeft = nArrowInt ;
		}
		//nLyrTop = nHookTop + hook.clientHeight- (lHiehgt+5); 단어 위에 위치할 경우
		nLyrTop = nHookTop + hook.clientHeight +18;//단어 아래에 위치할 경우
		oPrev.style.left = nLyrLeft + "px" ;
		oPrev.style.top = nLyrTop + "px" ;
		oPrev.style.display = "block" ;
	}else
		oPrev.style.display = 'none';
}

// 메인 쿠키관련
function getCookie( name ){
    var nameOfCookie = name + "=";
    var x = 0;
        while ( x <= document.cookie.length )
    {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie )
        {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                endOfCookie = document.cookie.length;
            return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
            break;
    }
    return "";
}

function setCookie( name, value, expiredays ) {
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


