// JavaScript Document
var invoice_selected = false;

window.addEvent('domready', function() {
	
	$$('.payments_button').each(function(el) {
		
		var theid = el.id.substring(16);
		
		  el.addEvent('click', function(event){
			  
			 invoice_selected = true;
			  
			  $$('.lineinvoice').each(function(elinvoice) {
						
					elinvoice.removeClass('selected_invoice');
					
				});
				
				 $('lineinvoice_'+theid).addClass('selected_invoice');
			  
				 $$('.paymentline').each(function(elpayment) {
						
					elpayment.addClass('paymenthide');
					elpayment.removeClass('paymenthover');
					
				});
				
				$$('.payment_'+theid).each(function(elpaymentvalid) {
						
					elpaymentvalid.removeClass('paymenthide');
					
					
				});
				
				$('allpayments_button').removeClass('disabled');
		  
		  });
		 
		
	});
	
	$$('.lineinvoice').each(function(el) {
		
		var theid = el.id.substring(12);
		
		
		
		  el.addEvent('mouseover', function(event){
				  
				$$('.paymentline').each(function(elpayment) {
						
					if(!invoice_selected) elpayment.removeClass('paymenthover');
					
				});
				 
				$$('.payment_'+theid).each(function(elpaymentvalid) {
						
					if(!invoice_selected) elpaymentvalid.addClass('paymenthover');
					
				});
		  
		  });
		  
		  el.addEvent('mouseout', function(event){
				  
				$$('.paymentline').each(function(elpayment) {
						
					if(!invoice_selected) elpayment.removeClass('paymenthover');
					
				});
				
		  
		  });
		  
		
		
	});
	
	/*
	$$('.paymentline').each(function(el) {
		
		var theid = 0;//el.id.substring(12);
		//var classes = el.classes[0];
		//alert('d');
		  el.addEvent('mouseover', function(event){
			   
				$$('.lineinvoice').each(function(invoice) {
						
					invoice.removeClass('invoicehover');
					
				});
				 
				$('lineinvoice_'+theid).addClass('invoicehover');
		  
		  });
		  
		  el.addEvent('mouseout', function(event){
				  
				$$('.lineinvoice').each(function(invoice) {
						
					invoice.removeClass('invoicehover');
					
				});
				
		  });
		 
	});
	*/
	
});

function see_all_payments(){
	$$('.lineinvoice').each(function(elinvoice) {
						
		elinvoice.removeClass('selected_invoice');
		
	});
	
	$$('.paymentline').each(function(elpayment) {
						
		elpayment.removeClass('paymenthover');
		elpayment.removeClass('paymenthide');
		
	});
	
	$('allpayments_button').addClass('disabled');
	
	
	invoice_selected = false;
}