 //Sends the page back to the listing view.
function viewList(){

    var sLocation = '';
    var sPosition = 0;
    var sNewLocation = '';
    
    //Get the current location
    sLocation = window.location.href;
    //Find the position of the first ampersand
    sPosition = sLocation.indexOf('&');
    //Read the string of the current location up 
    //to the point of the first ampersand
    sNewLocation = sLocation.substring(0, sPosition);
    //Set the location to the new URL
    window.location.href = sNewLocation;    
}

//This function resets the collection status' for the Delivered Packages
function resetCollectedBy(){
    //Set the value for collected by to empty string. This value is the dermining condition for the status.
    document.getElementById('collected_by').value = '';
 
}

//This function resets the closed status' for the tenders
function resetClosedBy(){
    //Set the value for collected by to empty string. This value is the dermining condition for the status.
    document.getElementById('closed_by').value = '';
 
}

function saveTime(id, which){
	var curOBJ = document.getElementById(id);
	var strHRS = document.getElementById(which+'_hours').value;
	var strMNS = document.getElementById(which+'_mins').value;
	var strTOD = document.getElementById(which+'_tod').value;
	
	if (strTOD=="PM") {
		strHRS = strHRS*1 + 12;
	}
	
	strHRS+="";

	if (strHRS.length!=2) {
		strHRS = "0" + strHRS;
	}
	if (strMNS*1==0) {
		strMNS = "00";
	}
	curOBJ.value = strHRS + ":" + strMNS + ":00";
}

function doTimes(which) {
	strVAL = document.getElementById(which+"_time").value;
	if (strVAL!="") {
		var X = new Array()
		X = strVAL.split(":");
	
		var s = X[0]*1;
		
		s+="";
			
		if (s.length==2) {
			s = s*1;
			switch (s) {
				case 10:
				tod = "AM";
				break;
				case 11:
				tod = "AM";
				break;
				case 12:
				tod = "AM";
				break;
				default:
				tod = "PM";
				s = s*1-12;
				break;
			}
		} else {
			tod = "AM";
		}
		var iLen = strVAL .length;
		var iPos = iLen - 2;
		var sTOD = strVAL .substr(iPos, 2);
	  	tod = sTOD;
		document.getElementById(which+"_hours").value = s;
		document.getElementById(which+"_mins").value = X[1]*1;
		document.getElementById(which+"_tod").value = tod;
	}
}

String.prototype.clean_Up = function() {			// Remove single and double quotes from the string
	strQuote = /'/g;
	strDQuote= /"/g;
	strLT=/</g;
	strGT=/>/g;
    myString = this.replace(strQuote, "`");			// Single Quote
    myString = myString.replace(strDQuote, "");		// Double Quote
    myString = myString.replace(strLT, "[");		// Double Quote
    myString = myString.replace(strGT, "]");		// Double Quote
    myString = myString.trim();
    return myString
}

function GetDay(nDay)
{
	var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
	                     "Thursday","Friday","Saturday");
	return Days[nDay]
}

function GetMonth(nMonth)
{
	var Months = new Array("January","February","March","April","May","June",
	                       "July","August","September","October","November","December");
	return Months[nMonth] 	  	 
}
