// JavaScript Document @3madd.com
//declaring the class
var SubmitWatcher = Class.create();

//defining the rest of the class implementation
SubmitWatcher.prototype = {

  initialize: function(chkElem) {
    this.chkElem = $(chkElem);
    //assigning our method to the event

    this.chkElem.onmouseover = this.msover.bindAsEventListener(this);
	this.chkElem.onmouseout = this.msout.bindAsEventListener(this)
  },

  msover: function(evt) {
    	this.chkElem.setStyle({
	  	background: 'url(http://www.soberustice.ro/images/but_sub.jpg) 0px -23px no-repeat'	
		});
	  },
  msout: function(evt) {
    	this.chkElem.setStyle({
	  	background: 'url(http://www.soberustice.ro/images/but_sub.jpg) 0px 0px no-repeat'	
		});
	  }
};


var cantit = Class.create();

//defining the rest of the class implementation
cantit.prototype = {
	

  initialize: function(chkElemc) {	  
  
    this.chkElemc = $(chkElemc);
		
	 this.chkElemc.onkeyup = this.ckk.bindAsEventListener(this)
  },
  
  ckk: function(evt) {
	  
	 function IsNumeric(sText)

		{
		   var ValidChars = "0123456789.";
		   var IsNumber=true;
		   var Char;
		   for (i = 0; i < sText.length && IsNumber == true; i++) 
			  { 
			  Char = sText.charAt(i); 
			  if (ValidChars.indexOf(Char) == -1) 
				 {
				 IsNumber = false;
				 }
			  }
		   return IsNumber;
		   
		   }
	  
	  
    	var gel = document.getElementsByClassName("xxx");
		var gely = document.getElementsByClassName("yyy");
		var lung = gel.length;
		var sumat=0;
		for (i=0;i<lung;i++){
			
			sumat+=(Number(gel[i].value)*Number(gely[i].value));
		}
			if(isNaN(sumat)){
				// NU este numar
				alert('Completati doar cifre la cantitate');
			}else{
			$('suma').innerHTML = sumat;
			}
		}

  
};


