/* 
 *  author : Kenneth
 *  date : 2014-10-13
 */
// 브랜딩 출력 ㅋㅋㅋㅋ
//console.log('%c ZeroWeb Team Fighting!!! ', 'background: #222; color: #ff5500; font-size: 25px;');

var controller;
$(document).ready(function ($) {

    // init controller
    controller = new ScrollMagic();

    // build tween
    var tween = new TimelineMax()
          .add([
            TweenMax.to("#bottomMenuSet", 0.5, {bottom: '0px'})
          ]);

    // build scene
    var Scene = new ScrollScene({triggerElement: ".productinfo", triggerHook: '0'})
          .setTween(tween)
          .addTo(controller);

    // 사이드 메뉴에 리스트 아이템 애니메이션2오
    $('.menu-btn').click(function() {
        $('.pushy ul li').each(function(index) {
            // build tween
            TweenMax.from($(this), 0.5, {marginTop: '40px', opacity: 0})
        });
    });

    // go top 아이콘 스크롤시 액션
    $(window).scroll(function() {

        // IE 에서 scrollTop 관련 적용되지 않는현상으로 구별해서 얻음
        var ua = window.navigator.userAgent;
        var scrollvalue = 0;
        if(ua.indexOf('MSIE') > 0 || ua.indexOf('Trident') > 0)
        {
            scrollvalue = document.documentElement.scrollTop;
        }
        else
        {
            scrollvalue = $('body').scrollTop();
        }

        if(scrollvalue > 100)
        {
            $('#go-top').fadeIn(300);
        }
        else
        {
            $('#go-top').fadeOut(300);
        }
    });

    //화면 하단 TOP 버튼 클릭시 상단으로 이동
    $("#go-top-image").click(function(){
        window.scrollTo(0,0);
    });


    //// ajax 요청시 로딩 아이콘 노출
    //$( document ).ajaxStart(function() {
    //    $( "#icon-loading" ).fadeIn(200);
    //});
    //// ajax 요청 수행 후 아이콘 숨김
    //$( document ).ajaxComplete(function() {
    //    $( "#icon-loading" ).fadeOut(200);
    //});
});


/**
 * 쿠키 관련
 */
// Cookie값 정하기
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}
// Cookie값 구하기
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    }
    return "";
}

