/* Enable & Disable Scripts */	
function QTL_TBEnable(objText, boolClear) {
	if (boolClear == true) {
		objText.value = "";
	}
	objText.disabled = false;
}

function QTL_TBDisable(objText, boolClear) {
	if (boolClear == true) {
		objText.value = "";
	}
	objText.disabled = true;
}

function QTL_ButtonEnable(objButton) {
	objButton.disabled = false;
}

function QTL_ButtonDisable(objButton) {
  objButton.className = objButton.IdleCSS;
	objButton.disabled = true;
}					


/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Class       : None                                                                                         */
/* Method      : PositionDDL                                                                                  */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Positions The Drop Down List at the First Occurance of the Specified Value.                  */
/*                                                                                                            */
/* Arguments   : objDDL   - The Drop Down List to Position.                                                   */
/*               intValue - The Value to find in the Drop Down List.                                          */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/

function PositionDDL(objDDL, intValue) {
	var intDDLCounter = objDDL.options.length;
	for (var intTCount = 0; intTCount < intDDLCounter; intTCount++) {
		if (objDDL.options[intTCount].value == intValue) {
			objDDL.selectedIndex = intTCount;
			return true;
		}
	}
}

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Method      : PositionDDLByText                                                                            */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Positions The Drop Down List at the First Occurance of the Specified Text.                   */
/*                                                                                                            */
/* Arguments   : objDDL  - The Drop Down List to Position.                                                    */
/*               strText - The Text to find in the Drop Down List.                                            */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/

function PositionDDLByText(objDDL, strText) {
	var intDDLCounter = objDDL.options.length;
	for (var intTCount = 0; intTCount < intDDLCounter; intTCount++) {
		if (objDDL.options[intTCount].text == strText) {
			objDDL.selectedIndex = intTCount;
			return true;
		}
	}
}

function QTL_CInt(strValue) {
	try {
		strValue = strValue.TrimString();
		strValue = strValue.TrimLeadingZeros();
	}
	catch (ex) {
	}
	if (strValue == '') {
		return 0;
	}
	else if (isNaN(parseInt(strValue)) == true) {
		return 0;
	}
	else {
		return parseInt(strValue);
	}
}

function QTL_CFloat(strValue) {
	try {
		strValue = strValue.TrimString();
	}
	catch (ex) {
	}
	if (strValue == '') {
		return 0;
	}
	else if (isNaN(parseFloat(strValue)) == true) {
		return 0;
	}
	else {
		return parseFloat(strValue);
	}
}

function GetDDLValue(objDDL) {
	return objDDL.options[objDDL.selectedIndex].value;
}

function GetDDLText(objDDL) {
	return objDDL.options[objDDL.selectedIndex].text;
}

function GetDDLTextByValue(objDDL, intValue) {
	var intDDLCounter = objDDL.options.length;
	for (var intTCount = 0; intTCount < intDDLCounter; intTCount++) {
		if (objDDL.options[intTCount].value == intValue) {
			return objDDL.options[intTCount].text;
		}
	}
	return '';
}

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Method      : BinTheBox                                                                                    */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Reads a Checkbox's State and Returns a 1 for Checked or a 0 for Not Checked.                 */
/*                                                                                                            */
/* Arguments   : objCheck   - The Checkbox to Read.                                                           */
/*                                                                                                            */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/

function BinTheBox(objCheck) {
	if (objCheck.checked == true) {
		return 1;
	}
	else {
		return 0;
	}
}

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Method      : BoxTheBin                                                                                    */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Checks/Unchecks A Check Box Based on a 0 or 1 input.                                         */
/*                                                                                                            */
/* Arguments   : objCheck   - The Checkbox to Modify.                                                         */
/*               intChecked - The 0 or 1 Value to Apply to the Checkbox.                                      */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/

function BoxTheBin(objCheck, intChecked) {
	if (intChecked == 1) {
		objCheck.checked = true
	}
	else {
		objCheck.checked = false
	}
}

/*  HTML Table Support Functions */

function QTL_DeleteTableRows(objTable) {
	for (var intCounter = (objTable.rows.length - 1); intCounter >= 0; intCounter--) {
		objTable.deleteRow(intCounter);
	}
}

function QTL_GetCTL(strControlID) {
	return document.getElementById(strControlID);
}

