/* ***************************************************************
 * script: szabogi.js  											 *
 * purpose: grant szabo's javascript functions	 				 *
 * Created 12/1/2005 by Grant Szabo (grant@quagmire.com)		 *
 *****************************************************************/
 
//Custom JavaScript Functions to Provide Extended Capabilities
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

String.prototype.removePunct=function() {
	return this.replace(/[;|'|"|,]*/g,'');
}
 
 //Redirects from utlData.cfm Please Wait after processing is completed
 function fcnRedirect(url)
 {
	location.href(url);
 }
 
//call this in body onload event.
function fcnParsePrepop()
{
	//alert(location.search.substring(1));
	var querystring = location.search.substring(1);
	var args = fcnGetArgs(querystring);

	if(args.email != null) //see if we have an email address
	{
		//set iFrame source property
		document.getElementById("if1").src = "http://www.listenerrewards.com/wjr?email=" + args.email;
	}				
}

//call this in body onload event.  Used for dealing with iFrame hosted TAF web forms
function fcnParseTAF()
{
	//alert(location.search.substring(1));
	var querystring = location.search.substring(1);
	var args = fcnGetArgs(querystring);

	if(args.refer_web_id != null) //see if we have an email address
	{
		//set iFrame source property
		document.getElementById("if1").src = "http://www.listenerrewards.com/957BENfm/?refer_web_id=" + args.refer_web_id;
	}				
}

// parses query string into name/value pairs object
// call like this: var args = fcnGetArgs(location.search.substring(1));
// then, you can get at the name/value pairs by saying args.email if email was one of the querystring variables present
function fcnGetArgs(query) 
{
	var args = new Object();
	var pairs = query.split(",");
	for(var i=0; i < pairs.length; i++) 
	{	
		var pos = pairs[i].indexOf('='); // look for "name=value"
		if(pos == -1) continue; //if not found, skip
		var argname = pairs[i].substring(0,pos); //extract the name
		var value = pairs[i].substring(pos+1); //extract the value 
		args[argname] = unescape(value); //store as a property
	}
	return args;
}

//only checks for required fields
function fcnBasicValidation(f) 
{
var msg;
	var empty_fields = "";
	var errors = "";
	var aRadioGroup = new Array(); //array to hold radio button groups
	
	//loop through the elements of the form, looking for all
	//text, textarea, and select-one (html select max 1) elements that don't have an "optional" property defined.
	//Also, if any of these elements have a "min" or a "max" property definied, then 
	//verify that they are numbers and that they are in the correct range.  If the 
	//element has a "numeric" propery defined, verify that it is a number, but don't
	//check its range.  Put together an error message based on result.
	for(var i=0; i < f.length; i++)
	{
		var e = f.elements[i];
		
		if (((e.type == "text") || (e.type == "textarea") || (e.type == "select-one") || (e.type == "radio") || (e.type == "password")) && !e.optional)
		{
			//first check if the field is empty
			if ((e.value == null) || (e.value == "") || isblank(e.value)) 
			{
				
				if(e.alt == null)
					empty_fields += "\n      " + e.name;
				else
					empty_fields += "\n      " + e.alt;
					
				continue;
			}
			
			//handle radio buttons.  Routine below groups radio buttons on e.NAME
			if (e.type == "radio")
			{
				//add this radio group to the aRadioGroup array and get 
				//back the array position for the element.  If the value
				//has already been processed, then POS will be the positon
				//where the value was found.
				pos = AddRadioGroup(aRadioGroup, e.name, false);

				fieldName = e.name;
				bOK = false;

				//process all form elements, looking for the radio group
				//as long as the group hasn't been processed already
				if(!aRadioGroup[pos][1])
				{
					for(var x=0; x < f.length; x++) 
					{
						var z = f.elements[x];
						
						if(z.name == aRadioGroup[pos][0]) 
						{
							if(z.checked) 
							{
								bOK = true;
								break;
							}
						}	
						
						//indicate that the radio group has been processed
						aRadioGroup[pos][1] = true;	
					}
					
					if(!bOK) 
					{
						if(e.alt == null)
							empty_fields += "\n      " + e.name;
						else
							empty_fields += "\n      " + e.alt;
						continue;				
					}
				}
			}
		}
	} //end for loop
	
	//now if there were any errors, display the messages and return false to prevent form from
	//being submitted.  Otherwise return true after stripping punctuation and converting fields to uppercase.
	if(!empty_fields && !errors)  
	{
		return true;
	}
	else 
	{
		msg  = "____________________________________________________\n\n"
		msg += "The form was not submitted because of the following error(s).\n";
		msg += "Please correct these error(s) and re-submit.\n"; 
		msg += "____________________________________________________\n\n"		
		
		if (empty_fields)
		{
			msg += "- The following required field(s) are empty:" + empty_fields + "\n";
			if (errors) msg += "\n";
		}
	
		msg += errors;
		alert(msg);
		return false;
	}
}
 
//Validates Form Post
// *** Uses ALT or NAME field for validation ***
//Created 12/8/2005 by G.Szabo, borrowing heavily from David Flanagan's JavaScript, The Definitive Guide, 3rd Ed. (O'Reilly)
//Invoked by onSubmit() event handler.  Example:
//<form action="" method="post" onSubmit="
//		this.re_add1.optional = true;
//		this.re_city.optional = true;
//		this.re_zipcode.optional = true;
//		this.age.numeric = true;				
//		return fcnValidateForm(this); ">
function fcnValidateForm(f) 
{
	var msg;
	var empty_fields = "";
	var errors = "";
	var aRadioGroup = new Array(); //array to hold radio button groups
	
	//loop through the elements of the form, looking for all
	//text, textarea, and select-one (html select max 1) elements that don't have an "optional" property defined.
	//Also, if any of these elements have a "min" or a "max" property definied, then 
	//verify that they are numbers and that they are in the correct range.  If the 
	//element has a "numeric" propery defined, verify that it is a number, but don't
	//check its range.  Put together an error message based on result.
	for(var i=0; i < f.length; i++)
	{
		var e = f.elements[i];
		
		if (((e.type == "text") || (e.type == "textarea") || (e.type == "select-one") || (e.type == "radio") || (e.type == "radio")) && !e.optional)
		{
			//first check if the field is empty
			if ((e.value == null) || (e.value == "") || isblank(e.value)) 
			{
				
				if(e.alt == null)
					empty_fields += "\n      " + e.name;
				else
					empty_fields += "\n      " + e.alt;
					
				continue;
			}
			
			//handle radio buttons.  Routine below groups radio buttons on e.NAME
			if (e.type == "radio")
			{
				//add this radio group to the aRadioGroup array and get 
				//back the array position for the element.  If the value
				//has already been processed, then POS will be the positon
				//where the value was found.
				pos = AddRadioGroup(aRadioGroup, e.name, false);

				fieldName = e.name;
				bOK = false;

				//process all form elements, looking for the radio group
				//as long as the group hasn't been processed already
				if(!aRadioGroup[pos][1])
				{
					for(var x=0; x < f.length; x++) 
					{
						var z = f.elements[x];
						
						if(z.name == aRadioGroup[pos][0]) 
						{
							if(z.checked) 
							{
								bOK = true;
								break;
							}
						}	
						
						//indicate that the radio group has been processed
						aRadioGroup[pos][1] = true;	
					}
					
					if(!bOK) 
					{
						if(e.alt == null)
							empty_fields += "\n      " + e.name;
						else
							empty_fields += "\n      " + e.alt;
						continue;				
					}
				}
			}
		}
	} //end for loop
	
	//perform email address checks
	if(document.getElementById("txtEmail") != null)
	{
		//trim any whitespace characters from email address
		document.getElementById("txtEmail").value = document.getElementById("txtEmail").value.trim();
		document.getElementById("txtEmail_confirm").value = document.getElementById("txtEmail_confirm").value.trim();		
		
		//verify that field email is a valid looking email address
		if( !fcnIsEmail(document.getElementById("txtEmail")) )
			errors += "- The entered email address does not appear to be a valid email address.\n";

		//verify that the email and confirm email fields match
		if( !fcnEmailConfirmMatch() ) 
			errors += "- The fields email and email_confirm do not match.\n";	
						
		//Removed 1/20/2009						
		//if( !fcnIsValidZip(document.getElementById("zipcode")) )
			//errors += "- The zip code / postal code entered does not appear to be valid.\n";
	}

	//now if there were any errors, display the messages and return false to prevent form from
	//being submitted.  Otherwise return true after stripping punctuation and converting fields to uppercase.
	if(!empty_fields && !errors)  
	{
	
		//loop through all elements, removing bad punctuation and converting to uppercase
		for(var i=0; i < f.length; i++)
		{
			var e = f.elements[i];
			
			if (e.type == "text")
			{
				//e.value = e.value.removePunct().toUpperCase();
				e.value = e.value.removePunct();
			}

		} //end for loop	
	
		//immediately before returning true, write out missing LT's to the form
		//fcnWriteFalseLTs(f, true);
		return true;
	}
	else 
	{
		msg  = "____________________________________________________\n\n"
		msg += "The form was not submitted because of the following error(s).\n";
		msg += "Please correct these error(s) and re-submit.\n"; 
		msg += "____________________________________________________\n\n"		
		
		if (empty_fields)
		{
			msg += "- The following required field(s) are empty:" + empty_fields + "\n";
			if (errors) msg += "\n";
		}
	
		msg += errors;
		alert(msg);
		return false;
	}
} //end fcnDMRValidate

function AddRadioGroup(aRadioGroup, name, bProcessed) 
{
	//fcnDMRValidateV3 instantiates the aRadioGroup array, which we pass into this method
	//this method takes aRadioGroup and adds an array named aGroup to it.  Thus, we have an
	//array of arrays.  To access the elements:
	
	//aRadioGroup[0][0] : this will retrieve the NAME in the first aRadioGroup position
	//aRadioGroup[0][1] : this will retreive the boolean value for whether or not the NAME was processed already

	var L = aRadioGroup.length;
	var bFound = false; //variable to indicate whether the NAME has already been processed
	var aGroup = new Array();
	aGroup[0] = name; //position 0 will hold the NAME property of the radio button
	aGroup[1] = bProcessed; //position 1 will hold the true/false value for bProcessed

	//check to see if the NAME has already been processed
	if(L > 0) 
	{
		for(var i = 0; i < aRadioGroup.length; i++)
		{
			if (aRadioGroup[i][0] == name)
			{
				bFound = true;
				L = i; //set the position that gets returned to the array location where the value was found
				break;
			}
		}
	}
	
	//it the radio group NAME has not been found, go ahead and add it
	if(!bFound)
	{
		aRadioGroup[L] = aGroup;
	}
	
	//return the array position
	return L;
}

//used by fcnValidate
function isblank(s)
{
	for(var i=0; i < s.length; i++) 
	{
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

//used by fcnValidate
function fcnEmailConfirmMatch() 
{
	if(document.getElementById("txtEmail").value.toUpperCase() == document.getElementById("txtEmail_confirm").value.toUpperCase()) return true;
	return false;
}

//tests for 5-digit US zip, zip plus 4, and canadian postal code
function fcnIsValidZip(s)
{
	val = s.value.trim();

	usZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	caZip = new RegExp(/(^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$)|(^[A-Z][0-9][A-Z].[0-9][A-Z][0-9]$)/); //matches V3A3N1 or V3A 3N1 or V3A.3N1
	
	if (usZip.test(val)) 
	{
		return true;
	}
	
	val = val.toUpperCase();

	if (caZip.test(val.toUpperCase()))
	{
		return true;
	}
	
	//zip fails validation
	return false;
}

//validate email address
function fcnIsEmail ( obj ) 
{
	var emailStr = obj.value.toLowerCase(); //make sure don't run into a case issue when pattern matching by setting to lowercase
	var isOK = true;
	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	
	var checkTLD=1;
	
	/* The following is the list of known TLDs that an e-mail address must end with. */
	
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|cc|org)$/;
	
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	
	var emailPat=/^(.+)@(.+)$/;
	
	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */
	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	
	var validChars="\[^\\s" + specialChars + "\]";
	
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	
	var quotedUser="(\"[^\"]*\")";
	
	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
	/* The following string represents an atom (basically a series of non-special characters.) */
	
	var atom=validChars + '+';
	
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	/* Finally, let's start trying to figure out if the supplied address is valid. */
	
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {
	
	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */
	
	//alert("The email address you entered is incorrect.    \nPlease reenter (checking for @ and .)");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		//alert("The username portion of the email address contains invalid characters.");
		return false;
	   	}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			//alert("Ths domain name portion of the email address contains invalid characters.");
			return false;
		   }
	}
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		// user is not valid
		//alert("The username portion of the email address doesn't seem to be valid.");
		return false;
	}
	
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		// this is an IP address
		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			//alert("Destination IP address of the email address is invalid!");
			return false;
		   }
		}
		return true;
	}
	
	// Domain is symbolic name.  Check if it's valid.
	// ^[^\s\(\)><@,;:\\\"\.\[\]]+$ = RegEx Pattern of atom
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if ( !domArr[i].match(atomPat) ) {
			//alert("The domain name portion of the email address does not seem to be valid.");
			return false;
		}
	}
	
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		//alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}
	
	// Make sure there's a host name preceding the domain.
	
	if (len<2) {
		//alert("This address is missing a hostname!");
		return false;
	}
	
	// If we've gotten this far, everything's valid!
	return true;
}


