//----------------------------------------------------------------
//Check the value of Error control on the page, then display the 
//content as an error message.
//----------------------------------------------------------------
function fncCheckError() {   
	if (Maint.error.value != "")
		alert(Maint.error.value);
}

function RefreshStateList(pArray, pCtry, pState) {
	pState.innerText = "";
	if (pCtry != "NOL") {
		var newOption = new Option("          ", "")
		pState[pState.length] = newOption;
	}

	if (pCtry == "NOL" || pCtry != "") {
		var newOption = new Option("Not Listed", "NOL")
		pState[pState.length] = newOption;
	}
	for (i = 0; i < pArray.length; i++) {
		if (pArray[i][0] == pCtry) {
			var newOption = new Option(pArray[i][2], pArray[i][1])
			// put the new option at the end of the current list
			pState[pState.length] = newOption;
		}
	}
}

//LTrim(string) : Returns a copy of a string without leading spaces.
function LTrim(str)
/*
    PURPOSE: Remove leading blanks from our string.
    IN: str - the string we want to LTrim
*/
{
    var whitespace = new String(" \t\n\r");

    var s = new String(str);

    if (whitespace.indexOf(s.charAt(0)) != -1) {
        // We have a string with leading blank(s)...

        var j=0, i = s.length;

        // Iterate from the far left of string until we
        // don't have any more whitespace...
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
            j++;


        // Get the substring from the first non-whitespace
        // character to the end of the string...
        s = s.substring(j, i);
    }

    return s;
}


//RTrim(string) : Returns a copy of a string without trailing spaces.
function RTrim(str)
/*
    PURPOSE: Remove trailing blanks from our string.
    IN: str - the string we want to RTrim

*/
{
    // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
    // "trim" here in Whitespace
    var whitespace = new String(" \t\n\r");

    var s = new String(str);

    if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
        // We have a string with trailing blank(s)...

        var i = s.length - 1;       // Get length of string

        // Iterate from the far right of string until we
        // don't have any more whitespace...
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
            i--;


        // Get the substring from the front of the string to
        // where the last non-whitespace character is...
        s = s.substring(0, i+1);
    }

    return s;
}


//Trim(string) : Returns a copy of a string without leading or trailing spaces
function Trim(str)
/*
    PURPOSE: Remove trailing and leading blanks from our string.
    IN: str - the string we want to Trim

    RETVAL: A Trimmed string!
*/
{
    return RTrim(LTrim(str));
}



//----------------------------------------------------------------
//Search the list box for the string entered.
//----------------------------------------------------------------
var strPrevSearchStr="";
function fncSearchList(strListBoxId, strSearchStrId) {
 	var objListBox = document.all.item(strListBoxId);
	var objSearchStr = document.all.item(strSearchStrId);
	//var objListBox = strListBoxId;
	//var objSearchStr = strSearchStrId;
	var strTemp = objSearchStr.value;
	var intStart, strOptionText;
	if (strTemp == "")	{
		alert("Enter a string to search for");
		objSearchStr.focus();
	}
	else {
		if (strTemp.toLowerCase() == strPrevSearchStr)
		  intStart = objListBox.selectedIndex + 1;
		else
		  intStart = 0;
		
		for (var i=intStart;i<objListBox.length;i++) {
			strOptionText = objListBox.options(i).text.toLowerCase();
			if (strOptionText.indexOf(strTemp.toLowerCase(), 0) >= 0) {
				objListBox.selectedIndex = i;
				if (document.all.lblCount) 
					document.all.lblCount.innerText = i;
			strPrevSearchStr = strTemp.toLowerCase();
				return;
			}
		}
		if (strTemp.toLowerCase() == strPrevSearchStr) {
			alert("Reached end of the List");
			strPrevSearchStr = "";
		}
		else {
			alert("Search string '" + strTemp + "' not found");
			objSearchStr.focus();
		}
	}
	return;
}
//----------------------------------------------------------------

//----------------------------------------------------------------
//DisplayComments(string,strHead) : Displays the comment
//----------------------------------------------------------------

