function deletePlayer(player_ID, playerName){
	if (confirm ("Θέλετε σίγουρα να διαγράψετε τον παικτη "+ playerName + ";") ) {
		location.href=('deletePlayer.php?player_ID='+ player_ID)
	}
		else close();
}
function deleteCoach(coach_ID, coachName){
	if (confirm ("Θέλετε σίγουρα να διαγράψετε τον προπονητή "+ coachName + ";") ) {
		location.href=('deleteCoach.php?coach_ID='+ coach_ID)
	}
		else close();
}
function deleteAEKSub(substAEK_ID, player_In, player_Out, period, details_ID){
	if (confirm ("Θέλετε σίγουρα να διαγράψετε την αλλαγή " + player_In + "->" + player_Out + ";")) {
		location.href=('deleteAEKSub.php?substAEK_ID='+ substAEK_ID + "&period=" + period + "&details_ID=" + details_ID)
	}
		else close();
}
function deleteOppSub(substOpp_ID, player_In, player_Out, period, details_ID){
	if (confirm ("Θέλετε σίγουρα να διαγράψετε την αλλαγή " + player_In + "->" + player_Out + ";") ) {
		location.href=('deleteOppSub.php?substOpp_ID='+ substOpp_ID + "&period=" + period + "&details_ID=" + details_ID)
	}
		else close();
}
function deletePost(post_ID, playerName, min, period, details_ID){
	if (confirm ("Θέλετε σίγουρα να διαγράψετε το δοκάρι του ποδοσφαιριστή :" + playerName + ' στο ' + min + ' λεπτό;') ) {
		location.href=('deletePost.php?post_ID='+ post_ID + '&period=' + period + '&details_ID=' + details_ID)
	}
		else close();
}
function confEditPlayer(player_ID, action){
	if (action == "delete") {
		alert("Η διαγραφή του παίκτη έγινε")
		location.href=('editPlayerForm.php')
	}
	else if (action == "edit") {
		alert("Η μετατροπή του παίκτη έγινε")
		location.href=('editPlayerForm.php')
	}
}
function confEditCoach(coach_ID, action){
	if (action == "delete") {
		alert("Η διαγραφή του προπονητή έγινε")
		location.href=('editCoachForm.php')
	}
	else if (action == "edit") {
		alert("Η μετατροπή του προπονητή έγινε")
		location.href=('editCoachForm.php')
	}
}
function autoAEKChange(check,div){
	var check       = check.id
	var autoAEKDiv	= 'autoAEKdiv'+div
	var AEKDiv			= 'AEKdiv'+div
	if (document.getElementById(check).checked){
		document.getElementById(AEKDiv).style.visibility 		 = 'hidden'
		document.getElementById(autoAEKDiv).style.visibility = 'visible'
	}
	else {
		document.getElementById(AEKDiv).style.visibility = 'visible'
		document.getElementById(autoAEKDiv).style.visibility = 'hidden'
	}
}
function autoOppChange(check,div){
  var check       = check.id
	var autoOppDiv	= 'autoOppDiv'+div
	var oppDiv			= 'oppDiv'+div
	if (document.getElementById(check).checked){
		document.getElementById(oppDiv).style.visibility 		 = 'hidden'
		document.getElementById(autoOppDiv).style.visibility = 'visible'
	}
	else {
		document.getElementById(oppDiv).style.visibility = 'visible'
		document.getElementById(autoOppDiv).style.visibility = 'hidden'
	}
}
function changeLeague(el) {
	if (el.value == 1 ) {
		document.getElementById("prot").style.visibility = "visible"
		document.getElementById("kyp").style.visibility = "hidden"
		document.getElementById("roundCup").value	= "";
		}
	else {
		document.getElementById("prot").style.visibility = "hidden"
		document.getElementById("kyp").style.visibility = "visible"
		document.getElementById("agon").value	= "";
		document.getElementById("roundLeague").value	= "";
	}
}
function changeLeague2(el) {
	if (el.value == 1 ) {
		document.getElementById("prot").style.visibility = "visible"
		document.getElementById("kyp").style.visibility = "hidden"
		document.getElementById("roundCup").value	= "";
		}
	else {
		document.getElementById("prot").style.visibility = "hidden"
		document.getElementById("kyp").style.visibility = "visible"
		document.getElementById("agon").value	= "";
		document.getElementById("roundLeague").value	= "";
	}
}
function deleteMatch(matchName,details_ID, period){
	if (confirm ("Σίγουρα θέλετε να διαγράψετε τον αγώνα " + matchName + ";")){
		location.href = "deleteMatch.php?period=" + period + "&details_ID=" + details_ID
	}
}
function showStats(player_ID,league, stats, period){
	var win
	var left
	var top
	left = (screen.width - 600)/2
	top = (screen.height - 600)/2 - 20
	var url = "showStats.php?player_ID="+player_ID+"&league="+league+"&stats="+stats+"&period="+period
	win	=	window.open	(url,"","width=600,height=600,scrollbars=1,left="+left+",top=" + top)	
}
function chooseWhatToEdit(){
	var period
	var what
	period = document.getElementById("editMatch").period.value
	what	 = document.getElementById("editMatch").what.value
	if (what != "" && what != " ") {
		location.href = "editMatchForm.php?period="+period+"&what="+what
	}
}
function selectCardTeam(){
	if (document.getElementById("oppCardDiv").style.visibility == 'visible'){
			document.getElementById("oppCardDiv").style.visibility = 'hidden'
			document.getElementById("AEKCardDiv").style.visibility = 'visible'
			document.getElementById("oppCardDiv").style.position = 'absolute'
			document.getElementById("AEKCardDiv").style.position = 'relative'
	}
	else {
		document.getElementById("oppCardDiv").style.visibility = 'visible'
		document.getElementById("AEKCardDiv").style.visibility = 'hidden'
		document.getElementById("oppCardDiv").style.position = 'relative'
		document.getElementById("AEKCardDiv").style.position = 'absolute'
	}
}
function changeLeagueVis(el,max){
	cElement = 'temp'+el
	cHead = 'head' + el
	if (document.getElementById(cElement).style.visibility == 'visible'){
		//document.getElementById(element).style.visibility = 'hidden'
		//document.getElementById(element).style.position		=	'absolute'
	}
	else {
		hideAll(max)
		document.getElementById(cElement).style.visibility = 'visible'
		document.getElementById(cElement).style.position		=	'relative'	
		document.getElementById(cHead).className = 'yellow'		
	}
}
function hideAll(max){
	for (i=1;i<=max;i++){
		element = 'temp'+i
		head = 'head' + i
		if (document.getElementById(element)){
			document.getElementById(element).style.visibility = 'hidden'
			document.getElementById(element).style.position		=	'absolute'
			document.getElementById(head).className = ''
		}	
	}
}
function defineClass(cHead){
	element = 'temp'+cHead
	head = 'head' + cHead
	if (document.getElementById(element).style.visibility == 'visible') {
				document.getElementById(head).className = 'yellow'
			}
			else document.getElementById(head).className = ''
}
function showRosterLayer(div){
	var menuArr = new Array('league','cup','europe','total')
	document.getElementById(div).style.visibility = "visible"
	document.getElementById(div).style.position = "relative"
	document.getElementById(div+"Head").className = "yellow"
	for (var i in menuArr) {
		if (menuArr[i] != div) {
			document.getElementById(menuArr[i]).style.visibility = "hidden"
			document.getElementById(menuArr[i]).style.position = "absolute"
			document.getElementById(menuArr[i]+"Head").className = ""
			}
	}
	//document.getElementById(div).className = "yellow"
}
function defineRClass(el1,el2){
	if (document.getElementById(el2).style.visibility == "visible") {
		el1.className = 'yellow'
	}
	else {
		el1.className = ''
	}
}
function checkOppStats(country){
	if (country == 0){
		var sel = document.getElementById("opponentGr")
		var selVal = sel.options[sel.selectedIndex].value
	}
	else if (country == 1){
		var sel = document.getElementById("opponent")
		var selVal = sel.options[sel.selectedIndex].value
	}
	else if (country == 2){
		var sel = document.getElementById("opponentCount")
		var selValCount = sel.options[sel.selectedIndex].value
	}
	var selVal = sel.options[sel.selectedIndex].value
	if ((selVal == "") || (selVal == "-")){
		alert("Δεν διαλέξατε ομάδα")
	}
	else {
		if (country != 2){
			document.forms[0].action="statsAgainstTeam.php"
			document.forms[0].opponentTeam.value = selVal;
			document.forms[0].submit(); 
		}
		else {
			document.forms[0].action="statsAgainstCountry.php"
			document.forms[0].opponentCountry.value = selValCount;
			document.forms[0].submit(); 
		}
	}
}
	function defineSClass(el1,el2){
	if (document.getElementById(el2).style.visibility == "visible") {
		el1.className = 'yellow'
	}
	else {
		el1.className = ''
	}
}
	function showTab(id,numToHide){
		for(i=1;i<=numToHide;i++){
			var tabContentToHide	= "tabContent_" + i
			var tabToHide					=	"tab_" + i
			if 	(tabToHide != tab_id) {
				hideDiv(tabContentToHide,tabToHide)
			}
		}
		var tab_id = "tab_" + id
		var tabContent_id = "tabContent_" + id
		if (document.getElementById(tabContent_id)){
			elTabContent = document.getElementById(tabContent_id)
			elTab				 = document.getElementById(tab_id)
			elTabContent.style.visibility = "visible"
			elTabContent.style.position = "relative"
			elTabContent.className = "activeTabContent"
			elTab.className = "activeTab"
		}
	}
function hideDiv(tabContentToHide,tabToHide){
	elTabContent = document.getElementById(tabContentToHide)
	elTab				 = document.getElementById(tabToHide)
	if (document.getElementById(tabContentToHide)){
		elTabContent.style.position= "absolute"
		elTabContent.style.visibility = "hidden"
		//elTabContent.className = "inactiveTabContent"
		elTab.className = "inactiveTab"
	}
}
function changeNationality(player_ID){
	var textBox  = "nat["+player_ID+"]"
	if (document.getElementById(textBox).value == "Ελλάδα") {
		document.getElementById(textBox).value = ""
	}
	else {
		document.getElementById(textBox).value = "Ελλάδα"
	}
}
function updatePreview(){
	var src = document.getElementById("photo").value
	document.getElementById("pr").src = src
}
function refStats(el){
	var referee = el.value
	if (referee != 0) {
		document.forms[0].action = "stats_ref.php"
		document.getElementById("hidRef").value = referee
		document.forms[0].submit()
	}
	else {
	}
}

/**
 * changePage
 */
function changePage(url,variable,el) {
    var page = parseInt(el.value)+1;
    document.location.href = url + "?"+variable+"="+page;
}