//assumes aKeys and aVals are 1d arrays that are exactly aligned
//takes two arrays, a key array and a value array, along with the key to find the value for
//returns the value
function fcnGetKeyValue( aKeys, aVals, key ) {
	var msg = "";
	var rVal = "";

	for(i=0; i < aKeys.length; i++) {
		msg = msg + aKeys[i].trim().toUpperCase() + " = " + aVals[i].trim() + "\n";		
		if( aKeys[i].trim().toUpperCase() == key.trim().toUpperCase() ) {
			rVal = aVals[i].trim().toUpperCase();
		}
	}
	
	//uncomment for debugging purposes, shows key being returned, its value, and a full dump of key/value pairs
	//alert("key = " + key + "\n rVal = " + rVal + "\n\n" + msg);
	return rVal;
}

//Added 12/3/2007 by GSzabo.  
//Changes text_OptIn to true if a cell network is chosen.  
//Changes to false if default "choose" selection is made.
function cell_network_onChange()
{
	if(document.getElementById("cell_network").value != 0)
		document.getElementById("text_OptIn_Yes").checked = true;
	else
		document.getElementById("text_OptIn_No").checked = true;
}

function fcnWriteFalseLTs(f, bPostToDMR) {
	var strHTML = new Array();
	var x = 0; //strHTML Array Counter 
	var aCheckedTimes = fcnCheckedTimesArray(f, bPostToDMR);

	if (bPostToDMR)
		aLT = fcnDMRLTArray(); //get the dmr formatted array of all possible listening times
	else
		aLT = fcnUMLTArray(); //get the UM formatted array of all possible listening times
	
	//iterate over all listening times writing a checkbox only for times that are missing in the aLT array
	for(var i=0; i < aLT.length; i++)
	{
		//if the listening time isn't already checked...
		if( !fcnValueFound(aLT[i], aCheckedTimes.toString()) )
		{		
			//add it to the list of times that aren't checked (checked=false)
			strHTML[x] = '<input type="checkbox" name="' + aLT[i] + '" value="FALSE" checked>'
			x++;
		}
	}

	//alert(strHTML.join(" || "));

	//write out div tag of false LT checkboxes 
	document.getElementById("divMissingLTs").innerHTML = strHTML.join("");
}

