function Profile(cntrl)
{
	var profile = {};
	profile = new NET(cntrl);// inherit net class
	
	/* Attributes */
	profile.id 				= null;
	profile.clas			= null;
	profile.level			= null;
	profile.gang_size		= null;
	profile.name			= null;
	profile.race			= null;
	profile.income			= null;
	profile.commentStat 	= null;
	profile.profile_url 	= null;
	profile.misnCmpltd		= null;
	profile.bntyColectd		= null;
	profile.fghtWnCnt		= null;
	profile.fghtLstCnt		= null;
	profile.dthCnt			= null;
	profile.killCnt			= null;
	profile.thumbnail_url	= null;
	
	profile.armors			= new Array();
	profile.weapons			= new Array();
	profile.magic			= new Array();
	profile.loots			= new Array();
	profile.properties		= new Array();
	profile.newsfeeds		= new Array();
	profile.comments		= new Array();
	profile.commentsIndex	= new Array();
	profile.blacklists 		= new Array();
	profile.rank1			= new Array();
	profile.rank2			= new Array();
	profile.rank3			= new Array();
	profile.rank4			= new Array();
	profile.rank5			= new Array();
				
	profile.message			= null;
	profile.isLoaded = false;
	/* EOF Attributes */
	
	/* Function Declaration */
	profile.loadProfile 			= 	loadProfile;
	profile.loadProfileCallback 	= 	loadProfileCallback;
	profile.loadPage 				= 	loadPage;
	
	profile.loadUserStats 			=	loadUserStats;
	profile.loadUserProfile 		=	loadUserProfile;
	profile.loadUserBlackList 		= 	loadUserBlackList;
	profile.loadWeapons				= 	loadWeapons;
	profile.loadArmors				= 	loadArmors;
	profile.loadMagics				= 	loadMagics;
	profile.loadLoots				= 	loadLoots;
	profile.loadProperties			=	loadProperties;
	profile.loadComments			=	loadComments;
	profile.loadNewsfeeds			=	loadNewsfeeds;
	profile.deleteComment			=	deleteComment;
	profile.deleteCommentCallback	=	deleteCommentCallback;
	profile.addComment				=	addComment;
	profile.addCommentCallback		=	addCommentCallback;
	profile.getMessage				=	getMessage;
	profile.addToHitList			=	addToHitList;
	profile.addToHitListCallback	=	addToHitListCallback;
	profile.getHitlistInfo			=	getHitlistInfo;
	
	profile.getBlacklistInfo			=	getBlacklistInfo;
	profile.addToBlacklist				=	addToBlacklist;
	profile.addToBlacklistCallback		=	addToBlacklistCallback;
	profile.getBlockUser				=	getBlockUser;
	profile.getUnBlockUser				=	getUnBlockUser;
	profile.blockUser					=	blockUser;
	profile.unBlockUser					=	unBlockUser;
	profile.blockUserCallback			=	blockUserCallback;
	profile.unBlockUserCallback			=	unBlockUserCallback;
	profile.updateCommentStatus		 	=	updateCommentStatus;
	profile.getCommentStatus			=	getCommentStatus;
	profile.updateCommentStatusCallback =	updateCommentStatusCallback;
	profile.biteUser					=	biteUser;
	profile.biteUserCallback			= 	biteUserCallback;
	profile.refresh						= 	refresh;
	profile.getAttackResult				=	getAttackResult;
	profile.getAttackResultCallback		=	getAttackResultCallback;
	profile.getUnBlackUser              =  	getUnBlackUser;
	profile.removeFromBlist             =   removeFromBlist;
	profile.removeFromBlistCallback     =   removeFromBlistCallback;
	profile.stat						=	stat;
	profile.getFamilyTree				=	getFamilyTree;
	profile.getFamilyTreeCallback		=	getFamilyTreeCallback;
	profile.familyTree					=	familyTree;
	profile.removeGang					= 	removeGang;
	profile.removeGangCallback			=	removeGangCallback;
	// new changes for attack ie profile
	profile.generateResult		= generateResult;
	profile.disBlock = disBlock;
	
	/// end of changes
	
	
	
	/* EOF Function Declaration */
	
	/* Function Definition */
	function loadPage(id)
	{	
		profile.clearMessage();
		if(owner.loadUserId)
		{
			profile.id = owner.loadUserId;
			owner.loadUserId = null;
			id = profile.id;
			
			
		}
		$('#family_tree').hide();
		$('#profile_mid').hide();
			profile.id=id;
		
		if(!profile.id)
			{
				profile.id = owner.id;
				$('#comment_stat').show();
			}
		else
			{
				profile.id = profile.id;
				$('#comment_stat').hide();
			}
		profile.adjustWindowHeight();
		profile.clas=null;
		profile.level=null;
		profile.gang_size=null;
		profile.name=null;
		profile.race=null;
		profile.income=null;
		
		profile.misnCmpltd=null;
		profile.bntyColectd=null;
		profile.fghtWnCnt=null;
		profile.fghtLstCnt=null;
		profile.dthCnt=null;
		profile.killCnt=null;
		profile.thmbUrl			= null;
			
		profile.armors			= new Array();
		profile.weapons			= new Array();
		profile.magics			= new Array();
		profile.loots			= new Array();
		profile.properties		= new Array();
		profile.newsfeeds		= new Array();
		profile.comments		= new Array();
		profile.commentsIndex	= new Array();
		profile.blacklists 		= new Array();
		profile.loadProfile(profile.id);
	
	
	};
		
	function loadProfile(user_id)
	{
		profile.makeRequest();
	};
		
	function loadUserStats(user_id)
	{
		profile.makeRequest();
	};
	function loadProfileCallback(xml)
	{
		$('#profile_mid').show();
		profile.isblock = $('stats', xml).find('block').text();
		profile.commentStat = parseInt($('stats', xml).find('comstat').text());
		profile.isblack = $('stats', xml).find('black_stat').text();
		
		owner.UreadComment=0;
		app.refreshApp();
		
		/* Block link hide if not blocked user */
		if(profile.isblock == 1)
			{
				$('#unblock_id').show();
				$('#block_id').hide();
			}
		/* Block link show if blocked user */
		if(profile.isblock == "")
			{
				$('#unblock_id').hide();
				$('#block_id').show();
			}
		
		/* Black link hide if not blocked user */
		if(profile.isblack == 1)
			{
				$('#unblack_id').show();
				$('#black_id').hide();
			}
		/* Black link show if blocked user */
		if(profile.isblack == "")
			{
				$('#black_id').show();
				$('#unblack_id').hide();
			}
		
		/*############# comment setting #############*/
		
		$('#comment_stat_val').find('option').each(function(){
		if($(this).val() == profile.commentStat)
		$(this).attr('selected', 'selected');
		});
		
		/* Parsing user profile*/
		profile.name = $('userprofile', xml).find('name').text();
		profile.ingang = parseInt($('userprofile', xml).find('inGang').text());
		profile.thumbnail_url = $('userprofile', xml).find('thmbUrl').text();
		profile.profile_url = $('userprofile', xml).find('prflUrl').text();
		profile.level = parseInt($('userprofile', xml).find('level').text());
		profile.gang_size = parseInt($('userprofile', xml).find('gngSz').text());
		profile.race = $('userprofile', xml).find('race').text();
		profile.clas = $('userprofile', xml).find('clas').text();
		profile.income = parseInt($('userprofile', xml).find('income').text());
		/* Parsing stat*/
		profile.mission_completed = $('stats', xml).find('misnCmpltd').text();
		profile.bounty_collected = $('stats', xml).find('bntyColectd').text();
		profile.fight_won = parseInt($('stats', xml).find('fghtWnCnt').text());
		profile.fight_lost = parseInt($('stats', xml).find('fghtLstCnt').text());
		profile.death_count = parseInt($('stats', xml).find('dthCnt').text());
		profile.kill_count = parseInt($('stats', xml).find('killCnt').text());
		
		
		/*############# parsing weapons #############*/
		$('weapon', $(xml).find('weapons')).each(function(){
											var weapon = new Array();
											weapon['im'] = $(this).find('im').text();
											weapon['title'] = $(this).find('title').text();
											weapon['ttal'] = $(this).find('total').text();
											weapon['defense'] = parseInt($(this).find('defense').text());
											weapon['attack'] =parseInt( $(this).find('attack').text());
											weapon['type'] =parseInt( $(this).find('type').text());
											var category = parseInt($(this).find('category').text());
											var type = parseInt($(this).find('type').text());
											
											switch(type)
											{
												case 1:
												case 3:
												case 4:
													switch(category)
													{		
														case 1:
															profile.weapons.push(weapon);
															break;
														case 2:
															profile.armors.push(weapon);
															break;
														case 3:
															profile.magics.push(weapon);
													    	break;														    
													}
												break;
												
												case 2:
													if(profile.id==owner.id)
													{
														switch(category)
														{		
															case 1:
																profile.weapons.push(weapon);
																break;
															case 2:
																profile.armors.push(weapon);
																break;
															case 3:
																profile.magics.push(weapon);
														    	break;														    
														}
													}
												break;
												
												case 6:
													profile.loots.push(weapon);
												break;
											
											}
												
											});
		/*############# parsing Properties #############*/
		$('property', $(xml).find('properties')).each(function(){
												var property = new Array();
												property['image'] = $(this).find('im').text();
												property['title'] = $(this).find('title').text();
												property['total'] = $(this).find('total').text();
												property['id']	  = parseInt($(this).attr('id'));
												profile.properties.push(property);
											});
		/*############# Parsing Comments #############*/
		$('comment', $(xml).find('comments')).each(function(){
												var comment = new Array();
												comment['id'] = $(this).attr('id');
												comment['from_url'] = $(this).find('from_url').text();
												comment['name'] = $(this).find('name').text();
												comment['date'] = $(this).find('date').text();
												comment['message'] = $(this).find('message').text();
												comment['from_id'] = $(this).find('from_id').text();
												profile.comments["'"+comment['id']+"'"] = comment;
												profile.commentsIndex.push(comment['id']);
											});
		/*############# Parsing Blacklist #############*/
		$('blacklist', $(xml).find('blacklists')).each(function(){
												var blacklist = new Array();
												blacklist['id'] = parseInt($(this).attr('id'));
												blacklist['name'] = $(this).find('name').text();
												blacklist['thmbUrl'] = $(this).find('thmbUrl1').text();
												profile.blacklists.push(blacklist);
											});
		/*############# Parsing news feeds #############*/
		$('newsfeed', $('newsfeeds', xml)).each(function(){
												var newsfeed = new Array();
												newsfeed['id'] = parseInt($(this).attr('id'));
												newsfeed['message'] = $(this).find('message').text();
												newsfeed['date'] = $(this).find('date').text();
												profile.newsfeeds.push(newsfeed);
											});
		
		loadUserProfile($(xml).find('data').find('userprofile'));
		loadUserStats($(xml).find('data').find('stats'));
		profile.loadUserBlackList(xml);
		profile.loadWeapons();
		profile.loadArmors();
		profile.loadMagics();
		profile.loadLoots();
		profile.loadProperties();
		profile.loadComments();
		profile.loadNewsfeeds();
		profile.getFamilyTree(profile.id);
		
	};
	
	/*############# USERS PROFILE INFO #############*/
	
	function loadUserProfile()
	{	
			var str="<div>"+
					"<div class=\"new_user_img\"><a href="+uuescape(profile.profile_url)+" target=\"blank\"><img src=\""+uuescape(profile.thumbnail_url)+"\" width=\"75\" height=\"75\" /></a>";
					if(profile.id!=owner.id && profile.ingang!=1)
{
						str+="<div><span><a href='http://friends.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID="+profile.id+"' target='_blank'>Add to Friend</a></span></div>";
					}
					str+="</div>"+
										"<div class=\"profile_user_info\">"+
											"<div><span  class=\"white_bold\">"+uuescape(profile.name)+"</span></div>"+
											"<div>Level <span>"+profile.level+", "+profile.race+"</span></div>"+
											"<div>Class: <span>"+profile.clas+"</span></div>"+
											"<div> Clan size: <span>"+profile.gang_size+"</span></div>";
											if(profile.id!=owner.id && profile.ingang==1)
												{
											str+="<div class=\"txt_highlight\" style=\"float:left;\">"+uuescape(profile.name)+" is in your clan&nbsp;&nbsp;</div>";
											str+="<div class=\"cross\" title=\"Remove Clan\" onClick=\"profile.removeGang("+parseInt(profile.id)+")\" "+config.hoverEffect+" ></div>";
											}
											else
											{
												if(profile.id!=owner.id)
													str+="<div class=\"txt_highlight\">"+uuescape(profile.name)+" is not in your clan</div>";
											}
											
										"</div><div class=\"clear\"></div>"+
									"</div>";
			$('#profile_info').html(str);
	};
	
	function removeGang(id)
	{
		//$.prompt(id+"dfasdf");return;
		profile.makeRequest();
	}
	
	function removeGangCallback(xml)
	{
		var message=$('data',xml).find('message').text(); 
		profile.outputMessage(message,'s');
		profile.loadPage(profile.id);
	}
	
	/*############# USERS STATUS INFO #############*/
	function loadUserStats()
	{	
		var strng="<div class=\"heading_white_medium\"> Stats</div>"+
									 "<div class=\"status_div\">"+
											"<div class=\"float_left\" style=\"margin-right:3em;\">"+
												"<div><span class=\"status_div_red\">Quest Completed:</span><span>"+profile.mission_completed+"</span></div>"+
												"<div><span class=\"status_div_red\">Fight Won:</span> <span>"+profile.fight_won+"</span></div>"+
												"<div><span class=\"status_div_red\">Fight Lost: </span><span>"+profile.fight_lost+"</span></div>"+
											"</div>"+
									  		"<div class=\"float_left\">"+
												"<div><span class=\"status_div_red\">Death: </span><span>"+profile.death_count+"</span></div>"+
												"<div><span class=\"status_div_red\">Kill Count: </span><span>"+profile.kill_count+"</span></div>"+
												"<div><span class=\"status_div_red\">Bounties Collected: </span><span>"+profile.bounty_collected+"</span></div>"+
											"</div>"+
									  "</div>"+
									  "<div class=\"clear\"></div>";
			$('#user_stats').html(strng);
		
	};
	
	/*############# USERS BLACKLIST LISTING #############*/
	
	function loadUserBlackList()
	{	
		var content="";
		$.each(profile.blacklists,function(){
		content +="<div class=\"new_user_box\">"+
									  			"<div class=\"new_user_img\">"+
													pImg(uuescape(this.thmbUrl),this.id,this.name,50,50)+
												"</div>"+
									  		"</div>";
		});
		if(content == "")
		{
			$('#blacklist_hide').hide();return;
		}
		content+="<div class=\"clear\"></div>";
		$('#blacklist_hide').show();
		$('#black_list').html(content);
		
	};
	/*############# USERS WEAPONS LISTING #############*/
	
	function loadWeapons()
	{	
		var content = "";
		var total=0;
		$.each(profile.weapons, function(){
			var stycss="";
			if(this.type==2)
			{
				stycss = "style='border:solid 1px #B6851D;'";
			}
			if(this.type==4)
			{
				stycss = "style='border:solid 1px #0B7170;'";
			}
				content += "<div class=\"item_box\" >"+
								"<img "+stycss+" src='"+config.shopIMGurl+this.im+"' title=\""+this.title+"&nbsp;&nbsp;A:"+this.attack+"/D:"+this.defense+"\" alt=\""+this.title+"\" width=\"75\"/>";
								if(profile.id==owner.id)
								{
								content +="<div>X"+this.ttal+"</div>";
								}
							content+="</div>";
							total=total+parseInt(this.ttal);
		});
		if(profile.id==owner.id)
			{
			$('#weapons_total').html("("+total+")");
			}
		if(content == "")
		{
			$('#weapon_hide').hide(); return;
		}
		content += "<div class=\"clear\"></div>";
		$('#weapon_hide').show();
		$('#profile_weapons').html(content);
	};
	/*############# USERS WEAPONS LISTING END #############*/
	
	/*############# USERS ARMORS LISTING #############*/
	
	function loadArmors()
	{
		var content="";
		var total=0;
		$.each(profile.armors,function(){
			var stycss="";
			if(this.type==2)
			{
				stycss = "style='border:solid 1px #B6851D;'";
			}
			if(this.type==4)
			{
				stycss = "style='border:solid 1px #0B7170;'";
			}
		content += "<div class=\"item_box\">"+
								"<img "+stycss+" src=\""+config.shopIMGurl+this.im+"\" width=\"75\" title=\""+this.title+"&nbsp;&nbsp;A:"+this.attack+"/D:"+this.defense+"\" alt=\""+this.title+"\" />";
								if(profile.id==owner.id)
								{
								content +="<div>X"+this.ttal+"</div>";
								}
							content+="</div>";
							total=total+parseInt(this.ttal);
		
		});
		
		if(profile.id==owner.id)
			{
			$('#armor_total').html("("+total+")");
			}
		if(content == "")
		{
			$('#armor_hide').hide(); return;
		}
		content += "<div class=\"clear\"></div>";
		$('#armor_hide').show();
		$('#profile_armors').html(content);
	
	};
	/*############# USERS ARMORS LISTING END #############*/
	
	/*############# USERS MAGICS LISTING #############*/
	function loadMagics()
	{
	var content="";
	var total=0;
	
	$.each(profile.magics,function(){
		var stycss="";
			if(this.type==2)
			{
				stycss = "style='border:solid 1px #B6851D;'";
			}
			if(this.type==4)
			{
				stycss = "style='border:solid 1px #0B7170;'";
			}
	content +="<div class=\"item_box\">"+
								"<img "+stycss+" src=\""+config.shopIMGurl+this.im+"\" width=\"75\" title=\""+this.title+"&nbsp;&nbsp;A:"+this.attack+"/D:"+this.defense+"\" alt=\""+this.title+"\" />";
								if(profile.id==owner.id)
								{
								content +="<div>X"+this.ttal+"</div>";
								}
							content+="</div>";
							total=total+parseInt(this.ttal);
	});
	if(profile.id==owner.id)
			{
			$('#magics_total').html("("+total+")");
			}
	if(content == "")
		{
			$('#magic_hide').hide(); return;
		}
		content += "<div class=\"clear\"></div>";
		$('#magic_hide').show();
		$('#profile_magics').html(content);
	};
	/*############# USERS MAGICS LISTING END #############*/
	
	/*############# USERS LOOT LISTING #############*/
	function loadLoots()
	{
	var content="";
	
	$.each(profile.loots,function(){
	content +="<div class=\"item_box\">"+
								"<img src=\""+config.shopIMGurl+this.im+"\" width=\"75\" title=\""+this.title+"&nbsp;&nbsp;A:"+this.attack+"/D:"+this.defense+"\" alt=\""+this.title+"\" />";
								if(profile.id==owner.id)
								{
								content +="<div>X"+this.ttal+"</div>";
								}
							content+="</div>";
	});
	if(content == "")
		{
			$('#loot_hide').hide(); return;
		}
		content += "<div class=\"clear\"></div>";
		$('#loot_hide').show();
		$('#profile_loots').html(content);
	};
	/*############# USERS LOOTS LISTING END #############*/
	
	/*############# USER PROPERTIES LISTING PAGE #############*/
	function loadProperties()
	{
	var content="";
	var total=0;
	
	$.each(profile.properties,function(){
	content +="<div class=\"item_box\">"+
								"<img src=\""+config.propertyImgUrl+this.image+"\" width=\"75\" title=\""+this.title+"\" alt=\""+this.title+"\" />";
											 if(profile.id==owner.id)
											 {
											 content += "<div>X"+this.total+"</div>";
											 }
	content += "</div>";
	total=total+parseInt(this.total);
	});
	if(profile.id==owner.id)
	{
	$('#property_total').html("("+total+")");
	}
	if(content == "")
	{
		$('#property_hide').hide();return;
	}
	content += "<div class=\"clear\"></div>";
	$('#property_hide').show();
	$('#profile_properties').html(content);
	};
	/*############# USER PROPERTIES LISTING PAGE END #############*/
	
	/*############# COMMENT LISTING PAGE #############*/
	function loadComments()
	{
		var content="";
		for(i in profile.commentsIndex)
		{
			var id = profile.commentsIndex[i];
			var comment = profile.comments["'"+id+"'"];
			content +="<div id=\"profile_comm"+id+"\" class=\"feed_content\">"+	
						"<div class=\"feed_conten_img\">"+
						pImg(uuescape(comment['from_url']),comment['from_id'],comment['name'],50,50)+
						"</div>"+
							"<div class=\"feed_desc\" style=\"width:470px;\">"+
								"<span class=\"red_feed\" >"+codeHtml(uuescape(comment['message']))+"</span>"+
							"</div>"+
							"<div class=\"float_right\" style=\"width:150px;\"><div class=\"newsfeed_date\"><span class=\"cross\" "+config.hoverEffect+" onClick=\"javascript:profile.deleteComment("+id+")\" title=\"Delete\"></span> <span>"+comment['date']+" ago &nbsp;</span></div>"+
							"</div>"+
							"<div class=\"clear\"></div>"+
					   "</div>";
		}		
		$('#profile_comments').html(content);
		//hover();
	};
	/*############# COMMENT LISTING PAGE END #############*/
	
	/*############# ADD COMMENT #############*/
	
	function getMessage(message)
	{
	var to=profile.id;
	var cash=owner.cash;
	/*check if user has enough cash in hand */
	if(cash<500)
	{
		profile.outputMessage('You need <span class="gold">500 g</span> to post comment.','e');
		return;
	}
	//check if the message box is blank or not
	if(message == "")
	{
		profile.outputMessage('Blank comment message could not be posted.', 'i');
		return;
	}
	profile.addComment(to,message);
	};
	
	function addComment(to,message)
	{
		profile.message = message;
		profile.makeRequest();
	};
	//################# SEND NOTIFICATION ############################
	
	function addCommentCallback(xml)
	{
		var message=$('data',xml).find('message').text(); 
		//var to=$('data',xml).find('toId').text(); 
		//msg=""+owner.name+" posted a comment on your profile";
		profile.outputMessage(message,'s');
		var comment = new Array();
		comment['id'] = $('data',xml).find('id').text();
		comment['from_url'] = owner.thumbnail_url;
		comment['name'] = owner.name;
		comment['date'] = 'a minute ago';
		comment['message'] = profile.message;
		
		profile.comments["'"+comment['id']+"'"] = comment;
		profile.commentsIndex.push(comment['id']);
		//profile.loadComments();
		var content ="<div id=\"profile_comm"+comment['id']+"\" class=\"feed_content\">"+	
						"<div class=\"feed_conten_img\"><img src=\""+uuescape(comment['from_url'])+"\"  /></div>"+
							"<div class=\"feed_desc\" style=\"width:470px;\">"+
								"<span class=\"red_feed\" >"+codeHtml(uuescape(comment['message']))+"</span>"+
							"</div>"+
							"<div class=\"float_right\" style=\"width:150px;\"><div class=\"newsfeed_date\"><span class=\"cross\" "+config.hoverEffect+" onClick=\"javascript:profile.deleteComment("+comment['id']+")\"></span> <span>"+comment['date']+" &nbsp;</span></div>"+
							"</div>"+
							"<div class=\"clear\"></div>"+
					   "</div>";
				
		$('#profile_comments').prepend(content);
		$('#message').val('');
		//hover();
		//notify(to,msg);
	};
	/*############# ADD COMMENT END #############*/
	
	/*############# DELETE COMMENT #############*/
	
	function deleteComment(id)
	{
		profile.makeRequest(false);
	};
	
	function deleteCommentCallback(xml)
	{
		var message=$('data',xml).find('message').text(); 
		//profile.outputMessage(message);
		id = $(xml).find('data').find('id').text();
		profile.comments.splice("'"+id+"'", 1);
		var index = $.inArray(id, profile.commentsIndex);
		profile.commentsIndex.splice(index, 1);
		$('#profile_comm'+parseInt(id)).fadeOut('slow');	
		//profile.loadComments();
	};
	
	/*############# DELETE COMMENT END #############*/
	
	
	
	/*############# NEWS FEED #############*/
			
	function loadNewsfeeds()
	{
	var content="";
	$.each(profile.newsfeeds,function(){
	content +="<div class=\"feed_box\">"+
									"<div class=\"feed_content\">"+
										"<div class=\"feed_desc_long\">"+
											"<div>"+
												"<div class=\"float_left\" style=\"width:auto;\"><img src=\""+config.imageUrl+"/icon-blood.gif\" style=\"vertical-align:text-top;\" /></div>";
												if(profile.id==owner.id){
												content +="<div class=\"newsfeed_info\">"+uuescape(this.message)+"</div>";
												}else
												{
												content +="<div class=\"newsfeed_info\">"+str_replace('You', uuescape(profile.name) ,uuescape(this.message))+"</div>";
													}
												content+="<div class=\"clear\"></div>"+
											"</div>"+
										"</div>"+
										"<div class=\"float_right\"><span class=\"newsfeed_date\" style=\"width:130px; padding-top:0px;\">"+this.date+" ago</span></div>"+
										"<div class=\"clear\"></div>"+
									"</div>"+
									"<div class=\"clear\"></div>"+
								"</div>";
	});
	if(content == "")
	{
		$('#newsfeed_hide').hide();return;
	}
	content += "<div class=\"clear\"></div>";
	$('#newsfeed_hide').show();
	$('#profile_newsfeed').html(content);
	};
	
	/*############# NEWS FEED END ##############*/
	
	
	/* Hitlist  */
	function getHitlistInfo()
	{
		var str="";
		id=profile.id;
		income=profile.income;
		bounty=((income==0)?10000:income*10);
		
		str="<div class=\"content_box\" >" +
				"<div class=\"float_left\" style=\"padding-top:3px;\">" +
					"<span class=\"white_bold\">Enter the Bounty Amount to place "+uuescape(profile.name)+" into the MarkList&nbsp;</span>" +
					"<input id=\"bounty_value\" type=\"text\" value=\""+bounty+"\"/>" +
				"</div>" +
					"<div class=\"btn_setbounty\" "+config.hoverEffect+" onclick=\"javascript:profile.addToHitList("+id+",$('#bounty_value').val())\"><div class=\"button_new\">Set Bounty</div></div>" +
					"<div class=\"clear\"></div>" +
			"</div>";
		
	
		profile.outputMessage(str,"m");
		//hover();
	};
	function addToHitList(id,bounty)
	{
		profile.makeRequest();
	};
	function addToHitListCallback(xml)
	{
		var message = $('data',xml).find('message').text();
		var bty = $('data',xml).find('bty').text();
		var tname = $('data',xml).find('name').text();
		var uid = $('data',xml).find('uid').text();
		
		profile.outputMessage(uuescape(message));
		message1="has placed "+uuescape(tname)+" into the Marked List for bounty worth $"+numberFormat(bounty);
		text1="Click to claim bounty";
		link1=config.appUrl;
		template_data1={"images":[{"src":config.timg['logo'],
						 	"href":link1},
						 	{"src":config.userImgUrl+owner.id,
						 	"href":link1},
						 	{"src":config.userImgUrl+uid,
						 	"href":link1}],
							"message":message1,
							"action_text":text1,
							"link":link1};
		publishStory(config.templateBundleId,template_data1);
		
	};
	
	/*
	Start Add to black list functions list
	*/
	function getBlacklistInfo()
	{
	var id=profile.id;
	if(id == owner.id)
		{
		profile.outputMessage('The Elder Spirit advises against this action. No self-respecting Vampire would take a blacklisted on oneself...	','i');return;
		}
	profile.addToBlacklist(id);
	};
	
	function addToBlacklist(id)
	{
	profile.makeRequest();
	};
	
	function addToBlacklistCallback(xml)
	{
	var message=$('data',xml).find('message').text(); 
	profile.outputMessage(message,'s');
	profile.isblack = $('owner', xml).find('black_stat').text();
	if(profile.isblack == 1)
		{
		$('#unblack_id').show();
		$('#black_id').hide();
		}
	};
	
	
	function getUnBlackUser()
	{
	var id=profile.id;
	profile.removeFromBlist(id);
	};
	function removeFromBlist(id)
	{
	profile.makeRequest();
	};
	
	function removeFromBlistCallback(xml)
	{
	var message=$('data',xml).find('message').text(); 
	profile.outputMessage(message,'s');
	profile.isblack = $('owner', xml).find('black_stat').text();
	
	if(profile.isblack == "")
		{
		$('#unblack_id').hide();
		$('#black_id').show();
		}
	};
	
	/*
	End Add to black list functions list
	*/
	
	/*############# COMMENT STATUS CHANGE #############*/
	function getCommentStatus()
	{
	if(profile.commentStat == '2')
	{
	profile.outputMessage("Admin has set your comment status to silent mode so you cannot change your status.",'i');return;
	}
	var stat_val = $('#comment_stat_val').val();
	profile.updateCommentStatus(stat_val);
	};
	function updateCommentStatus(val)
	{
	profile.makeRequest();
	};
	function updateCommentStatusCallback(xml)
	{
	var message=$('data',xml).find('message').text(); 
	profile.outputMessage(message,'s');
	var cstat=parseInt($('owner',xml).find('commentStat').text());
	//profile.loadProfile();
	};
	
	/*############# COMMENT STATUS CHANGE END #############*/
	
	/*############# BLCOCK AND UNBLOCK #############*/
	
	function getBlockUser()
	{
	var id=profile.id;
	if(id == owner.id)
	{
	profile.outputMessage("The Elder Spirit advises against this action. No self-respecting Vampire would take a blocklisted on oneself...	",'i');return;
	}
	profile.blockUser(id);
	};
	
	function blockUser(id)
	{
	profile.makeRequest();
	};
	
	function getUnBlockUser()
	{
	var id=profile.id;
	profile.unBlockUser(id);
	};
	function unBlockUser(id)
	{
	profile.makeRequest();
	};
	function blockUserCallback(xml)
	{
	var message=$('data',xml).find('message').text(); 
	profile.outputMessage(message,'s');
	profile.isblock = $('owner', xml).find('stat').text();
	if(profile.isblock == 1)
		{
		$('#unblock_id').show();
		$('#block_id').hide();
		}
	};
	function unBlockUserCallback(xml)
	{
	var message=$('data',xml).find('message').text(); 
	profile.outputMessage(message,'s');
	profile.isblock = $('owner', xml).find('stat').text();
	if(profile.isblock == "")
		{
		$('#unblock_id').hide();
		$('#block_id').show();
		}
	};
	
	function biteUser(id)
	{
		profile.makeRequest();
	};
	function biteUserCallback(xml)
	{
		var message=$('data',xml).find('message').text(); 
		profile.outputMessage(message,'s');
	};
	
	function refresh()
	{
		profile.loadPage(profile.id);
	};
	
	function getAttackResult()
	{			
		profile.makeRequest();
	};
	
	function getAttackResultCallback(xml)
	{
		if(!attack)
			attack = new Attack('attack');
			
		var str = attack.generateResult(xml,"profile");
		
		//$('#attack_result_list_new').html(str);
		profile.outputMessage(str,"m");
	};
	
	function getFamilyTree(id)
	{
		profile.makeRequest();
	}
	
	function getFamilyTreeCallback(xml)
	{
		//profile.rank1	= new Array();
		profile.rank2	= new Array();
		profile.rank3	= new Array();
		profile.rank4	= new Array();
		profile.rank5	= new Array();
		$('#family_tree').hide();
		$('member', xml).each(function()
				{	
					var member 		= new Array();	
					member['id']	= parseInt($(this).find('id').text());
					member['pic'] 	= uuescape($(this).find('pic').text());
					member['name'] 	= $(this).find('name').text();
					member['rank']	= parseInt($(this).find('rank').text());
					//$.prompt("memberjjj:"+member['rank']);
					switch(member['rank'])
					{
						case 2:
							profile.rank2.push(member);
							break;
						case 3:
							profile.rank3.push(member);
							break;
						case 4:
							profile.rank4.push(member);
							break;
						case 5:
							profile.rank5.push(member);
							break;
					}
					
				});
			
		var race = profile.race;
		//$.prompt("profile:::"+profile.race);
		//$.prompt("profile "+stringifyRank(profile.race, 1));
		var content ="";
		var content ="<div><strong>"+stringifyRank(race, 1)+"</strong></div>"+
					"<img src=\""+uuescape(profile.thumbnail_url)+"\" />"+
					"<div class=\"invite_form_txt\" >"+uuescape(profile.name)+"</div>"+
					"<div class=\"clear\"></div>";
		$('#rank_1').html(content);
		
		
		for(var rank=2; rank<=5; rank++)
		{
			var content ="";
		
			for(var count = 0; count < rank; count++)
			{
				switch(rank)
				{
					case 1:
						var currRank = profile.rank1[count];
						break;
					case 2:
						var currRank = profile.rank2[count];
						break;
					case 3:
						var currRank = profile.rank3[count];
						break;
					case 4:
						var currRank = profile.rank4[count];
						break;
					case 5:
						var currRank = profile.rank5[count];
						break;
				}
				/*if(rank==5)
				{
					if(!currRank || currRank==null)
					{
						content += 	"<div class=\"caporegime_box\" style=\"margin:10px 15px ; \" >"+
										"<div><strong>"+stringifyRank(race,rank)+"</strong></div>"+
										"<img src=\""+config.imageUrl+"/8.png\" />"+
										"<div class=\"invite_form_txt\" >&nbsp;</div>"+
										"<div class=\"clear\"></div>"+
									"</div>";
						continue;
					}
					var id 		= currRank.id;
					var name 	= currRank.name;
					var uRank 	= currRank.rank;
					var pic 	= currRank.pic;
					content += 	"<div class=\"caporegime_box\" style=\"margin:10px 15px ; \" >"+
									"<div><strong>"+stringifyRank(race,uRank)+"</strong></div>"+
									"<img src=\""+pic+"\" />"+
									"<div class=\"invite_form_txt\" >"+p(name,id)+"</div>"+
									"<div class=\"clear\"></div>"+
								"</div>";
				}
				else
				{*/
					
					if(!currRank || currRank==null)
					{
						content += 	"<div class=\"invite_form_box\" style=\"margin:10px 15px ; \" >"+
										"<div><strong>"+stringifyRank(race,rank)+"</strong></div>"+
										"<img src=\""+config.imageUrl+"/8.png\" />"+
										"<div class=\"invite_form_txt\" >&nbsp;</div>"+
										"<div class=\"clear\"></div>"+
									"</div>";
						continue;
					}
					var id 		= currRank.id;
					var name 	= currRank.name;
					var uRank 	= currRank.rank;
					var pic 	= currRank.pic;
					content += 	"<div class=\"invite_form_box\" style=\"margin:10px 15px ; \" >"+
									"<div><strong>"+stringifyRank(race,uRank)+"</strong></div>"+
									"<img src=\""+pic+"\" />"+
									"<div class=\"invite_form_txt\" >"+p(name,id)+"</div>"+
									"<div class=\"clear\"></div>"+
								"</div>";
				//}
			}
			$('#family_tree').show();
			$('#rank_'+rank).html(content);
		}
	};
	
	function stat()
	{
		$('#stat_main').show();
		$('#family_tree').hide();
	};
	
	function familyTree()
	{
		$('#family_tree').show();
		$('#stat_main').hide();
	};
	
	
	/*############# BLCOCK AND UNBLOCK END #############*/
	/* EOF Function Definition */
	
	return profile;
}

