﻿customer = function(){};

customer.prototype = {
    main : function(e){        
        $('.question').mouseover(function(){$(this).children().css('background-color','#f1f1f1');});
        $('.question').mouseout(function(){$(this).children().css('background-color','#ffffff');}); 
        $('.question').click(function(){
            $('.answer').slideUp('slow');
            $(this).parent().children().children().children().css('color', '#666666');
            $(this).children().children().css('color', '#ff6e1b');
            $(this).next().slideDown('slow');
        }); 
    },
    question : function(e){
        $('.question').mouseover(function(){$(this).children().css('background-color','#f1f1f1');});
        $('.question').mouseout(function(){$(this).children().css('background-color','#ffffff');}); 
        $('.question').click(function(){
            $('.answer').css('display','none');
            $(this).parent().children().children().children().css('color', '#666666');
            $(this).children().children().css('color', '#ff6e1b');
            $(this).next().css('display','block');
        });
        $('#question').click(function(){
            if($('#bcIdx').val() == 'default') {
                alert('대분류를 선택하세요'); 
                return false;
            }
            if($('#mcIdx').val() == 'default') {
                alert('중분류를 선택하세요'); 
                return false;
            }
            if($('#subject').val().length < 2) {
                alert('제목을 입력하세요'); 
                return false;
            }
            if($('#contents').val().length < 2) {
                alert('내용을 입력하세요'); 
                return false;
            }   
        });         
    },
    wrong : function(e){
        $('#received_img').click(function(){diary = new Diary(document.getElementById('received_date')); diary.curDiary();});            
        $('.question').click(function(){
            $('.answer').css('display','none');
            $(this).parent().children().children().children().css('color', '#666666');
            $(this).children().children().css('color', '#ff6e1b');
            $(this).next().css('display','block');
        }); 
        $('#submit').click(function(){                
            if(! new Validate().phone_number($('#phone_1').val() + '-' + $('#phone_2').val() + '-' + $('#phone_3').val())){alert('올바른 연락처를 입력하세요.'); return false;}            
            if(! new Validate().e_mail($('#email_1').val() + '@' + $('#email_2').val())) {alert('이메일 주소를 확인하세요.'); return false;}
            if($('#received_date').val() == '') {alert('연락 가능한 시간대를 입력해주세요.');  return false;} 
            if($('#subject').val() == '') {alert('제목을 입력해주세요.'); $('#subject').focus(); return false;}
            if($('#contents').val() == '') {alert('내용을 입력해주세요.'); $('#contents').focus(); return false;}
            if($('#imgName').val().length > 0) {
                var file_type = $('#imgName').val().split('.')[$('#imgName').val().split('.').length - 1];
                if(file_type == 'bmp' || file_type == 'jpg' || file_type == 'gif' || file_type == 'zip') {}
                else{
                    alert('파일 확장자는 bmp, jpg, gif, zip만 가능합니다.');
                    return false;
                }
            }
        }); 
    } 
}