var MAIN_LAYOUT_CASE = 1024;
//function
function id(a){return document.getElementById(a);}
function getTarget(a){return a.getElementsByTagName("a")[0].href.split("#")[1];}
function skipTextNodes(list){var i = 0, arr = [];for(; i < list.length; i++){if(list[i].nodeType == 1){arr.push(list[i]);}}return arr;}
$(function(){
var ui = MADEWEB.UI, api = MADEWEB.API, util = MADEWEB.UTIL, wj = WB;
if(document.body.firstChild.nodeName == "#text"){document.body.removeChild(document.body.firstChild);}//ie8 텍스트 노드 삭제
ui.domtree();//돔 읽기 실행
ui.selectbox();//디자인 셀렉트박스 실행//ie7 이상 사용가능
ui.arcodian();//아코디언리스트
wj.responsive.init();//반응형 구간별 함수호출
wj.setMinHeight();//id="body"에 최소 높이 할당
wj.gnb();
wj.sns_toggle();
wj.layer_popup();
wj.brand.rolling();//브랜드 제품소개 롤링 메뉴
wj.company_helper();
wj.cfview.init();//cf 영상리스트
wj.mainSetLayout();//메인 레이아웃 조정
});
$(window).scroll(function(e){
var ui = MADEWEB.UI, api = MADEWEB.API, util = MADEWEB.UTIL, wj = WB;
});
$(window).resize(function(){
var ui = MADEWEB.UI, api = MADEWEB.API, util = MADEWEB.UTIL, wj = WB;
wj.responsive.init();//반응형 구간별 함수호출
wj.setMinHeight();//id="body"에 최소 높이 할당
wj.brand.resizing();//브랜드 제품소개 롤링 메뉴
wj.gallery.resize("#gallery_view");//포토갤러리 리스트
wj._product_sort_resize();//제품연혁 리사이징
wj.cfview.resize();//cf 리스트 리사이징
imgCenter({//happy sns 이미지 센터조정
"valid" : "facebook_main",
"selector" : ".sns_other_cont ul li .thumb img"
});
imgCenter({//메인 module9 이미지 센터조정
"valid" : "sns_wrapper",
"selector" : "#contents .module9 .module_body li .thumb img"
});
});
$(window).load(function(){
var ui = MADEWEB.UI, api = MADEWEB.API, util = MADEWEB.UTIL, wj = WB;
wj.gallery.init("#gallery_view");//포토갤러리 리스트
imgCenter({//메인 module9 이미지 센터조정
"valid" : "sns_wrapper",
"selector" : "#contents .module9 .module_body li .thumb img"
});
imgCenter({//메인 sns블로그 이미지 센터조정
"valid" : "sns_wrapper",
"selector" : "#body .sns_wrapper .sns_type_blog .cont .sns_basic_list li .thumb img"
});
imgCenter({//happy sns 이미지 센터조정
"valid" : "facebook_main",
"selector" : ".sns_other_cont ul li .thumb img"
});
});
//ui namespace
var MADEWEB = {};
MADEWEB.UTIL = {
//현재 사용하는 기기명을 저장
browser : null,
//에이전트 리스트
agentList : ["MSIE 11","MSIE 10","MSIE 9","MSIE 8","Firefox","Chrome","OPR","Safari","iPhone","iPad","iPot","BlackBerry","Android","Windows Phone", "LG", "MOT", "SAMSUNG", "SonyEricsson"],
//에이전트 필터링
agent : function(){
var that = this, i;
for(i in this.agentList){
if(navigator.userAgent.match(this.agentList[i]) != null){
that.browser = this.agentList[i];
}
}
},
//브라우저별로 스크롤바의 넓이를 리턴
scrollbar : function(){
if(document.body.scrollHeight > document.body.clientHeight){
return 17;
}else{
return 0;
}
},
//반응형 구간표시
screensize : function(){
var browserSize = id("browserSize"), sizeOf, str = "";
str = "w :" + (document.body.clientWidth + MADEWEB.UTIL.scrollbar()) + "px / h :" + document.documentElement.clientHeight + "px";
if(browserSize){
sizeOf = $(browserSize).find("span")[0];
}else{
sizeOf = document.createElement("div");
sizeOf.id = sizeOf.className = "browserSize";
document.body.appendChild(sizeOf);
}
sizeOf.innerHTML = str;
},
//코딩가이드 소스복사툴
guide : function(){
if(!document.getElementById("dev_guide")) return false;
var obj = $("#dev_guide")
, list = $(obj).children()
, space = document.createElement("div")
, refer = document.createElement("div");
space.style.position = "absolute";
space.style.left = "-9999px";
refer.id = "sourceCopy";
refer.innerHTML = "true를 넣으면 요소 클릭시 소스복사됨(익스전용) ";
document.body.appendChild(space);
document.body.appendChild(refer);
list.each(function(event){
this.onclick = function(){
if(id("sourceCopy").getElementsByTagName("input")[0].value == "true"){
space.innerHTML = "";
if(this.nodeName.toLowerCase() != "h2"){
space.appendChild(this.cloneNode(true));
window.clipboardData.setData("text",space.innerHTML);
alert("복사완료 : \n" + space.innerHTML);
}
return false;
}
}
});
}
};
MADEWEB.UI = {
domtree : function(){
var node = this.dom = {};
node.tabmenu = $("[data-ui-tab]");
node.rolling_type1 = $("[data-ui-type='img_rotation_translate'], [data-ui-type='img_rotation_static']");
for(var i in node){
if(node[i].size() > 0){
this["func_" + i]();
}else{
continue;
}
}
},
selectbox : function(){
var that = this
, obj = $("[data-ui-type=selectbox]")
, defaultText = $("p", obj)
, option = $("li", obj)
, mywrap = null
, before = null;
defaultText.click(function(event){
reset();
mywrap = $(this).parents(obj);
mywrap.toggleClass("on");
return false;
});
function reset(){
$(document.body).bind("click",function(e){
obj.removeClass("on");
});
}
},
arcodian : function(){
var obj = $("[data-ui-type=arcodian]")
, link = $(" > ul > li > dl > dt > a", obj)
, before = null;
link.click(function(){
var dd = $(this).parents("dl").find(" > dd");
var wrap = $(this).parents("dl").find(" > dd .wrap");
if(before == null){
slide(dd,wrap[0].offsetHeight);
$(this).parents("li").addClass("on");
}else{
slide(before,0);
before.parents("li").removeClass("on");
if(dd.height() == 0){
slide(dd,wrap[0].offsetHeight);
$(this).parents("li").addClass("on");
}else{
slide(dd,0);
$(this).parents("li").removeClass("on");
}
}
before = dd;
return false;
});
function slide(dd,h){
dd.stop().animate({
"height" : h
},300);
}
},
func_rolling_type1 : function(){
var i = 0, element;
element = $("[data-ui-type='img_rotation_translate'], [data-ui-type='img_rotation_static']");
for(; i < element.size(); i++){
new translate(element.eq(i));
}
function translate(a){
var obj = $(a)
, list = $("ul:eq(0) li", obj)
, ctrl = $(".ctrl", obj)
, prev = $(".prev", ctrl)
, stop = $(".stop", ctrl)
, play = $(".play", ctrl)
, next = $(".next", ctrl)
, bullet = $(".nav button", obj)
, state = true
, before = list.eq(0)
, cnt = 0
, locked = "on"
, power = "on"
, delay = obj.attr("data-cycle") !== undefined ? obj.attr("data-cycle") * 1000 : 3000;
function barrier(){if(power == "off") return false;if(locked == "off") return false;}
ctrl.mouseenter(function(){locked = "off";});
ctrl.mouseleave(function(){locked = "on";});
bullet.bind("focusin mouseenter",function(event){
barrier();
locked = "off";
list.removeClass("on");
bullet.removeClass("on");
cnt = $(this).index();
list.eq(cnt).addClass("on");
bullet.eq(cnt).addClass("on");
});
bullet.bind("focusout mouseleave",function(){
locked = "on";
func();
});
stop.click(function(){
if(power == "off"){
power = "on";
$(this).removeClass("play");
}else{
power = "off";
$(this).addClass("play");
}
return false;
});
prev.click(function(){
if(state == false) return false;
state = false;
barrier();
if(cnt > 0){
cnt--;
}else{
cnt = list.size() - 1;
}
func();
return false;
});
next.click(function(){
if(state == false) return false;
state = false;
barrier();
if(cnt < list.size() - 1){
cnt++;
}else{
cnt = 0;
}
func();
return false;
});
var auto = setInterval(function(){
if(power == "off") return false;
if(locked == "off") return false;
next.click();
},delay);
function func(){
bullet.removeClass("on");
before.removeClass("on");
if(obj.attr("data-ui-type") == "img_rotation_translate"){//translate
list.eq(cnt).addClass("on").css({
"opacity" : 0,
"z-index" : list.size()
}).stop().animate({
"opacity" : 1
},{
duration : 500,
complete : function(){
before = list.eq(cnt);
state = true;
}
});
}else if(obj.attr("data-ui-type") == "img_rotation_static"){//static
bullet.eq(cnt).addClass("on");
list.eq(cnt).addClass("on").css({
"opacity" : 1
});
before = list.eq(cnt);
state = true;
}
}
}
},
func_tabmenu : function(){
var that = this
, dom = that.dom;
function Tabmenu(dom){//호출시 dom요소를 넘겨서 정보를 저장
this.prototype = {};
this.name = dom;
}
Tabmenu.prototype.classify = function(){
var This = this, state = true;
this.parent = this.name.children[0];//ul 또는 ol
this.list = $(" > li", this.parent);//li만 저장
this.before = $(" > li.on", this.parent);
this.before_cont = $("#" + getTarget(this.before[0]));
if(this.list.size() == 1){
$(this.list.eq(0).find("a").attr("href")).css("height","auto");
}
this.list.click(function(event){
var e = event || window.event;
if(e.stopPropagation) event.stopPropagation();
else e.cancelBubble = true;//버블링취소
if(This.name.getAttribute("data-ui-tab") == "fade"){
if(state == false) return false;
state = false;
if(This.before[0] === this){
state = true;
}
var nowCont = $("#" + getTarget(this)), h;
if(getTarget(this) == This.before_cont.attr("id")) return false;
This.before.removeClass("on");
This.before_cont.css({
"height" : 0,
"display" : "none"
});
$(this).addClass("on");
nowCont.css({
"height" : "auto",
"display" : "block"
});
h = nowCont.height();
nowCont.css("height",0).animate({
"height" : h + "px"
},{
duration : 500,
complete : function(){
nowCont.css("height","auto");
state = true;
}
});
This.before_cont = nowCont;
This.before = $(this);
var wrap = $("#product_detailview3 .vod_summary .vod")
, str = function(url){
var arr = [''].join("");
return arr;
};
if($(this).find("> a").attr("id") == "brand_vod_story"){
wrap.html(str($(this).find("> a:eq(0)").attr("data-vod-url")));
}else{
wrap.html("");
}
}else if(This.name.getAttribute("data-ui-tab") == ""){
This.before.removeClass("on");
This.before_cont.css("display","none");
$(this).addClass("on");
$("#" + getTarget(this)).css("display","block");
This.before_cont = $("#" + getTarget(this));
This.before = $(this);
if(this.querySelectorAll("[data-ui-tab]").length > 0) return false;
switch(This.name.getAttribute("data-ui-tab")){
case "page_hold" : return false;
break;
default : "";
}
}
});
}
dom.tabmenu.each(function(){
var instance = new Tabmenu(this);//this는 dom객체
instance.classify();
delete instance;
});
}
};
MADEWEB.API = {
googleMap : function(args){
if(!id(args["elementID"])) return false;
var map;
var seoulmarker = args["coords"];
var marker;
function initialize() {
var mapOptions = {
zoom: args["zoom"],
center: seoulmarker ,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(id(args["elementID"]),mapOptions);
marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
title: args["title"]
});
}
google.maps.event.addDomListener(window, 'load', initialize);
}
}
var WB = {};
WB = {
setMinHeight : function(){
if(id("sns_wrapper")) return false;
$("#body").css("min-height",document.body.clientHeight + "px");
},
gnb : function(){
var gnb = $("#gnb"), ul = $(".depth1 > ul", gnb), old_li = li = $("li", ul), a = $("a", ul), m = $(".m_nav, .m_nav_close", "#header"), m_state = true, cnt = 0, dep2, dep2_before = null, dep3, dep3_before = null, dep2_h, dep3_h, default_active = ul.find(".depth2 li.on");
while(ul.find("li").size() > 0){
cnt++;
ul.find("li").attr("stack","dep" + cnt);
ul = ul.find("ul");
}
var stack = {};
a.bind("click",function(e){
var e = e || window.event;
e.stopPropagation();
if(this.parentNode.className == "on"){
resizing($(this).next(), 0);
dep3_before = null;
this.parentNode.className = "";
return false;
}else{
//기본적으로 켜져있던 3뎁스를 끄기 - 추가 140821
if($(this).next().attr("class") == "depth3"){
default_active.removeClass("on");
resizing(default_active.find(".depth3"), 0);
}
if(document.body.clientWidth < 1023){//모바일일 경우...
var my = $(this).parent();
if(my.attr("stack") == "dep1" && my[0].getElementsByTagName("ul")[0]){
dep2 = my.find(".depth2");
dep2_h = dep2.find(" > ul").height() + 2;
if(dep2_before == null){
resizing(dep2, dep2_h);
dep2_before = dep2;
}else{
if(dep2[0] === dep2_before[0]){
resizing(dep2, 0);
dep2_before = null;
}else{
resizing(dep2, dep2_h);
resizing(dep2_before, 0);
dep2_before = dep2;
}
}
if(dep3 != undefined){
dep3.css("height",0);
dep3_before = null;
}
}else if(my.attr("stack") == "dep2" && my[0].getElementsByTagName("ul")[0]){
dep3 = my.find(".depth3");
dep3_h = dep3.find(" > ul").height() + 20;
if(dep3_before == null){
resizing(dep2, dep2_h + dep3_h);
resizing(dep3, dep3_h);
dep3_before = dep3;
}else{
if(dep3[0] === dep3_before[0]){
resizing(dep3, 0);
resizing(dep2, dep2_h);
dep3_before = null;
}else{
resizing(dep2, dep2_h + dep3_h);
resizing(dep3, dep3_h);
resizing(dep3_before, 0);
dep3_before = dep3;
}
}
}
}else{//pc 화면일 경우
var my = $(this).parent();
if(my.attr("stack") == "dep2" && my[0].getElementsByTagName("ul")[0]){
dep3 = my.find(".depth3");
dep3_h = dep3.find(" > ul").height() + 20;
if(dep3_before == null){
resizing(dep3, dep3_h);
dep3_before = dep3;
}else{
if(dep3[0] === dep3_before[0]){
resizing(dep3, 0);
dep3_before = null;
}else{
resizing(dep3, dep3_h);
resizing(dep3_before, 0);
dep3_before = dep3;
}
}
}
}
}
function resizing(a, b, c){
a.stop().animate({
"height" : b + "px"
});
}
//클래스 추가 삭제 및 스택 덮어쓰기
if(stack[$(this).parent().attr("stack")] != undefined){
if(stack[$(this).parent().attr("stack")][0] === this.parentNode){
if(this.parentNode.className.length > 0){
this.parentNode.className = "";
}else{
this.parentNode.className = "on";
}
}else{
stack[$(this).parent().attr("stack")].removeClass("on");
this.parentNode.className = "on";
}
}else{
this.parentNode.className = "on";
}
stack[$(this).parent().attr("stack")] = $(this).parent();
});
$(document.body).click(function(e){
if(document.body.clientWidth >= 1023){
for(var i in stack){
if(i != "dep2"){
stack[i].removeClass("on");
}
}
}
});
m.click(function(e){
if(m_state == false) return false;
m_state = false;
e.stopPropagation();
var w, o;
gnb.css("height",document.body.clientHeight + "px").find(" > ul").css("height",document.body.clientHeight + "px");//모바일에서 gnb를 열때 높이를 최대 사이즈로 고정(플로팅바로 만들기)
if(parseInt(gnb.css("left"),10) <= -2){
w = 0;
o = 1;
m.eq(1).show();
createDimd();
}else{
w = -237;
o = 0;
m.eq(1).hide();
removeDimd();
}
gnb.animate({
"left" : w + "px"
},{
complete : function(){
m_state = true;
}
});
m.eq(1).css({
"opacity" : o
});
});
},
gnb_reset : function(dir){//해상도 변경시 gnb 리셋
var gnb = $("#gnb"), ul = $(" > .depth1 > ul", gnb), li = $("li", ul);
li.removeClass("on");
if(dir == "to_pc"){//해상도 변경시 pc로 갈때...
gnb.css("height","auto").find(".depth2").css("height","auto").find(".depth3").css("height", 0 + "px");
}else if(dir == "to_tablet"){//해상도 변경시 태블릿으로 갈때...
gnb.css("height",document.body.clientHeight + "px").find(".depth2, .depth3").css("height", 0 + "px");
}else{}
//this.gnb();
},
responsive : {//해상도가 특정 구간으로 변경될때를 체크
oldsize : 0,
newsize : 0,
init : function(){
var resolution = "", w = document.body.clientWidth + MADEWEB.UTIL.scrollbar();
if(w >= 1024){
resolution = "w1280";
}else if(w < 1024 && w > 1023){
resolution = "w1024";
}else if(w <= 1023 && w > 400){
resolution = "tablet";
}else{
resolution = "mobile";
}
this.newsize = resolution;
if(this.oldsizeChk === undefined){
this.oldsize = resolution;
this.oldsizeChk = "complete";
}
if(this.oldsize != this.newsize){
this["_response_" + resolution]();
this.play(this.oldsize);
this.oldsize = resolution;
}
if(this.start === undefined){
this["_response_" + resolution]();
this.start = 0;
}
},
play : function(param){
var that = WB;
if(this.oldsize == ("tablet" || "mobile") && this.newsize == ("w1024" || "w1280")){
that.gnb_reset("to_pc");
sns_iframe_reset("to_pc");
}else if(this.oldsize == ("w1024" || "w1280") && this.newsize == ("tablet" || "mobile")){
that.gnb_reset("to_tablet");
sns_iframe_reset("to_tablet");
}else{
return false;
}
},
_response_w1280 : function(){
this.__response_motion({
"module1" : {"width" : 470, "height" : 578},
"module1 .nav" : {"width" : 100 + "%", "top" : 552, "left" : 0},
"module2" : {"width" : 230, "height" : 186, "top" : 0, "left" : 480},
"module3" : {"width" : 230, "height" : 186, "top" : 196, "left" : 480},
"module4" : {"width" : 232, "height" : 382, "top" : 0, "left" : 720},
"module5" : {"width" : 470, "height" : 186, "top" : 392, "left" : 480},
"module6" : {"width" : 470, "height" : 186, "top" : 588, "left" : 0},
"module7" : {"width" : 192, "height" : 167, "top" : 588, "left" : 480},
"module8" : {"width" : 194, "height" : 167, "top" : 588, "left" : 720},
"module9" : {"width" : 952, "height" : 231, "top" : 784, "left" : 0}
},"animate");
},
_response_w1024 : function(){
this.__response_motion({
"module1" : {"width" : 534, "height" : 434, "top" : 0, "left" : 0},
"module1 .nav" : {"width" : 272, "top" : 403, "left" : 272},
"module2" : {"width" : 262, "height" : 212, "top" : 444, "left" : 0},
"module3" : {"width" : 263, "height" : 212, "top" : 444, "left" : 544},
"module4" : {"width" : 261, "height" : 434, "top" : 0, "left" : 544},
"module5" : {"width" : 263, "height" : 212, "top" : 444, "left" : 272},
"module6" : {"width" : 263, "height" : 186, "top" : 666, "left" : 0},
"module7" : {"width" : 227, "height" : 167, "top" : 666, "left" : 271},
"module8" : {"width" : 226, "height" : 167, "top" : 666, "left" : 544},
"module9" : {"width" : 789, "height" : 231, "top" : 862, "left" : 0}
},"animate");
},
_response_tablet : function(){
this.__response_motion({
"module1" : {"width" : 508, "height" : 625, "top" : "auto", "left" : "auto"},
"module1 .nav" : {"width" : 100 + "%", "top" : 588, "left" : 0},
"module2" : {"width" : 249, "height" : 212, "top" : 424, "left" : 518},
"module3" : {"width" : 249, "height" : 201, "top" : 758, "left" : 518},
"module4" : {"width" : 249, "height" : 414, "top" : 0, "left" : 518},
"module5" : {"width" : 508, "height" : 202, "top" : 758, "left" : 0},
"module6" : {"width" : 249, "height" : 202, "top" : 969, "left" : 0},
"module7" : {"width" : 211, "height" : 183, "top" : 969, "left" : 259},
"module8" : {"width" : 211, "height" : 183, "top" : 969, "left" : 518},
"module9" : {"width" : 751, "height" : 231, "top" : 1180, "left" : 0}
},"animate");
},
_response_mobile : function(){
this.__response_motion({
"module1" : {"width" : "auto", "height" : "auto", "top" : "auto", "left" : "auto"},
"module1 .nav" : {"width" : 100 + "%", "top" : 95 + "%", "left" : 0},
"module2" : {"width" : "auto", "height" : "auto", "top" : 424, "left" : 518},
"module3" : {"width" : 100 + "%", "height" : "auto", "top" : 758, "left" : 518},
"module4" : {"width" : "auto", "height" : "auto", "top" : 0, "left" : 0},
"module5" : {"width" : 100 + "%", "height" : "auto", "top" : 758, "left" : 0},
"module6" : {"width" : 100 + "%", "height" : 128, "top" : 969, "left" : 0},
"module7" : {"width" : "auto", "height" : "auto", "top" : 969, "left" : 259},
"module8" : {"width" : "auto", "height" : "auto", "top" : 969, "left" : 518},
"module9" : {"width" : "auto", "height" : "auto", "top" : 1180, "left" : 0}
},"css");
},
__response_motion : function(fn, met){
var obj = null, option;
for(var i in fn){
if(obj == null){
obj = i;
option = fn[i];
ani();
obj = null;
}else{
break;
}
}
function ani(){
$("." + obj).stop()[met](option);
}
}
},
sns_toggle : function(){
var sns = $("#sns_wrapper"), overlay = sns.find(".overlay"), w, to = 0, o = 0, cls;
sns.find("nav a").click(function(){
w = document.body.clientWidth + MADEWEB.UTIL.scrollbar();
if(w <= 1023) return false;
if(w > 1023){
if(to == 0){
to = 0 - sns.offset().left - 7;
o = 0;
overlay.fadeOut(700);
cls = "on";
}else{
to = 0;
o = 0.6;
overlay.fadeIn(700);
cls = "";
}
}
sns.removeClass("on").addClass(cls);
$(document.body).stop().animate({
"margin-left" : to + "px"
});
});
},
layer_popup : function(){
var close = $(".layer .close");
close.click(function(){
$(this).parents(".layer").hide();
});
},
brand : {//브랜드 롤링 탭
rolling : function(){
this.obj = $("#product_scroller")
this.cont = $(".cont", this.obj)
this.ul = $("ul", this.obj)
this.li = $("li", this.obj)
this.link = $("a", this.li)
this.ctrl = $(".ctrl", this.obj)
this.prev = $(".prev", this.obj)
this.next = $(".next", this.obj)
this.cnt = 0;
this.state = true;
this.before_cnt = 0;
this.boxsize = this.li.eq(0).width() + 6;
this.beforelink = this.li.eq(0);
this.ul.css("width", this.li.size() * this.boxsize + "px");
if(this.ul.width() <= this.cont.width() - 66){//ul의 넓이가 box의 넓이보다 작으면 화살표 감추기
this.ctrl.hide();
}
this.prev.hide();//초기 로딩시 prev버튼 감추기
this.func();
},
func : function(){
var that = this;
this.prev.click(function(){
if(that.state == false) return false;
that.state = false;
if(that.cnt > 1){
that.cnt--;
that.next.show();
}else{
that.cnt = 0;
that.prev.hide();
}
that.move();
return false;
});
this.next.click(function(){
if(that.state == false) return false;
that.state = false;
if(that.cnt < that.li.size() - 1){
that.cnt++;
that.prev.show();
}else{
that.cnt = that.li.size() - 1;
}
that.move();
return false;
});
this.link.click(function(){
if(that.beforelink != null){
that.beforelink.removeClass("on");
}
$(this).parents("li").addClass("on");
that.beforelink = $(this).parents("li");
});
},
resizing : function(){
this.ul.css({
"width" : this.cont.width() - 66 + this.boxsize + "px",
"margin-left" : 0
});
this.cnt = 0;
this.before_cnt = 0;
this.prev.hide();//초기 로딩시 prev버튼 감추기
if(this.ul.width() <= this.cont.width() - 66){//ul의 넓이가 box의 넓이보다 작으면 화살표 감추기
this.ctrl.hide();
}
if(this.li.size() * this.boxsize > this.cont.width()){
this.next.show();
}
this.func();
},
move : function(){
var that = this;
this.ul.css("width", this.li.size() * this.boxsize + "px");
this.ul.animate({
"margin-left" : -that.cnt * this.boxsize + "px"
},{
complete : function(){
if(that.cont.width() - 66 > that.ul.width() - ((that.cnt + 1) * that.boxsize)){
that.next.hide();
}else{
that.next.show();
}
that.state = true;
}
});
this.cnt_before = this.cnt;
}
},
gallery : {//포토갤러리 리스트 : 이미지 사이즈를 체크해야하므로 윈도우 온로드에서 실행됨
init : function(el){
if(!id("gallery_view")) return false;
cds.add("design_scrolls");
var that = this;
this.wrapper = $(el);
this.preview = $(".preview .image", this.wrapper);
this.prev = $(".prev", this.wrapper);
this.next = $(".next", this.wrapper);
this.category = $(".category_scroll", this.wrapper);
this.ul = $(".category_scroll ul", this.wrapper);
this.list = $(".category_scroll ul li", this.wrapper);
this.scrollPrev = $(".scrollprev", this.wrapper);
this.scrollNext = $(".scrollnext", this.wrapper);
this.index = 0;
this.list.eq(0).addClass("on");
this.before_category = this.list.eq(0);
that.show();
this.resize();
this.eventbinding();
this.navState = true;
this.scrollPrev.addClass("disabled");
},
resize : function(){//초기 로딩시 호출, 데이터 변경시 호출, 리사이징시 호출
if(!id("gallery_view")) return false;
var img = this.preview.find("img").eq(0), h, that = this;
h = (this.preview.height() - img.height()) / 2//이미지 센터로 정렬
if(img.height() >= 638){
img.css({
"width" : "auto",
"height" : 100 + "%"
});
}
if(document.body.clientWidth < 1023){
this.ul.css("width", (this.list.size() * 45) + "px");
}else{
this.ul.css("width", "auto");
}
img.css("margin-top", Math.max(parseInt(h), 0) + "px");
this.listshowWidth = Math.round((this.category.width() - 60) / 45) * 45;
},
eventbinding : function(){//이벤트 바인딩
var that = this, data = this.data;
this.list.find("a").click(function(){
var my = $(this).parent();
that.before_category.removeClass("on");
that.index = my.index();
my.addClass("on");
$(this).focus();
that.before_category = my;
that.show();
return false;
});
that.prev.click(function(){
if(that.index > 0){
that.index--;
}else{
that.index = 0;
}
that.list.eq(that.index).find("a").click();
return false;
});
that.next.click(function(){
if(that.index < that.list.size() - 1){
that.index++;
}else{
that.index = that.list.size() - 1;
}
that.list.eq(that.index).find("a").click();
return false;
});
that.scrollPrev.click(function(){
if(that.navState == false) return false;
that.navState = false;
var to;
if(parseInt(that.ul.css("margin-left")) - that.category.width() > 0){
that.navState = true;
to = 0;
}else{
to = Math.min(0, parseInt(that.ul.css("margin-left")) + that.category.width() - 45);
if(parseInt(that.ul.css("margin-left")) + that.category.width() - 45 > 0){
that.scrollPrev.addClass("disabled");
}else{
that.scrollPrev.removeClass("disabled");
that.scrollNext.removeClass("disabled");
}
}
that.scrollerMoving(to);
return false;
});
that.scrollNext.click(function(){
if(that.navState == false) return false;
that.navState = false;
var to;
if(that.ul.width() <= that.category.width()){//전체 영역보다 이미지 갯수가 작을때
that.navState = true;
to = that.listshowWidth - that.ul.width();
}else{
to = Math.max(parseInt(that.ul.css("margin-left")) - that.listshowWidth, that.listshowWidth - that.ul.width());
if(parseInt(that.ul.css("margin-left")) - that.listshowWidth <= that.listshowWidth - that.ul.width()){
that.scrollNext.addClass("disabled");
}else{
that.scrollNext.removeClass("disabled");
that.scrollPrev.removeClass("disabled");
}
}
that.scrollerMoving(to);
return false;
});
},
show : function(){//view에 뿌려주기
var that = this;
that.preview.find("img").eq(0).attr({
"src" : that.list.eq(that.index).find("img").attr("bigsrc"),
"alt" : that.list.eq(that.index).find("img").attr("alt")
});
that.preview.find("img").eq(0).load(function(){//이미지 로딩후 사이즈 계산
that.resize();
});
},
scrollerMoving : function(to){
var that = this;
that.ul.animate({
"margin-left" : to + "px"
},{
duration : 700,
complete : function(){
that.navState = true;
}
});
}
},
company_helper : function(){
if(id("history_company")){
this._company_sort();
}else if(id("history_product_list")){
this._product_sort();
}else{}
},
_company_sort : function(){
var obj = $("#history_company"), sort_li = $("li", obj.find(".world_history .depth2 ul"));
sort_li.each(function(i){
if(i % 2 == 0){
$(this).addClass("odd");
}else{
$(this).addClass("even");
}
});
},
_product_sort : function(){
var obj = $("#history_product_list");
var li = $(" > ul > li", obj);
var before = null;
var state = true;
li.each(function(i){
$(this).addClass("list" + (i % 3 + 1));
if(i % 2 == 0){
$(this).addClass("odd");
}else{
$(this).addClass("even");
}
});
li.find("a").click(function(){
if(state == false) return false;
var my = $(this).parents("li");
var box = my.find(".detailview");
if(before != null){
if(my.hasClass("on")){
my.removeClass("on");
slide(my.find(".detailview"), 0);
}else{
before.removeClass("on");
before.find(".detailview").css("height", 0);
my.addClass("on");
slide(box, box.find(".cont").height() + 42);
}
}else{
my.addClass("on");
slide(box, box.find(".cont").height() + 42);
}
before = my;
return false;
});
function slide(el,size){
el.stop().animate({
"height" : size
},{
duration : 500,
easing : "easeInOutBack",
complete : function(){
state = true;
}
});
}
},
_product_sort_resize : function(){
if(!id("history_product_list")) return false;
$("#history_product_list ul li.on .detailview").css("height","auto");
},
cfview : {
init : function(){
if(!id("vod_list")) return false;
this.wrapper = $("#vod_list");
this.ul = $("ul", this.wrapper);
this.li = $(" > li", this.ul);
this.link = $(" > .simpleview", this.li);
this.close = $(".detailview .close", this.li);
this.before = null;
this.state = true;
this.browsertitle = document.title;
var that = this, my, evt, delay, delayTime = 300;
this.link.click(function(event){
if(that.state == false) return false;
that.state = false;
evt = event || window.event;
evt.preventDefault();
var str = function(url){//object 문자열 생성
var arr = [''].join("");
return arr;
}
my = $(this).parents("li");
if(that.before != null){
if(my.hasClass("on")){
my.removeClass("on");
that.ani(my.find(".detailview"), 0);
my.find(".ifrm").html("");
}else{
that.before.removeClass("on");
that.before.find(".detailview").css("height", 0);
that.before.find(".ifrm").html("");
my.addClass("on");
if(my.find(".ifrm").html().length == 0){
my.find(".ifrm").html(str(this.href));
}
that.ani(my.find(".detailview"), my.find(".cont").height() + 24);
}
}else{
my.addClass("on");
my.find(".ifrm").html(str(this.href));
that.ani(my.find(".detailview"), my.find(".cont").height() + 24);
}
that.before = my;
document.title = that.browsertitle;//클릭할때마다 브라우저 타이틀이 #으로 변경하는것 방지
});
this.close.click(function(){
my = $(this).parents("li");
my.removeClass("on");
that.ani(my.find(".detailview"), 0);
that.before.find(".ifrm").html("");
});
},
ani : function(el, size){
var that = this;
el.stop().animate({
"height" : size
},{
duration : 500,
easing : "easeInOutBack",
complete : function(){
that.state = true;
}
});
},
resize : function(){
if(!id("vod_list")) return false;
this.ul.find("li.on .detailview").css("height","auto");
}
},
mainSetLayout : function(){
if(!id("sns_wrapper")) return false;
var dir = screen.height < MAIN_LAYOUT_CASE ? "min" : "max"
, body = $("body")
, wrap = $("#wrapper")
, head = $("#header")
, body_id = $("#body")
, module9 = $("#contents .module9")
, sns_wrap = $("#sns_wrapper");
if(dir == "min"){
module9.hide();
sns_wrap.find(".sns_scrolls").css("height", 716 + "px").find(".cont").css("height", 635 + "px");
$(body, wrap, head, body_id).css("height","auto");
}else{
module9.show();
sns_wrap.find(".sns_scrolls").css("height", document.body.clientHeight - 59 + "px");
}
}
}
function sns_iframe_reset(str){//커뮤니티 행복 SNS에서 아이프레임 사이즈 변경이 안되므로, 스크립트 처리
if(!id("facebook_main")) return false;
var facemain = $("#facebook_main")
, facesky = $("#facebook_sky");
if(str == "to_pc"){
facemain.html('');
facesky.html('');
}else{
facemain.html('');
facesky.html('');
}
}
function imgCenter(arg){
if(!id(arg["valid"])) return false;
var imgs = $(arg["selector"]);
imgs.each(function(){
$(this).css("margin-left", -($(this).width() / 2) + "px");
});
}
function createDimd(){
var dimd, h, t;
if(id("dimdLayer")){
dimd = id("dimdLayer");
}else{
dimd = document.createElement("div");
dimd.id = dimd.className = "dimdLayer";
document.body.appendChild(dimd);
}
dimd.style.top = 106 + "px";
dimd.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - 106 + "px";
$(dimd).fadeIn(500);
}
function removeDimd(){
if(!id("dimdLayer")) return false;
document.body.removeChild(id("dimdLayer"));
}
function wow_ready(src){
var layer, dimd;
$(layer).bind("click",function(){
document.body.removeChild(dimd);
document.body.removeChild(layer);
});
}