function generateResult(xml,page)
{
	var str 								= "";
		var uname 								= $(xml).find('uname').text();
		var uid									= $(xml).find('uid').text();
		var sustained 							= $(xml).find('sustained').text();
		var inflicted 							= $(xml).find('inflicted').text();
		var urace 								= $(xml).find('urace').text();
		var ulevel 								= $(xml).find('ulevel').text();
		var tname 								= $(xml).find('tname').text();
		var tid									= $(xml).find('tid').text();
		var trace 								= $(xml).find('trace').text();
		var tlevel 								= $(xml).find('tlevel').text();
		var stolen 								= $(xml).find('stolen').text();
		var lost 								= $(xml).find('lost').text();
		var user_weapon1 						= $(xml).find('user_weapon1').text();
		var user_weapon2 						= $(xml).find('user_weapon2').text();
		var user_weapon3 						= $(xml).find('user_weapon3').text();
		var target_weapon1 						= $(xml).find('target_weapon1').text();
		var target_weapon2 						= $(xml).find('target_weapon2').text();
		var target_weapon3 						= $(xml).find('target_weapon3').text();
		var uimage 								= $(xml).find('uimage').text();
		var timage 								= $(xml).find('timage').text();
		var win 								= $(xml).find('win').text();
		var loss 								= $(xml).find('loss').text();
		var congrats 							= $(xml).find('congrats').text();
		var uhealth 							= parseInt($(xml).find('uhealth').text());
		var thealth 							= parseInt($(xml).find('thealth').text());
		var uexperience 						= $(xml).find('uexperience').text();
		var texperience 						= $(xml).find('texperience').text();
		var exp_gained_target 					= $(xml).find('exp_gained_target').text();
		var ucash 								= $(xml).find('ucash').text();
		var tcash 								= $(xml).find('tcash').text();
		var uhealthpec 							= $(xml).find('uhealthpec').text();
		var thealthpec 							= $(xml).find('thealthpec').text();
		var u_user_item 						= $(xml).find('u_user_item').text();
		var u_target_item 						= $(xml).find('u_target_item').text();
		var attackId 							= $(xml).find('attackId').text();
		var level_up_message 					= $(xml).find('level_up_message').text();
		var sklPnt								= $(xml).find('sklPnt').text();
		var favPoint							= parseInt($(xml).find('favPoint').text());
		var total_user_attack_strength			= $(xml).find('total_user_attack_strength').text();
		var total_user_defence_strength			= $(xml).find('total_user_defence_strength').text();
		var total_target_attack_strength		= $(xml).find('total_target_attack_strength').text();
		var total_target_defence_strength		= $(xml).find('total_target_defence_strength').text();
			
		str 			+="<div>"+
								"<p><span class=\"txt_orng\">"+congrats+"</span> You fought with <strong>"+tname+"</strong>  and <span class=\"green_bold\">"+win+"</span><span class=\"red_bold\">"+loss+"</span></p>"+
								"<p class=\"white\">You inflicted <span class=\"red_bold\">"+inflicted+"</span> damage to your enemy and sustained <span class=\"red_bold\">"+sustained+"</span> damage. <br />";
								if(stolen != '')
								{
									str +="You won, <span class=\"gold\">"+stolen+" g</span> and <span class=\"yellow_bold\">"+uexperience+"</span> experience in the battle.";
								}
								else
								{
									str +="You Lost: <span class=\"gold\">"+lost+" g</span> in the battle.";
								}
								str += "</p>";
								if(uhealth<=0)
								{
									str += "<p class=\"red_bold\">You died</p>";
								}
								else if(uhealthpec<20)
								{
									str += "<p class=\"blue_bold\">You went to Healer</p>";
								}
								if(thealth<=0)
								{
									str += "<p class=\"red_bold\">"+tname+" died</p>";
								}
								else if(thealthpec<20)
								{
									str += "<p class=\"blue_bold\">"+tname+" went to Healer</p>";										
								}
								if(level_up_message!="")
								{
									str += "<div class=\"mission_msg\" >"+
									"<div class=\"\"><span class=\"txt_orng\">Congratulations ! </span>You have made it to level "+level_up_message+". Your advancement has Gained you <span class=\"green_bold\"> "+sklPnt+" Skill Points</span> <a href=\"javascript:app.loadPage('skill')\">(Upgrade Skills ?)</a></div></div><div class=\"clear\"></div><br>";
									if(favPoint > 0)
										str += "You also earned <span class=\"coin\" onclick=\"app.loadPage('godfather')\">"+favPoint+" Coin</span>, Pay tribute to Elder ?";
									var message=" is gaining respect in his clan. He just advanced to level "+owner.level;
									var text="Find what happens at level "+owner.level;
									var link=config.appUrl;
									var template_data={"images":[{"src":config.timg['logo'] ,
											 "href":link},
											 {"src":config.userImgUrl+owner.id,
											 "href":link},
											 {"src":getRaceImage(owner.race),
											 "href":link}],
											"message":message,
											"action_text":text,
											"link":link};
									publishStory(config.templateBundleId,template_data);	
								}
								str += "<p><a class=\"red_link\" href=\"javascript:attack.disBlock()\">Show Details</a></p>";
								str += "<div id=\"attack_detail\" style=\"display:none;\">";
								str +="<div class=\"attack_mydetail\"><!--attack_mydetail starts-->"+
											"<div class=\"new_user_img\">"+pImg(uuescape(uimage),uid,uname,75,75)+"</div>"+
											"<div class=\"attack_info\">"+
												"<div class=\"white_bold\">"+uname+"</div>"+
												"<div class=\"user_level\"><span>Level "+ulevel+",</span> <span>"+urace+"</span></div>"+
												"<div class=\"user_level\">Health:</div>"+
											"</div>"+
											"<div class=\"attack_info\">";
											   if(win)
											   {
												str +="<div class=\"green\">+ "+ numberFormat(ucash)+" g</div>"+
												"<div><span class=\"yellow\">+ "+uexperience+" EXP</span></div>";
											   }
											   else
											   {
											   	str +="<div class=\"red\">- "+ numberFormat(ucash)+" g</div>"+
												"<div>&nbsp;</div>";
											   }
									str+="</div>"+
										  "<div class=\"progressbar_div\" >"+
												"<div class=\"progressbar\">"+
													"<div class=\"progressbar_green\" style=\"width:"+uhealthpec+"%;\" id=\"a_progress\">"+
													"</div>"+
													"<div class=\"progressbar_num\">"+uhealthpec+"%</div>"+
												"</div>"+
											"</div>"+
											"<div class=\"clear\"></div><br />"+
										  "<div>"+
												"<div>You attacked with </div>"+
												"<div class=\"weapons_list\">";
												ua_user_item  =$('userAttack', $(xml).find('userAttacks')).length;
												if(ua_user_item>0)
												{
													$('userAttack', $(xml).find('userAttacks')).each(function()
													{
													var qty=$(this).attr('qty');
													var type=parseInt($(this).attr('type'));
														
														if(type==5)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else if(type!=1)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else
														{
													  		str +=" "+qty+" "+$(this).text()+",";
														}
													});
												}
												else
												{
													 str +=" bare hands,";
												}
												str = comaSeparated(str);
											 	str +="</div>"+
												"</div><br>"+
										  "<div>"+
												"<div>You defended with </div>"+
												"<div class=\"weapons_list\">";
											 ud_user_item  =$('userDefence', $(xml).find('userDefences')).length;
											 	if(ud_user_item!=0)
											 	{													 	
												 	$('userDefence', $(xml).find('userDefences')).each(function()
														{
														var qty=$(this).attr('qty');
														var type=parseInt($(this).attr('type'));
														if(type==5)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else if(type!=1)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else
														{
													  		str +=" "+qty+" "+$(this).text()+",";
														}
													});
											 	}
											 	else
											 	{
											 		 str +=" bare hands,";
											 	}
											 	str = comaSeparated(str);
											 	str +="</div>"+
												"</div>"+
										"</div><!--attack_mydetail ends-->"+
										//"<div >"+
										"<div  class=\"attack_mydetail\"><!--attack_mydetail starts-->"+
											"<div class=\"new_user_img\">"+pImg(uuescape(timage),tid,tname,75,75)+"</div>"+
											"<div class=\"attack_info\">"+
												"<div class=\"white_bold\">"+tname+"</div>"+													
												"<div class=\"user_level\"><span>Level "+tlevel+",</span> <span>"+trace+"</span></div>"+
												"<div class=\"user_level\">Health:</div>"+
											"</div>"+
											"<div class=\"attack_info\">";
											   if(loss)
											   {
												str +="<div class=\"green\">+ "+ numberFormat(tcash)+" g</div>"+
												"<div><span class=\"yellow\">+ "+exp_gained_target+" EXP</span></div>";
											   }
											   else
											   {
											   	str +="<div class=\"red\">- "+ numberFormat(tcash)+" g</div>"+
												"<div>&nbsp;</div>";
											   }
									str+= "</div>"+
										  "<div class=\"progressbar_div\" >"+
												"<div class=\"progressbar\">"+
													"<div class=\"progressbar_green\" style=\"width:"+thealthpec+"%;\" id=\"t_progress\">"+
													"</div>"+
													"<div class=\"progressbar_num\">"+thealthpec+"%</div>"+
												"</div>"+
											"</div>"+
											"<div class=\"clear\"></div><br />"+
										  "<div>"+
												"<div>"+tname+" attacked with </div>"+
												"<div class=\"weapons_list\">";
											 	ua_target_item  =$('targetAttack', $(xml).find('targetAttacks')).length;
											 	if(ua_target_item!=0)
											 	{
													 $('targetAttack', $(xml).find('targetAttacks')).each(function()
														{
															var qty=$(this).attr('qty');
															var type=parseInt($(this).attr('type'));
															
															if(type==5)
															{
														  		str +=" "+qty+" "+$(this).text()+"";															
															}
															else if(type!=1)
															{
														  		str +=" "+qty+" "+$(this).text()+",";															
															}
															else
															{
														  		str +=" "+qty+" "+$(this).text()+",";
															}
														});
											 	}
											 else
												{
													 str +=" bare hands";
												}	
											 	str = comaSeparated(str);
											 	str +="</div>"+
												"</div><br>"+
										  "<div>"+
												"<div>"+tname+" defended with </div>"+
												"<div class=\"weapons_list\">";
											 	ud_target_item  =$('targetDefence', $(xml).find('targetDefences')).length;
											 	if(ud_target_item!=0)
											 	{
												 	$('targetDefence', $(xml).find('targetDefences')).each(function()
													{
														var qty=$(this).attr('qty');
														var type=parseInt($(this).attr('type'));
														if(type==5)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else if(type!=1)
														{
													  		str +=" "+qty+" "+$(this).text()+",";															
														}
														else
														{
													  		str +=" "+qty+" "+$(this).text()+",";
														}
													});
											 	}
												else
												{
													 str +="bare hands";
												}
											 	str = comaSeparated(str);
											 	 str +="</div>"+
												"</div>"+
										"</div>	<!--attack_mydetail ends-->"+
										"</div><!--attack_detail ends-->"+
										//"</div>"+
										"<div class=\"clear\"></div>"+
										"<div "+config.hoverEffect+" class=\"btn_attack_again_div\"  ><div  onclick=\""+page+".getAttackResult("+attackId;
										if(page=="attack")
											str +=",attack.currentSubPage";
										str+=")\">Attack Again</div></div>";
										if(win && level_up_message=="")
												{
													profile.publishFeed(stolen,tname,uid,tid);
												}
										str+="<div class=\"clear\"></div>"+
									"</div>";
		return "<div class=\"content_box\">"+str+"</div>";
}

	function disBlock()

	{

		$('#attack_detail_profile').slideToggle('show');

	};
	function comaSeparated(str)
	{
		var st=String(str);
		str=st.substr(0,st.length-1);
		return str;
	};