function g(elm) { return document.getElementById(elm); }
function handleKey(n,e) {
	var keynum;
	var keychar;
	var numcheck;

	if(window.event) {// IE
		keynum = e.keyCode;
	} else if(e.which) {// Netscape/Firefox/Opera
		keynum = e.which;
	}
	if(keynum==13) {
		g(n).submit();return false;
	}
	return true;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function showContestConfirm(hours,href) { //DOM
	g('comphours').innerHTML = hours;
	g('compstart').href = href;
	g('confirmstart').style.visibility='';
}

function showMoveProblem(id,name) { //DOM
	g('problemname').innerHTML=name;
	g('problemid').value=id;
	g('confirmmove').style.visibility='';
}

function showDeleteProblem(id,name) { //DOM
	g('actionheader').innerHTML="Διαγραφή προβλήματος;";
	g('actiontext').innerHTML="Είστε σίγουροι ότι θέλετε να διαγράψετε το πρόβλημα <b>"+name+"</b>;<br/>(Μπορείτε εναλλακτικά να το μετακινήσετε εκτός διαγωνισμού)";
	g('actionconfirmed').innerHTML="&nbsp;Εντάξει&nbsp;&nbsp;";
	g('actionconfirmed').href = "deleteproblem.php?id="+id;
	g('confirmaction').style.visibility='';
}

function showDeleteCompetition(id,name) { //DOM
	g('actionheader').innerHTML="Διαγραφή διαγωνισμού;";
	g('actiontext').innerHTML="Είστε σίγουροι ότι θέλετε να διαγράψετε το διαγωνισμό <b>"+name+"</b>;<br/>(Μπορείτε εναλλακτικά να τον επεξεργαστείτε)";
	g('actionconfirmed').innerHTML="&nbsp;Εντάξει&nbsp;&nbsp;";
	g('actionconfirmed').href = "deletecompetition.php?id="+id;
	g('confirmaction').style.visibility='';
}

function showChangePoints(id,name,val) { //DOM
	g('actionheader').innerHTML="Αλλαγή βαθμολογίας";
	g('actiontext').innerHTML="Βαθμολογία για το <b>"+name+"ο</b> αρχείο ελέγχου:<br /><br /><input id=\"testpoints\" type=\"text\" value=\"" + val + "\" style=\"width: 50px;\"></input> βαθμοί";
	g('actionconfirmed').innerHTML="&nbsp;Εντάξει&nbsp;&nbsp;";
	g('actionconfirmed').href = "javascript:window.location='testpoints.php?id=" + id + "&points=' + g('testpoints').value;";
	g('confirmaction').style.visibility='';
}

function changeSampleCount() {
	var curcount = g('samplecnt').options[ g('samplecnt').selectedIndex ].value;
	
	if ( curcount >= 2 ) {
		g('sampleio2').style.display = '';
	}
	else {
		g('sampleio2').style.display = 'none';
	}
	
	if ( curcount >= 3 ) {
		g('sampleio3').style.display = '';
	}
	else {
		g('sampleio3').style.display = 'none';
	}
}
 

