function stripCharString (InString, CharString)  {
	OutString = "";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar = InString.substring(Count, Count+1);
		Strip = false;
		for (Countx = 0; Countx < CharString.length; Countx++) {
			StripThis = CharString.substring(Countx, Countx+1)
			if (TempChar == StripThis) {
				Strip = true;
				break;
			}
		}
		if (!Strip)
			OutString = OutString + TempChar;
	}
	return (OutString);
}
function fNewFileName(){
	PageTitle = document.fAddPage.title.value;
	document.fAddPage.filename.value = stripCharString(PageTitle, "\/:*+=\"{'}&!?< >|") + ".aspx";	
}
function vAddPage(){
	
	filenameVal = document.fAddPage.filename.value;
	document.fAddPage.filename.value = stripCharString(filenameVal, "\/:*+=\"{'}&!?< >|");
	
	theFileName = document.fAddPage.filename.value;
	
	fileLength = theFileName.length;
	lastFourPos = (fileLength - 5);
	
	lastFourChars = theFileName.substring(lastFourPos, fileLength);

	if (lastFourChars != ".aspx" || theFileName == ".aspx" || theFileName == "") {		
		alert("The file extension for this page must be .aspx and the filename must not be left blank.");
		return false
	}
	
}
function vDeletePage(sectionID,pageID){
	
	if (confirm("If you delete this page, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "MyPages.aspx?Section=" + sectionID + "&delid=" + pageID;
	}
	
}

function vDeleteFolder(FolderID){
	
	if (confirm("If you delete this folder, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "Folders.aspx?DelID=" + FolderID;
	}
	
}

function vEditPage(pageID){
	
	top.location.href = "EditPage.aspx?editid=" + pageID;
	
}


function vUpdatePage(){

	//Get The Proposed File Name From The Text Field
	filenameVal = document.fUpdatePage.txtFilename.value;
	
	//Take that value and strip out offending characters. Put results back into the text field.
	document.fUpdatePage.txtFilename.value = stripCharString(filenameVal, "\/:*+=\"{'}&!?< >|");
	
	//Create new variable with the unoffending file name.
	theFileName = document.fUpdatePage.txtFilename.value;
	
	//How many characters is the filename?
	fileLength = theFileName.length;
	
	//What are the last four characters of the filename? We're looking for ".aspx" ...
	lastFourPos = (fileLength - 5);	
	lastFourChars = theFileName.substring(lastFourPos, fileLength);

	//Check if the last 4 chars is .aspx. Also look for a blank ".aspx" filename and an empty name,
	if (lastFourChars != ".aspx" || theFileName == ".aspx" || theFileName == "") {		
		alert("The file extension for this page must be .aspx and the filename must not be left blank.");
		return false;
	}
	
}

function vDeletePoll(pollID){
	
	if (confirm("If you delete this poll, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "Polls.aspx?delid=" + pollID;
	}
	
}

function vEditPoll(pollID){
	
	//if (confirm("Click OK to continue.")) {		
		top.location.href = "EditPoll.aspx?Editid=" + pollID;
	//}
	
}
function vUpdatePoll(){
	
	theQuestion = document.fUpdatePoll.txtQuestion.value;
	QuestionLength = theQuestion.length;

	if (QuestionLength > 200)
	{
		alert("The Question must be less than 200 characters long.")
		return false
	}
}

function vDeleteGuest(guestID){
	
	if (confirm("If you delete this guestbook entry, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "Guestbook.aspx?DelID=" + guestID;
	}
	
}

function vDeleteEmail(emailID){
	
	if (confirm("If you delete this email address, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "EmailList.aspx?DelID=" + emailID;
	}
	
}

function vDeleteUser(UserID){
	
	if (confirm("If you delete this user, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "UserAdmin.aspx?DelID=" + UserID;
	}
	
}

function vDeleteRecipient(RecipientID){
	
	if (confirm("If you delete this recipient, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "FeedbackForm.aspx?DelID=" + RecipientID;
	}
	
}

function vDeleteSubject(SubjectID){
	
	if (confirm("If you delete this subject, it cannot be undone. Click OK to continue.")) {		
		top.location.href = "FeedbackForm.aspx?DelSubjectID=" + SubjectID;
	}
	
}

function popPageAccess(UserID){
	
	var NewWindow;
	NewWindow = window.open('UserAdmin-AddPageRights.aspx?UserID='+UserID,'AddPageRights','height=500,width=600,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {
		NewWindow.focus()
	}
}

function vPageAddUserAccess(PageID,UserID){
	
	window.opener.top.location.href = "UserAdmin-Rights.aspx?UserID=" + UserID + "&AddPageID=" + PageID;
	window.close();
	
}
function vPageDelUserAccess(PageID,UserID){
	
	top.location.href = "UserAdmin-Rights.aspx?UserID=" + UserID + "&DelPageID=" + PageID;
	
}






