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: '#292929', 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="<br/><br/>";
					
					
					//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='header' style='background-color:#000000; height:30px;width:528px;margin: 20px 0px 0px 12px;padding-bottom:5px;'>";
						//str=str+"<div class='caption1'>"+document.getElementById("txttournament").value+" > "+document.getElementById("txtgroup").value+" > "+clubName+"</div>";
						//str=str+"</div><br/>";
						str=str+"<div id='pdetail'>"
						str=str+"<table width='600' border='0' cellspacing='0' cellpadding='0' align='center' style='text-align: left; margin-top:5px; margin-bottom:3px;'>"
                      	
						if(cpersonNode.childNodes.length>0)
						{
							var cpersonName=cpersonNode.childNodes[0].nodeValue;
							str=str+"<tr height='30'>"
                        	str=str+"<td width='150' style='font-weight:bold;'>Contact Person&nbsp;&nbsp;:&nbsp;</td>"
                        	str=str+"<td width='450'>"+cpersonName+"</td>"
                        	str=str+"</tr>"
						}
						
						if(addressNode.childNodes.length>0)
						{
							var address=addressNode.childNodes[0].nodeValue;
							str=str+"<tr height='30'>"
							str=str+"<td width='150' style='font-weight:bold;' valign='top'>Address&nbsp;&nbsp;:&nbsp;</td>"
							str=str+"<td width='450' valign='top'>"+address+"</td>"
							str=str+"</tr>"
						}
						
						if(phoneNode.childNodes.length>0)
						{
							var phone=phoneNode.childNodes[0].nodeValue;
                        	str=str+"<tr height='30'>"
                       	 	str=str+"<td width='150' style='font-weight:bold;'>Phone No.&nbsp;:&nbsp;</td>"
                        	str=str+"<td width='450'>"+phone+"</td>"
                        	str=str+"</tr>"
						}
						
						if(mobileNode.childNodes.length>0)
						{
							var mobile=mobileNode.childNodes[0].nodeValue;
							str=str+"<tr height='30'>"
							str=str+"<td width='150' style='font-weight:bold;'>Mobile No.&nbsp;:&nbsp;</td>"
							str=str+"<td width='450'>"+mobile+"</td>"
							str=str+"</tr>"
						}
						str=str+"</table>"
						if(typ==1)
						{
							str=str+"<div style='text-align:right; margin:0 7px 7px 0; font-weight:bold;' ><span style='cursor:pointer' onclick='showplayerstogroups()'>Back</span></div>"
						}
						else if(typ==2)
						{
							str=str+"<div style='text-align:right; margin:0 7px 7px 0; font-weight:bold;' ><span style='cursor:pointer' onclick='getteamstat("+clubid+","+tournamentid+",\""+clubName+"\")'>View team Statistics</span>&nbsp;&nbsp;<span style='cursor:pointer' onclick='showplayerstogroupswithoutdetail()'>Back</span></div>"
						}
						
						if(cnt>0)
						{
							str=str+"<table width='600' 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 classNode=ageNode.nextSibling;
								var sectionNode=classNode.nextSibling;
								var bowlingNode=sectionNode.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;'>"
								

								if(imageNode.childNodes.length>0)
								{
									str=str+"<img src='pimage/"+imageNode.childNodes[0].nodeValue+"' style='cursor:pointer' onClick='getProfile("+playerId+")' />"
								}
								else
								{
									str=str+"<img src='pimage/noimage.gif' border='0'  style='cursor:pointer' onClick='getProfile("+playerId+")' />"
								}
								str=str+"<br /><br />"
								str=str+"Name: "+playerNameNode.childNodes[0].nodeValue+"<br />"
								if(classNode.childNodes.length>0)
								{
									str=str+"Class: "+classNode.childNodes[0].nodeValue + "<br />"
								}
								if(sectionNode.childNodes.length>0)
								{
									str=str+"Section: "+sectionNode.childNodes[0].nodeValue 
								}
								str=str+"</td><td width='10'></td>"
								
								if(r%3==2)
								{
									str=str+"</tr>"
									str=str+"<tr height='10'></tr>"
								}
								
								r=r+1;
							}
							
							str=str+"</table>"
						}
						if(typ==1)
						{
							str=str+"<div style='text-align:right; margin:0 7px 7px 0; font-weight:bold;' ><span style='cursor:pointer' onclick='showplayerstogroups()'>Back</span></div>"
						}
						else if(typ==2)
						{
							str=str+"<div style='text-align:right; margin:0 7px 7px 0; font-weight:bold;' ><span style='cursor:pointer' onclick='showplayerstogroupswithoutdetail()'>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>"
						str=str+"</div>"
						
						 var strtitle="";
						 strtitle=strtitle+"<table width='600' border='0' cellspacing='0' cellpadding='0' style='margin-top:30px; text-align:left;'>";
						 strtitle=strtitle+"<tr height='14'>";
						 strtitle=strtitle+"<td width='15' bgcolor='#69c6c7'>&nbsp;</td>";
						 strtitle=strtitle+"<td width='125' align='center'><strong>Players List</strong></td>";
						 strtitle=strtitle+"<td width='460' background='image/line.jpg'>&nbsp;</td>";
						 strtitle=strtitle+"</tr></table>";
					 
						//document.getElementById("topindex").style.display="none";
						document.getElementById("toparea2").innerHTML="";
						document.getElementById("toparea3").innerHTML="";
						document.getElementById("toparea1").innerHTML=strtitle;
						document.getElementById("toparea3").innerHTML=str;
						
						$.unblockUI();
						strshowplayerslabel=strtitle;
						strshowplayers=str;
						
				}
			}
		}
		objRequest.send('cid='+clubid+'&tid='+tournamentid);
	}
}