//returns an array containing the times in dmr or UM format that are checked on the form
function fcnCheckedTimesArray(f, bPostToDMR) {
	var aCheckedTimes = new Array();
	var x = 0; //index counter
	
	if (bPostToDMR)
		aLT = fcnDMRLTArray(); //get the dmr formatted array of all possible listening times
	else
		aLT = fcnUMLTArray(); //get the UM formatted array of all possible listening times
	
	//loop through all elements, creating index array containing checked listening times
	for(var i=0; i < f.length; i++)
	{
		var e = f.elements[i];
		
		//if this is a listening time field in the form...
		if ( (e.type == "checkbox") && ( e.name.substring(0,1).toUpperCase() == "M" || e.name.substring(0,1).toUpperCase() == "T" || e.name.substring(0,1).toUpperCase() == "W" || e.name.substring(0,1).toUpperCase() == "H" || e.name.substring(0,1).toUpperCase() == "F" || e.name.substring(0,1).toUpperCase() == "S" || e.name.substring(0,1).toUpperCase() == "U") )
		{
			//iterate over each time in the array aLT
			for(var a=0; a < aLT.length; a++) 
			{
				//if we find a match...meaning this is a valid listening time...
				if( (e.name == aLT[a]) )
				{
					//and the checkbox is checked...
					if( e.checked )
					{
						//add it to the checkedTimes array
						aCheckedTimes[x] = e.name;
						x++;
					}
				}
			} //end LT array for loop
		} // end if
	} //end element for loop	
	
	//alert("Checked Times\n\n" + aCheckedTimes)
	
	//document.getElementById("divMissingLTs").innerHTML = strHTML.join("");
	return aCheckedTimes;	
}

