﻿$(document).ready(function(){
	function ajax_realurl(){
	$('#formid').submit(function(){
		var paurl,postdate;
		postdate = $('#shortUrl').val();
		paurl = 'http://leeiio.me/realurl/api/';
		$.ajax({
			url:paurl,
			data:"shortUrl="+postdate,
			dataType:'html',
			type: 'POST',
			beforeSend: function(){
				var loading='<span id="loading">Processing...Please wait</span>';
				document.body.style.cursor = 'wait';
				$('#realUrl').html(loading);
				var C=0.7;
				$('#realUrl').css({opacity:C,MozOpacity:C,KhtmlOpacity:C,filter:'alpha(opacity=' + C * 100 + ')'});
			},
			error: function(request) {
						//alert(request.responseText);
						alert('Error,I\'m sorry.you have to click the refresh button!');
			},
			success:function(data){
				$('#realUrl').html(data);
				var C=1;
				$('#realUrl').css({opacity:C,MozOpacity:C,KhtmlOpacity:C,filter:'alpha(opacity=' + C * 100 + ')'});
				document.body.style.cursor = 'auto';
			}
		});
		//run other js function;
		return false;
		});
	}
ajax_realurl();
//external link
$("a[rel*='external']").click(function(){window.open(this.href);return false});
});