/*
 * Client:		Steel Tank Institute
 *
 * Language:	JavaScript
 *
 * Created by:	Dean Jensen
 * Created on:	17-FEBRUARY-05
 *
 * Description:	SiteManager .NET
 * 
 * Version:	1.0.0
 *
 * Copyright:	The contents of this file are protected under the United States
 *   			copyright laws as an unpublished work, and is confidential and
 *   			proprietary to Synergistic Networks, Inc.  Its use or disclosure in
 *   			whole or in part without the expressed written permission of
 *   			Synergistic Networks, Inc. is expressly prohibited.
 *
 *   			© Copyright 2004-2005 by Synergistic Networks, Inc. All rights reserved.
 */
 
 
// Function to find number of charcters in string...
function getLastPosition(ch,str){
	cntr = 0;
	minValue = 0;
	maxValue = (str.length);
	intItem = 0;
 	for (var i = minValue; i <= maxValue; i++){
		if (str.charAt(i) == ch){
		cntr = cntr + 1;	
		intItem = i;
		}	   
	 } //End For

	if (cntr == 1)
		{
		return 0;
		}
	else
		{
		return intItem;
		}
} //End Function


function verifyFileName(form){
	var strFilePath = form.FILE1.value;	
	var intLength = strFilePath.length;
	var intLastSlashAt = getLastPosition("\\",strFilePath)
	intLastSlashAt=intLastSlashAt+1;
	var strFileName = "";
	
 	for (var i = intLastSlashAt; i <= intLength; i++){
		strFileName = strFileName + strFilePath.charAt(i)
	 } //End For
	
	if(strFilePath==""){alert('Please select a file to upload.');return;}
	//if(strFileName.indexOf(' ', 0) > 0){alert('Blank spaces in the file name are not allowed.');return;}
	if(strFileName.indexOf('&', 0) > 0){alert('Ampersand in the file name are not allowed.');return;}
	if(strFileName.indexOf('#', 0) > 0){alert('Pound sign in the file name are not allowed.');return;}
	form.submit();
	
	//alert('intLength=' + intLength + ' intLastSlashAt= ' + intLastSlashAt);
	//alert("strFileName= " + strFileName);
}

function popUpload(strURL){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(strURL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=300,left=150,top=200');");
}


// -------------------------------------------------------
// Jump Menu Function
// -------------------------------------------------------
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// -------------------------------------------------------
// Verify Delete Function
// -------------------------------------------------------
function verifyDelete(intID,strItem){
	     var strMsg = "*******************************\n\n";
	strMsg = strMsg + "Are you certain you want to delete!\n\n";
	strMsg = strMsg + "*******************************";
	if(confirm(strMsg)){
		if (strItem == "DeleteCategory"){
			window.location = 'category_process.aspx?Type=Category&Method=Delete&CatID='+intID;
		}
		if (strItem == "DeleteEvent"){
			window.location = 'process.aspx?Type=Event&Method=Delete&EvtID='+intID;
		}
		if (strItem == "DeleteLocation"){
			window.location = 'process.aspx?Type=Location&Method=Delete&LocID='+intID;
		}
		if (strItem == "DeleteSession"){
			window.location = 'process.aspx?Type=Session&Method=Delete&SecID='+intID;
		}
		if (strItem == "DeleteRegistration"){
			window.location = 'process.aspx?Type=Registration&Method=Delete&RegID='+intID;
		}
	}
	else{
		return;
	}
}// end function


// -------------------------------------------------------
// Verify File Delete Function
// -------------------------------------------------------
function verifyFileDelete(strURL){
		 var strMsg = "***********************************\n\n";
	strMsg = strMsg + "Are you certain you want to delete this file!\n\n";
	strMsg = strMsg + "***********************************";

	if(confirm(strMsg)){
		window.location = strURL;
	}
	else{
		return;
	}
}// end function

// -------------------------------------------------------
// Verify Processed Registration Function
// -------------------------------------------------------
function verifyProcessed(intID,strItem){
	var strMsg = "Are you certain you want to update this registration!";
	if(confirm(strMsg)){
		if (strItem == "True"){
			window.location = 'process.aspx?Type=Registration&Method=Edit&Processed=True&RegID='+intID;
		}
		if (strItem == "False"){
			window.location = 'process.aspx?Type=Registration&Method=Edit&Processed=False&RegID='+intID;
		}
	}
	else{
		return;
	}
}// end function


// -------------------------------------------------------
// Save the event description on add
// -------------------------------------------------------
	function SaveAddEventHTMLData(form)
	 {
		var htmlDescription = "";

		htmlDescription = form.eventdescription.docHtml;

 		// Replace Double Quotes (") with Single Quotes (') and save data

		if (htmlDescription != null)	
		 {
			htmlDescription = replaceDoubleQuotes(htmlDescription);
			document.getElementById('txtEventDescription').value = htmlDescription;
		 }
		else
		 {
			document.getElementById('txtEventDescription').value = "";	
		 }
	 }


// -------------------------------------------------------
// Save the event description on edit
// -------------------------------------------------------
	function SaveEditEventHTMLData(form)
	 {
		var htmlDescription = "";

		htmlDescription = form.eventdescription.docHtml;

 		// Replace Double Quotes (") with Single Quotes (') and save data

		if (htmlDescription != null)	
		 {
			htmlDescription = replaceDoubleQuotes(htmlDescription);
			document.getElementById('txtEventDescription').value = htmlDescription;
		 }
		else
		 {
			document.getElementById('txtEventDescription').value = "";	
		 }
	 }

// EOF
