var is_ssl = 0;
$( document ).ready(function(){
	$( '#enable_ssl' ).click(function(){
		if( is_ssl == 0 )
		{
			$( '#proxytextbox' ).fadeOut( 'fast', function(){
				var url = $( this ).val();
				$( '#form' ).attr( 'action', $( '#form' ).attr( 'action' ).replace( 'http://', 'https://' ) );
				//$( this ).val( ( !url.match( 'http://' ) && !url.match( 'https://' ) ) ? 'https://' + url : url.replace( 'http://', 'https://' ) );
				
				$( this ).attr( 'id', 'proxytextbox' );
				$( this ).fadeIn( 'fast' );
			});
			
			$( this ).html( '&nbsp;&raquo;&nbsp;Выключить SSL' );
			$( this ).attr( 'title', 'Turn off encryption' );
			
			$( '#sslproxy' ).attr( 'id', 'httpproxy' );
			is_ssl = 1;
		}
		else
		{
			$( '#proxytextbox' ).fadeOut( 'fast', function(){
				var url = $( this ).val();
				$( '#form' ).attr( 'action', $( '#form' ).attr( 'action' ).replace( 'https://', 'http://' ) );
				//$( this ).val( ( !url.match( 'https://' ) && !url.match( 'http://' ) ) ? 'http://' + url : url.replace( 'https://', 'http://' ) );
		
				$( this ).attr( 'id', 'proxytextbox' );
				$( this ).fadeIn( 'fast' );
			});

			$( this ).html( '&nbsp;&raquo;&nbsp;Включить SSL' );
			$( this ).attr( 'title', 'SSL Encryption secures your browser session' );
			
			$( '#httpproxy' ).attr( 'id', 'sslproxy' );
			is_ssl = 0;
		}
	});
});