
//check browser
var isie=(/msie/i).test(navigator.userAgent); //ie
var isie6=(/msie 6/i).test(navigator.userAgent); //ie 6
var isie7=(/msie 7/i).test(navigator.userAgent); //ie 7
var isie8=(/msie 8/i).test(navigator.userAgent); //ie 8
var isie9=(/msie 9/i).test(navigator.userAgent); //ie 9
var isfirefox=(/firefox/i).test(navigator.userAgent); //firefox
var isapple=(/applewebkit/i).test(navigator.userAgent); //safari,chrome
var isopera=(/opera/i).test(navigator.userAgent); //opera
var isios=(/(ipod|iphone|ipad)/i).test(navigator.userAgent);//ios
var isipad=(/(ipad)/i).test(navigator.userAgent);//ipad
var isandroid=(/android/i).test(navigator.userAgent);//android
if(isie7 || isie8 || isie9) isie6=false;
if(isie9) isie=false;

// IE6 PNG Load
if (isie6) {
	DD_belatedPNG.fix ( "img " );
	DD_belatedPNG.fix('.blogPop');
	DD_belatedPNG.fix('.webzinePop');
	DD_belatedPNG.fix('.inPop');
	DD_belatedPNG.fix('.menupan');
	DD_belatedPNG.fix('#topLine');
}

// IE6 background fix
try{
	document.execCommand('BackgroundImageCache',false,true);
}
catch(e){}

// popup
function popupOpen(url,w,h,type){
	window.open(url ,  "openWin", "width="+w+",height="+h+",top=30,left=100,resizable=no,scrollbars="+type) ;
}

// flash Laod
function flashX(src, w, h, swfid) {
	swf_html = '';
	swf_html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + w + '" height="' + h + '" id="' + swfid + '">';
	swf_html += '<param name="allowScriptAccess" value="sameDomain">';
	swf_html += '<param name="movie" value="' + src + '">';
	swf_html += '<param name="quality" value="high">';
	swf_html += '<param name="bgcolor" value="#FFFFFF">';
	swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
	swf_html += '<PARAM NAME="base" VALUE=".">';
	swf_html += '<embed base="." src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + swfid + '" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	swf_html += '</object>';
	document.write(swf_html);
}

//2011-08-07 수정 start
//Banner slide Module : ver 3.1 Scripting By won joso (www.mobilepub.co.kr)
var hyosung_slide_banner = function(){
	var id = '';
	var no = 0;
	var width = null;
	var count = null;
	var speed = 4000;
	var pause = true;

	return {
		set : function(el){
			id = $(el);
			width = id.width();
			count = id.find('ul li').length - 1;
			if(count < 1){
				return;
			}
			no = Math.floor(Math.random() * id.find('ul li').length);
			id.find('ul li:eq('+no+')').siblings('li').css('left',width+'px');

			var spage;
			for(var i=0;i<=count;i++){
				spage += "<li></li>";
			}
			$('<ol></ol>').appendTo(el);
			$(spage).appendTo(el+' ol');
			id.find('ol li:first').addClass('on');
			id.find('ol').css('margin-left', -(10 * count)+'px');

			id.find('ol li:eq('+no+')').addClass('on').siblings().removeClass('on');

			id.mouseover(function()	{pause = false;});
			id.mouseleave(function(){pause = true;});

			this.move();
			setInterval(this.ani, speed * 2);
		},
		ani : function(){
			if(pause){
				if(no === count){
					id.find('ul li:eq('+no+')').animate({left:-width}, width*4);
					id.find('ul li:first').animate({left:0}, width*4);
					id.find('ol li:eq('+no+')').removeClass('on');
					id.find('ol li:first').addClass('on');
					no = 0;
				}else{
					id.find('ul li:eq('+no+')').animate({left:-width}, width*4).next().animate({left:0}, width*4);
					id.find('ol li:eq('+no+')').removeClass('on').next().addClass('on');
					no = no + 1;
				}

				setTimeout(function(){id.find('ul li:eq('+no+')').siblings('li').css('left',width+'px');}, speed);
			}
		},
		move : function(){
			id.find('ol li').each(function(i){
				$(this).click(function(){
					if(no != i){
						id.find('ul li:eq('+i+')').animate({left:0});
						id.find('ul li:eq('+no+')').animate({left:-width});
						setTimeout(function(){
							id.find('ul li:eq('+i+')').siblings().css('left',width);
						}, 500);
						id.find('ol li:eq('+i+')').addClass('on').siblings().removeClass('on');
						no = i;
					}
				});
			});
		}
	};
};
//2011-08-07 수정 end


