
//var _pp_url = "https://www.sandbox.paypal.com/cgi-bin/youbscr";
var _pp_url = "https://www.paypal.com/cgi-bin/youbscr";


		$().ready(function() {
		
			$("#currency").change(onCurrencyChange);

			
			   var options = { 
                        target: '#result', 
                        success: showResponse 
                } 
		
			var v = $("#subscription").validate({
												rules: {
			captcha: {
				required: true,
				remote: "includes/process.php"
			}
		},
		messages: {
			captcha: "Correct captcha is required. Click the captcha to generate a new one"	
		},
		submitHandler: function() {
			jQuery(form).ajaxSubmit( options,  $('input[type=submit]', this).attr('disabled', 'disabled') );
		},
		onkeyup: false
			
				}
			);
			
			
			
		});
		
		$(function(){
	$("#refreshimg").click(function(){
		$.post('php/newsession.php');
		$("#captchaimage").load('php/image_req.php');
		return false;
	});
	});
		
		function onCurrencyChange(){
			var selected = $("#currency option:selected");		
			
			switch( selected.text() ){
				
				case "EUR":
					$("#currency_code").setValue( "EUR" ); 
					$("#business").setValue( "pierre-andre.dumont@wanadoo.fr" );
					$("#amount").setValue( "2000" );
					break;
				case "CHF":
					$("#currency_code").setValue( "CHF" ); 
					$("#business").setValue( "padumont@vipservices.ch" );
					$("#amount").setValue( "3000" );
					break;
			
			}
			
			
			/*
			alert( $("#currency_code").val() );
			alert( $("#business").val() );
			alert( $("#amount").val() );
			*/
		}
        
		

		function showResponse(responseText, statusText) { 
        
		        if( $("input[name='method']").getValue() == "pp"){
		        	
			        $("#subscription").unbind("submit");
			        
			        $("input[name='custom']").setValue( $("input[name='custom']").getValue() + "&&&&" + $("#email").val() + "&&&&" + $("#arg2").val() );
			        
			        $("#subscription").attr("action", _pp_url); 
			        
			        $("form").submit();     
					
				}
				else if( $("input[name='method']").getValue() == "p"){
					$("#civy").attr("disabled", "disabled");
					$("#fname").attr("disabled", "disabled");
					$("#lname").attr("disabled", "disabled");
					$("#fullAddress").attr("disabled", "disabled");
					$("#country").attr("disabled", "disabled");
					$("#landLine").attr("disabled", "disabled");
					$("#cellPhone").attr("disabled", "disabled");
					$("#email").attr("disabled", "disabled");
					$("#lang").attr("disabled", "disabled");
					$("#method").attr("disabled", "disabled");
					$('input[type=submit]', this).attr('disabled', 'disabled')
					
				}
			
		        return true; 
		} 

 

