function newExercisesCategory(uid,uid_id){
	newExerciseCategoryTXT = window.prompt("New exercise category:");
	if (newExerciseCategoryTXT!='' && newExerciseCategoryTXT!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&newExerciseCategory='+encodeURIComponent(newExerciseCategoryTXT)+'&'+uid+'='+uid_id;
	}
}
function editExercisesCategory(cat_name,cat_id,uid,uid_id){
	newExerciseCategoryTXT = window.prompt("New exercise category name:",cat_name);
	if (newExerciseCategoryTXT!=cat_name && newExerciseCategoryTXT!='' && newExerciseCategoryTXT!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&cat_name='+encodeURIComponent(newExerciseCategoryTXT)+'&cat_id='+cat_id+'&'+uid+'='+uid_id;
	}
}
function deleteExercisesCategory(cat_name,cat_id,uid,uid_id){
	var response=confirm('Do you really want to delete this category: '+cat_name);
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&delete_cat='+cat_id+'&'+uid+'='+uid_id;
	}
}


function editMainCategory(main_cat_name,main_cat_id,uid,uid_id){
	mainCategoryTXT = window.prompt("New main category name:",main_cat_name);
	if (mainCategoryTXT!=main_cat_name && mainCategoryTXT!='' && mainCategoryTXT!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&main_level_name='+encodeURIComponent(mainCategoryTXT)+'&main_level_id='+main_cat_id+'&'+uid+'='+uid_id;
	}
}


function editLevel(level_name,level_id,uid,uid_id){
	levelCategoryTXT = window.prompt("New level name:",level_name);
	if (levelCategoryTXT!=level_name && levelCategoryTXT!='' && levelCategoryTXT!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&level_name='+encodeURIComponent(levelCategoryTXT)+'&level_id='+level_id+'&'+uid+'='+uid_id;
	}
}

function editLevelCat(level_cat_name,level_cat_name_id,name_folder,level_id,uid,uid_id){
	levelCategoryTXT = window.prompt("New level category name:",level_cat_name);
	if (levelCategoryTXT!=level_cat_name && levelCategoryTXT!='' && levelCategoryTXT!=undefined){
		if (level_cat_name_id=='new') window.location = 'index.php?page=student_exercises&section=cpanel&new_level_cat_name='+encodeURIComponent(levelCategoryTXT)+'&level_id='+level_id+'&name_folder='+name_folder+'&'+uid+'='+uid_id;
		else window.location = 'index.php?page=student_exercises&section=cpanel&level_cat_name='+encodeURIComponent(levelCategoryTXT)+'&level_id='+level_id+'&level_cat_name_id='+level_cat_name_id+'&name_folder='+name_folder+'&'+uid+'='+uid_id;
	}
}
function newLinkCheck(theForm){
	if (theForm.new_link_txt.value!='' && theForm.new_link_url.value!='') return true;
	else return false;
}
function editLinkCheck(theForm){
	if (theForm.new_link_txt.value!='' && theForm.new_link_url.value!='') return true;
	else return false;
}
function newExerciseCheck(theForm){
	if (theForm.ex_title.value!='' && theForm.newLinkCat.value!='' && theForm.zipFile.value!='') return true;
	else return false;
}
function newExerciseCheckStep2(theForm){
	toReturn = false;
	if (theForm.fileList.length==undefined && theForm.fileList.value!=''){
		toReturn = true;
	} else {
		for (i=0;i<theForm.fileList.length;i++){
			if (theForm.fileList[i].checked) toReturn=true;
		}
	}
	if (toReturn==true && theForm.ex_title.value!='' && theForm.newLinkCat.value!='') {
	theForm.ex_title.disabled=false;
	theForm.newLinkCat.disabled=false;
	return true;
	} else return false;
}
function deleteExercise(ex_name,ex_id,level_id,uid,uid_id){
	var response=confirm('Do you really want to delete this exercise (and all the files it contains): '+ex_name);
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&delete_ex='+ex_id+'&level='+level_id+'&'+uid+'='+uid_id;
	}
}
function deleteLink(ex_name,ex_id,level_id,uid,uid_id){
	var response=confirm('Do you really want to delete this exercise link: '+ex_name);
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&delete_ex='+ex_id+'&level='+level_id+'&'+uid+'='+uid_id;
	}
}

function addNewLevel(main_cat_id,uid,uid_id){
	newLevelTxt = window.prompt("New level name:");
	if (newLevelTxt!='' && newLevelTxt!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&new_main_cat_id='+main_cat_id+'&newLevelTxt='+encodeURIComponent(newLevelTxt)+'&'+uid+'='+uid_id;
	}
}
function deleteLevel(level_id,uid,uid_id){
	var response=confirm("Are you SURE you want to DELETE this WHOLE LEVEL, all its exercises, its exams, and its files?");
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&deleteLevel='+level_id+'&'+uid+'='+uid_id;
	}
}
function deleteMainCat(cat_id,uid,uid_id){
	var response=confirm("Are you SURE you want to DELETE this WHOLE MAIN CATEGORY, all its levels, its exercises, its exams, and its files?");
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&deleteMainCat='+cat_id+'&'+uid+'='+uid_id;
	}
}
function addNewMainCat(uid,uid_id){
	newMainCatTxt = window.prompt("New main category name:");
	if (newMainCatTxt!='' && newMainCatTxt!=undefined){
		window.location = 'index.php?page=student_exercises&section=cpanel&newMainCatTxt='+encodeURIComponent(newMainCatTxt)+'&'+uid+'='+uid_id;
	}
}
function deletePrivateUpload(file_name,uid,uid_id){
	var response=confirm("Are you sure you want to delete this private file? "+file_name);
	if (response=="1"){
		window.location = 'index.php?page=student_exercises&section=cpanel&deletePrivateUpload='+encodeURIComponent(file_name)+'&'+uid+'='+uid_id;
	}
}