//returns an array containing the times in dmr format that are checked on the form
function fcnCheckedTimesArrayAddSlavedTimes(f, bPostToDMR) {
	var aCheckedTimes = new Array();
	var x = 0; //index counter
	
	if (bPostToDMR)
		aLT = fcnDMRLTArray(); //get the dmr formatted array of all possible listening times
	else
		aLT = fcnUMLTArray(); //get the UM formatted array of all possible listening times
	
	//loop through all elements, creating index array containing checked listening times
	for(var i=0; i < f.length; i++)
	{
		var e = f.elements[i];
		
		//if this is a listening time field in the form...
		if ( (e.type == "checkbox") && ( e.name.substring(0,1).toUpperCase() == "M" || e.name.substring(0,1).toUpperCase() == "T" || e.name.substring(0,1).toUpperCase() == "W" || e.name.substring(0,1).toUpperCase() == "H" || e.name.substring(0,1).toUpperCase() == "F" || e.name.substring(0,1).toUpperCase() == "S" || e.name.substring(0,1).toUpperCase() == "U") )
		{
			//iterate over each time in the array aLT
			for(var a=0; a < aLT.length; a++) 
			{
				//if we find a match...meaning this is a valid listening time...
				if( (e.name == aLT[a]) )
				{
					//and the checkbox is checked...
					if( e.checked )
					{
						//add it to the checkedTimes array
						aCheckedTimes[x] = e.name;
						x++;
					}
				}
			} //end LT array for loop
		} // end if
	} //end element for loop	
	
	//document.getElementById("divMissingLTs").innerHTML = strHTML.join("");
	return aCheckedTimes;	
}

