var objRequest=false;

function createXMLHttp()
{
		
	if(window.XMLHttpRequest)
	{
		objRequest=new XMLHttpRequest();
		
		if(objRequest==null)
			objRequest=new ActiveXObject("Microsoft.XMLHTTP");
		if(objRequest==null)
			objRequest=new ActiveXObject("MSXML2.XMLHTTP");
		if(objRequest==null)
			objRequest=new ActiveXObject("MSXML2.XMLHTTP.3.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.4.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.5.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.6.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.7.0")
		//objRequest.overrideMimeType("text/xml");
		
	}
	else if(window.ActiveXObject)
	{

		objRequest=new ActiveXObject("Microsoft.XMLHTTP");
		if(objRequest==null)
			objRequest=new ActiveXObject("MSXML2.XMLHTTP");
		if(objRequest==null)
			objRequest=new ActiveXObject("MSXML2.XMLHTTP.3.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.4.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.5.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.6.0");
		if(objRequest==null)
			objRequest=new ActiveXObject("Msxml2.XMLHTTP.7.0");

	}
	
}

function showPlayers(clubid,tournamentid,typ)
{
	
	
	$.blockUI({ message: '<img src=image/loader.gif></img>',css: { backgroundColor: '#000000', color: '#fff', width: '100', height: '100', border: '0px solid #f00', left: '50%', top: '50%'} });
	if(objRequest)
	{
		objRequest.open("POST","player.php?r="+ new Date().getTime());
		objRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		objRequest.onreadystatechange=function()
		{
		if(objRequest.readyState==4 && objRequest.status==200)
			{
				var doc=objRequest.responseXML;
				var clubNode=doc.documentElement;
				if(clubNode)
				{
					var str="";
					
					
					//for(var i=0;i<clubnameNode.length;i++)
					//{
						var idNode=clubNode.childNodes[0];
						var cid=idNode.childNodes[0].nodeValue;	
								
						var clubnameNode=idNode.nextSibling;
						var clubName=clubnameNode.childNodes[0].nodeValue;
						
						var cpersonNode=clubnameNode.nextSibling;
						var addressNode=cpersonNode.nextSibling;
						var phoneNode=addressNode.nextSibling;
						var mobileNode=phoneNode.nextSibling;												
						var playersNode=mobileNode.nextSibling;	
						var cnt=playersNode.childNodes.length;
						
						str=str+"<div id='pdetail'>"
	
						str=str+"<table align='center' width='99%' border='0' cellspacing='0' cellpadding='5' style='color:#ffffff; border:1px solid #596166; margin-top:10px; margin-bottom:7px'>"
						str=str+"<tr height='25' style='background:url(images/heading_grey.gif);font-weight:bold;color:#d7fe01'>"
						str=str+"<td colspan='3'>&nbsp;&nbsp;"+fromsession+" - "+tosession+" > "+document.getElementById("txttournament").value+" > "+document.getElementById("txtgroup").value+" > "+clubName+"</td></tr>"						
						
						
						str=str+"<tr><td>"						
						str=str+"<table width='100%' border='0' cellspacing='0' cellpadding='7' style='border:1px solid #000000;padding:5px;background:#323232'>"
                      	
						if(cpersonNode.childNodes.length>0)
						{
							var cpersonName=cpersonNode.childNodes[0].nodeValue;
							str=str+"<tr height='35'>"
                        	str=str+"<td width='20%' style='font-weight:bold;color:#45ccff;border-bottom:1px solid #000000'>Contact Person</td>"
							str=str+"<td width='5%' align='center' style='font-weight:bold;border-bottom:1px solid #000000'>:</td>"
                        	str=str+"<td width='75%' style='border-bottom:1px solid #000000'>"+cpersonName+"</td>"
                        	str=str+"</tr>"
						}
						
						if(addressNode.childNodes.length>0)
						{
							var address=addressNode.childNodes[0].nodeValue;
							str=str+"<tr height='35'>"
							str=str+"<td style='font-weight:bold;;color:#45ccff;border-bottom:1px solid #000000'>Address</td>"
							str=str+"<td align='center' style='font-weight:bold;border-bottom:1px solid #000000'>:</td>"
							str=str+"<td style='border-bottom:1px solid #000000'>"+address+"</td>"
							str=str+"</tr>"
						}
						
						if(phoneNode.childNodes.length>0)
						{
							var phone=phoneNode.childNodes[0].nodeValue;
                        	str=str+"<tr height='35'>"
                       	 	str=str+"<td style='font-weight:bold;;color:#45ccff;border-bottom:1px solid #000000'>Phone No.</td>"
							str=str+"<td align='center' style='font-weight:bold;border-bottom:1px solid #000000'>:</td>"
                        	str=str+"<td style='border-bottom:1px solid #000000'>"+phone+"</td>"
                        	str=str+"</tr>"
						}
						
						if(mobileNode.childNodes.length>0)
						{
							var mobile=mobileNode.childNodes[0].nodeValue;
							str=str+"<tr height='35'>"
							str=str+"<td style='font-weight:bold;;color:#45ccff;border-bottom:1px solid #000000'>Mobile No.</td>"
							str=str+"<td align='center' style='font-weight:bold;border-bottom:1px solid #000000'><b>:</b></td>"
							str=str+"<td style='border-bottom:1px solid #000000'>"+mobile+"</td>"
							str=str+"</tr>"
						}
						str=str+"</table></td></tr>"
						if(typ==1)
						{
							str=str+"<div class='back'><span onclick='showplayerstogroups()'>&laquo; Back</span></div>"
						}
						else if(typ==2)
						{
							str=str+"<div class='back'><span style='cursor:pointer' onclick='getteamstat("+clubid+","+tournamentid+",\""+clubName+"\")'>View team Statistics</span>&nbsp;&nbsp;<span onclick='showplayerstogroupswithoutdetail()'>&laquo; Back</span></div>"
						}
						
						if(cnt>0)
						{
							str=str+"<table width='99%' border='0' cellspacing='0' cellpadding='0' align='center' style='text-align: center;margin-bottom:7px;'>"
							var r=0;
							for(var j=0;j<playersNode.childNodes.length;j=j+9)
							{
								//alert(playersNode.childNodes[j].firstChild.nodeValue)
								var playerIdNode=playersNode.childNodes[j];
								var playerId=playerIdNode.childNodes[0].nodeValue;
								var playerNameNode=playerIdNode.nextSibling;
								var playerName=playerNameNode.childNodes[0].nodeValue;
								var ageNode=playerNameNode.nextSibling;
								var categoryNode=ageNode.nextSibling;
								var battingNode=categoryNode.nextSibling;
								var bowlingNode=battingNode.nextSibling;
								var otherNode=bowlingNode.nextSibling;
								var addressNode=otherNode.nextSibling;
								var imageNode=addressNode.nextSibling;
								
								if(r%3==0)
								{
									str=str+"<tr>"
								}
								
								str=str+"<td style='background-color:#000000; padding-top:10px; padding-bottom:7px;'>"
								var strbody="<table width=100% cellspacing=2 cellpadding=0>"
								
								if(categoryNode.childNodes.length>0)
								{
									strbody=strbody+"<tr><td valign=top align=left><b>Category :</b></td> <td valign=top align=left>&nbsp;&nbsp;"+categoryNode.childNodes[0].nodeValue+"</td></tr>";

								}
								
								if(battingNode.childNodes.length>0)
								{
									strbody=strbody+"<tr><td valign=top align=left><b>Bats :</b></td> <td valign=top align=left>&nbsp;&nbsp;"+battingNode.childNodes[0].nodeValue+"</td></tr>";

								}
								
								if(bowlingNode.childNodes.length>0)
								{
									strbody=strbody+"<tr><td valign=top align=left><b>Bowls :</b></td> <td valign=top align=left>&nbsp;&nbsp;"+bowlingNode.childNodes[0].nodeValue+"</td></tr>";

								}
								
								if(otherNode.childNodes.length>0)
								{
									strbody=strbody+"<tr><td valign=top align=left><b>Others : </b></td> <td valign=top align=left>&nbsp;&nbsp;"+otherNode.childNodes[0].nodeValue+"</td></tr>";
								}
								
								if(addressNode.childNodes.length>0)
								{
									strbody=strbody+"<tr><td valign=top align=left><b>Address : </b></td> <td valign=top align=left>&nbsp;&nbsp;"+addressNode.childNodes[0].nodeValue+"</td></tr>";
								}
								
								strbody=strbody+"</table>"
								
								if(imageNode.childNodes.length>0)
								{
									str=str+"<img src='pimage/"+imageNode.childNodes[0].nodeValue+"' style='cursor:pointer; border:1px solid #666666; padding:2px' onClick='getProfile("+playerId+")' title='header=[<span align=left><b>"+playerName+"</b></span>] fade=[on] cssbody=[dvbdy] cssheader=[dvhdr] body=["+strbody+"]'/>"
								}
								else
								{
									str=str+"<img src='pimage/noimage.gif' border='0'  style='cursor:pointer;border:1px solid #666666; padding:2px' onClick='getProfile("+playerId+")' title='header=[<span align=left><b>"+playerName+"</b></span>] fade=[on] cssbody=[dvbdy] cssheader=[dvhdr] body=["+strbody+"]'/>"
								}
								str=str+"<br /><br />"
								str=str+"Name: "+playerNameNode.childNodes[0].nodeValue+"<br />"
								if(ageNode.childNodes.length>0)
								{
									str=str+"Age: "+ageNode.childNodes[0].nodeValue
								}
								str=str+"</td>"
								
								if(r%3==2)
								{
									str=str+"</tr>"
									
								}
								
								r=r+1;
							}
							
							str=str+"</table>"
							str=str+"</td></tr></table>"
						}
						if(typ==1)
						{
							str=str+"<div class='back'><span onclick='showplayerstogroups()'>&laquo; Back</span></div>"
						}
						else if(typ==2)
						{
							str=str+"<div class='back'><span onclick='showplayerstogroupswithoutdetail()'>&laquo; Back</span></div>"
						}
						//str=str+"<div style='text-align:right; margin:0 7px 7px 0; font-weight:bold;' ><span style='cursor:pointer' onclick='showplayerstogroups()'>Back</span></div>"
						
					
					
					
						 var strtitle="";
						 strtitle=strtitle+"&nbsp;<font color='#fff000'><em>&nbsp;Players List&nbsp;</em></font>&nbsp;";
						 
						
					 
						document.getElementById("toparea2").style.display="none";
						document.getElementById("toparea2").innerHTML="";
						
						document.getElementById("toparea1").innerHTML=strtitle;
						document.getElementById("toparea4").innerHTML=str;
						
						$.unblockUI();
						strshowplayerslabel=strtitle;
						strshowplayers=str;
						str=str+"</div>"
						str=str+"</td></tr></table>"
						
				}
			}
		}
		objRequest.send('cid='+clubid+'&tid='+tournamentid);
	}
}