/*CLASS************************** --- © QTLogic 2006 - All Right Reserved --- ***************************CLASS*/
/* Class       : QTL String Extender                                                                          */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Extension to the String Class                                                                */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Class Created.                                                                               */
/*CLASS************************** --- © QTLogic 2006 - All Right Reserved --- ***************************CLASS*/

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Class       : QTL String Extender                                                                          */
/* Method      : TrimString                                                                                   */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Used to trim spaces from the beginning and the end of the String.                            */
/*                                                                                                            */
/* Arguments   : strString - The String to Trim.  If no String specified the one tied to the class is used.   */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
String.prototype.TrimString = function (strString) {
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
   while (strString.charAt(0) == ' ') {
      strString = strString.substring(1);
   }
   while (strString.charAt(strString.length - 1) == ' ') {
      strString = strString.substring(0, strString.length - 1);
   }
   return strString;
}

String.prototype.TrimLeadingZeros = function (strString) {
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
   while (strString.charAt(0) == '0') {
      strString = strString.substring(1);
   }
   return strString;
}

String.prototype.StripNumbers = function (strString) {
	 var strNewString = "";
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
	 var strNumbersMask = "0123456789";
	 for (var intCounter = 0; intCounter < strString.length; intCounter++) {
		if (strNumbersMask.indexOf(strString.substr(intCounter,1)) == -1) {
			strNewString += strString.substr(intCounter,1);
		}
	 }
   return strNewString;
}

String.prototype.KeepNumbers = function (strString) {
	 var strNewString = "";
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
	 var strNumbersMask = "0123456789";
	 for (var intCounter = 0; intCounter < strString.length; intCounter++) {
		if (strNumbersMask.indexOf(strString.substr(intCounter,1)) != -1) {
			strNewString += strString.substr(intCounter,1);
		}
	 }
   return strNewString;
}

String.prototype.KeepNumbersAndDecimal = function (strString) {
	 var strNewString = "";
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
	 var strNumbersMask = "0123456789.";
	 for (var intCounter = 0; intCounter < strString.length; intCounter++) {
		if (strNumbersMask.indexOf(strString.substr(intCounter,1)) != -1) {
			strNewString += strString.substr(intCounter,1);
		}
	 }
   return strNewString;
}

String.prototype.ApplyMask = function (strMask, boolKeepMask, strString) {
	var strNewString = "";
	if (strString == undefined) {
		strString = this;
	}
	if (strString == '') {
		return strString;
	}

	for (var intCounter = 0; intCounter < strString.length; intCounter++) {
		if (boolKeepMask == true) {
			if (strMask.indexOf(strString.substr(intCounter,1)) != -1) {
				strNewString += strString.substr(intCounter,1);
			}
		}
		else {
			if (strMask.indexOf(strString.substr(intCounter,1)) == -1) {
				strNewString += strString.substr(intCounter,1);
			}		
		}
	}
	return strNewString;
}

String.prototype.QTLAJAXUnescape = function (strString) {
	 var strNewString = "";
   if (strString == undefined) {
      strString = this;
   }
   if (strString == '') {
		return strString;
   }
	
	 strNewString = new String(strString).ReplaceAll("&gt;", ">");
	 strNewString = new String(strNewString).ReplaceAll("&lt;", "<");
	 strNewString = new String(strString).ReplaceAll("QTL_GT", ">");
	 strNewString = new String(strNewString).ReplaceAll("QTL_LT", "<");	 
	 strNewString = new String(strNewString).ReplaceAll("&amp;", "&");
   return strNewString;
}


/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Class       : QTL String Extender                                                                          */
/* Method      : CapWord                                                                                      */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Used to Capitolize the first character of the String.                                        */
/*                                                                                                            */
/* Arguments   : strWord - The String to Cap.  If no String specified the one tied to the class is used.      */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
String.prototype.CapWord = function (strWord) {
   if (!strWord) {
      strWord = this;
   }
	var strLetter = strWord.substring(0,1);
	strLetter = strLetter.toUpperCase();
	return (strLetter + strWord.toLowerCase().substring(1, strWord.length));
}

String.prototype.SizeString = function (intSize, boolAddDots, strString) {
	if (!strString) {
		strString = this;
	}
	if (strString.length > intSize) {
		if (boolAddDots == true) {
			return (strString.substring(0, (intSize - 4)) + "...");		
		}
		else {
			return strString.substring(0, (intSize - 1));
		}
	}
	else {
		return strString;
	}
}

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Class       : QTL String Extender                                                                          */
/* Method      : CapPhrase                                                                                    */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Used to Capitolize the first character of each word in the String.                           */
/*                                                                                                            */
/* Arguments   : strPhrase - The String to Cap.  If no String specified the one tied to the class is used.    */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
String.prototype.CapPhrase = function (strPhrase) {
   if (!strPhrase) {
      strPhrase = this;
   }
	var arrWords = strPhrase.split(" ");
	strPhrase = "";
	
	for (var intCounter = 0; intCounter < arrWords.length; intCounter++) {
		strPhrase += arrWords[intCounter].CapWord() + ' ';
	}
	return strPhrase;
}

