// JavaScript Document
var xmlHttp, xmlHttpFeatPhoto, photo_id, xmlHttpVideoTag, taggedMember=null;
function AddMoreVideosTag(vid){
	document.getElementById("add_more_vidoe_tag_status").innerHTML="Working...";
	var tag;
	tag=document.getElementById("add_more_vidoe_tag").value;
	if (tag.length==0)
  	{ 		
  		document.getElementById("add_more_vidoe_tag_status").innerHTML="";
		alert("Tag can not be empty");
  		return;
  	}
	
	taggedMember = document.getElementById("tagged_member").value;
	
	xmlHttpVideoTag=GetXmlHttpObject();
	if (xmlHttpVideoTag==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="addvideotag.php";
	url=url+"?vid="+vid+"&tag="+tag;
	if(taggedMember!=null)
		url += "&tM="+taggedMember;
	xmlHttpVideoTag.onreadystatechange=stateChangedVideoTag;
	xmlHttpVideoTag.open("GET",url,true);
	xmlHttpVideoTag.send(null);
}
function stateChangedVideoTag() 
{ 
	if (xmlHttpVideoTag.readyState==4)
	{ 
		document.getElementById("add_more_vidoe_tag_status").innerHTML=xmlHttpVideoTag.responseText;
		document.getElementById("add_more_vidoe_tag").value="";
		document.getElementById("tagged_member").value =null;
	}
}
function FillCombo(str)
{
	document.getElementById("posotion_loading").innerHTML="loading...";
	if (str.length==0)
  	{ 		
  		document.getElementById("sport_position").innerHTML="";
  		return;
  	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="getSportPositionComboValue.php";
	url=url+"?sport="+str;	
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("sport_position").innerHTML=xmlHttp.responseText;	
		document.getElementById("posotion_loading").innerHTML="";
	}
}

function MakeTeamPhotosFeatured(teamid,photoid,check,type)
{
	if(type=="" || type==null)
		type="group_images";
	photo_id=photoid
	document.getElementById("makefeatured"+photo_id).innerHTML="working...";
	if (teamid.length==0 || photoid.length==0)
  	{ 		
  		document.getElementById("makefeatured"+photo_id).innerHTML="";
  		return;
  	}
	xmlHttpFeatPhoto=GetXmlHttpObject();
	if (xmlHttpFeatPhoto==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var featured;
	if(check.checked==true)
		featured=1;
	else
		featured=0;
	var url="makeTeamPhotoFeatured.php";
	url=url+"?tid="+teamid+"&photoid="+photoid+"&featured="+featured+"&type="+type;	
	xmlHttpFeatPhoto.onreadystatechange=PhotoStateChanged;
	xmlHttpFeatPhoto.open("GET",url,true);
	xmlHttpFeatPhoto.send(null);
} 

function PhotoStateChanged() 
{ 
	if (xmlHttpFeatPhoto.readyState==4)
	{ 
		document.getElementById("makefeatured"+photo_id).innerHTML=xmlHttpFeatPhoto.responseText;			
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
  	{
  		// Internet Explorer
  		try
    	{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e)
    	{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}