﻿
function CreateStars(Placeholder, SetCallBack, DeleteCallBack) {
  //var starhtml = 'Rating: <span class="star-cap"></span><br />'
 //+ '<table cellpadding="0px" cellspacing="0px">'
 var starhtml = '<table cellpadding="0px" cellspacing="0px" class="star-table">'
    + '  <tr>'
    + '    <td class="star-delete" status="off">&nbsp;</td>'
    + '    <td class="star" value="1" title="Very poor" status="off">&nbsp;</td>'
    + '    <td class="star" value="25" title="Poor" status="off">&nbsp;</td>'
    + '    <td class="star" value="50" title="Average" status="off">&nbsp;</td>'
    + '    <td class="star" value="75" title="Good" status="off">&nbsp;</td>'
    + '    <td class="star" value="100" title="Excellent" status="off">&nbsp;</td>'
    + '  </tr>'
    + '</table>'

  j1_3_2("#" + Placeholder).html(starhtml)
  j1_3_2("#" + Placeholder + " .star-delete").addClass("star-delete-off");
    j1_3_2("#" + Placeholder + " .star-delete").mouseover(
       function() {
        j1_3_2(this).removeClass("star-delete-off");
        j1_3_2(this).addClass("star-delete-on");
      });

    j1_3_2("#" + Placeholder + " .star-delete").mouseout(
       function() {
         j1_3_2(this).removeClass("star-delete-on");
         j1_3_2(this).addClass("star-delete-off");
       });
       j1_3_2("#" + Placeholder + " .star-delete").click(
       function() {
         DeleteCallBack();
       });
        
    j1_3_2("#" + Placeholder + " .star").addClass("star-off")
    j1_3_2("#" + Placeholder + " .star").mouseover(
      function() {
        //j1_3_2(this).prevAll().removeClass("star-off");
        j1_3_2(this).prevAll().addClass("star-hover");
        //j1_3_2(this).removeClass("star-off");
        j1_3_2(this).addClass("star-hover");
      });
    j1_3_2("#" + Placeholder + " .star").mouseout(
      function() {
        j1_3_2(this).prevAll().removeClass("star-hover");
        //j1_3_2(this).prevAll().addClass("star-off");
        j1_3_2(this).removeClass("star-hover");
        //j1_3_2(this).addClass("star-off");
      });
      j1_3_2("#" + Placeholder + " .star").click(
      function() {
        j1_3_2("#" + Placeholder).attr("UserValue", j1_3_2(this).attr("value"));
        SetCallBack();
      });
}


function SetStars(Placeholder, value) {
  value = value * 1
  if (value > 1 && value < 25)
  {
    if (value > 12) {
      value = 25
    }
    else {
      value = 1    
    }
  }
  if (value > 25 && value < 50) {
    if (value > 37) {
      value = 50
    }
    else {
      value = 25
    }
  }
  if (value > 50 && value < 75) {
    if (value > 62) {
      value = 75
    }
    else {
      value = 50
    }
  }
  if (value > 75 && value < 100) {
    if (value > 87) {
      value = 100
    }
    else {
      value = 75
    }
  }
  j1_3_2("#" + Placeholder + " .star").removeClass("star-on");
  j1_3_2("#" + Placeholder + " .star[value='" + value + "']").addClass("star-on");
  j1_3_2("#" + Placeholder + " .star[value='" + value + "']").prevAll().addClass("star-on");
  //var caption = j1_3_2("#" + Placeholder + " .star[value='" + value + "']").attr("title")
   //j1_3_2("#" + Placeholder + " .star-cap").text(caption)
}