// jQuery Load
(function($){
	$(document).ready(function(){
		// leyout dom setting for ie6
		if(isie6){
			$('#contents, #leftmenu').css('height','350px');
			$('#header #search .keyword').css('top','-1px');
		}

		// 2011-06-29 추가 : PI 섹션에서 높이값 내림 - start
		if($('#sub_title').length){
			//$('.piBox').css('top','205px');
		}
		// 2011-06-29 추가 : PI 섹션에서 높이값 내림 - start

		// Search Bar Background Show Hidden in GNB - start
		/*$('.keyword input').focus(function(){
			$(this).css('background','none');
		});
		$('.keyword input').blur(function(){
			$(this).css('background','url(/images/kor/gnb/txtSearch.gif) no-repeat 6px 4px');
		});*/
		// Search Bar Background Show Hidden in GNB - end

		$('#util ol li img:last').css('margin-top','0');
		$('.fmenu li:first').css('background','none');
		$('.fmenu li:last').css('padding-right','0');

		// GNB, LNB Menu Focus by pageNum
		
		if(pageNum1){
			$('#gnb ul li:eq('+(pageNum1-1)+')').addClass('on');
			$('.menupan ol:eq('+(pageNum1-1)+') li:eq('+(pageNum2-1)+')').addClass('on');
		}
		if(pageNum2){
			$('#lnb > li:eq('+(pageNum2-1)+')').addClass('on');
			$('#lnb > li:eq('+(pageNum2-1)+') ol li:eq('+(pageNum3-1)+')').addClass('on');
		}

		// 2011-06-29 GNB 잔상 수정 ========= start
		// GNB - start
		if($('#gnb').length){
			$('#gnb ul > li > a > img').each(function(i){
				$(this).mouseover(function(){
					$('#gnb').css('height','280px');
					$('#gnb > div').removeClass('off');
					$('.menupan').animate({top:'-5px'},'fast');
				});
			});

			$('#gnb').mouseleave(function(){
				$(this).find('ol').css('top','-280px');
				$('#gnb').css('height','15px');
				var hcheck = $('#gnb').height();
				if(hcheck === 15){
					$('.menupan').css('top','-280px');
				}
				$('#gnb > div').addClass('off');
			});
			// 2011-06-29 GNB 잔상 수정 ========= end

			$('#gnb li:not(.on) img').mouseover(function(){
				var onoff = $(this).attr('src');
				$(this).attr('src',onoff.replace('off.gif','on.gif'));
			});
			$('#gnb li:not(.on) img').mouseout(function(){
				var onoff = $(this).attr('src');
				$(this).attr('src',onoff.replace('on.gif','off.gif'));
			});

			if($('#gnb ul > li.on').length > 0){
				var onfocus = $('#gnb ul > li.on > a > img').attr('src');
				$('#gnb ul > li.on > a > img').attr('src',onfocus.replace('off.gif','on.gif'));
				
				if($('.menupan ol li.on').length > 0){
					var onfocuss = $('.menupan ol li.on a img').attr('src');
					$('.menupan ol li.on a img').attr('src',onfocuss.replace('off.gif','on.gif'));
				}
			}

			$('#util li:first').click(function(){
				if($('.lan:visible').length){
					$('.lan').hide();
				}else{
					$('.lan').show();
				}
			});
		}
		// GNB - end

	// LNB - start
		if($('#lnb').length){
			$('#lnb li:not(.on) img').mouseover(function(){
				var onoff = $(this).attr('src');
				$(this).attr('src',onoff.replace('off.gif','on.gif'));
			});
			$('#lnb li:not(.on) img').mouseout(function(){
				var onoff = $(this).attr('src');
				$(this).attr('src',onoff.replace('on.gif','off.gif'));
			});

			if($('#lnb > li.on').length > 0){
				var onfocus = $('#lnb > li.on > a > img').attr('src');
				$('#lnb > li.on > a > img').attr('src',onfocus.replace('off.gif','on.gif'));
				$('#lnb > li.on ol').css('display','block');
			}
			if($('#lnb > li.on > ol li.on').length > 0){
				var onfocus = $('#lnb > li.on > ol li.on > a > img').attr('src');
				$('#lnb > li.on > ol li.on > a > img').attr('src',onfocus.replace('off.gif','on.gif'));
			}
		}
		// LNB - end

		// Main Product Index - start
		if($('.piBox').length){
			$('.piBtn p').click(function(){
				if($('.piBox:visible').length){
					$('.piBox').fadeOut();
				}else{
					$('.piBox').fadeIn();
				}
			});
			$('.piBox .r').click(function(){
				$('.piBox').fadeOut();
			});

			$('#index dl').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('boxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('boxOn');
				});
			});
			$('.midbox').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('midboxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('midboxOn');
				});
			});
			$('.bigbox').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('bigboxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('bigboxOn');
				});
			});
		}

		// Sub Product Index - start
		if($('#titlebar_ln, #titlebar').length){
			$('#titlebar_ln span img, #titlebar span img').click(function(){
				if($('.piBox:visible').length){
					$('.piBox').fadeOut();
				}else{
					$('.piBox').fadeIn();
				}
			});
			$('.piBox .r').click(function(){
				$('.piBox').fadeOut();
			});

			$('#index dl').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('boxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('boxOn');
				});
			});
			$('.bigbox').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('bigboxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('bigboxOn');
				});
			});
		}

		// Section Product Index - start
		if($('.sub_title_box').length){
			$('.sub_title_box span img').click(function(){
				if($('.piBox:visible').length){
					$('.piBox').fadeOut();
				}else{
					$('.piBox').fadeIn();
				}
			});
			$('.piBox .r').click(function(){
				$('.piBox').fadeOut();
			});

			$('#index dl').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('boxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('boxOn');
				});
			});
			$('.bigbox').each(function(){
				$(this).mouseover(function(){
					$(this).addClass('bigboxOn');
				});
				$(this).mouseout(function(){
					$(this).removeClass('bigboxOn');
				});
			});
		}

		// Main Banner Slide - start 
		if($('#hs_bn_01').length){
			var hs_bn_01 = hyosung_slide_banner();
			hs_bn_01.set('#hs_bn_01');

			var hs_bn_02 = hyosung_slide_banner();
			hs_bn_02.set('#hs_bn_02');
		}
		// Main Banner Slide - end 

		// 2011-06-28 수정 ============================================================ start
		//아코디언
		$(".accordion li.activity").each(function(){
			$(".accordion li.activity:not('.on')").next(".activeTB").css('display','none');
			$(this).click(function(){
				if($(this).find('a').hasClass('open')){
					$(this).next('.activeTB').hide();
					$(this).find('a').removeClass('open');
				}else{
					$('.activeTB').hide();
					$(this).next('.activeTB').show();
					$(".accordion li.activity a").removeClass('open');
					$(this).find('a').addClass('open');
				}
			});
		});

		$(".accordion li.activity00").each(function(){
			$(".accordion li.activity00:not('.on')").next(".netcon").css('display','none');
			$(this).click(function(){
				if($(this).find('a').hasClass('open')){
					$(this).next('.netcon').hide();
					$(this).find('a').removeClass('open');
				}else{
					$('.netcon').hide();
					$(this).next('.netcon').show();
					$(".accordion li.activity00 a").removeClass('open');
					$(this).find('a').addClass('open');
				}
			});
		});

		// contact us 모달 팝업창 - start
		if($('.pop_contact_wrap').length){
			var contact_modal = $('.pop_contact_wrap');

			// Show Hide
			$('.load_modal').click(function(){
				contact_modal.css('display','block');
			});
			$('.pop_contact_box .close').click(function(){
				contact_modal.css('display','none');
			});

			//contact_modal.find('>.bg').mousedown(function(event){
			//	contact_modal.css('display','none');
			//});
		}
		// contact us 모달 팝업창 - end
		// 2011-06-28 수정 ==================================================================end

		// 사업부 길찾기 모달 팝업창 - start
		if($('.pop_map_wrap').length){
			var contact_modal = $('.pop_map_wrap');

			// Show Hide
			$('.map_modal').click(function(){
				contact_modal.css('display','block');
			});
			$('.pop_map_box .close').click(function(){
				contact_modal.css('display','none');
			});

			contact_modal.find('>.bg').mousedown(function(event){
				contact_modal.css('display','none');
			});
		}
		// 사업부 길찾기 모달 팝업창 - end

		// 그린 나눔 섹션 비쥬얼 스왑 - start
		$('#vi_manage_01 .prev').click(function(){
			$('#vi_manage_01').hide();
			$('#vi_manage_02').show();
		});
		$('#vi_manage_02 .next').click(function(){
			$('#vi_manage_01').show();
			$('#vi_manage_02').hide();
		});
		// 그린 나눔 섹션 비쥬얼 스왑 - end
	});
})(jQuery);

