﻿var myserver = "http://www.brewium.com/";
var novote0 = new Image();
novote0.src = myserver + "images/rating/nim_low.gif";

var novote1 = new Image();
novote1.src = myserver + "images/rating/nim_high.gif";

var on1 = new Image();
on1.src = myserver + "images/rating/stars_1.gif";

var off1 = new Image();
off1.src = myserver + "images/rating/stars_0.gif";

var thename;

function updateDIV(div, shtml){
	if (document.getElementById || document.all) {
    var ll = document.getElementById? document.getElementById(div): document.all[div];
    if (ll && typeof ll.innerHTML != "undefined") ll.innerHTML = shtml;
    }
}

function callRate(type,myID,itemID,div,score)
{
/*type	-	recipe "recipes"
		-	help "knowledgebase"
		-	merchant "merchants"
		-	article "articles" 
*/
  var url;
  url = myserver + "BrewiumRater.php?type="+type+"&id="+myID+"&item="+itemID+"&div="+div+"&score="+score;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);     
}

function onStar(ID, Type, Score) {
  if (Score == 0){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote1.src;
    thename = Type + "1_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "2_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "3_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = off1.src;
  }
  
  if (Score == 1){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote0.src;
    thename = Type + "1_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "2_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "3_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = off1.src;
  }
  
  if (Score == 2){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote0.src;
	thename = Type + "1_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "2_" + ID;
    document.images[thename].src = on1.src;
	thename = Type + "3_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = off1.src;
  }
  
  if (Score == 3){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote0.src;
    thename = Type + "1_" + ID;
    document.images[thename].src = on1.src;
	thename = Type + "2_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "3_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = off1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = off1.src;
  }
  
  if (Score == 4){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote0.src;
    thename = Type + "1_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "2_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "3_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = off1.src;
  }
  
  if (Score == 5){
    thename = Type + "0_" + ID;
    document.images[thename].src = novote0.src;
    thename = Type + "1_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "2_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "3_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "4_" + ID;
    document.images[thename].src = on1.src;
    thename = Type + "5_" + ID;
    document.images[thename].src = on1.src;
  }
}

function offStar(ID, Type, Score) {
  thename = Type + "0_" + ID;
	  document.images[thename].src = novote0.src;
  thename = Type + "1_" + ID;
      document.images[thename].src = off1.src;
  thename = Type + "2_" + ID;
      document.images[thename].src = off1.src;
  thename = Type + "3_" + ID;
      document.images[thename].src = off1.src;
  thename = Type + "4_" + ID;
      document.images[thename].src = off1.src;
  thename = Type + "5_" + ID;
      document.images[thename].src = off1.src;
}