function DisplayComments(strComments, strHead) {
	if((!strComments) || (strComments == ""))
	{
		txtDispComments.style.display = "none";
	}
	else
	{	var strHTML;	
		var intWidth = 500 ;
		while(strComments.search('\r\n') >0)
		{	strComments = strComments.replace('\r\n','<br>');
		}
		strHTML = "<div class=clComments><center><b>" + strHead + "</b></center><hr>" + strComments + "</div>"
		txtDispComments.style.left = (document.body.clientWidth - intWidth ) /2 
		txtDispComments.style.top  = window.event.clientY + 20;
		txtDispComments.innerHTML = strHTML;
		txtDispComments.style.display = "inline";
		
	}	
}
//----------------------------------------------------------------

//----------------------------------------------------------------
//DisplayComments(string,strHead) : Displays the comment
//----------------------------------------------------------------

function DisplaySMComments(strComments, strHead) {
var cname, caddress, ccity, cstate, czip, ccountry, ss
	if((!strComments) || (strComments == ""))
	{
		txtDispComments.style.display = "none";
	}
	else
	{	var strHTML;	
		var intWidth = 500 ;
		ss = strComments.split('|');
		cname = ss[1];
		caddress = ss[2] + ss[3] + ss[4];
		ccity = ss[5];
		cstate = ss[6];
		czip = ss[7];
		ccountry = ss[8];

//		while(strComments.search('\r\n') >0)
//		{	strComments = strComments.replace('\r\n','<br>');
//		}
		strHTML = "<div class=clComments><center><b>" + strHead + "</b></center><hr>" 
		strHTML = strHTML + "<b> Company Name : </b> &nbsp; " + cname + "<br>"; 
		strHTML = strHTML + "<b> Address : </b> &nbsp; " + caddress + "<br>"; 
		strHTML = strHTML + "<b> City : </b> &nbsp; " + ccity + "<br>"; 
		strHTML = strHTML + "<b> State : </b> &nbsp; " + cstate + "<br>"; 
		strHTML = strHTML + "<b> Zip : </b> &nbsp; " + czip + "<br>"; 
		strHTML = strHTML + "<b> Country : </b> &nbsp; " + ccountry + "<br>"; 
		strHTML = strHTML + "</div>"
		txtDispComments.style.left = (document.body.clientWidth - intWidth ) /2 
		txtDispComments.style.top  = window.event.clientY + 20;
		txtDispComments.innerHTML = strHTML;
		txtDispComments.style.display = "inline";
		
	}	
}
//----------------------------------------------------------------

//----------------------------------------------------------------
//GetComments(string,strHead) : Get the comments
//----------------------------------------------------------------

function GetCommentData(that,strHead)
{
	if(that.value==null){strArgVal = "" } else {strArgVal = that.value};
	var strUrl = '../comments.asp?Heading=' + strHead
	var strComment = window.showModalDialog(strUrl,strArgVal,'dialogHeight: 300px; dialogWidth: 500px; dialogTop: 300px; dialogLeft: 300px; center: Yes; help: Yes; resizable: Yes; status: Yes;')
	if (strComment == -1 || strComment == null)
        {that.value = ''}
	else {that.value = strComment ;}
}
//----------------------------------------------------------------

//----------------------------------------------------------------
//Get Report Comments(string) : Get the comments
//----------------------------------------------------------------

function GetReportComment(that)
{
//	if(that.value==null){strArgVal = "" } else {strArgVal = that.value};
	var strUrl = '../ReportComments.asp'
	var strComment = window.showModalDialog(strUrl,'','dialogHeight: 300px; dialogWidth: 500px; dialogTop: 300px; dialogLeft: 300px; center: Yes; help: Yes; resizable: Yes; status: Yes;')
	if (strComment == -1 || strComment == null)
        {that.value = ''}
	else {that.value = strComment ;}
}
//----------------------------------------------------------------



//----------------------------------------------------------------
//GetOwner(string) : Get the owner
//----------------------------------------------------------------

