function checkForm(form,sel) {
	if(sel != 1) {
	alert("Please select an item before proceeding.");
	return false;
	}else{
	return true;
	}
}

function checkAction(selForm,actID,sel,eID,cID,subCat) {
	if(actID == 1) {
	//Delete Category Action
		delCheck = confirm("Are you sure you wish to delete this category?\n\nCaution: Deleting this category will delete all articles contained\nwithin and is not reversable.");
		if(delCheck) {
			location.href='scripts/del_cat.php?aID=1&cID='+cID+'&catName='+subCat;
			return true;
			}else{
			return false;
		}
	}

	if(actID == 2 && cID == 1) {
	//Edit Article Action
		if(checkForm(selForm,sel)) {
		//Confirm Edit Article Action
		location.href='admin.php?cid='+cID+'&actionID='+actID+'&subCategory='+subCat+'&eID='+eID;
		}
	}

	if(actID == 2 && cID == 2) {
	//Edit News Action
		if(checkForm(selForm,sel)) {
		//Confirm Edit News Action
		location.href='admin.php?cid='+cID+'&actionID='+actID+'&subCategory='+subCat+'&eID='+eID;
		}
	}
	
	if(actID == 3) {
	//Publish Article Action
		if(checkForm(selForm,sel)) {
		//Confirm Publish Article Action
		location.href='admin.php?cid='+cID+'&actionID='+actID+'&subCategory='+subCat+'&eID='+eID;
		}
	}

	if(actID == 4 && cID == 1) {
	//Delete Article Action
		if(checkForm(selForm,sel)) {
		//Confirm Delete Article Action
		var check=confirm("Are you sure you wish to delete the article below?\n\nArticle ID: "+eID+"\n\n");
			if(check) {
			location.href = 'scripts/delete_article.php?cid='+cID+'&actionid='+actID+'&eID='+eID+'&subCatName='+subCat;
			return true;
			}else{
			return false;
			}
		}
	}

	if(actID == 4 && cID == 2) {
	//Delete News Action
		if(checkForm(selForm,sel)) {
		//Confirm Delete News Action
		var check=confirm("Are you sure you wish to delete the news item below?\n\nNews ID: "+eID+"\n\n");
			if(check) {
			location.href = 'scripts/delete_news.php?cid='+cID+'&actionid='+actID+'&eID='+eID;
			return true;
			}else{
			return false;
			}
		}
	}

	if(actID == 5 && cID == 1) {
		//New Article Action
		location.href='admin.php?cid='+cID+'&actionID='+actID+'&subCategory='+subCat;
	}

	if(actID == 5 && cID == 2) {
		//New News Action
		location.href='admin.php?cid='+cID+'&actionID='+actID+'&saID=1';
	}

	if(actID == 6 && cID == 1) {
		//Cancel Article Action
		location.href='admin.php?cid=1&subCatName=General&sortBy=all';
	}

	if(actID == 6 && cID == 2) {
		//Cancel News Action
		location.href='admin.php?cid=2&subCatName=General';
	}
}

function checkPubAction(selForm,actID,eID,pubID,pagID,sel) {
	if(checkForm(selForm,sel)) {
		if(pubID == 1) {
			var posArt = document.frmPub.pos_article1.value;
			if(posArt != "") {
				var check = confirm("NOTICE: You are attempting to publish an article over an existing publish.  Do you wish to continue?");
				if(check) {
					document.frmPub.submit();
					return true;
					}else{
					return false;
					}
			}
		}
		if(pubID == 2) {
			var posArt = document.frmPub.pos_article2.value;
			if(posArt != "") {
				var check = confirm("NOTICE: You are attempting to publish an article over an existing publish.  Do you wish to continue?");
				if(check) {
					document.frmPub.submit();
					return true;
					}else{
					return false;
					}
			}
		
		}
		if(pubID == 3) {
			var posArt = document.frmPub.pos_article3.value;
			if(posArt != "") {
				var check = confirm("NOTICE: You are attempting to publish an article over an existing publish.  Do you wish to continue?");
				if(check) {
					document.frmPub.submit();
					return true;
					}else{
					return false;
					}
			}
		
		}
		if(pubID == 4) {
			var posArt = document.frmPub.pos_article4.value;
			if(posArt != "") {
				var check = confirm("NOTICE: You are attempting to publish an article over an existing publish.  Do you wish to continue?");
				if(check) {
					document.frmPub.submit();
					return true;
					}else{
					return false;
					}
			}
		
		}
		if(pubID == 5) {
			var posArt = document.frmPub.pos_article5.value;
			if(posArt != "") {
				var check = confirm("NOTICE: You are attempting to publish an article over an existing publish.  Do you wish to continue?");
				if(check) {
					document.frmPub.submit();
					return true;
					}else{
					return false;
					}
			}
		
		}
	document.frmPub.submit();
	}
}

