  /**
   * 만족도 유효성 검사
   * @author 정석호
   * @return
   */
function validateScore(){
  var question = document.getElementById('scoreform');
  var inputs = question.getElementsByTagName('input');
  var score = 0;
  var checkCount = 0;
  for ( var i = 0; i < inputs.length; i++ ){
    if ( inputs[i].type == 'radio'){
      if ( inputs[i].checked == true ){
        score = inputs[i].value;
        checkCount++;
      }
    }
  }
  if ( checkCount < 1 ) {
    alert("만족도를 선택해 주세요.");
    return false;
  }
  if ( document.getElementById('opinion').value.length > 1000 ) {
    alert("1,000자 이내로 입력하여 주십시오.");
    return false;
  }
  
  insertMenuScore(score);
  return false;
}

/**
 * 만족도 조사   평점가져오기
 * @author 서경대
 * @return
 */
function getAverage(){
  $.post("../../main/menuScoreAverage.jsp",
      { 'menuID':document.getElementById('menuID2').value},
      function(data) {        
        var cnt = 0;
        var sum = 0;
        var avg = 0;
        var obj = data.split('|');        
        if ( obj.length > 1 && obj[0] != 0 ) {        	
          cnt = parseFloat(obj[0]);          
          sum = parseFloat(obj[1]);          
          avg = new Number(sum/cnt).toFixed(1);          
        }        
        $("#average").html(avg);
        $("#averageCount").html(cnt);
      }, 
      "text");  
}

/**
 * 만족도 내용길이검사
 * @author 정석호
 * @return
 */
function lengthCheck(){
  addHTML = new Array();
  addHTML.push(document.getElementById('opinion').value.length);
  document.getElementById('opinionlength').innerHTML = addHTML.join("");
}

/**
 * 만족도  기록
 * @author 정석호
 * @return
 */
function insertMenuScore(score){  
  $.post("../../main/menuScoreProcess.jsp",
      { "menuID":document.getElementById("menuID2").value, "menuScore":score, "opinion":document.getElementById("opinion").value },
      function(data) {        
        document.getElementById("opinion").value = "";
        var inputs = document.getElementById("scoreform").getElementsByTagName("input");
        for ( var i = 0; i < inputs.length; i++ ){
          if ( inputs[i].type == "radio"){
            inputs[i].checked = false;
          }
        }
        alert(trim(data));
      });
}

/**
 * okOnline 회원가입 이용약관동의
 * @author 정석호
 * @return
 */
function okOnlineMemberJoin(){
  if ( document.getElementById("okOnlineMemberJoin").checked ) {
    document.location.replace("../../program/member/okOnlineMemberJoin.jsp?menuID=100008002");
  } else {
    alert("이용약관에 동의하셔야 합니다.");
    return false;
  }
  return false;
}

/**
 * 트림
 * @author 정석호
 * @return
 */
function trim(str){
  str = str.replace(/^\s*/,'').replace(/\s*$/, '');
  return str;
}

function toolTab(item,num)
{
 var str="";
 for(i=1; i<=num; i++){
  if(i<10) str = "toolTab_"+i;
  else str = "toolTab_"+i;
  document.getElementById(str).style.display = "none";
 }
 document.getElementById(item).style.display = "";
}


function setCookie (name,value,expiredays){
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate()+expireDays);
  document.cookie = name + "=" + escape(value) + ";path=/;expires=" + todayDate.toGMTString()+";";
}
   
function clearCookie(name){
       document.cookie = name + "= ''";
}
   
function getCookie (name){
   var search = name + "=";       
   if (document.cookie.length > 0){
       offset = document.cookie.indexOf(search);
       
       if (offset != -1){
           offset += search.length;
           end = document.cookie.indexOf(";",offset);
       
           if (end == -1) end = document.cookie.length;
           return unescape(document.cookie.substring(offset,end));
       }
       else return false;
   }
   else return false;
}