﻿var addOverlay;

$(function() {
    //전화번호 마스크
    $("#cellphone").mask("019-9999999?9");

    // initialize scrollable 
    $("div.scrollable").scrollable({
        vertical: true,
        size: 2

        // use mousewheel plugin
    }).mousewheel();

    $("#qnas h3[rel]").overlay({ effect: 'apple' });
    addOverlay = $("#addqna").overlay({ effect: 'apple', api: true });

    $("#qnas h3[rel]").bind('click', function(sender) {
        qnaid = $(this).attr("name").toString().substring(3);

        //alert(qnaid);
        $.getJSON('/Home/aQnaStatus', { qnaid: qnaid }, function(data) {

            $("#question").html(data.question);
            $("#response").html(data.response);
            $("#askedon").html(data.submitted);
            $("#answeredon").html(data.answered);
            $("#responseby").html(data.responseby);
            $("#delay").html(data.delay);

        });
    });

    // 사이트맵 열고 닫기
    $("#sitemapCloser").bind('click', function() {
        $("#sitemap_opened").animate({ top: "-290px" }, 500);
        $("#closeSitemap").animate({ top: "0px" }, 500);
        setTimeout(function() {
            $("#sitemap_opened").hide();
            $("#closeSitemap").hide();
        }, 500);
    });
    $("#sitemapOpener").bind('click', function() {
        $("#sitemap_opened").show();
        $("#closeSitemap").show();
        $("#sitemap_opened").animate({ top: "0px" }, 500);
        $("#closeSitemap").animate({ top: "290px" }, 500);
    });

    // 사이트맵 가로 사이즈 및 여백 설정
    $("#sitemap_opened").css("width", $(window).width());
    $("#closeSitemap").css("width", $(window).width());

    $(window).bind('resize', function() {
        $("#sitemap_opened").css("width", $(window).width());
        $("#closeSitemap").css("width", $(window).width());
    });

    // 히어로 이미지 탭
    $("#ht_intro").bind('mouseover', function() {
        if (!($("#ht_intro").hasClass("current"))) {
            $("#ht_intro").addClass("current");
            $("#ht_participate").removeClass("current");
            $("#ht_location").removeClass("current");
            $("#hero_location a").removeClass("current");
            $("#hero_participate a").removeClass("current");
            $("#hero_intro a").addClass("current");
        }
    });
    $("#ht_participate").bind('mouseover', function() {
        if (!($("#ht_participate").hasClass("current"))) {
            $("#ht_participate").addClass("current");
            $("#ht_intro").removeClass("current");
            $("#ht_location").removeClass("current");
            $("#hero_location a").removeClass("current");
            $("#hero_intro a").removeClass("current");
            $("#hero_participate a").addClass("current");
        }
    });
    $("#ht_location").bind('mouseover', function() {
        if (!($("#ht_location").hasClass("current"))) {
            $("#ht_location").addClass("current");
            $("#ht_participate").removeClass("current");
            $("#ht_intro").removeClass("current");
            $("#hero_intro a").removeClass("current");
            $("#hero_participate a").removeClass("current");
            $("#hero_location a").addClass("current");
        }
    });
});

function submitquestion() {

    
    if (!($("#email").val() && $("#cellphone").val() && $("#questionarea").val())) {
        alert("빠진 내용이 있습니다.");
        return;
    }
    else {
        $("#questionform").ajaxSubmit(function() {
            alert("질문이 등록되었습니다.");
            addOverlay.close();
            $("#questionform").clearForm();
        });
        
    }
    
}