function nAllow(e) {
	alert('The typed special characters are not allowed.');
	
	if(navigator.appName!="Netscape"){ 
		event.returnValue = false;        
	}else{            
		e.preventDefault();
	}
	
}

$(function() {
	if ($.browser.msie && $.browser.version == '6.0') {
		alert("Does not support Internet Explorer 6.\n\nPlease use the parent version of the browser.");
	}
});

function fc_chk_byte(memo){
	var ari_max = 3000;
	var ls_str = memo.value; 
	var li_str_len = ls_str.length; 

	var li_max = ari_max; 
	var i = 0; 
	var li_byte = 0; 
	var li_len = 0; 
	var ls_one_char = ""; 
	var ls_str2 = ""; 

	for(i=0; i< li_str_len; i++) { 
		ls_one_char = ls_str.charAt(i); 

		if (escape(ls_one_char).length > 4) { 
			li_byte += 2; 
		}else{ 
			li_byte++; 
		} 
		
		if(li_byte <= li_max){ 
			li_len = i + 1; 
		} 
	}

	if(li_byte > li_max){ 
		alert("You can enter up to 3000 characters in English or 1500 in Korean."); 
		ls_str2 = ls_str.substr(0, li_len); 
		memo.value = ls_str2; 
	} 
	memo.focus(); 
}

// Business Area, About Hyosung main visual 1px pixed
if($.browser.msie && $.browser.version == 7) {
	$(function() {
		$('#mPub_loop').css('margin-top', -1);
		$('.prd_list dl .pic').css({'padding':'1px 0 3px 2px','border':'1px solid #dadada', 'margin-bottom':'10px'});
		$('#header #search .btnOpen').css({'display':'block','position':'absolute','top':'4px','left':'112px'});
	});
}