//searches a comma seperated values string for a specified value
function fcnValueFound(valToFind, stringToSearch) {
	var aVals = stringToSearch.split(","); //split csv string into an array
	for(var i=0; i < aVals.length; i++) //iterate over values, testing each one
	{	
		val = aVals[i]; //the value to test
 		
		if(	val.trim() == valToFind.trim() ) 
			return true; //the value is found, stop iterating and return true
	}
	
	//if we got here, the value wasn't found
	return false;
}

//UnityMail Format Listening Times Array
function fcnUMLTArray() {
    var aLT = new Array();

	aLT[0] = "m1";
	aLT[1] = "m2";
	aLT[2] = "m3";
	aLT[3] = "m4";
	aLT[4] = "m5";
	aLT[5] = "m6";
	aLT[6] = "m7";
	aLT[7] = "m8";
	aLT[8] = "m9"
	aLT[9] = "m10";
	aLT[10] = "m11";
	aLT[11] = "m12";
	aLT[12] = "m13";

	aLT[13] = "t1";
	aLT[14] = "t2";
	aLT[15] = "t3";
	aLT[16] = "t4";
	aLT[17] = "t5";
	aLT[18] = "t6";
	aLT[19] = "t7";
	aLT[20] = "t8";
	aLT[21] = "t9";
	aLT[22] = "t10";
	aLT[23] = "t11";
	aLT[24] = "t12";
	aLT[25] = "t13";
	
	aLT[26] = "w1";
	aLT[27] = "w2";
	aLT[28] = "w3";
	aLT[29] = "w4";
	aLT[30] = "w5";
	aLT[31] = "w6";
	aLT[32] = "w7";
	aLT[33] = "w8";
	aLT[34] = "w9";
	aLT[35] = "w10";
	aLT[36] = "w11";
	aLT[37] = "w12";
	aLT[38] = "w13";
	
	aLT[39] = "h1";
	aLT[40] = "h2";
	aLT[41] = "h3";
	aLT[42] = "h4";
	aLT[43] = "h5";
	aLT[44] = "h6";
	aLT[45] = "h7";
	aLT[46] = "h8";
	aLT[47] = "h9";
	aLT[48] = "h10";
	aLT[49] = "h11";
	aLT[50] = "h12";
	aLT[51] = "h13";
	
	aLT[52] = "f1";
	aLT[53] = "f2";
	aLT[54] = "f3";
	aLT[55] = "f4";
	aLT[56] = "f5";
	aLT[57] = "f6";
	aLT[58] = "f7";
	aLT[59] = "f8";
	aLT[60] = "f9";
	aLT[61] = "f10";
	aLT[62] = "f11";
	aLT[63] = "f12";
	aLT[64] = "f13";
	
	aLT[65] = "s1";
	aLT[66] = "s2";
	aLT[67] = "s3";
	aLT[68] = "s4";
	aLT[69] = "s5";
	aLT[70] = "s6";
	aLT[71] = "s7";
	aLT[72] = "s8";
	aLT[73] = "s9";
	aLT[74] = "s10";
	aLT[75] = "s11";
	aLT[76] = "s12";
	aLT[77] = "s13";
	
	aLT[78] = "u1";
	aLT[79] = "u2";
	aLT[80] = "u3";
	aLT[81] = "u4";
	aLT[82] = "u5";
	aLT[83] = "u6";
	aLT[84] = "u7";
	aLT[85] = "u8";
	aLT[86] = "u9";
	aLT[87] = "u10";
	aLT[88] = "u11";
	aLT[89] = "u12";
	aLT[90] = "u13";
	
	return aLT;
}