function GetOwner(that)
{
	if(that.value==null){strArgVal = "" } else {strArgVal = that.value};
	var strUrl = '../WarrantyFlow/ExistOwner.asp?' 
	var strComment = window.showModalDialog(strUrl,strArgVal,'dialogHeight: 200px; dialogWidth: 500px; dialogTop: 300px; dialogLeft: 300px; center: Yes; help: Yes; resizable: Yes; status: Yes;')
	if (strComment == -1 || strComment == null)
        {that.value = 'cancel'}
	else {that.value = strComment ;}
}
//----------------------------------------------------------------

//----------------------------------------------------------------
//replaceSample(string) : Get the owner
//----------------------------------------------------------------

function replaceSample(that,returnThis)
{   var ss, bId, sId, tValue,Type, smData, status;
	if(that.value==null){strArgVal = "" } else {strArgVal = that.value};
	
	ss = that.split('|');
	bId = ss[0];
	sId = ss[1];
	tValue = ss[2];
	Type = ss[3];
	smData = ss[4];
	status = ss[5];

	var strUrl = '../Sealant/Sealant_SampleReplace.asp?Building_id=' + bId + '&Sample_Id=' + sId + '&TypeValue=' + tValue + '&Type=' + Type + '&SMData=' + smData + '&Status=' + status; 
	var strComment = window.showModalDialog(strUrl,strArgVal,'dialogHeight: 450px; dialogWidth: 550px; dialogTop: 200px; dialogLeft: 200px; center: Yes; help: Yes; resizable: Yes; status: Yes;')
	if (strComment == -1 || strComment == null)
        {returnThis.value = ''}
	else {returnThis.value = strComment ;}
}
//----------------------------------------------------------------


<!--
/************************************************************************
*Include Name:				string_functions.inc						*
*Version:					2.0											*
*Last Modification Date:	10/17/2000									*
*Last Modified By:			STJOBE										*
*************************************************************************
*string_functions.inc contains code to extend the javascript string		*
*function.  Contains the following functions:							*
*ClientCode:															*
*-----------------------------------------------------------------------*
*strim	-- string.trim()												*
*************************************************************************/

//Adds another method to javascript string object. 
//Method executes strim() function declared below.
String.prototype.trim = strim; 

/************************************************************************
*STRIM																	*
*************************************************************************
*Description:															*
*      Extends the string object adding String.trim.  String.trim		*
*	   removes spaces from beginning and end of the string.	  Call		*
*	   by coding string_variable.trim()									*
*Arguments:																*
*		string to trim													*
*Returns:																*
*       trimmed string													*
*																		*
*Created/Modified:														*
* User Name		Date		Description									*
* STJOBE		1999		Original Version							*
* STJOBE		10/17/2000	Comments Added								*
*************************************************************************/
function strim() { 
	var v, ileft, iright;
	
	v = this; 
	
	ileft = 0;
	iright = v.length - 1; 
	
	
	while (v.charAt(ileft) == ' ') ileft++; 
	
	while ((v.charAt(iright) == ' ') && (iright > ileft)) iright--; 
	
	return v.substring(ileft,iright+1); 
} 

//----------------------------------------------------------------
//Append "&nbsp;" for each space required. This is used to align
//string in the HTML.
//----------------------------------------------------------------
function appendSpaces(strText, intLen)
{
	var intCnt;
	intCnt = strText.length;
	if (intCnt > intLen)
		strText = strText.substr(1,intLen);
	else {
		for (intCnt = intCnt + 1; intCnt <= intLen ; intCnt ++)
			strText = strText + " ";
	}
	return (strText);
}

function CheckNumeric(pObj) {
	var strTemp;
	strTemp = pObj.value;
	if (isNaN(strTemp)) {
		alert("Field is numeric!");
		pObj.focus();
	}
}

//If pKey exists in pArray then returns the index of the array, otherwise returns -1.
function SearchArray(pArray, pKey) {
	var bottom, top;	
	top = pArray.length - 1;
	for (bottom=0; bottom <= top; bottom++)
	{
		if (pArray[bottom][0] == pKey) 
			return bottom;
		
	}
	retun -1;
	
}


//-->

