
function getRowCount()
{
	rows = 5;
	
	return rows;
}

function checkLogin()
{
	if($('uname').value.toString().match(/\s/g))
	{
		$('errUser').innerHTML = 'Username can not contain space';
		$('errUser').style.visibility='visible';
		
		if($('pword').value == '')
		{
			$('errPassword').style.visibility='visible';
		}
		else
		{
			$('errPassword').innerHTML = '';
		}
		
		return false;
	}
	else
	{
		$('errUser').innerHTML = '';
	}
	
	if($('uname').value != '' && $('pword').value != '')
	{
		return true;
	}
	else
	{
		if($('uname').value == '')
		{
			$('errUser').innerHTML = 'Please enter your username';
			$('errUser').style.visibility='visible';
		}
		else
		{
			$('errUser').innerHTML = '';
		}
		
		if($('pword').value == '')
		{
			$('errPassword').style.visibility='visible';
		}
		else
		{
			$('errPassword').innerHTML = '';
		}
		

		return false;
	}	
}

function memberDetail(t,uname,p)
{
	//console.log('in tribes')
	// p=1 indicate this is the fantasy game
	var url1 = '../../../community/pickgame/tribeListUserPicks.html';

	new Ajax.Request(url1, {
	  method: 'post',
	  parameters: {t: t},

	  onSuccess: function(transport) {
			//var jsonTXT = transport.responseText;
			var json = transport.responseText.evalJSON();



			//console.log(json.tribeList.length);

			var max = json.members.length;
			var arrID = new Array();
	
			//$('insertMemberInfo').innerHTML = max;

			for(i=0; i<max; i++)
			{
				if(json.members[i].username == uname)
				{
					
					//console.log('colins:'+json.members[i].answerSetList[0].bonusChoiceIdList.length)
			
					if(json.members[i].answerSetList.length > 0)
					{

						//console.log(json.members[i].username)	
						for(j=0; j<json.members[i].answerSetList[0].actorChoiceIdList.length; j++)
						{
							arrID.push(json.members[i].answerSetList[0].actorChoiceIdList[j]);
							
						}
					}
					else
					{
						
						jQuery('#DetailInfo').fadeOut('slow',
												   function() 
												   	{ 
														memberInfo = '<div style="font-weight:bold;">This Group Member has currently not made any picks</div>';
														$('insertMemberInfo').innerHTML = '<h3 style="border-bottom:none;">'+uname+'</h3><p style="height:auto;">'+memberInfo+'</p><div class="clear"></div>';
													}
												);
						//$('DetailInfo').style.display = 'block';
						jQuery('#DetailInfo').fadeIn('slow');						
						
					}
				}
			}

	
//	alert(arrID)
	
			if(arrID.length > 0)
			{
				//match this against the display controller
				memberDetailDisplay(arrID,uname, p);
			}
	  }
	});


	return false;
}

function memberDetailDisplay(arrID,uname,p)
{
	//console.log('in tribes')
	
	var url1 = '../../../community/pickgame/display.html';

	new Ajax.Request(url1, {
	  method: 'post',
	  parameters: {p: p},

	  onSuccess: function(transport) {
			//var jsonTXT = transport.responseText;
			//console.log(jsonTXT)
			//alert(jsonTXT)
			
			var json = transport.responseText.evalJSON();

			//console.log(json.tribeList.length);

			var myTribes = '';
			var myTribesHeader = '';
			var myMore = '';
var memberInfo = '';
			var maxI = json.pickGame.segmentList[0].actorChoiceList.length;

//console.log(max)			
			//$('insertMemberInfo').innerHTML = max;
			var max = arrID.length;
			
			
			
			if (max == 0)
			{
				memberInfo = '<div style="font-weight:bold;">This Group Member has currently not made any picks</div>';
				$('insertMemberInfo').innerHTML = '<h3 style="border-bottom:none;">'+uname+'</h3><p style="height:auto;">'+memberInfo+'</p><div class="clear"></div>';
				$('DetailInfo').style.display = 'block';

				
			}
			else
			{
			
			
			for(k=0; k<max; k++)
			{
			

				curID = arrID.pop();
//console.log(curID)

				
				
//console.log(max2)

				for(i=0; i<maxI; i++) // loop thru all 12 tables
				{
//alert(json.pickGame.segmentList[0].actorChoiceList[i].actor.name);
					var max2 = json.pickGame.segmentList[0].actorChoiceList.length;
//alert("1");
					
//					for(j=0; j<max2; j++) // loop thru each of the 12 table
					{
//alert("2");
						
	//console.log(curID+'---'+json.pickGame.segmentList[0].bonusQuestionList[i].bonusChoiceList[j].id);					
						
						if(curID == json.pickGame.segmentList[0].actorChoiceList[i].id)
						{
//alert("3");
							
							//console.log('match:'+curID)
							
							
							//console.log(json.pickGame.segmentList[0].bonusQuestionList[i].question)
							//console.log(json.pickGame.segmentList[0].bonusQuestionList[i].bonusChoiceList[j].choice)
							
//							memberInfo += '<div style="font-weight:bold;">'+json.pickGame.segmentList[0].bonusQuestionList[i].question+'</div>';
//							memberInfo += '<div style="margin-bottom:5px;">'+json.pickGame.segmentList[0].actorChoiceList[i].actor.name+'</div>';
							memberInfo += '<li style="padding-right: 8px;"><a href="'+json.pickGame.segmentList[0].actorChoiceList[i].actor.defaultBioUrl+'?season=11"></a><div><a href="'+json.pickGame.segmentList[0].actorChoiceList[i].actor.defaultBioUrl+'?season=11"><img src="'+json.pickGame.segmentList[0].actorChoiceList[i].actor.defaultBioPhotoUrl+'"></a><p><a href="'+json.pickGame.segmentList[0].actorChoiceList[i].actor.defaultBioUrl+'?season=11">'+json.pickGame.segmentList[0].actorChoiceList[i].actor.name+'</a></p><p></p></div></li>';
	
						}
					}
				} // end k loop
			}
			
			jQuery('#DetailInfo').fadeOut('slow',function() { $('insertMemberInfo').innerHTML = '<h3 style="border-bottom:none;">'+uname+'</h3><p style="height:auto;"><UL>'+memberInfo+'</UL></p><div class="clear"></div>'; });
			//$('DetailInfo').style.display = 'block';
			jQuery('#DetailInfo').fadeIn('slow');

			} // end else
			
			
			
	  }
	});


}