/*
review.js
2009年10月30日
*/

function Review()
{
  this.box=new ColeBox();
  this.data={
id:"",
productid:"",
review1:0,
review2:0,
review3:0,
content:""
  };
}

Review.prototype.collect=function()
{
  this.data.review1=($("review.review1").checked==true?1:0);
  this.data.review2=($("review.review2").checked==true?1:0);
  this.data.review3=($("review.review3").checked==true?1:0);  
  this.data.content=$("review.content").value;
  if(this.data.content=="")
  {
    alert("请填写内容。");
    $("review.content").focus();
    return false;
  }
  return true;
}

Review.prototype.add=function(id,name)
{
    if(this.collect()==false)
      return;
    var obj=new Ajax(this);
    obj.post("/servlet/product/review.servlet.php",
    "action","add",
    "productid",this.data.productid,
    "review1",this.data.review1,
    "review2",this.data.review2,
    "review3",this.data.review3,
    "content",this.data.content,
    this.addback);
}

Review.prototype.addback=function(value)
{
  if(value=="#未登录") 
  {
    alert('请先登录您的帐号。');
    return;
  }

  if(value=="成功") 
  {
    alert("恭喜，成功了。");
    top.location.reload();
  }
  else 
  {
    alert("发送失败，请稍候重试。");
  }
}

//评价框
Review.prototype.showreviewbox=function(target)
{	
  if($("review_box"))
  {
    this.box.closeflowbox();
    return;  
  }
  
  this.target=target;
  var obj=new Ajax(this);
  obj.post("/_box/review.box.php",  
  this.showreviewboxback);
}

Review.prototype.showreviewboxback=function(html)
{
  this.box.showflowbox(this.target,html);
}

var review=new Review();

//End
