// JavaScript Document
function formatTheDate(theDate){
	if ((theDate.value.length==2) || (theDate.value.length==5))
		theDate.value+="/";
}

function toUpper(objName){
	objName.value=objName.value.toUpperCase();
}

function Verify_Exit() {
	return confirm ( "Are you sure you want to logout?" );
}			

function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode!=45 && charCode!=46 && charCode > 31 && (charCode < 47 || charCode > 57))
    	return false;

   return true;
}

function checkEmail(objName){
	if(objName.value.length>0){
		atPos=objName.value.indexOf("@");
		period=objName.value.indexOf(".")-1;
		guestEmailLen=objName.value.length-1;
		lastPeriod=objName.value.substr(guestEmailLen,1);		
		if ( atPos<3 || atPos==guestEmailLen || period==atPos || lastPeriod=="." ){
			alert("The email address \""+objName.value+"\" is incorrect. Please enter a valid email address. Thank you.");
			objName.value="";
			return false;
		}
		return true;
	}
}

function EditRecord(page,action,id){
	if(confirm("Do you want to edit this record?")==true){						
		document.location = "tupcms.php?request="+page+"&action="+action+"&id="+id;
		return true;
	}
}	

function ViewRecord(page,action,status,id){
	
	if(confirm("Do you want to "+status+" this record?")==true){						
		document.location = "cms_actions.php?module="+page+"&action="+action+"&id="+id+"&status="+status;
		return true;
	}
}
function DeleteRecord(page,action,id){
	if(confirm("Do you want to delete this record?")==true){			
		document.location = "cms_actions.php?module="+page+"&action="+action+"&id="+id;
		return true;
	}	
}

function cancelEntry(request,action){
	if(confirm("Do you want to exit this form?")==true){				
		document.location = "admin.php?page=site";
		return true;
	}			
}