/*var Input = {
   initialize: function(index) {
   	this.index = index;
   	
     if(document.getElementsByTagName("form")) {
      var divs = document.getElementsByTagName("div");
      
      for(var i = 0; i < divs.length; i++) {
      	
        if(divs[i].className.match("radio"+this.index)) {
           divs[i].onmousedown 	= Input.effect;
           divs[i].onmouseup 	= Input.handle;
          // divs[i].onmouseover 	= Input.handle;
          // divs[i].onmouseout 	= Input.handle;
           window.onmouseup 	= Input.clear;
           }
         }
       }
     },
 
    effect: function() {
     if(this.className == "radio"+index) {
        this.style.backgroundPosition = "0 0";
      } 
   },

 handle: function() {
	selector = this.getElementsByTagName("input")[0];
	alert(this.index);
	selector.checked = true;
	this.className = "radio"+index+" selected";
	var divs = document.getElementsByClassName("radio"+index);

	inputs = document.getElementsByTagName("input");
	var len = inputs.length;
	

	for(var i = 0; i < len; i++) {
	 if(inputs[i].getAttribute("name") == selector.getAttribute("name")) {
	   	   
	   if(inputs[i] != selector) {
	     inputs[i].parentNode.className = "radio"+index;
	    }
	  }
	}
	
	for(var i = 0; i < len; i++) {
	
	   if (inputs[i].checked == true) {
 			var selectorChecked = inputs[i].value;
	   }
	
	}
	
	for (var i = 0; i < selectorChecked-1; i++) {
		divs[i].className = "radio"+index+" selected";
	}
    },
	
    clear: function() {
      divs = document.getElementsByTagName("div");
      for(var i = 0; i < divs.length; i++) {
       if(divs[i].className == "radio"+index) {
        divs[i].style.backgroundPosition = "0 0";
        } else if(divs[i].className == "radio"+index+" selected") {
          	divs[i].style.backgroundPosition = "0 0";
       }
      }
    }
 }
 */

function radioBoxes (index) {
	this.index = index;
	this.selector = document.getElementsByName("rating_general")[0];
	
}

radioBoxes.prototype.initialize =  function() 
{
		
 if(document.getElementsByTagName("form")) {
 
  var divs = document.getElementsByTagName("div");
  for(var i = 0; i < divs.length; i++) {
  	 
    if(divs[i].className.match("radio"+this.index)) {
   		
       divs[i].onmousedown 	= this.effect();
       divs[i].onmouseup 	= this.handle();
       //divs[i].onmouseover 	= this.handle();
      // divs[i].onmouseout 	= this.handle();
       window.onmouseup 	= this.clear();
       }
     }
  }
}
 
radioBoxes.prototype.effect = function() {
 	
     if(this.className == "radio"+this.index) {
        this.style.backgroundPosition = "0 0";
      } 
}

radioBoxes.prototype.handle = function()
{
	this.selector.checked = true;
	
	this.selector.className = "radio"+this.index+" selected";
	var divs = document.getElementsByClassName("radio"+this.index);

	inputs = document.getElementsByName("rating_general");
	var len = inputs.length;
	
	//alert(len);
	for(var i = 0; i < len; i++) {
	 if(inputs[i].getAttribute("name") == this.selector.getAttribute("name")) {
	    
	  if(inputs[i] != this.selector) {
	     inputs[i].parentNode.className = "radio"+this.index;
	    
	    }
	  }
	}
	
	for(var i = 0; i < len; i++) {
	
	   if (inputs[i].checked == true) {
 			var selectorChecked = inputs[i].value;
	   }
	
	}
	
	for (var i = 0; i < selectorChecked-1; i++) {
		divs[i].className = "radio"+this.index+" selected";
	}
}

radioBoxes.prototype.clear = function() {
	divs = document.getElementsByTagName("div");
	for(var i = 0; i < divs.length; i++) {
	if(divs[i].className == "radio"+this.index) {
		divs[i].style.backgroundPosition = "0 0";
	} else if(divs[i].className == "radio"+this.index+" selected") {
	  	divs[i].style.backgroundPosition = "0 0";
		}
	}
}