/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
/* Class       : QTL String Extender                                                                          */
/* Method      : ReplaceAll                                                                                   */
/* Created By  : RadiateLogic                                                                                 */
/* Copyright   : © QTLogic 2006 - All Right Reserved                                                          */
/*                                                                                                            */
/* Description : Used to Replace all the occurances of a character or sub-string in the String.               */
/*                                                                                                            */
/* Arguments   : strFind    - The String or character to Find.                                                */
/*               strReplace - The String or character to Replace the strFind value with.                      */
/*               strPhrase  - The String to manipulate.  If no String specified the one tied to the class     */
/*                           is used.                                                                         */
/*                                                                                                            */
/* History                                                                                                    */
/* -------                                                                                                    */
/* 12/23/2005  - Method Created.                                                                              */
/*METHOD************************** --- © QTLogic 2006 - All Right Reserved --- *************************METHOD*/
String.prototype.ReplaceAll = function (strFind, strReplace, strPhrase) {
  if (!strPhrase) {
    strPhrase = this;
  }
  
  eval('var strRep = /' + strFind + '/g');
  return strPhrase.replace(strRep, strReplace); 
}

function QTL_Date8Digit(dtNow) {
	if (!dtNow) {
		dtNow = new Date();
	}
	var strMonth = parseInt(dtNow.getMonth() + 1).toString();
	var strDay = parseInt(dtNow.getDate()).toString();
	
	if (strMonth.length == 1) {
		strMonth = "0" + strMonth;
	}
	
	if (strDay.length == 1) {
		strDay = "0" + strDay;
	}
	
	return strMonth + strDay + parseInt(dtNow.getFullYear()).toString();
}

function QTL_Date8DigitWithFormat(dtNow) {
	if (!dtNow) {
		dtNow = new Date();
	}
	var strMonth = parseInt(dtNow.getMonth() + 1).toString();
	var strDay = parseInt(dtNow.getDate()).toString();
	
	if (strMonth.length == 1) {
		strMonth = "0" + strMonth;
	}
	
	if (strDay.length == 1) {
		strDay = "0" + strDay;
	}
	
	return strMonth + "/" + strDay + "/" + parseInt(dtNow.getFullYear()).toString();
}

function QTL_GetDateTime(objDate) { 
	if (!objDate) {
		objDate = new Date();
	}
	var intHour = objDate.getHours();
	var intMinutes = objDate.getMinutes();
	var intMonth = objDate.getMonth() + 1;
	var intDay = objDate.getDate();
	var intYear = objDate.getFullYear();
	var strAMPM = "AM";
	
	if (intHour > 12) {
		intHour = (intHour - 12);
		strAMPM = "PM"
	}
	else if (intHour == 12) {
		strAMPM = "PM"
	}
	else if (intHour == 0) {
		intHour = 12;
		strAMPM = "AM";
	}
	
	if (intMinutes < 10) {
		intMinutes = "0" + intMinutes;
	}

	return "" + intMonth + "/" + intDay + "/" + intYear + " " + intHour + ":" + intMinutes + strAMPM;
}

function QTL_GetDateTimeWithSeconds(objDate) {
	if (!objDate) {
		objDate = new Date();
	}
	var intHour = objDate.getHours();
	var intMinutes = objDate.getMinutes();
	var intSeconds = objDate.getSeconds();
	var intMonth = objDate.getMonth() + 1;
	var intDay = objDate.getDate();
	var intYear = objDate.getFullYear();
	var strAMPM = "AM";
	
	if (intHour > 12) {
		intHour = (intHour - 12);
		strAMPM = "PM"
	}
	else if (intHour == 12) {
		strAMPM = "PM"
	}
	else if (intHour == 0) {
		intHour = 12;
		strAMPM = "AM";
	}
	
	if (intMinutes < 10) {
		intMinutes = "0" + intMinutes;
	}
	
	if (intSeconds < 10) {
		intSeconds = "0" + intSeconds;
	}

	return "" + intMonth + "/" + intDay + "/" + intYear + " " + intHour + ":" + intMinutes + ":" + intSeconds + strAMPM;
}