function checkPagAction(form,actID,sel,pagID,cID) {
	if(actID == 5) {
	location.href='admin.php?cid='+cID+'&actionID='+actID+'&subCategory='+subCat;
	}

	if(actID == 4) {
		if(checkForm(form,sel)) {
		//Confirm Delete Action
		var check=confirm("Are you sure you wish to delete the page below?\n\nPage ID: "+pagID+"\n\n");
			if(check) {
			location.href = 'temp.php?cid='+cID+'&actionid='+actID+'&pid='+pagID;
			return true;
			}else{
			return false;
			}
		}
	}
	
	if(actID == 3) {
		if(checkForm(form,sel)) {
		//Publish Article Action
		}
	}
	if(actID == 6) {
	history.back();
	}
}

function checkType(aType,action) {
			switch(aType) {
			case "Inline":	document.all['aAlert'].style.display = "none";
					document.all['type_desc'].innerHTML="Chose the article type from below.";
					document.all['aLink'].style.visibility = "hidden";
					document.forms[0].artLink.disabled=true;
					document.all['trBody'].style.display = "block";
					break;
			case "External":	document.all['aAlert'].style.display = "block";
					document.all['aAlert'].innerHTML = "<table><tr><td style=\"font-weight:bold;\" class=\"mainBtd\" valign=\"top\">Notice:</td><td class=\"mainBtd\">By saving this article to type \"External\" all article content contained in article \"Body\" will be lost.  To retrieve your article \"Body\" content revert back to an \"Inline\" article type before saving.</td></tr></table>";
					document.all['type_desc'].innerHTML="Please provide the URL for the external article below.";
					document.all['aLink'].style.visibility = "visible";
					document.forms[0].artLink.value = "http://";
					document.forms[0].artLink.disabled=false;
					document.all['trBody'].style.display = "none";
					break;
			}
}

function checkGroup(grp) {
	if(grp == "Other") {
		document.pgNew.other.disabled=false;
		document.pgNew.other.style.background="FFFFFF";
	}else{
		document.pgNew.other.disabled=true;
		document.pgNew.other.value="";
		document.pgNew.other.style.background="CCCCCC";
	}
}

function addCategory() {
	newCat = prompt("Please specifiy the new category name below.", "Category Name Here");
	if(newCat && newCat != "Category Name Here") {
		frmURL = window.location;
		location.href="scripts/new_cat.php?fromURL="+frmURL+"&newCat=1&CatName="+newCat;
		return true;
		}else{
		alert("An acceptable category name was not entered, please try again.");
		return false;
	}
}

function addNewsTypeCheck() {
	window.open("scripts/news_check_type.php", 'ssFS',  "width=300,height=240,scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function RenameDo(file) {
	window.open("scripts/page_rename.php?fID="+file, 'PageRename',  "width=400,height=150,scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function NewPage() {
	window.open("scripts/page_new.php", 'PageNew',  "width=400,height=150,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function NewSermon() {
	window.open("scripts/sermon_new.php", 'SermonNew',  "width=400,height=290,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function NewEvent(date) {
	window.open("scripts/news_new.php?actionID=5&saID=1&dID="+date+"", 'EventNew',  "width=400,height=350,scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function NewGallery() {
	window.open("scripts/gallery_new.php", 'GalleryNew',  "width=400,height=150,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function UploadPics(album) {
	window.open("scripts/gallery_upload.php?aid="+album, 'GalleryUpload',  "width=600,height=500,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}
<!-- width=400 height=200 -->

function EditEvent(eID,tID) {
	if(checkForm('frmResult',document.frmResult.selArt.value)) {
	window.open("scripts/news_edit.php?cid=2&actionID=3&saID="+tID+"&eID="+eID, 'EventEdit', "width=600,height=350,scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
	}
}

function edit_img(pic,gal,path) {
	window.open("scripts/edit_pic.php?img="+pic+"&gal="+gal, 'PictureEdit', "width=650,height=650,scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function DeletePics(aPic) {
if(aPic != '' || aPic != 0){
var check=confirm("WARNING: This operation can't be reversed. Proceed?");
if(check){
document.gal_present.action='scripts/pictures_delete.php';
document.gal_present.method='post';
document.gal_present.submit();
}
}else{
alert("ALERT: You must make a selection to perform this operation.")
}
}

function DeleteGallery(gID) {
var check=confirm("WARNING: This operation can't be reversed. Proceed?");
if(check){
location.href='scripts/gallery_delete.php?del=true&gID='+gID;
}
}

function sermonDelete(sID,sTitle,sLoc) {
if(sID != '' && sTitle != '' && sLoc != ''){
var check=confirm("WARNING: Deleting this sermon will also\nremove all saved sermon statistic reports.\nPress OK to continue or CANCEL to abort\nthis delete request.");
if(check){
location.href='scripts/sermon_delete.php?del=1&fid='+sID+'&fname='+sTitle+'&floc='+sLoc;
}
}else{
alert("You must select a file before procceding.")
}
}

function sermonEdit(sID) {
if(sID != ''){
window.open("scripts/sermon_edit.php?sid="+sID, 'SermonEdit', "width=400,height=290,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}else{
alert("You must select a file before procceding.")
}
}

function sermonStats(){
window.open("scripts/sermon_stat.php", 'SermonStats', "width=700,height=450,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

function galleryStats(){
window.open("scripts/gallery_stat.php", 'GalleryStats', "width=700,height=450,scrollbars=no,status=yes,toolbar=no,resizable=no,menubar=no,directories=no,location=no");
}

