var option=null;
var userProfileDataHandler = {
getProfileData: function(opt,dataString,uri){
			option = opt;
			YAHOO.util.Connect.asyncRequest('POST', uri, userProfileDataHandlerCallback,dataString);
	},
	successHandler: function (obj){
				var root = obj.responseXML.documentElement;
				if(option=="Ads"){
					var profileTop = document.getElementById('profileTop');
					var content = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
                    for(i=0;i<root.getElementsByTagName('catId').length;i++){
                    	catId = root.getElementsByTagName("catId")[i].firstChild.nodeValue;
                    	category= root.getElementsByTagName("category")[i].firstChild.nodeValue;
                    	count = root.getElementsByTagName("count")[i].firstChild.nodeValue;
                   		content+="<tr bgcolor='#FFFFFF'>";
                        content+="<td class='AdOfTheDaySubheading'>";
                        content+="<a href='userProfile/AdsExhibition.php?cid=" + catId + "' class='AdOfTheDaySubheading'>" + category + "</a>" +" ( " + count + " )";
                        content+="</td></tr>";
                    }   			  
                     content+="</table>";
                     profileTop.innerHTML = content;
				}

				if(option=="Workers"){
					var profileTop = document.getElementById('profileTop');
					var content = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
					for(i=0;i<root.getElementsByTagName('catMetaId').length;i++){
                    	catMetaId = root.getElementsByTagName("catMetaId")[i].firstChild.nodeValue;
                    	Key = root.getElementsByTagName("Key")[i].firstChild.nodeValue;
                    	count= root.getElementsByTagName("count")[i].firstChild.nodeValue;
                   		content+="<tr bgcolor='#FFFFFF'>";
                        content+="<td class='AdOfTheDaySubheading'>";
                        content+="<a href='userProfile/workersCategoryProfile.php?key=" + catMetaId + "' class='AdOfTheDaySubheading'>" + Key + "</a>" +" ( " + count + " )";
                        content+="</td></tr>";
                    }   			  
                     content+="</table>";
                     profileTop.innerHTML = content;
				}
	},
	failureHandler: function (obj){
				//alert('Failure');
	}
};

var userProfileDataHandlerCallback = {
			success: userProfileDataHandler.successHandler,
			failure: userProfileDataHandler.failureHandler,
 			scope  : userProfileDataHandler  
};
