	$(function(){
		
	
$('.textfield').focus(function(){$('.error').fadeOut();
			}
			);				
	
			$('#buy_calculate').click(
					function(){
					$('.error').fadeOut();
						if($('#buy_currency_amount').val()==""){
								$('#buy_currency_amount_error').fadeIn();
								//this feels better than the alert thingy
								//alert("Please specify amount you want");
								
								return false;
							}
	
						if(
							$('#buy_currency_select').val()=="alertpay" && $('#buy_payment_method_select').val()=="naira"){
								
								var minimum_amount = parseInt($('#others_buy_minimum').val());//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#alertpay_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}	
								
						if(
							$('#buy_currency_select').val()=="liberty_reserve" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#lr_buy_minimum').val());
								
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#lr_buy').val());
								var amount_due = buy_currency_amount * buy_rate;
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}	
								
								
						if(
							$('#buy_currency_select').val()=="moneybookers" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
																if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								
								//get the fixed amount
								var buy_rate = parseInt($('#moneybookers_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}
								
						if(
							$('#buy_currency_select').val()=="paypal" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								
																if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#paypal_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}						
								
						if(
							$('#buy_currency_select').val()=="procurrex" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								
																if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#procurrex_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}	
								
																																											
						if(
							$('#buy_currency_select').val()=="webmoney" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								
																if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#webmoney_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}
								
								
						if(
							$('#buy_currency_select').val()=="cashu" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
								
																if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeIn();
									return false;
								}
								//get the fixed amount
								var buy_rate = parseInt($('#cashu_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}
								
						if(
							$('#buy_currency_select').val()=="ukash" && $('#buy_payment_method_select').val()=="naira"){
								var minimum_amount = parseInt($('#others_buy_minimum').val());
								//get the  amount the dude inputs
								var buy_currency_amount = parseInt($('#buy_currency_amount').val()); 
							
								if(buy_currency_amount < minimum_amount){
									$('#buy_amount_due').html('<p>You have entered a value below the minimum</p>').fadeOut().fadeIn();
									return false;
								}
							//get the fixed amount
								var buy_rate = parseInt($('#ukash_buy').val());
								if(buy_currency_amount < parseInt($('#others_service_charge_treshold').val())){
								var initial_amount = buy_currency_amount * buy_rate;
								var amount_due = initial_amount + parseInt($('#others_service_charge').val());
								}
								else{
								var amount_due = buy_currency_amount * buy_rate;
								}
								$('#buy_amount_due').html(amount_due).fadeIn();
								$('#buy_amount_due_label').html('Amount Due (Naira)').fadeIn();
								
								return false;
								
								}																
								
						if(
							$('#buy_currency_select').val()=="alertpay" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="liberty_reserve" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}																
								
								
						if(
							$('#buy_currency_select').val()=="moneybookers" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}	
								
								
						if(
							$('#buy_currency_select').val()=="paypal" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}			
								
						if(
							$('#buy_currency_select').val()=="procurrex" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="webmoney" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="cashu" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}			

						if(
							$('#buy_currency_select').val()=="ukash" && $('#buy_payment_method_select').val()=="wu"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}															
								
								
								
								
								
								
								//moneygram
	if(
							$('#buy_currency_select').val()=="alertpay" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="liberty_reserve" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}																
								
								
						if(
							$('#buy_currency_select').val()=="moneybookers" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}	
								
								
						if(
							$('#buy_currency_select').val()=="paypal" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}			
								
						if(
							$('#buy_currency_select').val()=="procurrex" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="webmoney" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}		
								
								
						if(
							$('#buy_currency_select').val()=="cashu" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}	
								
								
						if(
							$('#buy_currency_select').val()=="ukash" && $('#buy_payment_method_select').val()=="moneygram"){
								$('#buy_amount_due').html('<p style="color:#900;">An email will be sent to you with the price, please continue and submit the form.</p>').fadeIn();
								$('#buy_amount_due_label').hide();
								return false;

								}																																																					
													
						}
						
				);//end of math
				
	//validation			
				$('#buy_submit').click(
					function(){
						if($('#buy_currency_amount').val()==""){
							$('#buy_currency_amount_error').fadeIn();
							return false;
						}
						
						if($('#buy_account_id').val()==""){
							$('#buy_account_id_error').fadeIn();
							return false;
						}
						
						if($('#buy_confirm_account_id').val()==""){
							$('#buy_confirm_account_id_error').fadeIn();
							return false;
						}	

						if($('#buy_fullname').val()==""){
							$('#buy_fullname_error').fadeIn();
							return false;
						}

						if($('#buy_email').val()==""){
							$('#buy_email_error').fadeIn();
							return false;
						}		
						if($('#buy_confirm_email').val()==""){
							$('#buy_confirm_email_error').fadeIn();
							return false;
						}							
						if($('#buy_phone').val()==""){
							$('#buy_phone_error').fadeIn();
							return false;
						}	
							var account_id = $('#buy_account_id').val();
							var confirm_account_id= $('#buy_confirm_account_id').val();
						
						if( account_id !== confirm_account_id ){
							$('#buy_confirm_account_id_error').html('<p class="error">Account ID mismatch</p>').fadeIn();
							return false;
						}						
						
							var email = $('#buy_email').val();
							var confirm_email= $('#buy_confirm_email').val();
						
						if( email !== confirm_email ){
							$('#buy_confirm_email_error').html('<p class="error">Email mismatch!</p>').fadeIn();
							return false;
						}								
					}
				);				
				
	});		
