function MM_jumpMenu(selObj){

  var index = selObj.options[selObj.selectedIndex].value;
  var gid = index.split(":");


  window.location="?gid="+gid[0];

}

function addNewArea(){
  if (document.form1.newArea.value != ""){
  	document.form1.action.value="newArea";
  	document.form1.submit();

  }else {
  	alert("Please enter Area Name");
  	document.form1.newArea.focus();
  }
}


function updateArea(an, oldValue){

  var temp = prompt("Please enter the new Area Name", oldValue)

  if (!temp){
  }else if ((oldValue != temp)&&(temp)){
  	document.form1.action.value="updateArea";
  	document.form1.oldAreaName.value=oldValue;
  	document.form1.newAreaName.value=temp;
  	// alert(oldValue+""+temp+" "+an);
  	document.form1.submit();

  }else {
  	alert("Area name is the same.");
  }
}

function deleteArea(areaName){

  var agree=confirm("Are you sure you wish to delete this area and all it's locations?");
  if (agree)
  {
	document.form1.action.value="deleteArea";
  	document.form1.areaGroup.value=areaName;
  	document.form1.submit();

  }
}

function setLocation(an, t_areaName, t_locationName, t_difficulty){

  if (an!=""){

  	//alert(an+" "+ t_areaName+" "+ t_locationName+" "+ t_difficulty);

	for(i=0; i<document.form1.elements["selectarea"].length; i++){
		if (document.form1.elements["selectarea"].options[i].value ==  t_areaName){
			document.form1.elements["selectarea"].options[i].selected = 1;
		}
	}

	for(i=0; i<document.form1.elements["difficulty"].length; i++){
		if (document.form1.elements["difficulty"].options[i].value ==  t_difficulty){
			document.form1.elements["difficulty"].options[i].selected = 1;
		}
	}

    document.form1.elements["location"].value = t_locationName
  	document.form1.elements["location"].select();
	document.form1.elements["addLoc"].value = "Update Location";
   	document.form1.changePK.value=an;

  	//document.form1.submit();
  }else {
  	alert("Location is the same.");
  }
}


function addLocation(){

  var location = document.form1.elements["location"].value;
  var areaName = document.form1.selectarea.options[document.form1.selectarea.selectedIndex].value;
  var difficulty = document.form1.difficulty.options[document.form1.difficulty.selectedIndex].value;
  var an = document.form1.elements["changePK"].value;

  if ((location!="")&&(difficulty!="")){

  	if (document.form1.elements["addLoc"].value == "Update Location"){
  		document.form1.action.value="updateLocation";
   		document.form1.changePK.value=an;
		document.form1.areaGroup.value=areaName;
		document.form1.newAreaName.value=location;
		document.form1.difficulty.value=difficulty;
		document.form1.submit();

  	}else{
		document.form1.action.value="addLocation";
		document.form1.areaGroup.value=areaName;
		document.form1.newAreaName.value=location;
		document.form1.difficulty.value=difficulty;
		//alert(location +" "+areaName+" "+difficulty);
		document.form1.submit();
	}
  }else {
  	alert("Please enter a location name and select a difficulty");
  	document.form1.elements["location"].focus();
  }
}

function deleteLocation(pk){

  var agree=confirm("Are you sure you wish this location ?");
  if (agree)
  {
	document.form1.action.value="deleteLocation";
  	document.form1.changePK.value=pk;
  	document.form1.submit();

  }
}
