window.addEvent('domready',function(){
	function updateSubscription(expires){
		if(expires==''){//expired
			$$('.mjexpired').setStyle('display', 'inline');
			$$('.mjrenewurl').setStyle('display', 'inline');
		}else{//active
			var mjsubscription=$('mjsubscription');
			if(mjsubscription!=null){
				if(MooTools.version>='1.2')
					mjsubscription.set('html', expires);
				else
					mjsubscription.setHTML(expires);
			}
			$$('.mjactive').setStyle('display', 'inline');
			if(parseInt(expires)<=30)
				$$('.mjrenewurl').setStyle('display', 'inline');
		}
	}

	function checkSubscription(){
		if(typeof Request == "function"){
			new Request.HTML( {
				url: 'http://www.mobilejoomla.com/getsubs.php?app=mjpro&domain=' + document.domain,
				method: 'get',
				onSuccess : function(tree, elements, response){
					updateSubscription(response);
				}
			}).send();
			if($('mjpronotify') != null){
				new Request.HTML( {
					url: 'http://www.mobilejoomla.com/getsubsnotify.php?app=mjpro&domain=' + document.domain,
					method: 'get',
					onSuccess : function(tree, elements, response){
						$('mjpronotify').set('html', response);
					}
				}).send();
			}
		} else if(typeof Ajax == "function"){
			new Ajax( 'http://www.mobilejoomla.com/getsubs.php?app=mjpro&domain=' + document.domain, {
				method: 'get',
				onComplete: function(response){
					updateSubscription(response);
				}
			}).request();
			if($('mjpronotify') != null){
				new Ajax( 'http://www.mobilejoomla.com/getsubsnotify.php?app=mjpro&domain=' + document.domain, {
					method: 'get',
					onComplete: function(response){
						$('mjpronotify').setHTML(response);
					}
				}).request();
			}
		}
	}

	try{
		checkSubscription();
	}catch(e){}
});
