function reloadWithPlayTime(){
    fadedDiv(true);
    play_time = callGet();
    window.location.href= appURL +"?playtime="+play_time;
}

function mark_as_complete_generic(game_video_id,chk_value)
{
	var alert_msg ="Are you sure you want to mark this game/event incomplete for indexing";
	if ($('mark_complete').checked==true)
	{
		alert_msg = "Are you sure you want to mark this game/event complete for indexing";
	}

	if (confirm(alert_msg))
	{
		var	mark_complete=0;
		if ($('mark_complete').checked==true)
		{
			mark_complete=1;
		}

		new Ajax.Request('/ajax/mark_game_complete_generic', {asynchronous:true, evalScripts:true, parameters:'mark_complete=' + mark_complete+'&game_video_id='+game_video_id});
	}
	else
	{
		if ($('mark_complete').checked==true)
		{
			$('mark_complete').checked=false;
		}
		else
		{
			$('mark_complete').checked=true;
		}
	}

}

function mark_as_complete(game_video_id,chk_value)
{
	var alert_msg ="Are you sure you want to mark this game/event incomplete for indexing";
	if ($('mark_complete').checked==true)
	{
		alert_msg = "Are you sure you want to mark this game/event complete for indexing";
	}

	if (confirm(alert_msg))
	{
		var	mark_complete=0;
		if ($('mark_complete').checked==true)
		{
			mark_complete=1;
		}

		new Ajax.Request('/ajax/mark_game_complete', {asynchronous:true, evalScripts:true, parameters:'mark_complete=' + mark_complete+'&game_video_id='+game_video_id});
	}
	else
	{
		if ($('mark_complete').checked==true)
		{
			$('mark_complete').checked=false;
		}
		else
		{
			$('mark_complete').checked=true;
		}
	}

}


function openPlayerList(divname,game_video_id,school_id,onCompleteJS)
{

  disable_shortcuts=true;
  fadedDiv(1);
  $(divname).style.display="block";
   $(divname).style.left=(((document.body.clientWidth+document.body.scrollLeft))-600-40)+"px";
  $(divname).innerHTML="<img src='/images/loading2.gif' />";
  url="/roster/fetch_players?onCompleteJS="+onCompleteJS+"&divname="+divname+"&game_video_id="+game_video_id+"&school_id="+school_id;
  opt={method:"post",onComplete:function(t){}};
  new Ajax.Updater(divname,url,opt);
}
function togglePlayerEdit(id,cond)
{
  if($("gr_jersey_no_"+id))
  {
    $("gr_jersey_no_"+id).style.display=(cond?"inline":"none");
    $("gr_jersey_no_text_"+id).style.display=(!cond?"inline":"none");
  }
  if ($("gr_position_"+id)) $("gr_position_"+id).style.display=(cond?"inline":"none");
}
function closePanel(divname)
{
  fadedDiv(0);
  $(divname).style.display="none";
}
function refreshRosterList(gvid,is_home,scid)
{
  divname="game_rosters_"+scid;
  $(divname).innerHTML="<img src='/images/loading2.gif' />";
  var opt={ method: 'post',before: function() {},onComplete: function(t){enableHover();}}
  new Ajax.Updater(divname,"/volleyball/get_roster_list?gvid="+gvid+"&is_home="+is_home+"&scid="+scid,opt);
  return false;

}


function unlock_request(name_of_indexer,email_of_indexer)
{

	fadedDiv_index_link(true);

	divele=document.createElement("div");
	divele.id="unlock_div";
	$(divele).className="pop_up_div";
	divele.style.background="#0262C4";
	divele.style.color="#fff";
	divele.style.width="400px";
	divele.style.position="absolute";
	divele.style.top=(document.body.clientHeight/2-200)+"px";
	divele.style.left=(document.body.clientWidth/2-10)+"px";
	window.scrollTo(0,0);

	divele.innerHTML="<font class='pop_up_loading'>Loading...</font>";
	document.body.appendChild(divele);
	var opt = { method: 'post',
				before: function(){ },
				onComplete: function(t) {divele.innerHTML=t.responseText;}
			    }
	new Ajax.Request('/ajax/unlock_request?name_of_indexer='+name_of_indexer+'&email_of_indexer='+email_of_indexer,opt);


}


function fadedDiv_index_link(cond)
{
	 if(cond)
	 {
		 divele=document.createElement("div");
		 divele.style.position="absolute";
		 divele.id="faded_div";
		 divele.style.top="0px";
		 divele.style.left="0px";
		 divele.style.height=document.body.scrollHeight+"px";
		 divele.style.width=document.body.scrollWidth+"px";
		 divele.style.backgroundColor="#95C0F1";
		 if(navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion)>=5)
		 divele.style.MozOpacity = 0.6;
		 else if (navigator.appName.indexOf("Microsoft")!= -1 && parseInt(navigator.appVersion)>=4)
		 divele.style.filter="alpha(opacity=60)";
		 document.body.appendChild(divele);
	 }
	 else
	 {
		document.body.removeChild(document.getElementById('faded_div'));
	 }
}

function close_fadedDiv_index_link()
{

	document.body.removeChild(document.getElementById('unlock_div'));
	fadedDiv_index_link(false);
}


function enable_shortcuts()
{
	if (typeof(disable_shortcuts)!='undefined')
	{
		disable_shortcuts=false;
	}
}

