var method = 1 ; /*Telex*/
var auto 	= 0;
var telex 	= 1;
var vni 	= 2;
var off 	= 3;

$(document).ready(function(){			
	$("#idNotification").click(function() {			
		hideTyping();
		hideNotifyFeed();
		notification();		
	});	
	$("#hiddenNotify").click(function() {			
		hideNotification();
	});	
	$("#idTyping").click(function() {			
		hideNotification();
		hideNotifyFeed();
		typing();		
	});
	setAvimTypeChecked(vnc_getCookie( 'typing' )); 
});

setAvimTypeChecked = function(val){	
	vnc_setCookie( 'typing', val)	
	if(val>0){
		setMethodAvim(val);		
	}else{
		setMethodAvim(-1);		
	}
	if(vnc_getCookie( 'typing' )==-1){
		$('#idOnOffTyping').removeClass('iconTypingOn');
		$('#idOnOffTyping').addClass('iconTypingOff');
	}else{
		$('#idOnOffTyping').removeClass('iconTypingOff');
		$('#idOnOffTyping').addClass('iconTypingOn');			
	}
}

notification = function() {
	$.getJSON (
		HOST_API + 'notification?callback=?',
		function(response) {			
			var msg = response['msg'];	
			if (msg) {
				$('#showNotification').html(msg);
				var animStyle = 'slide';
				$('#showNotification').notificationmsg({animation:animStyle});
				$('#showNotification').show();			
				$('a#idNotification').attr('id', 'hiddenNotify');
			}
		}
	);
}

hideNotification = function() {
	$('#showNotification').notificationmsg('hide');	
}

notifyFeed = function(ptype) {
	return;
	hideNotification();
	hideTyping();
	$.getJSON (
		HOST_API+'notifyfeed?type='+ptype+'&callback=?',
		function(response) {			
			var msg = response['msg'];	
			if (msg) {				
				for (i=1; i<=3; i++) {
					if (i==ptype) {
						$('#idfeed'+i).show();
					} else {
						$('#idfeed'+i).hide();
					}
				}
				$('#showFeedRelation').html(msg);
				var animStyle = 'slide';
				$('#showFeedRelation').notificationmsg({animation:animStyle});
				$('#showFeedRelation').show();				
			}
		}
	);	
}

hideNotifyFeed = function() {
	//$('#showFeedRelation').notificationmsg('hide');	
}

typing = function() {	 
	$.getJSON (
		HOST_API + 'typing?callback=?',
		function(response) {			
			var msg = response['msg'];				
			if (msg) {				
				$('#showTyping').html(msg);
				var animStyle = 'slide';
				$('#showTyping').notificationmsg({animation:animStyle});
				$('#showTyping').show();
			}
		}
	);
}
hideTyping = function() {
	$('#showTyping').val('');
	$('#showTyping').notificationmsg('hide');	
}
