	jQuery(document).ready(function(){
                // binds form submission and fields to the validation engine
                
               
                jQuery("#invoice").validationEngine();
                $("#select").change(onSelectChange);
				$("#paypal").hide();
				$("#Wire").hide();
				$("#id_pop").hide();
				$("#id_pop_Payoneer").hide();
				$("#id_pop_Wire").hide();
				$("#Payoneer").hide();
				$("#Revenue2").hide();
				$("#Revenue2_Payoneer").hide();
				$("#Revenue3_Payoneer").hide();
				$("#Revenue2_Wire").hide();
				$("#Revenue3_Wire").hide();
				$("#Revenue3").hide();
				$("#Revenue3_Payoneer").hide();
				 $(".Activity_Amount").each(function() {
 
           				 $(this).keyup(function(){
               			 calculateSum();
            });
        });
        
        $(".Activity_Amount_Payoneer").each(function() {
 
           				 $(this).keyup(function(){
               			 calculateSum_Payoneer();
            });
        });
		$(".Activity_Amount_Wire").each(function() {
 
           				 $(this).keyup(function(){
               			 calculateSum_Wire();
            });
        });
        
        

                
             
        
       });

	
			
			
	function onSelectChange(){
		
		
		
			 $("input:text#").val( '');
			 
			 
			 
		 $("input:text#Revenue_total_Payoneer").val( '');
		 $("input:text#Revenue_total").val( '');
		 $("input:text#Revenue_total_Wire").val( '');
		$("input:text#Activity_Amount").val( ''); 
		 $("input:text#Activity_Amount2").val( ''); 
		 $("input:text#Activity_Amount3").val( ''); 
		 
		 $("input:text#Activity_Amount_Payoneer").val( ''); 
		 $("input:text#Activity_Amount2_Payoneer").val( ''); 
		 $("input:text#Activity_Amount3_Payoneer").val( ''); 
		 $("input:text#Activity_Amount_Wire").val( ''); 
		 $("input:text#Activity_Amount2_Wire").val( ''); 
		 $("input:text#Activity_Amount3_Wire").val( ''); 
		 
	    var selected = $("#select option:selected").html();    
	    
	if(selected == "PayPal"){
			document.forms[0].reset();
			$('#select').val("PayPal");
			$("#paypal").show();
			$("#Wire").hide();
			$("#Payoneer").hide();
			
			}

	if(selected == "Wire Transfer"){
			document.forms[0].reset();
			$('#select').val("Wire Transfer");
			$("#Wire").show();
			$("#Payoneer").hide();
			$("#paypal").hide();

			}

	if(selected == "Matomy Payoneer Card"){
			document.forms[0].reset();
			$('#select').val("Matomy Payoneer Card");
			$("#Payoneer").show();
			$("#paypal").hide();
			$("#Wire").hide();
			}
		}

		function pop(){
			$("#id_pop").show();
			$("#id_pop_Payoneer").show();
			$("#id_pop_Wire").show();
				}

		function pop_close(){
			$("#id_pop").hide();
			$("#id_pop_Payoneer").hide();
			$("#id_pop_Wire").hide();
			
				}
	

		function addRev(rev , type)  {
			
			$("#Revenue"+rev+type).show();
		  
		}

		function hideRev(rev , type){
		
			$("#Revenue"+rev+type).hide();
		}

		
		
    function calculateSum() {
 	 var sum = 0;
       
        //iterate through each textboxes and add the values
        $(".Activity_Amount").each(function() {
 
            //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);
            }
 
        });
        
        sum = '$'+sum;
        //.toFixed() method will roundoff the final sum to 2 decimal places
       $("input:text#Revenue_total").val(sum );
	   $("input:text#Revenue_total").formatCurrency();
    }


	function calculateSum_Payoneer() {
	 	 var sum = 0;
	       
	        //iterate through each textboxes and add the values
	        $(".Activity_Amount_Payoneer").each(function() {
	 
	            //add only if the value is number
	            if(!isNaN(this.value) && this.value.length!=0) {
	                sum += parseFloat(this.value);
	            }
	 
	        });
	        sum = '$'+sum;
	       $("input:text#Revenue_total_Payoneer").val(sum );
		   $("input:text#Revenue_total_Payoneer").formatCurrency();
	    }
	    
	    function calculateSum_Wire() {
	 	 var sum = 0;
	       
	        //iterate through each textboxes and add the values
	        $(".Activity_Amount_Wire").each(function() {
	 
	            //add only if the value is number
	            if(!isNaN(this.value) && this.value.length!=0) {
	                sum += parseFloat(this.value);
	            }
	 
	        });
	        
	        
	        
	        
	        sum = '$'+sum;
	       $("input:text#Revenue_total_Wire").val(sum );
		   $("input:text#Revenue_total_Wire").formatCurrency();
	    }
		
		
		
/*

	$(document).ready(function()
			{
				$('.currency').blur(function()
				{
					$('.currency').formatCurrency();
				});
			});
	

*/














