function BlockCountry(id){
	function UrlSuccess(t) {
		var json=t.responseText.evalJSON();
		if (json.url!='') {
			$('LoadUrl').hide();
//			$('BlockResultInput').innerHTML=json.url;
			$('BlockResultInput').value=json.url;
			$('BlockResult').appear("BlockResult",
				{
					duration:1.0,
					from:0.0,
					to:1.0
				}
			);
			$('BlockResult').show();
			$('BlockResultInput').focus();
			$('BlockResultInput').select();
		}
	}
	function UrlFailure(t) {
		alert(t.responseText);
	}
	$('BlockResult').hide();
	if ($('LoadUrl').stretch!=true) {
		new Effect.BlindDown('StretchDown',
			{
				duration:0.2,
				afterFinishInternal: function(effect) {
					$('LoadUrl').show();
					$('LoadUrl').stretch=true;
				}
			}
		);
	} else {
		$('LoadUrl').show();
	}
	var params=$('SelectCountryForm').serialize();
	new Ajax.Request('index.php?a_m=ajaxblock', {asynchronous:true, parameters:params, onException: UrlFailure, on404: UrlFailure, onFailure: UrlFailure, onSuccess: UrlSuccess});
}

function UrlSend(id){
	function UrlSuccess(t) {
		var json=t.responseText.evalJSON();
		if (json.url!='') {
			$('LoadUrl').hide();
			$('ShortUrlInput').value=json.url;
			$('ShortUrl').appear("ShortUrl",
				{
					duration:1.0,
					from:0.0,
					to:1.0
				}
			);
			$('ShortUrl').show();
			$('ShortUrlInput').focus();
			$('ShortUrlInput').select();
		}
	}
	function UrlFailure(t) {
		alert(t.responseText);
	}
	$('ShortUrl').hide();
	if ($('LoadUrl').stretch!=true) {
		new Effect.BlindDown('StretchDown',
			{
				duration:0.2,
				afterFinishInternal: function(effect) {
					$('LoadUrl').show();
					$('LoadUrl').stretch=true;
				}
			}
		);
	} else {
		$('LoadUrl').show();
	}
	var params=$('LongUrlForm').serialize();
	new Ajax.Request('index.php?a_m=ajaxshort', {asynchronous:true, parameters:params, onException: UrlFailure, on404: UrlFailure, onFailure: UrlFailure, onSuccess: UrlSuccess});
}

function PageInit() {
	$('LongUrlInput').onkeypress=function(e) {
		e = e || window.event;
		var code = e.keyCode || e.which;
		if (code==13) {
			if ($('LongUrlForm').elements['HideUrl'][0].checked==true) {
				$('LongTitleInput').focus();
				$('LongTitleInput').select();
			} else {
				$('ShoxtItAnchor').onclick();
			}
		}
	}

	$('LongTitleInput').onkeypress=function(e) {
		e = e || window.event;
		var code = e.keyCode || e.which;
		if (code==13) {
			if ($('LongUrlInput').value=='http://' || $('LongUrlInput').value=='') {
				$('LongUrlInput').focus();
				$('LongUrlInput').select();
			} else {
				$('ShoxtItAnchor').onclick();
			}
		}
	}

	$('ShortUrlInput').onkeypress=function(e) {
		e = e || window.event;
		var code = e.keyCode || e.which;
		if (code==13) {
			$('LongUrlInput').focus();
			$('LongUrlInput').select();
		}
	}
	$('LongUrlInput').focus();
	$('LongUrlInput').select();
}

function LongTitleShow() {
	if($('LongUrlForm').elements['HideUrl'][0].checked==false) {
		new Effect.BlindUp('LongTitle',{duration:1});
	} else {
		new Effect.BlindDown('LongTitle',
			{
				duration:1,
				afterFinishInternal: function(effect) {
					$('LongTitleInput').focus();
					$('LongTitleInput').select();
				}
			}
		);
//				$('LongTitle').show();
//				$('LongTitleInput').focus();
//				$('LongTitleInput').select();
	};
}

function TestIt() {
	$('TestItAnchor').href=$('ShortUrlInput').value;
}