function toggle_player_for_editing(plid,cond)
{

	$('gr_jersey_no_text_'+plid).style.display=(cond?'none':'inline');
	$('gr_last_name_text_'+plid).style.display=(cond?'none':'inline');
	$('gr_first_name_text_'+plid).style.display=(cond?'none':'inline');
	$('edit_link_'+plid).style.display=(cond?'none':'inline');

	$('delete_link_'+plid).style.display=(cond?'none':'inline');

	$('gr_jersey_no_'+plid).style.display=(cond?'inline':'none');
	$('gr_last_name_'+plid).style.display=(cond?'inline':'none');
	$('gr_first_name_'+plid).style.display=(cond?'inline':'none');
	$('cancel_link_'+plid).style.display=(cond?'inline':'none');
	$('save_link_'+plid).style.display=(cond?'inline':'none');

	$('gr_save_'+plid).value=(cond?plid:"");
    if(!cond)
	{
		$('gr_jersey_no_'+plid).value= $('gr_jersey_no_text_'+plid).innerHTML;
		$('gr_last_name_'+plid).value= $('gr_last_name_text_'+plid).innerHTML;
		$('gr_first_name_'+plid).value= $('gr_first_name_text_'+plid).innerHTML;
	}
}


function delete_player(school_player_id,sport_id)
{

	if (confirm("Are you sure you want to delete this player?"))
	{

	var opt = { method: 'post',
				before: function(){},
				onComplete: function() {}
			    }

	new Ajax.Request('/roster/delete_school_player?school_player_id='+school_player_id+'&aoi_type=sport&aoi_id='+sport_id,opt);
	}
}

function delete_row_element(school_player_id)
{
	$('roster_row_id_'+school_player_id).remove();
}

function player_in_out(game_roster_id,ele)
{


	if (ele.checked==true)
	{
		player_in='y'
	}
	else
	{
		player_in='n'
	}

	var opt = {method: 'post',before: function(){},onComplete: function(t){}}
	new	Ajax.Request('/roster/player_in?player_in='+player_in+'&game_roster_id='+game_roster_id,opt)


}

function eval_on_complete_js()
{
	if(($('onCompleteJS').value)!='')
	{
		eval($('onCompleteJS').value);
	}
}

function game_roster_add_remove(divname,player_id,game_school_id,school_player_id,sport_id,ele,player_in)
{
	//alert(school_player_id + "---"+sport_id);
  
		jersey_no= $('gr_jersey_no_'+player_id).value;

	//alert(jersey_no);
	if(ele.checked==true)
	{
		add_roster='y';
  $('delete_link_'+player_id).setStyle({display:'none'});
	}
	else
	{
		add_roster='n';
	}
	//return false;
	$('close_small_div').setStyle({display: 'none'})
	$('msg_id').setStyle({display: 'block'})
	
	var opt = { method: 'post',
				before: function(){},
				onComplete: function(t) {$('delete_link_'+player_id).setStyle({display:(ele.checked?'none':'inline')});$('close_small_div').setStyle({display: 'block'}); $('msg_id').setStyle({display: 'none'})}
			    }
	new Ajax.Request('/roster/game_roster_add_remove?player_in='+player_in+'&school_player_id='+school_player_id+'&sport_id='+sport_id+'&add_roster='+add_roster+'&jersey_no='+jersey_no+'&game_school_id='+game_school_id+'&game_video_id='+$('game_video_id').value+'&gs_id='+$('gs_id').value+'&divname='+$('divname').value+'&onCompleteJS='+$('onCompleteJS').value,opt);
 //$(divname).innerHTML="<img src='/images/loading2.gif' />";
}



function submit_roster_form(gv_id,school_id)
{
	ele ="showlistDiv_"+school_id;
	//alert(ele);


	new Ajax.Request('/roster/mng_roster', {asynchronous:true, evalScripts:true, onComplete:function(request){}, parameters:Form.serialize($('addrosterform_'+gv_id))});
	$(ele).innerHTML="<img src='/images/loading2.gif' />";
	return false;
}





function enableHover(){
    img_elements = $('tblRosterListH').getElementsBySelector('img')
    //alert(img_elements.length);

    for(i=0;i<img_elements.length;i++){
        img_elements[i].className = "indexing_button_dark";
        Event.observe(img_elements[i],"mouseover",onScoreButtonMouseHover);
        Event.observe(img_elements[i],"mouseout",onScoreButtonMouseOut);
    }

    img_elements = $('tblRosterListV').getElementsBySelector('img')

    for(i=0;i<img_elements.length;i++){
        img_elements[i].className = "indexing_button_dark";
        Event.observe(img_elements[i],"mouseover",onScoreButtonMouseHover);
        Event.observe(img_elements[i],"mouseout",onScoreButtonMouseOut);
    }

}

function onScoreButtonMouseHover(evt){
    //alert(Event.element(evt));
    //Event.element(evt).style.borderColor='#eee #888 #888 #eee';
    //Effect.Highlight(Event.element(evt));
    //makevisible(Event.element(evt),0);
    ele = Event.element(evt);
    ele_id_parts = ele.id.split("_");
    //Effect.Highlight($("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]));
    $("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]).style.backgroundColor = "#F89F1D";
    $("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]).previous("td").style.backgroundColor = "#F89F1D";
    ele.className = "indexing_button_dim";

}

function onScoreButtonMouseOut(evt){
    //alert(Event.element(evt).style.borderColor);
    //Effect.Highlight(Event.element(evt));
    //makevisible(Event.element(evt),1);

    ele = Event.element(evt);
    ele_id_parts = ele.id.split("_");
    $("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]).style.backgroundColor = $("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]).previous("td").style.backgroundColor =  $("tdPlayerName_"+ele_id_parts[ele_id_parts.length-1]).next("td").style.backgroundColor;
     ele.className = "indexing_button_dark";
}


function makevisible(cur,which){
    strength=(which==0)? 1 : 0.5;

    if (cur.style.MozOpacity){
        cur.style.MozOpacity=strength;
    }else if (cur.filters){
        cur.filters.alpha.opacity=strength*100
     }

}
