function confirmChange(){
	var doit=confirm("Are you sure you want to make this change?")
	if (doit) return true;
	else return false;
}
function confirmIncomplete(){
	var doit=confirm("If the category field is not filled out, your items will not appear on the live when set to active. Do you want to continue?")
	if (doit) return true;
	else return false;
}

$(document).ready(function() {
	$(".close").click(function(){
		window.location= "admin.php";
	})
	$(".addEntry, .clearAddEntryForm").click(function(){
		window.location= "admin.php?q=add";
	})
	$(".viewArchive").click(function(){
		window.location= "admin.php?q=archive";
	})
	$(".viewSite").click(function(){
		window.location= "index.php";
	})
	$(".editCategories").click(function(){
		window.location= "admin.php?q=categories";
	})
	$(".addNewCat").click(function(){
		window.location= "admin.php?q=categories&new=yes";
	})
	$(".settings").click(function(){
		window.location= "admin.php?q=settings";
	})
	$(".orderEntries").click(function(){
		window.location= "admin.php?q=order";
	})
	$(".logout").click(function(){
		window.location= "login.php?logout=yes";
	})
	$(".viewButton").click(function(){
		window.location= "buttons";
	})
	$(".viewUpdates").click(function(){
		window.location= "updates";
	})
	$(".validate").click(function(event){
		event.preventDefault();
		var $form = $(this).parent().parent(),
		newCat = $form.find('input[name="newCategory"]').val();
		if (!$("input[@name='category']:checked").val()) {
		   alert('No category is selected');
			return false;
		}
		else {
		var id = $("input[@name=CategoryGroup]:checked").attr('id');
			if(id=="new_category"&&newCat==""){
				alert("No Category Name Submitted");
			}else{
				$(".changeEntryForm").submit();	
			}
		}
	})
	$(".moveUp").click(function(event){
		event.preventDefault();
		node1=$(this).attr("href");
		node2=$(this).parent().prev().children(".moveUp").attr("href");
		//alert(node1);
		//alert(node2);
		if (node2){
			window.location= "admin.php?q=order&node1="+node1+"&node2="+node2;
		}
	})
	$(".moveDown").click(function(event){
		event.preventDefault();
		node1=$(this).attr("href");
		node2=$(this).parent().next().children(".moveUp").attr("href");
		//alert(node1);
		//alert(node2);
		if (node2){
			window.location= "admin.php?q=order&node1="+node1+"&node2="+node2;
		}
	})

	
});