//dmr Format Listening Times Array
function fcnDMRLTArray() {
    var aLT = new Array();

	aLT[0] = "mon1";
	aLT[1] = "mon2";
	aLT[2] = "mon3";
	aLT[3] = "mon4";
	aLT[4] = "mon5";
	aLT[5] = "mon6";
	aLT[6] = "mon7";
	aLT[7] = "mon8";
	aLT[8] = "mon9";
	aLT[9] = "mon10";
	aLT[10] = "mon11";
	aLT[11] = "mon12";
	aLT[12] = "mon13";

	aLT[13] = "tue1";
	aLT[14] = "tue2";
	aLT[15] = "tue3";
	aLT[16] = "tue4";
	aLT[17] = "tue5";
	aLT[18] = "tue6";
	aLT[19] = "tue7";
	aLT[20] = "tue8";
	aLT[21] = "tue9";
	aLT[22] = "tue10";
	aLT[23] = "tue11";
	aLT[24] = "tue12";
	aLT[25] = "tue13";
	
	aLT[26] = "wed1";
	aLT[27] = "wed2";
	aLT[28] = "wed3";
	aLT[29] = "wed4";
	aLT[30] = "wed5";
	aLT[31] = "wed6";
	aLT[32] = "wed7";
	aLT[33] = "wed8";
	aLT[34] = "wed9";
	aLT[35] = "wed10";
	aLT[36] = "wed11";
	aLT[37] = "wed12";
	aLT[38] = "wed13";
	
	aLT[39] = "thu1";
	aLT[40] = "thu2";
	aLT[41] = "thu3";
	aLT[42] = "thu4";
	aLT[43] = "thu5";
	aLT[44] = "thu6";
	aLT[45] = "thu7";
	aLT[46] = "thu8";
	aLT[47] = "thu9";
	aLT[48] = "thu10";
	aLT[49] = "thu11";
	aLT[50] = "thu12";
	aLT[51] = "thu13";
	
	aLT[52] = "fri1";
	aLT[53] = "fri2";
	aLT[54] = "fri3";
	aLT[55] = "fri4";
	aLT[56] = "fri5";
	aLT[57] = "fri6";
	aLT[58] = "fri7";
	aLT[59] = "fri8";
	aLT[60] = "fri9";
	aLT[61] = "fri10";
	aLT[62] = "fri11";
	aLT[63] = "fri12";
	aLT[64] = "fri13";
	
	aLT[65] = "sat1";
	aLT[66] = "sat2";
	aLT[67] = "sat3";
	aLT[68] = "sat4";
	aLT[69] = "sat5";
	aLT[70] = "sat6";
	aLT[71] = "sat7";
	aLT[72] = "sat8";
	aLT[73] = "sat9";
	aLT[74] = "sat10";
	aLT[75] = "sat11";
	aLT[76] = "sat12";
	aLT[77] = "sat13";
	
	aLT[78] = "sun1";
	aLT[79] = "sun2";
	aLT[80] = "sun3";
	aLT[81] = "sun4";
	aLT[82] = "sun5";
	aLT[83] = "sun6";
	aLT[84] = "sun7";
	aLT[85] = "sun8";
	aLT[86] = "sun9";
	aLT[87] = "sun10";
	aLT[88] = "sun11";
	aLT[89] = "sun12";
	aLT[90] = "sun13";
	
	return aLT;
}