window.onload = function() {
	$('TextButon').onclick = Text2Bin;
	$('BinButon').onclick = Bin2Text;
}


function Text2Bin() {
	if( $F('text').length < 1 ) {
		alert('Boş bir ifade gönderilmez !');
		$('text').focus();
		return false;
	}
	
	// AJAX ile gönder
	$('bin').value = 'Dönüştürme yapılıyor ...'
	
	new Ajax.Request(
		'Text2Bin.php',
		{
			method: 'post', 
			parameters: 'text=' + encodeURIComponent($F('text')),
			onComplete: function(ajax) {
				$('bin').value = ajax.responseText;
			}
		}
	);
}


function Bin2Text() {
	if( $F('bin').length < 1 ) {
		alert('Boş bir ifade gönderilmez !');
		$('bin').focus();
		return false
	}
	
	// AJAX ile gönder
	$('text').value = 'Dönüştürme yapılıyor ...'
	
	new Ajax.Request(
		'Bin2Text.php',
		{
			method: 'post', 
			parameters: 'bin=' + encodeURIComponent($F('bin')),
			onComplete: function(ajax) {
				$('text').value = ajax.responseText;
			}
		}
	);	
}