//window.setInterval(ProfileCountQuery.query(),10*60*1000);
function ProfileCountQueryStart(){
	ProfileCountQuery.queryAll();
}
var ProfileCountQuery = {
	"queryAll"://query for the count of new message and new friend invitation
		function(){
			$.post("user.profile.countremind.do",{"ajax":"1","counttype":"all"},
				function(res){
					var resarray = res.split(":");
					if(resarray.length==3){//msg:invitefriend:favoriteitem
						var profile = document.getElementById("profileid");
						if(resarray[0]=="0" && resarray[1]=="0"){
							profile.title = "";
							profile.className = "";
						}else{
							profile.title = "";
							if($.trim(resarray[0])!="0"){
								profile.title += resarray[0]+" new Message(s)";
								profile.className = "profilecountremind";
							}
							if($.trim(resarray[1])!="0"){
								profile.title += " "+resarray[1]+" new Friend Invitations(s)";
								profile.className = "profilecountremind";
							}
						}
						var favoriteitem = document.getElementById("shopcar");
						favoriteitem.title = ""+resarray[2]+" items";
					}else{
						//error
					}
				}
			);
		},
	"queryProfileMsgFrInv"://query for the count of new message and new friend invitation
		function(){
			$.post("user.profile.countremind.do",{"ajax":"1","counttype":"msgfrinv"},
				function(res){
					var resarray = res.split(":");
					if(resarray.length==2){//msg:invitefriend:favoriteitem
						var profile = document.getElementById("profileid");
						if(resarray[0]=="0" && resarray[1]=="0"){
							profile.title = "";
							profile.className = "";
						}else{
							profile.title = "";
							if($.trim(resarray[0])!="0"){
								profile.title += resarray[0]+" new Message(s)";
								profile.className = "profilecountremind";
							}
							if($.trim(resarray[1])!="0"){
								profile.title += " "+resarray[1]+" new Friend Invitations(s)";
								profile.className = "profilecountremind";
							}
						}
					}else{
						//error
					}
				}
			);
		},
	"queryFavoriteItem":
		function(favoriteitem){
			if(favoriteitem){
				$.post("user.profile.countremind.do",{"ajax":"1","counttype":"favItem"},
				function(res){
					//var favoriteitem = document.getElementById("shopcar");
					var resarray = res.split(":");
					if(resarray[0]=="1"){
						favoriteitem.title = ""+resarray[1]+" items";
					}else{//error
					
					}
				}
				);
			}
		}
}
