var all_checked = false;

function check_all(obj) {
	var checks = document.getElementsByName('pics[]');

	if (all_checked) { // uncheck
		for (i = checks.length-1; i>=0; i--) {
			checks[i].checked = false;
		}
		all_checked = false;
		obj.value = "Επιλογή όλων";
	} else { // check
		for (i = checks.length-1; i>=0; i--) {
			checks[i].checked = true;
		}
		all_checked = true;
		obj.value = "Αποεπιλογή όλων";
	}
}

function count_checked() {
	var checks = document.getElementsByName('pics[]');
	var c = 0;
	for (i = checks.length-1; i>=0; i--) {
		if (checks[i].checked) c++;
	}
	if (c == 0) {
		alert("Δεν έχετε επιλέξει καμία εικόνα για αποστολή!");
		return false;
	}
	
	var email = document.getElementById('email');
	if (email.value == 'required') {
		var input = prompt('Σε ποια διεύθυνση e-mail θέλετε να σταλούν οι φωτογραφίες;')
		if (input == '' || input == null) return false;
		email.value = input;
	}
	return true;
}

document.getElementById('box_list').onchange = function () {
	var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
	window.location = url + '?box='+this.value;
}

document.getElementById('archive_list').onchange = function () {
	if (this.value.substring(0, 7) == 'http://') {
		window.location = this.value;
	} else {
		var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
		window.location = url + '?archive='+this.value;
	}
}
