/*  db: needed to color code in vs, ignored when running
	<script>
*/
/*********************************************************************
'***    Program: selectListItem( objList, strItemValue )
'***    Type: Function
'***
'***    Function: Selects item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemValue  - value to look for. the item with this value gets selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function selectListItem( objList, strItemValue ) {
	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].value == strItemValue) {
			// this item needs to get selected
			objList.options[i].selected = true;
			break;
		}
	}
	return;
}
/*********************************************************************
'***    Function: selectAllListboxOptions
'***
'***    Parameters: 
'***		listbox, - listbox (select-multiple) id/object
'***
'***    Returns: Void
'***    Remarks: selects all options for given listbox id
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 12/22/2010
'*********************************************************************/
function selectAllListboxOptions(listbox) {
    if (listbox == "" || listbox == null)
        return false;

    var objListbox = listbox;

    //get object if argument is not an object
    //expect that its an id string, get by id instead
    if (typeof (objListbox) != "object")
        objListbox = document.getElementById(listbox);

    if (objListbox == null)
        return false;

    var objOptions = objListbox.options;
    if (objOptions == null || objOptions.length == 0) {
        objListbox = null;
        return false;
    }

    //must select all options
    for (var i = 0, len = objOptions.length; i < len; i++) {
        objOptions[i].selected = true;
    }

    objListbox = null

    return true;
}
/*********************************************************************
'***    Program: selectListItemByText( objList, strItemText )
'***    Type: Function
'***
'***    Function: Selects item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemText  - text to look for. the item with this text gets selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function selectListItemByText( objList, strItemText ) {
	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].text == strItemText) {
			// this item needs to get selected
			objList.options[i].selected = true;
			break;
		}
	}
	return;
}

/*********************************************************************
'***    Program: isAlphaAndDigitString(strToCheck) 
'***    Type: Function
'***
'***    Function: Tests a string for presence of alpha and digit chars only
'***
'***    Parameters: 
'***		strToCheck - sting to check for validity
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isAlphaAndDigitString(strToCheck) {
  var checkOK = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.@%*()#"';
  var checkStr = strToCheck;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  return (allValid);
}

/*********************************************************************
'***    Program: isAlphaAndDigitEntry(objText) 
'***    Type: Function
'***
'***    Function: Checks a text box object's value for alpha and digit chars only
'***
'***    Parameters: 
'***		objText - object to check value in
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isAlphaAndDigitEntry(objText) {
  return (isAlphaAndDigitString(objText.value));
}

/*********************************************************************
'***    Program: isObjectOnForm(objForm, strObjName)
'***    Type: Function
'***
'***    Function: Checks whether an object exists on a given form 
'***
'***    Parameters: 
'***		objForm - form object to use when looking for an element
'***		strObjName - name of an object to look for. Case sensitive!
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isObjectOnForm(objForm, strObjName) {
	for (intFormIndex = 0; intFormIndex < objForm.elements.length; intFormIndex++) {
		if (objForm.elements[intFormIndex].name == strObjName) {
			return true;
		}
	}
	return false;
}

/*********************************************************************
'***    Program: getSelectedItems( lstWhereToLook )
'***    Type: Function
'***
'***    Function: Enumerates through a list box and returns a comma separated list of selected
'***		items
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/30/99
'*********************************************************************/
function getSelectedItems( lstWhereToLook ) {
	if (lstWhereToLook == null) {
		return "";
	}

	var strResult = "", intItemIndex = 0;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected) {
			strResult += "," + lstWhereToLook[intItemIndex].value;
		}
	}
	if (strResult.length > 0) {
		return strResult.substring(1); // all but first comma
	}
	
	return strResult;
}

function getListBoxSelectedValue(listbox){
    if (listbox == "" || listbox == null)
        return "";
    
    var objListbox = listbox;
    //get object if argument is not an object
    if(typeof(objListbox) != "object"){ 
        objListbox = document.getElementById(listbox); //expect that its an id string, get by id instead
        
        if(objListbox == null)
            return "";
    }
    
    var strValue = objListbox[objListbox.selectedIndex].value;
    
    return strValue;
}

/*********************************************************************
'***    Program: getSelectedItemCount( lstWhereToLook )
'***    Type: Function
'***
'***    Function: Calculates a number of selected items in a listbox
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***
'***    Returns: interger
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 1/9/07
'*********************************************************************/
function getSelectedItemCount( lstWhereToLook ) {
	if (lstWhereToLook == null) {
		return 0;
	}
	var intCount = 0;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected)
			intCount++;
	}
	return intCount;
}

/*********************************************************************
'***    Program: getSelectedItemTexts( lstWhereToLook )
'***    Type: Function
'***
'***    Function: Enumerates through a list box and returns a comma separated list of selected
'***		item text (display value)
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/30/99
'*********************************************************************/
function getSelectedItemTexts( lstWhereToLook ) {
	if (lstWhereToLook == null) {
		return "";
	}

	var strResult = "" ;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected) {
			strResult += "," + lstWhereToLook[intItemIndex].text;
		}
	}
	if (strResult.length > 0) {
		return strResult.substring(1); // all but first comma
	}
	return strResult
}

/*********************************************************************
'***    Program: getSelectedItemsWithDevider( lstWhereToLook, strDevider )
'***    Type: Function
'***
'***    Function: Enumerates through a list box and returns a "strDevider" separated list of selected
'***		items
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***		strDevider  - Devider 
'***			Sample:	  getSelectedItemsWithDevider( lstWhereToLook, "&NewExistingJobReferences=" )	
'***        
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 9/30/99
'*********************************************************************/
function getSelectedItemsWithDevider( lstWhereToLook, strDevider ) {
	if (lstWhereToLook == null) {
		return "";
	}

	if (strDevider == "") {
		strDevider = ","	
	}

	var strResult = "" ;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected) {
			strResult += strDevider + lstWhereToLook[intItemIndex].value;
		}
	}
	//if (strResult.length > 0) {
	//	return strResult.substring(strDevider.length); // all but first comma
	//}
	
	return strResult
}


/*********************************************************************
'***    Program: getCleanKeywords
'***    Type: Function
'***
'***    Function: Analized incoming string for signs of full text search syntax
'***		and attempts to fix syntax issues by adding "AND" operator if
'***		users do not specify full text search syntax.
'***
'***    Parameters: 
'***		strKeywords - string to analyze
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/7/2001
'*********************************************************************/
function getCleanKeywords( strDirtyKeywords ) {

	var sValue = strDirtyKeywords;
        sValue = " " + strDirtyKeywords;
        
        // remove commers
	sValue = sValue.replace(/(,+)/g, "");
        
        // remove leading and trailing spaces
	sValue = sValue.replace(/(^ *)|( *$)/g, "");

        // replace any number of spaces with just one space
	sValue = sValue.replace(/( +)/g, " ");
	
        if ((sValue.toLowerCase().indexOf(" and ") == -1) && (sValue.toLowerCase().indexOf(" or ") == -1) && (sValue.toLowerCase().indexOf(" near ") == -1)) {

		// no "OR"s and "AND"s
		if (sValue.indexOf('"') == -1)  {
	  
			// replace spaces with " and "
			sValue = sValue.replace(/ /g, " and ");
		}
		else {
			// replace expression in quotes+space with itself following "and "
			re = /(".*" )/g;
			sValue = sValue.replace(re, "$1and ");
		}
	}


	return sValue;
}


/*********************************************************************
'***    Program: getCleanCCNo( strDirtyCCNo )
'***    Type: Function
'***
'***    Function: removes spaces and dashes from given string
'***		
'***
'***    Parameters: 
'***		strDirtyCCNo - string (cc no) to clean
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 5/18/2001
'*********************************************************************/
function getCleanCCNo( strDirtyCCNo ) {
	var strNewString = new String(strDirtyCCNo);
	return strNewString.replace(/[ -]/g, "");
}

/*********************************************************************
'***    Program: unselectListItems( objList )
'***    Type: Function
'***
'***    Function: unselects all item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 5/24/2001
'*********************************************************************/
function unselectListItems( objList ) {
	for (var i=0; i < objList.length; i++) {
		// this item needs to get selected
		objList.options[i].selected = false;
	}
	return 0;
}

/*********************************************************************
'***    Program: isListItemSelected( objList, strItemValue )
'***    Type: Function
'***
'***    Function: unselects all item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemValue - value of item to test
'***
'***    Returns: Boolean
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/13/2001
'*********************************************************************/
function isListItemSelected( objList, strItemValue ) {
	for (var i=0; i < objList.length; i++) {
		// this item needs to get selected
		if (objList.options[i].value == strItemValue) {
			return objList.options[i].selected == 1;
		}
	}
	return false;
}

/*********************************************************************
'***    Program:  isnertFirstElementIntoListObject
'***    Type: Function
'***
'***    Function: Inserts a first element into list object passed into this function as 
'***		parameter.
'***
'***    Parameters: 
'***		objList - object reference. must be a select object
'***		strElementText  - text to use when inserting element
'***		strElementValue - value of new element
'***
'***    Returns: String
'***    Remarks: First element will be selected
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/19/2001
'*********************************************************************/
function isnertFirstElementIntoListObject( objList, strElementText, strElementValue ) {
	arrNewLabels = new Array( objList.length );
	var intOption = 0;

	// save all options
	for (intOption = 0; intOption < objList.length; intOption++) {
		arrNewLabels[intOption] = new Option(  objList.options[intOption].text, objList.options[intOption].value );
	}

	// remove all options
	for (objList.length; intOption >= 0; intOption--) {
		objList.options[intOption] = null;
	}


	// add new first option
	objList.options[0] = new Option(strElementText, strElementValue, true, true );

	// add saved options
	for (intOption = 0; intOption < arrNewLabels.length; intOption++) {
		objList.options[intOption+1] = arrNewLabels[intOption];
	}
 
	return true;
}

/*********************************************************************
'***    Program:  getFullURL( strURL, blnSecure )
'***    Type: Function
'***
'***    Function: Returns a URL that begins with "http://" / "https://"
'***		if base url does not already have it
'***
'***    Parameters: 
'***		strURL - URL to check
'***		blnSecure - if true append "https://"
'***
'***    Returns: String
'***    Remarks: 
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 12/20/2001
'*********************************************************************/
function getFullURL(strURL, blnSecure) {
	var strProtocol = (blnSecure) ? "https://" : "http://";
	var strFinalURL = "";
	if (strURL.toLowerCase().indexOf(strProtocol) == -1) {
		strFinalURL = strProtocol + strURL;
	}
	else {
		strFinalURL = strURL;
	}
	return strFinalURL;
}

/*********************************************************************
'***    Program:  validateAndSubmitBulkAction()
'***    Type: Procedure
'***
'***    Function: on View pages that contain FormBulk, validates input
'***
'***    Parameters: none
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: sofiav
'***    Changed by: niloa
'***    Last change: 07/13/2011
'*********************************************************************/
function validateAndSubmitBulkAction(){
	var blnSelectionMade = false;
	//var strBulkOperation = "";
	var strBulkOperationSelect = false;
	var strBulkOperationName = "";
	
	var frmBulk = eval("document.FormBulk");
	if (frmBulk == null)
	    return;
    
    var blkOperType = frmBulk["BulkOperationType"];
    if (blkOperType == null)
        return;
    
    var blkOptions = blkOperType.options;
    
    //strBulkOperation = BulkOperationType.options[BulkOperationType.selectedIndex].value;
    switch (blkOptions[blkOperType.selectedIndex].value) {
		case "DeleteSelected":
			strBulkOperationSelect = true;
			strBulkOperationName = "delete";
			break;
		case "DeleteFilter":
			strBulkOperationSelect = false;
			strBulkOperationName = "delete";
			break;
		case "DisableSelected":
			strBulkOperationSelect = true;
			strBulkOperationName = "disable";
			break;
		case "DisableFilter":
			strBulkOperationSelect = false;
			strBulkOperationName = "disable";
			break;
		case "EnableSelected":
			strBulkOperationSelect = true;
			strBulkOperationName = "enable";
			break;
		case "EnableFilter":
			strBulkOperationSelect = false;
			strBulkOperationName = "enable";
			break;
		case "ExportSelected":
			strBulkOperationSelect = true;
			strBulkOperationName = "export";
			break;
		case "ExportFilter":
			strBulkOperationSelect = false;
			strBulkOperationName = "export";
			break;

	}
	if (strBulkOperationSelect){
		
		if (elements.length > 0) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == "checkbox") {
					if (elements[i].checked) {
						blnSelectionMade = true;
						break;
					}
				}
			}
		}
		if (!blnSelectionMade) {
			alert("Please select at least one item.")
			return false;
		}

	   	if (confirm('Are you sure you want to ' + strBulkOperationName + ' the selected items?')) {
			//Form name on calling page must be named "FormBulk"
			submit();
		}
	}
	else{
	   	if (confirm('Are you sure you want to ' + strBulkOperationName + ' all items that\nqualify the filter condition?\n\nNOTE: This action can ' + strBulkOperationName + ' all items depending on your filter.')) {
			//Form name on calling page must be named "FormBulk"
			submit();
		}
	}
}
/*********************************************************************
'***    Program:  isUserLoggedIn()
'***    Type: function
'***
'***    Function: Returns True if current user is logged in
'***
'***    Parameters: none
'***
'***    Returns: boolean
'***    Remarks: 
'***
'***    Created by: dimab
'***    Changed by: dimab
'***    Last change: 04/02/01
'*********************************************************************/
function isUserLoggedIn() {
	var strCooke = new String(self.document.cookie);
	return (strCooke.indexOf("FormsAuth") >= 0);
}

/* the following 2 functions determine if em/js is logged in. 
   they will work only if ISSUE_USER_SIGNATURE_COOKIES is true
*/
function isEmLoggedIn() {
	var strCooke = new String(self.document.cookie);
	var re = /\=/g;
	strCooke = strCooke.replace(re, ""); // remove = (addresses browser diff)
	return (strCooke.indexOf("FormsAuth") >= 0 && strCooke.indexOf("EmployerSignature") >= 0 && strCooke.indexOf("JobSeekerSignature;") >= 0);
}
function isJsLoggedIn() {
	var strCooke = new String(self.document.cookie);
	var re = /\=/g;
	strCooke = strCooke.replace(re, ""); // remove = (addresses browser diff)

	return (strCooke.indexOf("FormsAuth") >= 0 && strCooke.indexOf("JobSeekerSignature") >= 0 && strCooke.indexOf("EmployerSignature;") >= 0);
}
/*********************************************************************
'***    Program:  isEmployerUserAccountManager()
'***    Type: function
'***
'***    Function: Returns True if current user is logged in
'***
'***    Parameters: none
'***
'***    Returns: boolean
'***    Remarks: 
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 08/10/07
'*********************************************************************/
function isEmployerUserAccountManager() {
	var strCookie = new String(self.document.cookie);
	return ( isUserLoggedIn() && strCookie.indexOf("EmployerManagerSignature") >= 0 );
}
/*********************************************************************
'***    Program:  isCompanyProfileAvailable()
'***    Type: function
'***
'***    Function: Returns True if current user is logged in and Has company profile on account
'***
'***    Parameters: none
'***
'***    Returns: boolean
'***    Remarks: 
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 08/10/07
'*********************************************************************/
function isCompanyProfileAvailable(){
    var strCookie = new String(self.document.cookie);
    return ( isUserLoggedIn() && strCookie.indexOf("CompanyProfileSignature") >= 0 );
} 
/*********************************************************************
'***    Program:  isOneCheckBoxSelected( objCheckBoxArray )
'***    Type: function
'***
'***    Function: Checks whether at least one checkbox is selelcted within a group
'***
'***    Parameters: none
'***
'***    Returns: boolean
'***    Remarks: 
'***
'***    Created by: dimab
'***    Changed by: dimab
'***    Last change: 04/02/01
'*********************************************************************/
function isCheckBoxSelected( objCheckBoxArray ) {
	if (objCheckBoxArray.length) {
		// Array
		for (var i=0; i < objCheckBoxArray.length; i++) {
			if (objCheckBoxArray[i].checked) {
				return true;
			}
		}
		return false;
	}
	else {
		// single checkbox
		return objCheckBoxArray.checked;
	}
}


/*********************************************************************
'***    Program:  isOneCheckBoxSelected( objCheckBoxArray )
'***    Type: function
'***
'***    Function: Checks whether at least one checkbox is selelcted within a group and returns its value,
'***		or empty string
'***
'***    Parameters: none
'***
'***    Returns: boolean
'***    Remarks: 
'***
'***    Created by: dimab
'***    Changed by: dimab
'***    Last change: 05/08/01
'*********************************************************************/
function getSelectedCheckBoxValue( objCheckBoxArray ) {
	if (objCheckBoxArray.length) {
		// Array
		for (var i=0; i < objCheckBoxArray.length; i++) {
			if (objCheckBoxArray[i].checked) {
				return objCheckBoxArray[i].value;
			}
		}
	}
	else {
		// single checkbox
		if ( objCheckBoxArray.checked ) {
			return objCheckBoxArray.value;
		}
	}
	return "";
}



/*********************************************************************
'***    Program:  removeUnspecifiedValues()
'***    Type: Procedure
'***
'***    Function: on Load Form removes from multiselected list item vith value = "0" ( name = "unspecified" or "-Select-") 
'***
'***    Parameters: FormName 
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: rburdan
'***    Changed by: niloa
'***    Last change: 07/13/2011
'*********************************************************************/
function removeUnspecifiedValues(objForm) {

	if(objForm == null)
	    return;
	var elems = objForm.elements;
	for (var i = 0; i < elems.length; i++) {
	    if (elems[i].type == "select-multiple") {
	        removeUnsepcifiedFromList(elems[i]);
		}
	}
}

/*********************************************************************
'***    Program:  removeUnsepcifiedFromList()
'***    Type: Procedure
'***
'***    Function: on Load Form removes from multiselected list item vith value = "0" ( name = "unspecified" or "-Select-") 
'***
'***    Parameters: FormName 
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 04/18/02
'*********************************************************************/
function removeUnsepcifiedFromList( objList ) {

	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].value == "0") {
			// remove
			objList.options[i] = null;
			return true;
		}
	}
	
	return true;

}



/*********************************************************************
'***    Program:  HasOneTextElementData()
'***    Type: Procedure
'***
'***    Function: Is true if at least one object type="text" contains data.
'***
'***    Parameters: FormName 
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 05/03/02
'*********************************************************************/
function HasOneTextElementData(objForm,strAlertText) {

	with (objForm){

		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == "text") {  
				if ( elements[i].value != "" ){ 	
					return true;
				}
			}
		}
		alert(strAlertText);
		return false;
	}		
}

/*********************************************************************
'***    Program:  HasOneTextElementNonZeroData()
'***    Type: Procedure
'***
'***    Function: Is true if at least one object type="text" contains data 
'***              other than 0 or blank
'***
'***    Parameters: FormName 
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 05/03/02
'*********************************************************************/
function HasOneTextElementNonZeroData(objForm,strAlertText) {

	with (objForm){

		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == "text") {  
				if ( elements[i].value != "" ){ 
					if ( elements[i].value != 0 ){ 	
						return true;
					}
				}
			}
		}
		alert(strAlertText);
		return false;
	}		
}

/*********************************************************************
'***    Program:  HasOneTextElementNonNumericData()
'***    Type: Procedure
'***
'***    Function: Is true if at least one object type="text" contains 
'***				non-numeric data
'***
'***    Parameters: FormName 
'***
'***    Returns: none
'***    Remarks: 
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 05/03/02
'*********************************************************************/
function HasOneTextElementNonNumericData(objForm,strAlertText) {
	var blnNonNumericDataFound = false;
	with (objForm){

		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == "text") {  
				if ( elements[i].value != "" ){ 
					if ( !isDigitString(elements[i].value) ){ 	
						blnNonNumericDataFound = true;
						break;
					}
				}
			}
		}
		if (blnNonNumericDataFound) {
			alert(strAlertText);
		}
	}	
	return blnNonNumericDataFound;
	
}
/*********************************************************************
'***    Program: isDigitString(strToCheck) 
'***    Type: Function
'***
'***    Function: Tests a string for presence of digit chars only
'***
'***    Parameters: 
'***		strToCheck - sting to check for validity
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: jeffl
'***    Changed by: jeffl
'***    Last change: 04/01/02
'*********************************************************************/
function isDigitString(strToCheck) {
  var checkOK = "0123456789.";
  var checkStr = new String(strToCheck);
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  return (allValid);
}


/*********************************************************
'***    Function: parseNumber( value[, defaultValue] )
'***    
'***    Parameters: 
'***        value - value to parse
'***        defaultValue - default value if value is empty
'***        
'***    Returns: returns number
'***    
'***	Remarks: parses and returns values while preserving type (float or int)
'***    
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 09/17/09
'***
**********************************************************/
function parseNumber(value, defaultValue) {
    if (isNaN(parseFloat(defaultValue))) defaultValue = 0;
    
    //parseFloat preserves original type (float or int)
    return isNaN(parseFloat(value)) ? defaultValue : parseFloat(value);
}

/*********************************************************************
'***    Program: isMultiSelectListSelected( objList )
'***    Type: Function
'***
'***    Function: True if at least one item is selected
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemValue - value of item to test
'***
'***    Returns: Boolean
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 05/16/02
'*********************************************************************/
function isMultiSelectListSelected( objList ) {
	for (var i=0; i < objList.length; i++) {
		// if item is selected
		if (objList.options[i].selected) {
			return true;
		}
	}
	return false;
}
/*********************************************************************
'***    Program: setOnChangeInForm
'***    Type: Procedure
'***
'***    Function: goes through the elements of a given form
'***			  and sets onChange/onClick events to setDataChanged(objForm)
'***
'***    Parameters: 
'***		objForm - form 
'***
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 07/12/02
'*********************************************************************/
function setOnChangeInForm(objForm) {
	with (objForm){
		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == "text" || elements[i].type == "textarea" || elements[i].type == "select-one"  || elements[i].type == "select-multiple") {  
				elements[i].onchange = setDataChanged;
				
			}
			if (elements[i].type == "checkbox" || elements[i].type == "radio") {  
				elements[i].onclick = setDataChanged;
			}
		}
	}		
}

/*********************************************************************
'***    Program: isFormDataChanged
'***    Type: Function
'***
'***    Function: returns true if DataChanged textbox value is anything but blank
'***
'***    Parameters: 
'***		objForm - form 
'***
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 07/12/02
'*********************************************************************/
function isFormDataChanged(objForm) {
	var blnReturnValue = false;
	
	if (objForm.DataChanged) {
		if (objForm.DataChanged.value != "") {
			blnReturnValue = true;
		}
	}
	return blnReturnValue;
}

/*********************************************************************
'***    Program: canLeaveForm
'***    Type: Function
'***
'***    Function: returns true if no changes were made to form elements
'***              or user chooses to loose the changes
'***
'***    Parameters: 
'***		objForm - form 
'***
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 07/14/02
'*********************************************************************/
function canLeaveForm(objForm) {
	var blnReturnValue		 = true;
	var strButtonValue		 = "";
	var strButtonValueInPast = "";
	
	if (objForm.submit) {
		strButtonValue = objForm.submit.value
	}
	else {
		strButtonValue = "Add";
	}
	
	if (strButtonValue == "Change") {
		strButtonValueInPast = "changed";
	}
	else {
		strButtonValueInPast = "added";
	}
	
	if (isFormDataChanged(objForm)) {
		if (!confirm("You have entered new information but have not saved it yet.\nYou must press the " + strButtonValue + " button to save your changes.\n\nPress Cancel to return to editing or OK to proceed without saving.")) {
			blnReturnValue = false;
		}	
	}
	return blnReturnValue;
}

/*********************************************************************
'***    Program: setDataChangedInForm
'***    Type: Procedure
'***
'***    Function: changes value of DataChanged hidden element on form
'***
'***    Parameters: 
'***		objForm - form 
'***
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 07/14/02
'*********************************************************************/
function setDataChangedInForm(objForm) {
	if (objForm.DataChanged) {
		objForm.DataChanged.value = 1;
	}
}



/*********************************************************************
'***    Program: escapeKeywords
'***    Type: Function
'***
'***    Function: Analized incoming string for signs of full text search syntax
'***		and attempts to fix syntax issues
'***
'***    Parameters: 
'***		strKeywords - string to analyze
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 07/19/02
'*********************************************************************/
function escapeKeywords( strDirtyKeywords ) {

	var sValue = strDirtyKeywords;

    sValue = escape(sValue).replace(/\x2B/g,'%2B')


	return sValue;
}

/*********************************************************************
'***    Program: stripTextboxText
'***    Type: Function
'***
'***    Function: removes default text in a text box when user places
'***		the cursor in the text box
'***
'***    Parameters: 
'***		objForm - form and element name
'***
'***    Returns: empty string
'***    Remarks: requires "var blnStrippedText = false" variable declaration in calling page
'***
'***    Created by: jeffl
'***    Changed by: jeffl
'***    Last change: 09/19/02
'*********************************************************************/
function stripTextboxText(objFormElement){
	if (! blnStrippedText) {
		objFormElement.value = "";
		blnStrippedText = true ;
	}	
	return;
}



/*********************************************************************
'***    Program: countDelimiters(strToCheck,strDelimiter) 
'***    Type: Function
'***
'***    Function: Tests a string for presence of delimiters
'***
'***    Parameters: 
'***		strToCheck - sting to check for validity
'***        strDelimiter - delimiter string
'*** 
'***    Returns: Qty of found delimiters
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 11/04/02
'*********************************************************************/
function countDelimiters(strToCheck,strDelimiter) {
 
  var checkStr = strToCheck;
  var DelimiterCounter = 0 ;
 
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    if (ch == strDelimiter){
		DelimiterCounter = DelimiterCounter + 1;
    }
  }
  return (DelimiterCounter);
  
}



/*********************************************************************
'***    Program: getCleanKeywordsForJobCompanyName
'***    Type: Function
'***
'***   Function: Analyze incoming string for signs of full text search syntax
'***    	      and attempts to fix syntax issues by removing comers and replacing them with " or" operator.
'***		
'***
'***    Parameters: 
'***		strKeywords - string to analyze
'***
'***    Returns: String
'***    Remarks: none
'***    created by: rburdan
'***    Changed by: 
'***    Last change: 11/15/02
'*********************************************************************/
function getCleanKeywordsForJobCompanyName( strDirtyKeywords ) {

	var sValue = strDirtyKeywords;
        
    // remove leading and trailing spaces
	sValue = sValue.replace(/(^ *)|( *$)/g, "");

    // remove commers and replace them with " or"
	sValue = sValue.replace(/(,+)/g, " or ");
	
    // replace any number of spaces with just one space
	sValue = sValue.replace(/( +)/g, " ");
	

	return sValue;
}

/*********************************************************************
'***    Program: checkAllBoxes
'***    Type: Procedure
'***
'***   Function: puts checkmarks in all checkboxes of the specified array
'***		
'***
'***    Parameters: 
'***		objCheckBoxArray - array of checkboxes
'***
'***    Returns: none
'***    Remarks: none
'***    created by: sofiav
'***    Changed by: 
'***    Last change: 5/7/03
'*********************************************************************/
function checkAllBoxes( objCheckBoxArray ) {
	if (objCheckBoxArray.length) {
		// Array
		for (var i=0; i < objCheckBoxArray.length; i++) {
			objCheckBoxArray[i].checked = true;
		}
	}
	else {
		// single checkbox
		objCheckBoxArray.checked = true;
	}
}

function getVarDate( strDate, strFormat ) {
	var dtmResult = NaN;
	var intMonthPos = -1;
	var intYearPos  = -1;
	var intMonth = 0;
	var intDay = 0;
	var intYear = 0;
	
	if (strFormat != null && strFormat != "" && strDate != "") {
		strFormat = strFormat.toUpperCase();
		
		intMonthPos = strFormat.indexOf("MM");
		intDayPos   = strFormat.indexOf("DD");
		intYearPos  = strFormat.indexOf("YYYY");
		
		if (intDayPos >= 0 && intMonthPos >= 0 && intYearPos >= 0) {
			intMonth = strDate.substr(intMonthPos, 2);
			intDay   = strDate.substr(intDayPos,   2);
			intYear  = strDate.substr(intYearPos,  4);
			
			if (intDay <= 31 && intMonth <= 12 && intYear <= 9999) {
				dtmResult = new Date(intYear, intMonth - 1, intDay).getVarDate();
			}
		}
	}
	return dtmResult;
}

/*********************************************************************
'***    Function: isLeapYear( intYear )
'***
'***    Parameters: 
'***        intYear - year to check for leap year
'***	Return: boolean (true - is a leap year, false - not a leap year)
'***
'***    Remarks:     
'***        //A year is a leap year not only if it is divisible by 4 
'***        //it also has to be divisible by 400 if it is a centurial year. 
'***        //e.g. 1700, 1800 and 1900 were not leap years, but 2000 was.
'***
'***	Use example:
'***		isLeapYear( 2008 ) --> true - is a leap year
'***		isLeapYear( 2009 ) --> false - not a leap year
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 10/07/2009
'*********************************************************************/
function isLeapYear(year) {
    year = parseInt(year);
    if (isNaN(year)) return false;
    return ((year % 4 == 0) && (!(year % 100 == 0) || (year % 400 == 0)));
}

/*********************************************************************
'***    Function: getDaysInMonth( month, year )
'***
'***    Parameters: 
'***		month - month number
'***        year - year to check for leap year
'***	Return: integer
'***
'***    Remarks: get the correct number of days in month for year
'***    considering leap years for february days
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 10/07/2009
'*********************************************************************/
function getDaysInMonth(month, year) {
    month = parseInt(month,10);
    year = parseInt(year);

    if (isNaN(month) || isNaN(year))
        return 0;

    if ((month < 1) || (month > 12) || (year <= 0))
        return 0;

    //check leap year to set Feb days: 28 or 29
    var daysInFeb = isLeapYear(year) ? 29 : 28;
    var days = [0, 31, daysInFeb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    return days[month];
}

function populateAttachedDocumentsOnParentForm(objForm) {
	var strAttachedDocsHTML = "";
	var divAttachedDocs     = null;
	var objAttachDocs = null;

	if (!self.opener.closed) {
		if (navigator.appName == "Netscape") {
			strVersion = new String(navigator.appVersion);
			if (strVersion.charAt(0) >= 5) {
				if (eval('self.opener.document.getElementById("AttachDocs")')) {
					objAttachDocs = self.opener.document.getElementById("AttachDocs");
				}
			}
		}
		else {
			if (eval('self.opener.document.all.AttachDocs')) {
				objAttachDocs = self.opener.document.all.AttachDocs;
			}
		}
		if (objAttachDocs != null) {
			if (eval('objForm.AttachedDocsHTML')) {
				with (objForm) {
					objAttachDocs.innerHTML = AttachedDocsHTML.value;
				}
			}
		}
	}
	CloseCurrentWindow();
}

/*********************************************************************
'***    Program: isCurrencyString(strToCheck) 
'***    Type: Function
'***
'***    Function: Tests a string for presence of digit and formatting chars
'***				$,
'***
'***    Parameters: 
'***		strToCheck - sting to check for validity
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: sofiav
'***    Changed by: sofiav
'***    Last change: 09/23/04
'*********************************************************************/
function isCurrencyString(strToCheck) {
  var checkOK = "0123456789.,$ ";
  var checkStr = strToCheck;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  return (allValid);
}


/*********************************************************************
'***    Program: Trim
'***    Type: Procedure
'***
'***   Function: trims string
'***		
'***
'***    Parameters: 
'***		strToTrim - string
'***
'***    Returns: trim string
'***    Remarks: none
'***    created by: rburdan
'***    Changed by: 
'***    Last change: 11/01/04
'*********************************************************************/

function Trim(strToTrim){
	var strName = new String(strToTrim);

	while(''+strName.charAt(strName.length-1)==' ')
	strName=strName.substring(0,strName.length-1);
	return strName
}


/*********************************************************************
'***    Program: 
'***    Type: 
'***
'***    Function: 
'***		
'***
'***    Parameters: objParentListBox - Parent ListBox
'***	       	    objChildListBox  - Child ListBox
'***
'***    Returns: 
'***    Remarks: none
'***    created by:  rburdan
'***    Changed by:  rburdan
'***    Last change: 04/08/05
'*********************************************************************/
function populateChildListBoxHTML(objParentListBox, objChildListBox, strDefaultText, blnShowDefaultTextIfEmpty){
	var strParentValue = new String("");
	var strParentText = new String("");
	var intParentOption = 0;
	var intChildOption = 0;
	var arrParentSelected = new Array();
	var arrParentTextSelected = new Array();
	var strHTML = "";
	var strChildSelectedItems = new String("");
	var strSelect = "";
	var blnChildHasListOptions = false;

	if (strDefaultText == null) {
		strDefaultText = "Select Parent";
	}
	if (blnShowDefaultTextIfEmpty == null) {
		blnShowDefaultTextIfEmpty = false;
	}

	strParentValue = getSelectedItems(objParentListBox);
	strParentText  = getSelectedItemTexts(objParentListBox);
	
	arrParentSelected = strParentValue.split(",");
	arrParentTextSelected = strParentText.split(",");
	
	if (objChildListBox == null) {
		strChildListBoxName = "cg"; 
		strChildListBoxSize = 11;
		strChildSelectedItems = "";
	}
	else {
		strChildListBoxName = objChildListBox.name;
		strChildListBoxSize = objChildListBox.size;
		// Save Selected Items from Child ListBox
		strChildSelectedItems = getSelectedItems(objChildListBox);
	}
	
	strHTML = " <SELECT NAME='" + strChildListBoxName + "' MULTIPLE SIZE='" + strChildListBoxSize + "'> ";
	
	
	strChildSelectedItems = "," + strChildSelectedItems + ","
	
	for (var intIndex = 0; intIndex < arrParentSelected.length; intIndex++) {

        strParentValue = arrParentSelected[intIndex];
        strParentText = arrParentTextSelected[intIndex];
        
		for (intParentOption = 0; intParentOption < arrDroups.length-1; intParentOption++) {
	
			if(arrDroups[intParentOption].id1 == strParentValue){
			
				if( strChildSelectedItems.indexOf("," + arrDroups[intParentOption].id2 + ","  )  >=0 ){
					strSelect = " SELECTED ";
			    }
			
			    strHTML += " <OPTION VALUE='" + arrDroups[intParentOption].id2 + "'" + strSelect  + ">" + arrDroups[intParentOption].name2 + "</OPTION>";
			
				//alert(arrDroups[intParentOption].name2);
				
				intChildOption += intChildOption;
				strSelect = "";	
				
				blnChildHasListOptions = true;
				
			}
		}
	}
	
	strHTML += " </SELECT> ";

	// Replace Child ListBox with a new Data using DIV id="Child_" + strChildListBoxName
	if (eval('document.getElementById("Child_" + strChildListBoxName)')) {
		var objChild = document.getElementById("Child_" + strChildListBoxName);
		objChild.innerHTML = strHTML;
		if (!blnChildHasListOptions && blnShowDefaultTextIfEmpty) {
			objChild.innerHTML = strDefaultText;
		}
	}

	return true;
}

/*********************************************************************
'***    Program: 
'***    Type: 
'***
'***    Function: 
'***		
'***
'***    Parameters: 
'***		
'***
'***    Returns: 
'***    Remarks: none
'***    created by: rburdan
'***    Changed by: 
'***    Last change: 04/08/05
'*********************************************************************/

function Group(id1, id2, name2){
	this.id1 = id1;

	this.id2 = id2;
	this.name2 = name2;
	
	return true;
}

/*********************************************************************
'***    Program: unSelectListItem( objList, strItemValue )
'***    Type: Function
'***
'***    Function: un-Selects item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemValue  - value to look for. the item with this value gets un-selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function unSelectListItem( objList, strItemValue ) {
	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].value == strItemValue) {
			// this item needs to get selected
			objList.options[i].selected = false;
		}
	}
	return;
}

/*********************************************************************
'***    Program: unSelectListItemByText( objList, strItemText )
'***    Type: Function
'***
'***    Function: un-Selects item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemText  - text to look for. the item with this text gets un-selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function unSelectListItemByText( objList, strItemText ) {
	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].text == strItemText) {
			// this item needs to get unselected
			objList.options[i].selected = false;
		}
	}
	return;
}


/*********************************************************************
'***    Program: isRadioButtonSelectionMade
'***    Type: function
'***
'***   Function: returns true if any radio button of the specified name is 
'***			 selected on the specified form
'***		
'***
'***    Parameters: 
'***		objForm - form object
'***		strRadioName - name of the radiobutton group
'***
'***    Returns: trim string
'***    Remarks: none
'***    created by: rburdan
'***    Changed by: niloa
'***    Last change: 07/13/2011
'*********************************************************************/

function isRadioButtonSelectionMade(objForm, strRadioName) {
	var objButton = null;
	var blnResult = false;
		
	if(objForm != null)//modified to not use eval
		objButton = objForm[strRadioName];//eval(strRadioName)
	
	if (objButton == null)
	    return;
    
	for (var i = 0; i < objButton.length; i++) {
		if (objButton[i].checked) {
			blnResult = true;
			break;
		}
	}
		
	return blnResult;
}


/*********************************************************************
'***    Program: SelectedListItemsLimiter(lstWhereToLook, intItemsLimit, strLimitedItemsName)
'***    Type: Function
'***
'***    Function: 
'***
'***    Parameters: 
'***		lstWhereToLook      - listbox object where to look
'***        intItemsLimit       - items limit
'***		strLimitedItemsName - Name of group( like: "Category" or "Employment Type",...)
'*** 
'*** 
'***    Returns: false if user chose more then intItemsLimit items
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by: rburdan
'***    Last change: 07/08/2005
'*********************************************************************/

function SelectedListItemsLimiter(lstWhereToLook, intItemsLimit, strLimitedItemsName) {
	var strCategories = new String("");
	var intCount = 0;
	
	strCategories = getSelectedItemsWithDevider(lstWhereToLook, ",");
	intCount      = countDelimiters(strCategories, ",");
		
	if(intCount > intItemsLimit){
		alert("Please choose less then " + intItemsLimit + " " + strLimitedItemsName);
		lstWhereToLook.focus();
		return false;
	}
	
	return true;
} 

/*********************************************************************
'***    Program: getNumberOfSelectedCheckboxes
'***    Type: Function
'***
'***    Function: calculates a number of selected checkboxes using the current document's DOM
'***
'***    Parameters: none
'*** 
'***    Returns: integer, a number of checkboxes selected
'***    Remarks: none
'***
'***    Created by: dimab
'***    Changed by: dimab
'***    Last change: 04/18/2007
'*********************************************************************/
function getNumberOfSelectedCheckboxes() {
	var intCheckedCount = 0;
	var objElements = document.getElementsByTagName("input");
	for (intItemIndex = 0; intItemIndex < objElements.length; intItemIndex++) {
		if (objElements[intItemIndex].type=="checkbox" && objElements[intItemIndex].checked)
			intCheckedCount++;
	}
	return intCheckedCount;
}

/*********************************************************************
'***    Program: takes an Option Text value and selects, preserves previous selection
'***    Type: Function
'***
'***    Function: selectListboxOptionByText( objForm, objElement, strNewOptionText ) 
'***
'***    Parameters: objForm, - form the element is on
					objElement, - the element on the form, to select item
					strNewOptionText - Option text value to select
'*** 
'***    Returns: integer, a number of checkboxes selected
'***    Remarks: none
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 07/13/2011
'*********************************************************************/
function selectListboxOptionByText( objForm, objElement, strNewOptionText ){
	var strSelectedItems	= new String( "" );
	var strItemValue		= new String( strNewOptionText );

	if (objForm == null || objElement == null)
	    return;
	
	//Get all listbox options selected 
	strSelectedItems = 	getSelectedItems( objElement );
	
	//check if there are any selected items 
	if( !IsStringEmpty( strSelectedItems ) ){
		//check if new value has been specified to select
		if( !IsStringEmpty( strItemValue ) ){
			for( var iOption = 0; iOption < objElement.options.length; iOption++ ){
				selectListItemByText( objElement, strItemValue );
			}
		}
	}
}	

/*********************************************************************
'***    Program: takes an Option Text value and selects, preserves previous selection
'***    Type: Function
'***
'***    Function: IsStringEmpty( strString )
'***
'***    Parameters: strString - string to check for emptyness
'*** 
'***    Returns: If Emptry: true, else : false
'***    Remarks: none
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 06/28/2007
'*********************************************************************/
function IsStringEmpty( strValue ){
    //check string length or nullness, return true either is true, else false
    return ( 0 == new String( ( strValue == null ) ? "" : Trim(strValue) ).length );
}

/*********************************************************************
'***    Program: tickCheckBoxesByName(objCheckBox)
'***    Type: Function
'***
'***    Function: "select all" specified checkboxes
'***
'***    Parameters: array or single objCheckBox
'***		
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 07/12/2007
'*********************************************************************/
function tickCheckBoxesByName( objCheckBox ){
	var blnExists = ( ( typeof(objCheckBox) == "object" )  && ( objCheckBox[0].type == "checkbox" ) );

    if( blnExists ){
        var intCheckBoxCount = objCheckBox.length;

        if( intCheckBoxCount ){
	        if (isCheckBoxSelected( objCheckBox )){
		        for(var i = 0; i < intCheckBoxCount; i++) objCheckBox[i].checked = false;
	        } else{ 
	            for(var i = 0; i < intCheckBoxCount; i++) objCheckBox[i].checked = true; 
	        }
	    } else {
	        if (isCheckBoxSelected( objCheckBox )){objCheckBox.checked = false;} 
	        else{objCheckBox.checked = true; }	    
	    }
	} else {
	    alert("Either the checkbox does not exist or you may have specified an incorrect name!");
	}
return blnExists;
}

/*********************************************************************
'***    Function: selectAllListOptionsWithToggle( objListBox, blnOnOffToggle )
'***
'***    Parameters: 
'***		objListBox, - listbox (select-multiple) object
'***		blnOnOffToggle - select unselect toggle
'***
'***    Returns: Void
'***    Remarks: no toggle specified functions as select all
'***             with toggle, functions as select/unselect all
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 08/22/2008
'*********************************************************************/
function selectAllListOptionsWithToggle( objListBox, blnOnOffToggle ){
    
    blnOnOffToggle = ( typeof(blnOnOffToggle) == "boolean" ) ? blnOnOffToggle : true;
    var blnIsMultiSelect = (typeof(objListBox) == "object") && 
                            (objListBox.type == "select-multiple");    
    if( blnIsMultiSelect ){
        var objOptions = objListBox.options;

        for (var i=0, optLen = objOptions.length; i < optLen; i++) {
            objOptions[i].selected = blnOnOffToggle;
        }
    }
}

/*********************************************************************
'***    Function: isAllListBoxOptionSelected( objListBox )
'***
'***    Parameters: 
'***		objListBox, - listbox (select-multiple) object
'***
'***    Returns: boolean {all options selected: true | false, otherwise }
'***    Remarks: checks whether all multi-select listbox options are selected
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 08/22/2008
'*********************************************************************/
function isAllListBoxOptionSelected( objListBox ){

    var blnIsMultiSelect = (typeof(objListBox) == "object") && 
                            (objListBox.type == "select-multiple");
    var blnSelected = false;
    if( blnIsMultiSelect ){
        var objOpts = objListBox.options;
        var intOptLen = objOpts.length;
        var intSelOptCount = 0;
	    
	    //for each option, if it is selected increment count
	    for (var i=0; i < intOptLen; i++) {
            //increment count for each option selected
            if(objOpts[i].selected) intSelOptCount++;
	    }
	    //if selected option count == options.length
	    //then every option is selected
	    blnSelected = ( intOptLen == intSelOptCount );
	    objListBox = objOpts = null;
    }
return blnSelected;
}

/*********************************************************************
'***    Function: resetPageSection
'***
'***    Parameters: strDivID - div to show/hide
'***		        strImgID - image to click on to show/hide div
'***
'***    Returns: 
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 12/03/2008
'*********************************************************************/
function resetPageSection( strDivID, strImgID ){

    var objDiv = document.getElementById(strDivID);
    
    if(objDiv.style.visibility == "visible"){
        blnVisible = false;
    }
    else{
        blnVisible = true;
    }
    
    showHidePageSection( strDivID, strImgID, blnVisible);
}

/*********************************************************************
'***    Function: resetPageSection
'***
'***    Parameters: strDivID   - div to show/hide
'***		        strImgID   - image to click on to show/hide div
'***                blnVisible - set show/hide
'***    Returns: 
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 12/03/2008
'*********************************************************************/
function showHidePageSection( strDivID, strImgID,  blnVisible ){
    blnVisible = (typeof(blnVisible) == "boolean") ? blnVisible : false;
    
    var objDiv = document.getElementById(strDivID);
    var objImg = document.getElementById(strImgID);

    if( objDiv != null ){

        objDiv.style.visibility = (blnVisible) ? "visible" : "hidden";
        objDiv.style.position   = (blnVisible) ? "static" : "absolute"; 

        if( objImg != null )
            objImg.src = (blnVisible) ? "/Media/Images/hide.gif" : "/Media/Images/show.gif"; 
        
    }
}

/*********************************************************************
'***    Function: ifCheckBoxSelectedSubmit
'***
'***    Parameters: objForm    - object Html Form
'***		        strMessage - message string
'***                
'***    Returns: 
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 12/12/2008
'*********************************************************************/
function ifCheckBoxSelectedSubmit(objForm, strMessage){

    if(strMessage == null){
        strMessage = "Please select at least one job";
    }
    
	if (! isCheckBoxSelected(objForm.JobID) ) {
		alert(strMessage);
	}
	else {
		objForm.submit();
	}
}

/*********************************************************************
'***    Program: stripTextboxTextEx
'***    Type: Function
'***
'***    Function: removes default text in a text box when user places
'***		the cursor in the text box
'***
'***    Parameters: 
'***		objForm - form and element name
'***
'***    Returns: empty string
'***    Remarks: requires "
'***
'***    Created by: jeffl
'***    Changed by: rburdan
'***    Last change: 12/22/08
'*********************************************************************/
function stripTextboxTextEx(objFormElement){
	objFormElement.value = "";
	return;
}

/*********************************************************************
'***    Program: SelectAllCheckBox()
'***    Type: Function
'***
'***    Function: select all checkbox
'***
'***    Parameters: 
'***		objFormId (optional) - select checkboxes only in given formId (see example on SearchJobs pages)
'***
'***    Created by: jzhou
'***    Changed by: sergeyh
'***    Last change: 07/13/2010
'*********************************************************************/
function SelectAllCheckBoxesWithHighlight(objFormId){
    var blnFirstCheckValue = IsFirstCheckBoxChecked();
    var aDivs = null;
    
    // if given id exist and it is string - getElements only from the form
    if(objFormId != null && typeof(objFormId) == "string" && document.getElementById(objFormId) != null)
        aDivs = document.getElementById(objFormId).getElementsByTagName('input');
    else
        aDivs = document.getElementsByTagName('input');
    
    for(var i = 0; i < aDivs.length; i++){
        if(aDivs[i].type == "checkbox" && aDivs[i].disabled == false){
	        aDivs[i].checked = ! blnFirstCheckValue;
	        highlightParentRow(aDivs[i]);
        }
    }
}

/*
	same as above, but does not highlight rows 
*/
function SelectAllCheckBoxes(objFormId){
	var blnFirstCheckValue = IsFirstCheckBoxChecked();
	var aDivs = null;
    
    // if given id exist and it is string - getElements only from the form
    if(objFormId != null && typeof(objFormId) == "string" && document.getElementById(objFormId) != null)
        aDivs = document.getElementById(objFormId).getElementsByTagName('input');
    else
        aDivs = document.getElementsByTagName('input');

	for(var i = 0; i < aDivs.length; i++) {
		if(aDivs[i].type == "checkbox" && aDivs[i].disabled == false)
			aDivs[i].checked = ! blnFirstCheckValue;
	}
}
/*********************************************************************
'***    Function: determines if 1st checkbox found on the page is checked
'***
'***    Parameters: none
'***    Returns: boolean
'***
'***    Created by: dimab
'***    Changed by: 
'***    Last change: 12/28/2008
'*********************************************************************/
function IsFirstCheckBoxChecked(){
	var aDivs = document.getElementsByTagName('input');
	
	for(var i = 0; i < aDivs.length; i++) {
		if(aDivs[i].type == "checkbox")
			return aDivs[i].checked;
	}
	return false;
}
/*********************************************************************
'***    Function: highlights selected checkboxes on a page
'***
'***    Parameters: 
'***                aDivs [obj] - highlights elements only in specified array
'***    
'***    Returns: void
'***    
'***    Remarks: assumes
'***        1. that each is located in a <td> within <tr>
'***        2. class "highlight" is available in current css
'***        3. based on first assumption, if row is not a TR, skip to next record
'***
'***    Created by: dimab
'***    Changed by: sergeyh
'***    Last change: 06/09/2011
'*********************************************************************/
function HighlightSelectedCheckBoxes(aDivs){
	if(typeof(aDivs) != "object") // if object wasn't set - use items on all page
	    aDivs = document.getElementsByTagName('input');
	
	var row = null, nodeName = "";
	
	for(var i = 0; i < aDivs.length; i++) {
		row = aDivs[i].parentNode.parentNode;
		nodeName = new String(row.nodeName).toLowerCase();

		if ( (aDivs[i].type == "checkbox") && (nodeName == "tr")) {
			if (aDivs[i].checked) {
				// swap classes. use alt
				if (row.className != "highlight")
					row.alt = row.className;
				row.className = "highlight";
			}
			else {
				// swap class back, but only if hightlighed. use alt
				if (row.className == "highlight")
					row.className = row.alt;
			}
		}
	}
}


/*********************************************************************
'***    Function: highlights selected radio button on a page
'***
'***    Parameters: none
'***    Returns: void

assumes:
1. that each is located in a <td> within <tr>
2. class "highlight" is available in current css

'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 08/31/2009
'*********************************************************************/
function highlightSelectedRadioButton() {
    var aInput = document.getElementsByTagName('input');
    var row = null;
    for (var i = 0; i < aInput.length; i++) {
        row = aInput[i].parentNode.parentNode;

        if (aInput[i].type != "radio")
            continue;

        if (aInput[i].checked) {
            // swap classes. use alt
            if (row.className != "highlight")
                row.alt = row.className;
            row.className = "highlight";
        }
        else {
            // swap class back, but only if hightlighed. use alt
            if (row.className == "highlight")
                row.className = row.alt;
        }
    }
} 

/*********************************************************************
***	Function: designed to be called from within a table cell
	un/highlights parent row
***	
***	Parameters: checkBox - instance of checkbox object
***	
***
***	Created by: dimab
***	Modified by: dimab
***	Last modified: 1/22/2008
***
*********************************************************************/
function highlightParentRow( checkBox ){
	var row = checkBox.parentNode.parentNode;
	if (row.nodeName.toLowerCase() != "tr") 
		return;
		
	if (checkBox != null) {
		if (checkBox.checked) {
			// save current class to alt
			row.alt = (row.className == "highlight" ? "" : row.className);
			row.className = "highlight";
		}
		else {
			row.className = (row.alt == "highlight" ? "" : row.alt);
		}
	}
}


/*********************************************************************
'***    Function: showHideDiv
'***
'***    Parameters: strDivID   - div to show/hide
'***                blnVisible - set show/hide
'***    Returns: 
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 01/02/2009
'*********************************************************************/
function showHideDiv( strDivID,  blnVisible ){
	
    blnVisible = (typeof(blnVisible) == "boolean") ? blnVisible : false;
    
    var objDiv = document.getElementById(strDivID);

    if( objDiv != null ){
        objDiv.style.visibility = (blnVisible) ? "visible" : "hidden";
        objDiv.style.position   = (blnVisible) ? "static" : "absolute"; 
    }
}
    
/*********************************************************************
'***    Function: AjaxGet
'***
'***    Parameters: 

			url - url to request
			resultId - id where result is shown (must be visible)
			errorMessage - custom error message in case of http error

'***    Returns: void
'***	Remarks: requires reference to prototype.js
'***
'***    Created by: dimab
'***    Changed by: 
'***    Last change: 14/03/2009
'*********************************************************************/
function AjaxGet( url, resultId, errorMessage ) {
	if (errorMessage == null)
	    errorMessage = "error";
	var settings = null;
	try {
	    var objCnt = jQuery("#" + resultId);
	    settings = {
	        type: 'get',
	        url: url,
	        success: function(data, textStatus, xhr) {
	            objCnt.html(xhr.responseText);
	        },
	        error: function(xhr, textStatus, errorThrown) {
	            objCnt.html(errorMessage);
	        }
	    };

	    jQuery.ajax(settings);
	}
	catch (ex) {
	    settings = { method: 'get',
	        onSuccess: function(transport) {
	            var e = document.getElementById(resultId);
	            if (e != null)
	                e.innerHTML = transport.responseText;
	        },
	        onFailure: function() {
	            var e = document.getElementById(resultId);
	            if (e != null)
	                e.innerHTML = errorMessage;
	        }
	    };
	    new Ajax.Request(url, settings);
	}
	finally {
	    settings = null;
	}
}

/*********************************************************************
'***    Function: AjaxGetWithCallback
'***
'***    Parameters: 
        strURL      - url to issue ajax get
        containerId - elem to update with respnse result
        msgErr      - error msg to set to element if op. failed
        onSuccessFunc - callback func. if op. is successful
'***
'***    Returns: void
'***    Remarks: 
'***    - get all current resume's experience items
'***
'***    Created by: niloa
'***    Changed by: vadymn
'***    Last change: 08/09/2010
'*********************************************************************/
function AjaxGetWithCallback(strURL, containerId, msgErr, onSuccessFunc, onCompleteFunc) {
    msgErr = (msgErr == null) ? "request failed!" : msgErr;
    var settings = null;
    try {
        var objCnt = jQuery("#" + containerId);
        settings = {
            type: 'get',
            url: strURL,
            success: function(data, textStatus, xhr) {
                //if param is not a function, add data to container
                if (typeof (onSuccessFunc) == "function") {
                    onSuccessFunc(xhr);
                }
                //otherwise execute callback function
                else {
                    if (objCnt != null)
                        objCnt.html(xhr.responseText);
                    
                    return;
                }
            },
            complete: function(xhr, textStatus) {
                if (typeof (onCompleteFunc) == "function")
                    onCompleteFunc(xhr);
            },
            error: function(xhr, textStatus, errorThrown) {
                objCnt.html(msgErr);
            }
        }
        jQuery.ajax(settings);
    }
    //always default to using prototype.js functionality
    catch (ex) {
        settings = {
            method: 'get',
            onSuccess: function(transport) {
                if (typeof (onSuccessFunc) == "function") {
                    onSuccessFunc(transport);
                }
                else {//add by vadymn to make onSuccessFunc parameter optional
                    var e = document.getElementById(containerId);
                    if (e != null)
                        e.innerHTML = transport.responseText;
                }
            },
            onComplete: function(transport) {
                if (typeof (onCompleteFunc) == "function")
                    onCompleteFunc(transport);
            },
            onFailure: function(transport) {
                //set error message
                var el = document.getElementById(containerId);
                if (el != null)
                    el.innerHTML = msgErr;
            }
        };
        new Ajax.Request(strURL, settings);
    }
    finally {
        settings = null;
    }
}

/*********************************************************************
'***    Function: AjaxFormSubmit(
'***
'***    Parameters: 
        formID          - form element id submitting the data
        onCompleteFunc  - func ref. to call when op. is complete
        onSuccessFunc   - func ref. to call when op. is successful
        onFailureFunc   - func ref. to call when op. failed
'***
'***    Returns: void
'***    Remarks: 
        - serializes elements as <name> : <value> page
        - submits url on form.action, or current page url
        - calls func ref as callback based on response state
        - depends on prototype.js ajax library
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function AjaxFormSubmit(formID, onCompleteFunc, onSuccessFunc, onFailureFunc) {
    var settings = null;
    try {
        var selector = "#" + formID;
        var objForm = jQuery(selector);
        if (objForm == null)
            return;

        var actionUrl = objForm.attr("action");
        var params = jQuery(selector).serialize();
        
        settings = {
            type: 'get',
            url: actionUrl,
            data: params,
            complete: function(xhr, textStatus) {
                if (typeof (onCompleteFunc) == "function")
                    onCompleteFunc(xhr);
            },
            success: function(data, textStatus, xhr) {
                if (typeof (onSuccessFunc) == "function")
                    onSuccessFunc(xhr);
            },
            error: function(xhr, textStatus, errorThrown) {
                if (typeof (onFailureFunc) == "function")
                    onFailureFunc(xhr);
            }
        }
        
        jQuery.ajax(settings);
    }
    catch (ex) {
        //build options with callback functions
        settings = {
            //call call back when operation is complete
            onComplete: function(transport) {
                if (typeof (onCompleteFunc) == "function")
                    onCompleteFunc(transport);
            },
            //call call back function if operation is sucessful
            onSuccess: function(transport) {
                if (typeof (onSuccessFunc) == "function")
                    onSuccessFunc(transport);
            },
            //call call back function if operation failed
            onFailure: function(transport) {
                if (typeof (onFailureFunc) == "function")
                    onFailureFunc(transport);
            }
        };

        //extended form element request serializes form elements as {<name> : <value>} pair
        //submits to form action url, if no action url foud, it uses current page url
        $(formID).request(settings);
    }
    finally {
        settings = null;
    }
}

/*********************************************************************
'***    Function: getLoadedXmlDoc
'***
'***    Parameters:
'***        xmlData - response xml string to check for error 
'***    Returns: boolean
'***	Remarks:
'***		returns XmlDocument
'***    Format:
'***    Sample XML Error Response
        <response>
            <returnCode>-1</returnCode>
                <result>
                    <error>
                        <number>100</number>
                        <description>Resume Experience was not found.</description>
                        <source/>
                    </error>
                    <error>...<//error>
                </result>
            </response>
'***    Sample XML Success Response
        <response>
            <returnCode>0</returnCode>
            <result>Resume Experience record has been changed.<result>
        </response>
            
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/13/2009
'*********************************************************************/
function getLoadedXmlDoc(xmlData) {
    var xmlDoc = null;

    //return null if response is empty
    if ((xmlData == null) || (xmlData == ""))
        return xmlDoc;

    //to respect different browser implementation, try
    try {//Internet Explorer
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(xmlData);
    }
    catch (e) {//Firefox, Mozilla, Opera, etc.
        try {
            var parser = new DOMParser();
            xmlDoc = parser.parseFromString(xmlData, "text/xml");
            parser = null;
        }
        catch (e) {
            //return null if unable to parse
            xmlDoc = null;
        }
    }
    return xmlDoc;
}

/*********************************************************************
'***    Function: responseHasError
'***
'***    Parameters:
'***        xmlData - response xml string to check for error 
'***    Returns: boolean
'***	Remarks:
'***		returns true if response has error, false otherwise
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/12/2009
'*********************************************************************/
function responseHasError(xmlData) {
    //get a response error code
    var intCode = getResponseCode(xmlData);

    //if code is not 0, error exist, else no error detected
    return (intCode != 0) ? true : false;
}

/*********************************************************************
'***
'***    Function: getResponseErrorMessage
'***
'***    Parameters:
'***				xmlData - response xml to with error messages
'***				
'***    Returns: string
'***	Remarks:
'***		returns "" if no error, error description content if has error
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/12/09
'*********************************************************************/
function getResponseErrorMessage(xmlData) {

    var msgDesc = "";

    try {
        var xmlDoc = getLoadedXmlDoc(xmlData);
        var nodeList = xmlDoc.getElementsByTagName("description");

        //extract the all error descriptions from node list using a loop.
        if (nodeList != null) {
            var i = 0;
            //uncomment loop to get multiple description errors
            //for(i = 0; i < nodeList.length - 1;i++)
            msgDesc += nodeList[i].firstChild.nodeValue + "\n";
        }

        xmlDoc = nodeList = null;
    }
    catch (e) {
        // parsing error message
        msgDesc = "parsing error. unable to parse response";
    }
    return msgDesc;
}

/*********************************************************************
'***
'***    Function: getResponseSuccessMessage
'***
'***    Parameters:
'***				xmlData - response xml string
'***				
'***    Returns: string
'***	Remarks:
'***		returns success message if successful
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/12/09
'*********************************************************************/
function getResponseSuccessMessage(xmlData) {

    var msgDesc = "";

    try {
        //if no response error, grab text from result node
        if (!responseHasError(xmlData)) {
            var xmlDoc = getLoadedXmlDoc(xmlData);
            var objNode = xmlDoc.getElementsByTagName("result");
            //extract the result message, make sure node is not empty (e.g. <result />)
            if (objNode != null && ( objNode[0].firstChild != null) )
                msgDesc = objNode[0].firstChild.nodeValue + "\n";

            xmlDoc = objNode = null;
        }
    }
    catch (e) {
        // parsing error message
        msgDesc = "parsing error. unable to parse response";
    }
    return msgDesc;
}

/*********************************************************************
'***
'***    Function: getResponseMessage
'***
'***    Parameters:
'***        xmlData - response xml string
'***				
'***    Returns: string
'***	Remarks:
'***		returns response message
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/13/09
'*********************************************************************/
function getResponseMessage(xmlData, msgDefault) {
    var msgText = "";
    if (responseHasError(xmlData))
        msgText = getResponseErrorMessage(xmlData);
    else
        msgText = getResponseSuccessMessage(xmlData);

    //if message is empty use specified default message
    if (msgText == "")
        msgText = ((msgDefault == null) ? "" : msgDefault);

    return msgText;
}

/*********************************************************************
'***
'***    Function: getResponseErrorCode
'***
'***    Parameters:
'***				xmlData - response xml to check for error
'***				
'***    Returns: XML string
'***	Remarks:
'***		returns true if response has error
'***
'***    Created  by: niloa
'***    Changed  by: niloa
'***    Last change: 03/13/09
'*********************************************************************/
function getResponseCode(xmlData) {
    var intCode = 0;
    try {
        //load xml data
        var xmlDoc = getLoadedXmlDoc(xmlData);
        //get return code node
        var objNode = xmlDoc.getElementsByTagName("returnCode")[0].childNodes[0];
        if (objNode != null)
            intCode = objNode.nodeValue;
    }
    catch (e) {
        intCode = -100; //parsing error
    }
    return intCode;
}

/*********************************************************************
'***    Function: showElementById
'***
'***    Parameters: 
'***    elemId - element id to show
'***
'***    Returns: void
'***    Remarks: 
'***    - makes elem visible via its display property
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function showElementById(elemId) {
    //get the element
    var el = document.getElementById(elemId);

    //if found, set display property to none (hide)
    if (el != null)
        el.style.display = "block";
}

/*********************************************************************
'***    Function: hideElementById
'***
'***    Parameters: 
'***    elemId - element id to hide
'***
'***    Returns: void
'***    Remarks: 
'***    - makes elem invisible via its display property
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function hideElementById(elemId) {
    //get the element
    var el = document.getElementById(elemId);
    //if found, set display property to none (hide)
    if (el != null)
        el.style.display = "none";
}

/*********************************************************************
'***    Function: toggles element's display property between none and block
'***
'***    Parameters: 
'***    elemId - element id to toggle
'***
'***    Returns: boolean
'***	Remarks: returns the last state of element true-visible, false-hidden
'***
'***    Created by: dimab
'***    Changed by: 
'***    Last change: 10/3/2009
'*********************************************************************/
function toggleElementById(elemId) {
    //get the element
    var el = document.getElementById(elemId);
    //if found, set display property to none (hide)
    if (el != null) {
        if (el.style.display == "none") {
			showElementById(elemId);
			return true;
		}
		else {
			hideElementById(elemId);
			return false;
		}
	}
	return false;
}


/*********************************************************************
'***    Function: setElementClassById
'***
'***    Parameters: 
'***    elemId - element id to show
'***    className - existing css class name to use
'***
'***    Returns: void
'***    Remarks: 
'***    - sets elem css class via its className property
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function setElementClassById(elemId, className) {
    //get element by id
    var el = document.getElementById(elemId);
    if (el != null)
        el.className = className;
}

/*********************************************************************
'***    Function: toggleElementClassById
'***
'***    Parameters: 
'***    elemId     - element id to show
'***
'***    Returns: void
'***    Remarks: 
'***    - alternates element class
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function toggleElementClassById(elemId, className1, className2) {
    var el = document.getElementById(elemId);

    //make sure element exist
    if (el == null)
        return;
    
    //if current class is not className1, change it
    if (el.className != className1)
        setElementClassById(elemId, className1);

    //otherwise, set it to className2
    else
        setElementClassById(elemId, className2);
    return;
}

/*********************************************************************
'***    Function: toggleElementDisplayById
'***
'***    Parameters: 
'***    elemId     - element id to show
'***
'***    Returns: void
'***    Remarks: 
'***    - makes elem visible via its display property
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 03/17/2009
'*********************************************************************/
function toggleElementDisplayById(elemId) {
    var el = document.getElementById(elemId);

    //make sure element exist
    if (el == null)
        return;
    
    //if element is invisible, display it
    if (el.style.display == "none")
        showElementById(elemId);

    //if element is visible, hide it
    else
        hideElementById(elemId);
    
    return;        
}

/*********************************************************************
'***    Program: PopupViewWindow( strURL, strWindow, nWidth, nHeight )
'***    Type: Function
'***
'***    Function: Pops up a new window with displaying the URL passed
'***
'***    Parameters: 
'***		strURL  - the URL to display within the new window
'***
'***	Note: TO GET CONTROL ON TURNNING ON POPUP OR NOT, NEED TO SET CONST SE_SUPPORTS_POPUPS TO true
'***
'***	SE_LINK_SUPPORT_POPUP_WINDOW = true;
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Jeffl
'***    Changed by: Jeffl
'***    Last change: 08/10/01
'*********************************************************************/
function PopupViewWindow( strURL, strWindow, nWidth, nHeight, strToolbar, strStatus, strLocation, strDirectories, strMenubar) {

   var SE_SUPPORTS_POPUPS = true;
   //Default Page
   var strWindowVal = "New";
   //Default Width
   var nWidthVal = new Number(520);
   //Default Height
   var nHeightVal = new Number(600);
   //Default Toolbar
   var strToolbarVal = "no";
   //Default Statusbar
   var strStatusVal = "no";
   //Default Location
   var strLocationVal = "no";
   //Default Directories
   var strDirectoriesVal = "no";
   //Default Menubar
   var strMenubarVal = "no";

   if (strWindow){
     strWindowVal = strWindow
   }
   if (nWidth){
     nWidthVal = nWidth
   }
   if (nHeight){
     nHeightVal = nHeight
   }
   if (strToolbar){
     strToolbarVal = "yes"
   }
   if (strStatus){
     strStatusVal = "yes"
   }
   if (strLocation){
     strLocationVal = "yes"
   }
   if (strDirectories){
     strDirectoriesVal = "yes"
   }
   if (strMenubar){
     strMenubarVal = "yes"
   }

   if (SE_SUPPORTS_POPUPS == (true || null || "")){
		aPopupViewWindowTest = window.open( strURL,strWindowVal,"toolbar=" + strToolbarVal + ",location=" + strLocationVal + ",directories=" + strDirectoriesVal + ",status=" + strStatusVal + ",scrollbars=yes,resizable=yes,width="+nWidthVal.toString()+",height="+nHeightVal.toString()+ ",menubar=" + strMenubarVal);
		aPopupViewWindowTest.focus();	 
   }
   else {
	    window.location.href = strURL;
   }

}

/*********************************************************************
'***    Function: showRemainingChars
'***
'***    Parameters: 
'***    elFieldId - field element id to retrieve text
'***    elMsgId - message container element id 
'***    maxCharCount - maximun characters allowed
'***
'***    Returns: void
'***    Remarks: 
'***    - calculates and updates unused chars for a form field element
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 04/16/2009
'*********************************************************************/
function showRemainingChars(elFieldId, elMsgId, maxCharCount) {

    if (elFieldId == null)
        elFieldId = 'Summary';

    if (elMsgId == null)
        elMsgId = 'charsRemain';

    //max chars allowed
    if (maxCharCount == null)
        maxCharCount = 300;

    var doc = document;
    var elField = doc.getElementById(elFieldId);
    var elMsg = doc.getElementById(elMsgId);
    
    //remaining chars -1 to compensate for lag time
    var intCharsRemain = Math.max(0, (maxCharCount - elField.value.length));
    if (intCharsRemain > maxCharCount)
        intCharsRemain = 0;
    
    //chars over the limit +1 to compensate for lag time
    var charsOver = (elField.value.length - maxCharCount);
    var msg = "remaining characters: " + intCharsRemain;
    if (charsOver > 0)
        msg += " (" + charsOver + " over limit and will be truncated)";
    
    //refresh remaining chars section (subtract -1 due to keypress event delay)
    elMsg.innerHTML = msg;
}

/*********************************************************************
'***    Function: truncateText
'***
'***    Parameters: 
'***    elFieldId - field element id to retrieve text
'***    elMsgId - message container element id 
'***    maxCharCount - maximun characters allowed
'***
'***    Returns: void
'***    Remarks: 
'***    - shortens Form field element text to specified length
'***
'***    Created by: niloa
'***    Changed by: niloa
'***    Last change: 04/16/2009
'*********************************************************************/
function truncateFieldValue(elFieldId, elMsgId, maxCharCount) {

    if (elFieldId == null)
        elFieldId = 'Summary';

    if (elMsgId == null)
        elMsgId = 'charsRemain';

    //max chars allowed
    if (maxCharCount == null)
        maxCharCount = 300;

    //get values and message elements
    var elField = document.getElementById(elFieldId);
    var elMsg = document.getElementById(elMsgId);

    var intCharsRemain = Math.max(0, maxCharCount - elField.value.length);

    //if value's over the limit, shorten to fit, and set messages
    if (elField.value.length > maxCharCount) {
        elField.value = String(Trim(elField.value)).slice(0, maxCharCount);
        var msg = "remaining characters: " + intCharsRemain +
                        " (truncated to maximum length of " + maxCharCount + ")";
        elMsg.innerHTML = msg;
    }
}

/*********************************************************************
'***    Function: initTinyMCE
'***
'***    Parameters: 
'***    elements - list of field element ids to (TinyMCE) rich text
'***    contentClassPath - Cascading Style Sheet (CSS) file name
'***
'***    Returns: void
'***    Remarks: 
'***    - add TinyMCE rich text tool to specified TextArea elements
'***
'***    Created by: niloa
'***    Changed by: sergeyh
'***    Last change: 07/07/2010
'*********************************************************************/
function initTinyMCE(elements, contentClassPath) {
    if (contentClassPath == null)
        contentClassPath = "/Styles/tinyMceContent.css";
    
    tinyMCE.init({
        theme: "advanced",
        mode: "exact",
        elements: elements,
        plugins: "searchreplace,paste,spellchecker",
        
        theme_advanced_layout_manager: "SimpleLayout",
        theme_advanced_buttons1: "bold,italic,underline,|,undo,redo,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,|,search,preview,|,paste,pastetext,pasteword,|,spellchecker",
        theme_advanced_buttons2: "formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons3: "",
        
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        content_css: contentClassPath,
        setup: function(ed) { // remove unsupported html tags before saving to DB
            // gets executed after DOM to HTML string serialization
            ed.onPostProcess.add(function(ed, o){
                //if state get is not set when contents is extracted from editor, just return
                if (!o.get) return;
                //get content text
                var content = new String(o.content);
                
                //pattern to test if text contains any unsupported html tags
                pattern = "(?:&lt;)\s*(?:/?(?:!doctype|html|body|head|title|link|meta|style|script|i?frame|object|embed|param|form|input|textarea|select|option|fieldset|legend)(?:.*?))(?:&gt;)";
                re = new RegExp(pattern, "gim");
                
                //if none of tags are found, do not replace anything
                if(content.match(re) == null) return;
                
                //replace all unsupported html tags with ""
                content = content.replace(re,'');
                o.content = content; // save corrected content
            }); // onPostProcess
        } // end setup
    });
}

/*********************************************************
'***    Program: HTMLdecode
'***
'***    Parameters: value
'***		
'***    Returns: string
'***
'***    Created by: 
'***    Changed by: 
'***    Last change: 06/10/09
'***
**********************************************************/
function HTMLDecode(s) 

{ 

      var out = ""; 

      if (s==null) return; 

  

      var l = s.length; 

      for (var i=0; i<l; i++) 

      { 

            var ch = s.charAt(i); 

            

            if (ch == '&') 

            { 

                  var semicolonIndex = s.indexOf(';', i+1); 

                  

            if (semicolonIndex > 0) 

            { 

                        var entity = s.substring(i + 1, semicolonIndex); 

                        if (entity.length > 1 && entity.charAt(0) == '#') 

                        { 

                              if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X') 

                                    ch = String.fromCharCode(eval('0'+entity.substring(1))); 

                              else 

                                    ch = String.fromCharCode(eval(entity.substring(1))); 

                        } 

                    else 

                      { 

                              switch (entity) 

                              { 

                                    case 'quot': ch = String.fromCharCode(0x0022); break; 

                                    case 'amp': ch = String.fromCharCode(0x0026); break; 

                                    case 'lt': ch = String.fromCharCode(0x003c); break; 

                                    case 'gt': ch = String.fromCharCode(0x003e); break; 

                                    case 'nbsp': ch = String.fromCharCode(0x00a0); break; 

                                    case 'iexcl': ch = String.fromCharCode(0x00a1); break; 

                                    case 'cent': ch = String.fromCharCode(0x00a2); break; 

                                    case 'pound': ch = String.fromCharCode(0x00a3); break; 

                                    case 'curren': ch = String.fromCharCode(0x00a4); break; 

                                    case 'yen': ch = String.fromCharCode(0x00a5); break; 

                                    case 'brvbar': ch = String.fromCharCode(0x00a6); break; 

                                    case 'sect': ch = String.fromCharCode(0x00a7); break; 

                                    case 'uml': ch = String.fromCharCode(0x00a8); break; 

                                    case 'copy': ch = String.fromCharCode(0x00a9); break; 

                                    case 'ordf': ch = String.fromCharCode(0x00aa); break; 

                                    case 'laquo': ch = String.fromCharCode(0x00ab); break; 

                                    case 'not': ch = String.fromCharCode(0x00ac); break; 

                                    case 'shy': ch = String.fromCharCode(0x00ad); break; 

                                    case 'reg': ch = String.fromCharCode(0x00ae); break; 

                                    case 'macr': ch = String.fromCharCode(0x00af); break; 

                                    case 'deg': ch = String.fromCharCode(0x00b0); break; 

                                    case 'plusmn': ch = String.fromCharCode(0x00b1); break; 

                                    case 'sup2': ch = String.fromCharCode(0x00b2); break; 

                                    case 'sup3': ch = String.fromCharCode(0x00b3); break; 

                                    case 'acute': ch = String.fromCharCode(0x00b4); break; 

                                    case 'micro': ch = String.fromCharCode(0x00b5); break; 

                                    case 'para': ch = String.fromCharCode(0x00b6); break; 

                                    case 'middot': ch = String.fromCharCode(0x00b7); break; 

                                    case 'cedil': ch = String.fromCharCode(0x00b8); break; 

                                    case 'sup1': ch = String.fromCharCode(0x00b9); break; 

                                    case 'ordm': ch = String.fromCharCode(0x00ba); break; 

                                    case 'raquo': ch = String.fromCharCode(0x00bb); break; 

                                    case 'frac14': ch = String.fromCharCode(0x00bc); break; 

                                    case 'frac12': ch = String.fromCharCode(0x00bd); break; 

                                    case 'frac34': ch = String.fromCharCode(0x00be); break; 

                                    case 'iquest': ch = String.fromCharCode(0x00bf); break; 

                                    case 'Agrave': ch = String.fromCharCode(0x00c0); break; 

                                    case 'Aacute': ch = String.fromCharCode(0x00c1); break; 

                                    case 'Acirc': ch = String.fromCharCode(0x00c2); break; 

                                    case 'Atilde': ch = String.fromCharCode(0x00c3); break; 

                                    case 'Auml': ch = String.fromCharCode(0x00c4); break; 

                                    case 'Aring': ch = String.fromCharCode(0x00c5); break; 

                                    case 'AElig': ch = String.fromCharCode(0x00c6); break; 

                                    case 'Ccedil': ch = String.fromCharCode(0x00c7); break; 

                                    case 'Egrave': ch = String.fromCharCode(0x00c8); break; 

                                    case 'Eacute': ch = String.fromCharCode(0x00c9); break; 

                                    case 'Ecirc': ch = String.fromCharCode(0x00ca); break; 

                                    case 'Euml': ch = String.fromCharCode(0x00cb); break; 

                                    case 'Igrave': ch = String.fromCharCode(0x00cc); break; 

                                    case 'Iacute': ch = String.fromCharCode(0x00cd); break; 

                                    case 'Icirc': ch = String.fromCharCode(0x00ce ); break; 

                                    case 'Iuml': ch = String.fromCharCode(0x00cf); break; 

                                    case 'ETH': ch = String.fromCharCode(0x00d0); break; 

                                    case 'Ntilde': ch = String.fromCharCode(0x00d1); break; 

                                    case 'Ograve': ch = String.fromCharCode(0x00d2); break; 

                                    case 'Oacute': ch = String.fromCharCode(0x00d3); break; 

                                    case 'Ocirc': ch = String.fromCharCode(0x00d4); break; 

                                    case 'Otilde': ch = String.fromCharCode(0x00d5); break; 

                                    case 'Ouml': ch = String.fromCharCode(0x00d6); break; 

                                    case 'times': ch = String.fromCharCode(0x00d7); break; 

                                    case 'Oslash': ch = String.fromCharCode(0x00d8); break; 

                                    case 'Ugrave': ch = String.fromCharCode(0x00d9); break; 

                                    case 'Uacute': ch = String.fromCharCode(0x00da); break; 

                                    case 'Ucirc': ch = String.fromCharCode(0x00db); break; 

                                    case 'Uuml': ch = String.fromCharCode(0x00dc); break; 

                                    case 'Yacute': ch = String.fromCharCode(0x00dd); break; 

                                    case 'THORN': ch = String.fromCharCode(0x00de); break; 

                                    case 'szlig': ch = String.fromCharCode(0x00df); break; 

                                    case 'agrave': ch = String.fromCharCode(0x00e0); break; 

                                    case 'aacute': ch = String.fromCharCode(0x00e1); break; 

                                    case 'acirc': ch = String.fromCharCode(0x00e2); break; 

                                    case 'atilde': ch = String.fromCharCode(0x00e3); break; 

                                    case 'auml': ch = String.fromCharCode(0x00e4); break; 

                                    case 'aring': ch = String.fromCharCode(0x00e5); break; 

                                    case 'aelig': ch = String.fromCharCode(0x00e6); break; 

                                    case 'ccedil': ch = String.fromCharCode(0x00e7); break; 

                                    case 'egrave': ch = String.fromCharCode(0x00e8); break; 

                                    case 'eacute': ch = String.fromCharCode(0x00e9); break; 

                                    case 'ecirc': ch = String.fromCharCode(0x00ea); break; 

                                    case 'euml': ch = String.fromCharCode(0x00eb); break; 

                                    case 'igrave': ch = String.fromCharCode(0x00ec); break; 

                                    case 'iacute': ch = String.fromCharCode(0x00ed); break; 

                                    case 'icirc': ch = String.fromCharCode(0x00ee); break; 

                                    case 'iuml': ch = String.fromCharCode(0x00ef); break; 

                                    case 'eth': ch = String.fromCharCode(0x00f0); break; 

                                    case 'ntilde': ch = String.fromCharCode(0x00f1); break; 

                                    case 'ograve': ch = String.fromCharCode(0x00f2); break; 

                                    case 'oacute': ch = String.fromCharCode(0x00f3); break; 

                                    case 'ocirc': ch = String.fromCharCode(0x00f4); break; 

                                    case 'otilde': ch = String.fromCharCode(0x00f5); break; 

                                    case 'ouml': ch = String.fromCharCode(0x00f6); break; 

                                    case 'divide': ch = String.fromCharCode(0x00f7); break; 

                                    case 'oslash': ch = String.fromCharCode(0x00f8); break; 

                                    case 'ugrave': ch = String.fromCharCode(0x00f9); break; 

                                    case 'uacute': ch = String.fromCharCode(0x00fa); break; 

                                    case 'ucirc': ch = String.fromCharCode(0x00fb); break; 

                                    case 'uuml': ch = String.fromCharCode(0x00fc); break; 

                                    case 'yacute': ch = String.fromCharCode(0x00fd); break; 

                                    case 'thorn': ch = String.fromCharCode(0x00fe); break; 

                                    case 'yuml': ch = String.fromCharCode(0x00ff); break; 

                                    case 'OElig': ch = String.fromCharCode(0x0152); break; 

                                    case 'oelig': ch = String.fromCharCode(0x0153); break; 

                                    case 'Scaron': ch = String.fromCharCode(0x0160); break; 

                                    case 'scaron': ch = String.fromCharCode(0x0161); break; 

                                    case 'Yuml': ch = String.fromCharCode(0x0178); break; 

                                    case 'fnof': ch = String.fromCharCode(0x0192); break; 

                                    case 'circ': ch = String.fromCharCode(0x02c6); break; 

                                    case 'tilde': ch = String.fromCharCode(0x02dc); break; 

                                    case 'Alpha': ch = String.fromCharCode(0x0391); break; 

                                    case 'Beta': ch = String.fromCharCode(0x0392); break; 

                                    case 'Gamma': ch = String.fromCharCode(0x0393); break; 

                                    case 'Delta': ch = String.fromCharCode(0x0394); break; 

                                    case 'Epsilon': ch = String.fromCharCode(0x0395); break; 

                                    case 'Zeta': ch = String.fromCharCode(0x0396); break; 

                                    case 'Eta': ch = String.fromCharCode(0x0397); break; 

                                    case 'Theta': ch = String.fromCharCode(0x0398); break; 

                                    case 'Iota': ch = String.fromCharCode(0x0399); break; 

                                    case 'Kappa': ch = String.fromCharCode(0x039a); break; 

                                    case 'Lambda': ch = String.fromCharCode(0x039b); break; 

                                    case 'Mu': ch = String.fromCharCode(0x039c); break; 

                                    case 'Nu': ch = String.fromCharCode(0x039d); break; 

                                    case 'Xi': ch = String.fromCharCode(0x039e); break; 

                                    case 'Omicron': ch = String.fromCharCode(0x039f); break; 

                                    case 'Pi': ch = String.fromCharCode(0x03a0); break; 

                                    case ' Rho ': ch = String.fromCharCode(0x03a1); break; 

                                    case 'Sigma': ch = String.fromCharCode(0x03a3); break; 

                                    case 'Tau': ch = String.fromCharCode(0x03a4); break; 

                                    case 'Upsilon': ch = String.fromCharCode(0x03a5); break; 

                                    case 'Phi': ch = String.fromCharCode(0x03a6); break; 

                                    case 'Chi': ch = String.fromCharCode(0x03a7); break; 

                                    case 'Psi': ch = String.fromCharCode(0x03a8); break; 

                                    case 'Omega': ch = String.fromCharCode(0x03a9); break; 

                                    case 'alpha': ch = String.fromCharCode(0x03b1); break; 

                                    case 'beta': ch = String.fromCharCode(0x03b2); break; 

                                    case 'gamma': ch = String.fromCharCode(0x03b3); break; 

                                    case 'delta': ch = String.fromCharCode(0x03b4); break; 

                                    case 'epsilon': ch = String.fromCharCode(0x03b5); break; 

                                    case 'zeta': ch = String.fromCharCode(0x03b6); break; 

                                    case 'eta': ch = String.fromCharCode(0x03b7); break; 

                                    case 'theta': ch = String.fromCharCode(0x03b8); break; 

                                    case 'iota': ch = String.fromCharCode(0x03b9); break; 

                                    case 'kappa': ch = String.fromCharCode(0x03ba); break; 

                                    case 'lambda': ch = String.fromCharCode(0x03bb); break; 

                                    case 'mu': ch = String.fromCharCode(0x03bc); break; 

                                    case 'nu': ch = String.fromCharCode(0x03bd); break; 

                                    case 'xi': ch = String.fromCharCode(0x03be); break; 

                                    case 'omicron': ch = String.fromCharCode(0x03bf); break; 

                                    case 'pi': ch = String.fromCharCode(0x03c0); break; 

                                    case 'rho': ch = String.fromCharCode(0x03c1); break; 

                                    case 'sigmaf': ch = String.fromCharCode(0x03c2); break; 

                                    case 'sigma': ch = String.fromCharCode(0x03c3); break; 

                                    case 'tau': ch = String.fromCharCode(0x03c4); break; 

                                    case 'upsilon': ch = String.fromCharCode(0x03c5); break; 

                                    case 'phi': ch = String.fromCharCode(0x03c6); break; 

                                    case 'chi': ch = String.fromCharCode(0x03c7); break; 

                                    case 'psi': ch = String.fromCharCode(0x03c8); break; 

                                    case 'omega': ch = String.fromCharCode(0x03c9); break; 

                                    case 'thetasym': ch = String.fromCharCode(0x03d1); break; 

                                    case 'upsih': ch = String.fromCharCode(0x03d2); break; 

                                    case 'piv': ch = String.fromCharCode(0x03d6); break; 

                                    case 'ensp': ch = String.fromCharCode(0x2002); break; 

                                    case 'emsp': ch = String.fromCharCode(0x2003); break; 

                                    case 'thinsp': ch = String.fromCharCode(0x2009); break; 

                                    case 'zwnj': ch = String.fromCharCode(0x200c); break; 

                                    case 'zwj': ch = String.fromCharCode(0x200d); break; 

                                    case 'lrm': ch = String.fromCharCode(0x200e); break; 

                                    case 'rlm': ch = String.fromCharCode(0x200f); break; 

                                    case 'ndash': ch = String.fromCharCode(0x2013); break; 

                                    case 'mdash': ch = String.fromCharCode(0x2014); break; 

                                    case 'lsquo': ch = String.fromCharCode(0x2018); break; 

                                    case 'rsquo': ch = String.fromCharCode(0x2019); break; 

                                    case 'sbquo': ch = String.fromCharCode(0x201a); break; 

                                    case 'ldquo': ch = String.fromCharCode(0x201c); break; 

                                    case 'rdquo': ch = String.fromCharCode(0x201d); break; 

                                    case 'bdquo': ch = String.fromCharCode(0x201e); break; 

                                    case 'dagger': ch = String.fromCharCode(0x2020); break; 

                                    case 'Dagger': ch = String.fromCharCode(0x2021); break; 

                                    case 'bull': ch = String.fromCharCode(0x2022); break; 

                                    case 'hellip': ch = String.fromCharCode(0x2026); break; 

                                    case 'permil': ch = String.fromCharCode(0x2030); break; 

                                    case 'prime': ch = String.fromCharCode(0x2032); break; 

                                    case 'Prime': ch = String.fromCharCode(0x2033); break; 

                                    case 'lsaquo': ch = String.fromCharCode(0x2039); break; 

                                    case 'rsaquo': ch = String.fromCharCode(0x203a); break; 

                                    case 'oline': ch = String.fromCharCode(0x203e); break; 

                                    case 'frasl': ch = String.fromCharCode(0x2044); break; 

                                    case 'euro': ch = String.fromCharCode(0x20ac); break; 

                                    case 'image': ch = String.fromCharCode(0x2111); break; 

                                    case 'weierp': ch = String.fromCharCode(0x2118); break; 

                                    case 'real': ch = String.fromCharCode(0x211c); break; 

                                    case 'trade': ch = String.fromCharCode(0x2122); break; 

                                    case 'alefsym': ch = String.fromCharCode(0x2135); break; 

                                    case 'larr': ch = String.fromCharCode(0x2190); break; 

                                    case 'uarr': ch = String.fromCharCode(0x2191); break; 

                                    case 'rarr': ch = String.fromCharCode(0x2192); break; 

                                    case 'darr': ch = String.fromCharCode(0x2193); break; 

                                    case 'harr': ch = String.fromCharCode(0x2194); break; 

                                    case 'crarr': ch = String.fromCharCode(0x21b5); break; 

                                    case 'lArr': ch = String.fromCharCode(0x21d0); break; 

                                    case 'uArr': ch = String.fromCharCode(0x21d1); break; 

                                    case 'rArr': ch = String.fromCharCode(0x21d2); break; 

                                    case 'dArr': ch = String.fromCharCode(0x21d3); break; 

                                    case 'hArr': ch = String.fromCharCode(0x21d4); break; 

                                    case 'forall': ch = String.fromCharCode(0x2200); break; 

                                    case 'part': ch = String.fromCharCode(0x2202); break; 

                                    case 'exist': ch = String.fromCharCode(0x2203); break; 

                                    case 'empty': ch = String.fromCharCode(0x2205); break; 

                                    case 'nabla': ch = String.fromCharCode(0x2207); break; 

                                    case 'isin': ch = String.fromCharCode(0x2208); break; 

                                    case 'notin': ch = String.fromCharCode(0x2209); break; 

                                    case 'ni': ch = String.fromCharCode(0x220b); break; 

                                    case 'prod': ch = String.fromCharCode(0x220f); break; 

                                    case 'sum': ch = String.fromCharCode(0x2211); break; 

                                    case 'minus': ch = String.fromCharCode(0x2212); break; 

                                    case 'lowast': ch = String.fromCharCode(0x2217); break; 

                                    case 'radic': ch = String.fromCharCode(0x221a); break; 

                                    case 'prop': ch = String.fromCharCode(0x221d); break; 

                                    case 'infin': ch = String.fromCharCode(0x221e); break; 

                                    case 'ang': ch = String.fromCharCode(0x2220); break; 

                                    case 'and': ch = String.fromCharCode(0x2227); break; 

                                    case 'or': ch = String.fromCharCode(0x2228); break; 

                                    case 'cap': ch = String.fromCharCode(0x2229); break; 

                                    case 'cup': ch = String.fromCharCode(0x222a); break; 

                                    case 'int': ch = String.fromCharCode(0x222b); break; 

                                    case 'there4': ch = String.fromCharCode(0x2234); break; 

                                    case 'sim': ch = String.fromCharCode(0x223c); break; 

                                    case 'cong': ch = String.fromCharCode(0x2245); break; 

                                    case 'asymp': ch = String.fromCharCode(0x2248); break; 

                                    case 'ne': ch = String.fromCharCode(0x2260); break; 

                                    case 'equiv': ch = String.fromCharCode(0x2261); break; 

                                    case 'le': ch = String.fromCharCode(0x2264); break; 

                                    case 'ge': ch = String.fromCharCode(0x2265); break; 

                                    case 'sub': ch = String.fromCharCode(0x2282); break; 

                                    case 'sup': ch = String.fromCharCode(0x2283); break; 

                                    case 'nsub': ch = String.fromCharCode(0x2284); break; 

                                    case 'sube': ch = String.fromCharCode(0x2286); break; 

                                    case 'supe': ch = String.fromCharCode(0x2287); break; 

                                    case 'oplus': ch = String.fromCharCode(0x2295); break; 

                                    case 'otimes': ch = String.fromCharCode(0x2297); break; 

                                    case 'perp': ch = String.fromCharCode(0x22a5); break; 

                                    case 'sdot': ch = String.fromCharCode(0x22c5); break; 

                                    case 'lceil': ch = String.fromCharCode(0x2308); break; 

                                    case 'rceil': ch = String.fromCharCode(0x2309); break; 

                                    case 'lfloor': ch = String.fromCharCode(0x230a); break; 

                                    case 'rfloor': ch = String.fromCharCode(0x230b); break; 

                                    case 'lang': ch = String.fromCharCode(0x2329); break; 

                                    case 'rang': ch = String.fromCharCode(0x232a); break; 

                                    case 'loz': ch = String.fromCharCode(0x25ca); break; 

                                    case 'spades': ch = String.fromCharCode(0x2660); break; 

                                    case 'clubs': ch = String.fromCharCode(0x2663); break; 

                                    case 'hearts': ch = String.fromCharCode(0x2665); break; 

                                    case 'diams': ch = String.fromCharCode(0x2666); break; 

                                    default: ch = ''; break; 

                              } 

                        } 

                        i = semicolonIndex; 

                  } 

            } 

            out += ch; 

      } 

      return out; 

} 


/*********************************************************
'***    Program: URLEncode
'***
'***    Parameters: str
'***		
'***    Returns: string
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 06/10/09
'***
**********************************************************/
function URLEncode(str) {
    str = encodeURI(str);
    
    str = str.replace(/%C2%A0/g, '+');
    str = str.replace(/&/g, '%26');
    str = str.replace(/'/g, "%27");
    str = str.replace(/\+/g, '%2B');

    return str;
}

/*********************************************************************
'***    Function: evalScriptInHtml
'***
'***    Parameters: 
'***        htmlSourceCode - html source code to parse script from
'***        blnKeepScript - whether to keep script in html or strip it
'***                        by default all scripts are stripped
'***                
'***    Returns: string
'***    Remarks: 
'***        1. parses from html source code
'***        2. evaluates each script 
'***        3. returns source code w/o script to avoid second calls
'***
'***    Created by: internet source
'***    Changed by: niloa
'***    Last change: 06/22/2009
'*********************************************************************/
function evalScriptInHtml(htmlSourceCode, blnKeepScript) {
    var source = new String(htmlSourceCode);
    var scripts = new Array();
    //default to false not to return scripts in original html
    if (typeof (blnKeepScript) != "boolean")
        blnKeepScript = false;

    //get all script values and strip out the tags, push result into an array
    while (source.indexOf("<scr" + "ipt") > -1 || source.indexOf("</scr" + "ipt") > -1) {
        //script open tag index
        var intScriptOpen = source.indexOf("<scr" + "ipt");

        //script close tag index
        var intScriptEndChar = source.indexOf(">", intScriptOpen);

        //end script open tag index
        var intScriptClose = source.indexOf("</scr" + "ipt", intScriptOpen);

        //end of script close tag index
        var intScriptCloseEndChar = source.indexOf(">", intScriptClose);

        // Add to scripts array
        var code = source.substring(intScriptEndChar + 1, intScriptClose);
        if (code != "")
            scripts.push(code);

        // Strip from source
        if (!blnKeepScript)
            source = source.substring(0, intScriptOpen) + source.substring(intScriptCloseEndChar + 1);
    }

    // Loop through every script collected and eval it
    for (var i = 0; i < scripts.length; i++) {
        try {
            eval(scripts[i]);
        }
        catch (ex) {
            // do nothing as script failed
        }
    }

    //return cleaned source code
    return source;
}

/*********************************************************************
'***    Function: getSelectedCheckboxValuesAsDilimitedString
'***
'***    Parameters: 
'***        id  - checkbox id
'***        sep - optional separator string to delimit values
'***            defaults to "," if not specified
'***                
'***    Returns: string
'***    Remarks: 
'***        1. builds selected checkbox values as string
'***        2. separator default so , if not specified
'***        3. first separator is always removed from result string
'***
'***    Created by: niloa
'***    Changed by: rburdan
'***    Last change: 01/19/12
'*********************************************************************/
function getSelectedCheckboxValuesAsDilimitedString(obj, sep) {

    if ((obj == null) || (typeof (obj) == "undefined"))
        return "";

    sep = String((sep == null) || (sep == "") ? "," : sep);

    var strValues = new String("");

    // Array
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].checked)
            strValues = strValues.concat(sep, obj[i].value);
    }

    //chop off first separator from beginning of string
    strValues = strValues.substring(sep.length);

    return strValues;
}

//returns an array of all text field elements on a form
function getFormTextFieldsAsArray(Form) {
    var textFields = new Array();

    if ((Form == null) || (Form == ""))
        return textFields;

    var objForm = Form;
    //if form id is passed, get form by id
    if (typeof (Form) == "string")
        objForm = document.getElementById(Form);
   
    //if not an object
    if (typeof (objForm) != "object")
        return textFields;

    var inputFields = objForm.getElementsByTagName("input");
    
    //get all non empty text fields
    var inputField = null, fieldCount = 0;
    for (var i = 0, len = inputFields.length; i < len; i++) {
        inputField = inputFields[i]; //get field

        //get all quantity text fields
        if (inputField.type == "text") {
            textFields[fieldCount] = inputField;  //add field
            //increment number of text fields added
            fieldCount++;
        }
    }
    return textFields;
}

/*used to validate quantity text field for invalid value*/
function HasAnyQuantityTextFieldInvalidValue(ProductsForm, intMinValidValue) {
    //get all quantity text fields for this form
    var qtyFields = getFormTextFieldsAsArray(ProductsForm);
    intMinValidValue = isNaN(parseInt(intMinValidValue)) ? 1 : intMinValidValue;
    
    //validate quantity text field values(must be a numeric value)
    var qtyField = null, strValue = "";
    for (var i = 0, len = qtyFields.length; i < len; i++) {
        qtyField = qtyFields[i];

        //get quantity textfield value
        strValue = Trim(qtyField.value);

        if (strValue == "")
            continue;
        
        strValue = parseInt(strValue);
        //check for invalid value
        if (isNaN(strValue) || (strValue < intMinValidValue)) {
            qtyField.focus();//show which field
            return true;
        }
    }

    qtyFields = null;
    return false;
}

/*checks whether the order form has any select product
used to validate form prior to create order*/
function HasOrderFormAnySelectedProduct(OrderForm) {
    if ((OrderForm == null) || (OrderForm == ""))
        return false;

    var objOrderForm = OrderForm;
    //if form id is passed, get form object
    if (typeof (OrderForm) == "string")
        objOrderForm = document.getElementById(OrderForm);
    
    //if not an object return false
    if (typeof (objOrderForm) != "object")
        return false;

    var arrInput = OrderForm.elements;
    var intElemCounts = arrInput.length;
    if (intElemCounts == 0)
        return false;

    var blnProductSelected = false;
    //if either a checkbox, single select listbox or text field
    //is checked, selected or non empty, return true
    for (var i = 0; i < intElemCounts; i++) {
        if (arrInput[i].type == "checkbox") {
            if (arrInput[i].checked)
                blnProductSelected = true;
        }
        else if (arrInput[i].type == "select") {
            if (arrInput[i].selectedIndex > 0)
                blnProductSelected = true;
        }
        else if (arrInput[i].type == "text") {
            if (arrInput[i].value != "")
                blnProductSelected = true;
        }

        if (blnProductSelected)
            break;
    }

    return blnProductSelected;
}

/*********************************************************************
'***    Function: getSelectedRadioButtonIndex
'***
'***    Parameters: 
'***        buttonGroup  - radio button group obj or id
'***                
'***    Returns: integer - index of selected radio button
'***    Remarks: 
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 09/04/2009
'*********************************************************************/
function getSelectedRadioButtonIndex(buttonGroup) {
    
    //make object or id was specified
    if ((buttonGroup == null) || (buttonGroup == ""))
        return -1;

    var group = buttonGroup; //element reference
    
    if (typeof (buttonGroup) == "string")
        group = document.getElementById(buttonGroup);
        
    //make sure element exists and is a radio button
    if ((group == null) || (group.length == 0))
        return -1;

    //return index of checked radio button
    for (var index = 0, len = group.length; index < len; index++) {
        if (group[index].checked)
            return index;
    }
        
    return -1;
}

/*********************************************************************
'***    Function: getSelectedRadioButtonElementByName
'***
'***    Parameters: 
'***        radioName - radio button group name
'***                
'***    Returns: html element - selected radio button
'***    Remarks: returns selected radio button
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 09/04/2009
'*********************************************************************/
function getSelectedRadioButtonElementByName(radioName) {
    
    //get the radio button element by name
    var grpRadio = document.getElementsByName(radioName);
        
    //get the index of selected radio button
    var ixRadio = getSelectedRadioButtonIndex(grpRadio);
    
    //nothing selected? do not go any further
    if (ixRadio == -1)
        return null;
    
    //get selected radio element
    return grpRadio[ixRadio];
}

//changes button caption/label text
function changeButtonCaptionById(buttonId, caption) {

    var oBtn = document.getElementById(buttonId);
    caption = (caption == null) ? "" : caption;
    if ((oBtn != null) && (caption != ""))
        oBtn.value = caption;
}

/*********************************************************************
'***    Function: applyFixForFirefoxRadioButtonCycling
'***
'***    Parameters: 
'***        form  - form object or id
'***                
'***    Returns: void
'***    Remarks: 
            firefox has an issue where it cycles through 
            each radio button on a form. 
            fix can only be applied during onload event
            as the autocomplete attribute is not w3c compliant and does not validate
            it is tied to the autocomplete feature on firefox and must be turned off
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 09/04/2009
'*********************************************************************/
function applyFixForFirefoxRadioButtonCycling(elForm) {
    var oForm = elForm;

    //if a string is passed, get by id
    if (typeof (oForm) == "string")
        oForm = document.getElementById(elForm);
    if (oForm == null)
        return;

    var browser = new String(navigator.userAgent);
    browser = browser.toLowerCase();

    //if browser is firefox, disable autocomplete
    //this stops radio button cycling on firefox
    if (browser.indexOf("firefox") > -1)
        oForm.setAttribute("autocomplete", "off");
}

/*********************************************************************
'***    Function: isHTML 
'***
'***    Parameters: 
'***                 text - string
'***                
'***    Returns: boolean
'***    Remarks:
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 10/20/09
'*********************************************************************/
function isHTML(text){
    var blnResult = false;
    var sValue = new String(text);
    
	re = /([\<])[a-z]+([^\>]{1,})*([\>])/i;
    
    blnResult = re.test(text);
    
    return blnResult;
}

/*********************************************************************
'***    Function:  countEmails - returns amount of mail addresses which are set in mailString
'***
'***    Parameters: 
'***		mailString  - string with email addresses (f.e. sergeyh@searchease.com;sergey.hramov@searchease.com;sh@searchease.com)
'***
'***	Return: integer
'***
'***    Remarks:  
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 01/11/2010
'*********************************************************************/	
function countEmails(mailString){
    var pattern = "@";
    var pos = mailString.indexOf(pattern);
    for (var count = 0; pos != -1; count++)
        pos = mailString.indexOf(pattern, pos + pattern.length);
    
    return count;
}

/*********************************************************************
'***    Function:  setDefaultFieldValue - sets to field default alt text which disappears onclick, onblur
'***
'***    Parameters: 
'***		fieldId - id of the field to which needs apply
'***        defaultText - default text which is set when field.value is empty
'***        defaultEmptyText - (if not empty) this text will be set as default (non empty value)
'***        withDefaultClassName - when field is empty text color changes to gray (to be not very attractive) (default class input[type="text"].defaultAltText)
'***        withoutDefaultClassName - when field is not empty changes class back (by default non)
'***
'***	Return: void
'***
'***    Remarks: usually used for input[type='text'].
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 03/08/2010
'*********************************************************************/	
function setDefaultFieldValue(fieldId, defaultText, defaultEmptyText, withDefaultClassName, withoutDefaultClassName) {
    var Field = document.getElementById(fieldId);
    
    if(Field == null)
        return;
    if(Trim(defaultText) == ""){
        Field.value = "";
        return;
    }
    if(defaultEmptyText == null || Trim(defaultEmptyText) == ""){
        defaultEmptyText = defaultText;
    }
    if(withDefaultClassName == "" || withDefaultClassName == null)
        withDefaultClassName = "defaultAltText";
    if(withoutDefaultClassName == null)
        withoutDefaultClassName = "";
    
    if(defaultEmptyText != defaultText)
        withDefaultClassName = withoutDefaultClassName;
    
    Field.className = withDefaultClassName;
    Field.value = defaultEmptyText;
    Field.onfocus = function() { if (Field.value == defaultText) { Field.value = ''; Field.className = withoutDefaultClassName; } };
    Field.onclick = function() { if (Field.value == defaultText) { Field.value = ''; Field.className = withoutDefaultClassName; } };
    Field.onblur = function() { if (Field.value == '') { Field.value = defaultEmptyText; Field.className = withDefaultClassName; } };
}

/*********************************************************************
'***    Function:  clearDefaultFieldValue - clears default value (and onclick, onblur fns) which were set with setDefaultFieldValue fn
'***
'***    Parameters: 
'***		fieldId - id of the field to which needs apply
'***        defaultText - default text which is set when field.value is empty
'***        withoutDefaultClassName - when field is not empty changes class back (by default non)
'***
'***	Return: void
'***
'***    Remarks: usually used for input[type='text'] and set at the top of validateForm function
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 03/08/2010
'*********************************************************************/	
function clearDefaultFieldValue(fieldId, defaultText, withoutDefaultClassName) {
    var Field = document.getElementById(fieldId);
    
    if(Field == null)
        return;
    if(Trim(defaultText) == ""){
        Field.value = "";
        return;
    }
    if(Field.value == defaultText)
        Field.value = "";
    if(withoutDefaultClassName == null)
        withoutDefaultClassName = "";
    Field.onfocus = function() { };
    Field.onclick = function() {};
    Field.onblur = function() {};
    Field.className = withoutDefaultClassName;
}


/*********************************************************************
'***    Function:  prepareFieldDefault
'***
'***    Parameters: 
'***		selector - input field jquery selector
'***        defColor - text color for default value
'***
'***	Return: void
'***
'***    Remarks: prepares up text field default value
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 03/08/2010
'*********************************************************************/	
function prepareFieldDefaults(selector, defColor) {
    //auto reset value focus and restore on blur if empty
    var jq = jQuery;
    var defColor = defColor || "#666";
    var el = jq(selector);
    
    //get default value form placeholder attribute
    var defVal = el.attr("placeholder");
    if (!defVal)//no default? return
        return;
    
    //always gets live value form field
    var getVal = function() {
        return jq.trim(el.val());
    }

    //checks if cur val is default
    var isDefault = function() {
        return (getVal() == defVal);
    }
    
    //init: font color to gray by default
    if (isDefault())
        el.css({ color: defColor });
    
    //create a map of events with callback
    var eventsMap = {
        focus: function() {
            if (!isDefault())
                return;
        
            //need to ready field for typing
            //set color to black and empty field
            el.css({ color: 'black' }).val("");
        },
        blur: function() {
            if (getVal() != '')
                return;
            //since field is empty
            //reset to default color and value
            el.css({ color: defColor }).val(defVal);
        }
    };
    
    //bind all events
    el.bind(eventsMap);
}

/*********************************************************************
'***    Function:  toggleCheckbox - toggles input[type="checkbox"]
'***
'***    Parameters: 
'***		objId - id of the checkbox object
'***
'***	Return: void
'***
'***    Remarks: 
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 07/08/2010
'*********************************************************************/	
function toggleCheckbox(objId){
    var objChkbox = document.getElementById(objId);
    if(objChkbox == null) return;
    
    objChkbox.checked = !objChkbox.checked;
}

/*******************************************************************
FUNCTION ALLOWS: Add/Remove Options from Source to Destin. Lisboxes
********************************************************************/
/*
copies all selected options from listbox scrId to listbox destId
ignores any option wich already exsists in destId
    	
created by: dimab
created on: 12/20/2010
*/
function copySelectedOptionsToListbox(srcId, destId) {
    var src = document.getElementById(srcId);
    var dest = document.getElementById(destId);

    if (src == null || dest == null)
        return;

    for (var i = 0; i < src.options.length; i++) {

        if (src.options.item(i).selected == true) {
            var option = src.options.item(i);

            if (!optionWithValueExists(dest.options, option.value)) {

                var newOption = document.createElement("option");
                newOption.value = option.value;
                newOption.text = option.text;

                dest.options.add(newOption);
            }
        }
    }
}
/*
removes all selected options from listbox with specified DOM id
    	
created by: dimab
created on: 12/20/2010
*/
function removeSelectedOptionsFromListbox(id) {
    var dest = document.getElementById(id);

    if (dest == null)
        return;

    for (var i = dest.options.length - 1; i >= 0; i--) {
        if (dest.options.item(i).selected == true)
            dest.remove(i);
    }
}

/*
checks in array of options passed contains a specific value
params:
options - array of options (document.getElementById("someListBox").options
value - value to look for. case sensitive!
    	
created by: dimab
created on: 12/20/2010
*/
function optionWithValueExists(options, value) {
    for (var i = 0; i < options.length; i++) {
        if (options.item(i).value == value)
            return true;
    }
    return false;
}

/******************************************************************* 
'*** Function: toProperCase
'*** 
'*** Param: value - String to Convert to Proper Case
'*** 
'*** Remarks: converts string proprer case
'***
'*** Created by: internet source
'***
'*** Changed by: niloa
'*** 
'*** Last modified: 12/30/2010
'*** 
*******************************************************************/
function toProperCase(value) {
    var re = /^(.)|\s(.)/g;
    var newValue = value.toLowerCase()

    var replaceIt = function($1) {
        return $1.toUpperCase();
    };

    newValue = newValue.replace(re, replaceIt);

    return newValue;
}

/*********************************************************************
'***    Program: selectListItemElement( name, strItemValue )
'***    Type: Function
'***
'***    Function: Selects item in a list box
'***
'***    Parameters: 
'***		name -  object
'***		strItemValue  - value to look for. the item with this value gets selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by:  
'***    Last change: 01/21/11
'*********************************************************************/
function selectListItemElement(name, strItemValue) {
    var objList = document.getElementById(name);
    return selectListItem(objList, strItemValue);
}

/*********************************************************************
'***    Program: addOptionToListbox
'***    Type: Function
'***
'***    Function: adds item to a list box
'***
'***    Parameters: 
'***		listbox ID     - destId
'***		listbox value  - value
'***		listbox text   - text
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: rburdan
'***    Changed by:  
'***    Last change: 03/16/11
'*********************************************************************/
function addOptionToListbox(destId, value, text) {

    var dest = document.getElementById(destId);

    if (dest == null)
        return;

    var newOption = document.createElement("option");
    newOption.value = value;
    newOption.text = text;

    dest.options.add(newOption);
}
		
/*********************************************************************
'***    Function:   1. Adds onchange event to all fields of the passed form.
'***                2. Once data changed - all change events will be removed
'***
'***    Parameters: 
'***        frmId [id]* - html form being submitted (here simple object id could be used instead of form e.g. block)
'***        chngFieldId [id] - hidden field id (indicates if form data was changed: 0 - wasn't changed, 1- was changed)
'***
'***    Returns: void
'***    Remarks: 
'***            - requires jQuery to be already initialized
'***            - chngFieldId could be changed to different, but be sure that hasFormDataChanged will be called with the same id
'***            - adds listener only for visible elements (so if section is hidden with css rule display = none, this field won't get listener)
'***
'***    Created by: sergeyh
'***    Changed by: sergeyh
'***    Last change: 04/05/2011
'*********************************************************************/
function addListenerFormDataChanged(frmId, chngFieldId){
    // hidden field
    chngFieldId = (chngFieldId == null || chngFieldId == "") ? "DataChanged" : chngFieldId;
    var objChngField = jQuery("#" + chngFieldId);
    
    // add all possible form elements where data could be changed
    var strFrmElements = "#" + frmId + " :input:not(:hidden,:button)";
    
    // set for each element change event - set hidden field that data was changed
    // use custom event to avoid overlay with other change events of the form objects
    jQuery(strFrmElements).bind("change.frmElmChange", function(){
        // set 1 - form data changed
        objChngField.val("1");
        // once data was changed - no need in change functions for those elements (remove them)
        jQuery(strFrmElements).unbind("change.frmElmChange");
    });
}

// get hidden field value
function hasFormDataChanged(chngFieldId){
    chngFieldId = (chngFieldId == null || chngFieldId == "") ? "DataChanged" : chngFieldId;
    
    return parseInt(jQuery("#" + chngFieldId).val()) == 1;
}

/*********************************************************************
'***    Function:   1. Adds onchange event to all fields of the passed form/block.
'***                2. Once data changed - executes proposed function
'***
'***    Parameters: 
'***        frmId [id]* - html element (usually jQuery selector)
'***        fnFire [fn]* - function which will be executed after field data was changed
'***
'***    Returns: void
'***    Remarks: 
'***            - requires jQuery to be already initialized
'***            - adds listener only for visible elements (so if section is hidden with css rule display = none, this field won't get listener)
'***            - be careful!!! adds listener also for fields which were loaded after function was initialized (e.g. were loaded via ajax)
'***    
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 04/28/2011
'*********************************************************************/
function addChangeEventHandlerToFormInputFields(frmId, fnFire){
    if(typeof(fnFire) != "function")
        return;
    
    // add all possible form elements where data could be changed
    var strFrmElements = frmId + " :input:not(:hidden,:button)";
    
    // set for each element change event which will be fired when data was changed
    // use custom event to avoid overlay with other change events of the form objects
    // here keypress event added because when user makes selection from autocomplete list, changeEvent is not registering for this field
    jQuery(strFrmElements).live("change.frmElmChangeWithCallback keypress.frmElmChangeWithCallback", function(){
        // execute proposed function
        fnFire();
    });
}

/*********************************************************************
'***    Function:   shows confirm saving dialog on change user info pages, when data was changed
'***
'***    Parameters: 
'***        frmId [id]* - html form being submitted
'***        targetUrl [str]* - hidden target url (supposes that save page should redirect user to this url)
'***        fnValidate [fn] - if function passed then it will be called to validate fields
'***        blnShowConfirm [bln] - do not show confirm dialog when false (just save and redirect - usually 'finish' button)
'***
'***    Returns: void
'***    Remarks: requires jQuery, pageDialog to be already connected
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 03/18/2011
'*********************************************************************/
function confirmFormDataChanges(frmId, targetUrl, fnValidate, blnShowConfirm){
    // validate fields
    if(typeof(fnValidate) != "function"){
        fnValidate = function(){ return false; }
    }
    if(!fnValidate()){
        return false;
    }
    
    var saveDataWithRedirect = function(){
        //set form target url, to navigate once data is saved
        jQuery("#" + frmId + " input#TargetURL").val(targetUrl);
        jQuery("#" + frmId).submit();
    }
    var redirectToTarget = function(){
        document.location.href = targetUrl;
    }
    
    if(typeof(blnShowConfirm) != "boolean")
        blnShowConfirm = true;
    // if parameter wasn't set - show confirm dialog, otherwise - just save form data
    if(!blnShowConfirm){
        saveDataWithRedirect();
    }
    
    // show dialog
    if(blnShowConfirm){
        showConfirmChangesDialog(saveDataWithRedirect, redirectToTarget);
    }
}

/*********************************************************************
'***    Function:   shows confirm saving dialog on change user info pages, when data was changed
'***
'***    Parameters: 
'***        fnOk [fn]* - function which will be used on accept ("yes")
'***        fnCancel [fn]* - function which will be used on cancel ("no")
'***
'***    Returns: void
'***    Remarks: pageDialog should be already connected
'***
'***    Example: showConfirmChangesDialog(saveAnswerData, clearAnswerData);
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 05/31/2011
'*********************************************************************/
function showConfirmChangesDialog(fnOk, fnCancel){
    if(typeof(fnOk) != "function" || typeof(fnCancel) != "function")
        return;
    
    // pageDialog is a page level var that points to an instance of a dialog.
    pageDialog.message = "Would you like to save your changes?";
    pageDialog.title = "Data has Changed";
    
    document.getElementById("dialogOk").value = "Yes";
    document.getElementById("dialogCancel").value = "No";
    
    //call validate, set target url, and submit form
    pageDialog.onOk = fnOk;
    pageDialog.onCancel = fnCancel;
    
    pageDialog.modal = true;
    pageDialog.show();
}

/*********************************************************************
'***    Function: shows message to user (usually when data saved). Appends html to the given block and removes it after short delay.
'***
'***    Parameters: 
'***        blockSelector [str]* - jQuery selector for DOM block
'***        msg [str] - message that will be displayed to user
'***        msDelay [int] - how long the message will be visible (if set 0 - will be always shown) in ms
'***        msDuration [int] - how long message will be dimming in ms
'***
'***	Returns: void
'***
'***    Remarks: none
'***
'***	Use example:
'***		jQuery(document).ready(function(){ displayHintTextWithDelay("#FormJobSeekerUser") });
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 10/26/2011
'*********************************************************************/
function displayHintTextWithDelay(blockSelector, msg, msDelay, msDuration){
    if(msg == null || msg == "")
        msg = "Data has been saved.";
    if(blockSelector == null || blockSelector == "")
        return;
    msDelay = parseInt(msDelay);
    if(isNaN(msDelay))
        msDelay = 20000; // set default delay to 20 seconds

    // append message text in the given block
    jQuery(blockSelector).prepend('<div class="hintText"><p>' + msg + '</p></div>');
            
    // if delay was set to positive value - hide the field with message after countdown
    if(msDelay > 0){
        msDuration = parseInt(msDuration);
        if(isNaN(msDuration) || msDuration < 0)
            msDuration = 2000;  // set default fadeout time to 2 seconds
                
        var oHint = jQuery(blockSelector + " .hintText:first");
        // fadeout and remove message
        oHint.delay(msDelay).fadeOut(msDuration, function(){oHint.detach()});
    }
}

/*********************************************************************
'***    Function: Truncate
'***
'***    Parameters: 
        string - string to truncate
        length - if string is longer than specified lengh it is truncated
        end - chars to be added a the end if string was truncated

'***
'***	Use example: Shorter = Truncate(Longer, 40, "...");
'***    Returns: string
'***
'***    Created  by: dimab 
'***    Changed  by: niloa-relocated to client lib only
'***    Last change: 11/24/2010
'*********************************************************************/
function truncate(initialString, length, end) {
    if (length == null)
        length = 40;
    if (end == null)
        end = "...";

    var strWorkingString = new String(initialString);
    if (strWorkingString.length <= length)
        return initialString;
    return strWorkingString.substring(0, length) + end;
}


/*********************************************************************
'***    Function: returns options for jQuery ajax request
'***
'***    Parameters: 
'***        fieldId [str]* - jQuery selector for result field
'***        strUrl [str]* - path to remote script
'***        strQS [str] - query string which will be sent to remote script
'***        onSuccess [func] - use custom function when query data will be get
'***        onComplete [func] - use custom function when query data will be set
'***
'***	Returns: object
'***
'***    Remarks: none
'***
'***	Use example:
'***		var options = jQueryGetAjaxOptions(stateFieldCntId, strUrl, strQS, null, onCompleteFunc);
'***
'***    Created by: sergeyh
'***    Changed by: 
'***    Last change: 05/11/2011
'*********************************************************************/
function jQueryGetAjaxOptions(fieldId, strUrl, strQS, onSuccess, onComplete){
    if(fieldId == null || fieldId == "")
        return;
    if(typeof(onSuccess) != "function"){
        onSuccess = function(data, textStatus, XMLHttpRequest){
            jQuery(fieldId).html(data);
        }
    }
    if(typeof(onComplete) != "function"){
        onComplete = function(XMLHttpRequest, textStatus){
            return;
        }
    }
    if(strQS == null)
        strQS = "";
    var onError = function(XMLHttpRequest, textStatus, errorThrown){
         jQuery(fieldId).text("unable to load this field...");
    }
    
    var options = {
        type: "POST",
        url: strUrl,
        data: strQS,
        cache:false,
        success: onSuccess,
        complete: onComplete,
        error: onError
    }
    
    return options;
}

/*********************************************************************
'***    Function: getMonthNumberFromName
'***
'***    Parameters: month
'***                
'***    Returns: int
'***
'***    Created by: rburdan
'***    Changed by: 
'***    Last change: 06/22/11
'*********************************************************************/
function getMonthNumberFromName(month) {

    var intMonth = 0;

    switch (month.substring(0, 3).toLowerCase()) {
        case "jan":
            intMonth = 1;
            break;
        case "feb":
            intMonth = 2;
            break;
        case "mar":
            intMonth = 3;
            break;
        case "apr":
            intMonth = 4;
            break;
        case "may":
            intMonth = 5;
            break;
        case "jun":
            intMonth = 6;
            break;
        case "jul":
            intMonth = 7;
            break;
        case "aug":
            intMonth = 8;
            break;
        case "sep":
            intMonth = 9;
            break;
        case "oct":
            intMonth = 10;
            break;
        case "nov":
            intMonth = 11;
            break;
        case "dec":
            intMonth = 12;
            break;
    }

    return intMonth;
}

/*********************************************************************
'***    Function: toJSONString
'***
'***    Parameters: object - object to serialize to json string
'***                
'***    Returns: json string representing the serialized object
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 06/27/11
'*********************************************************************/
function toJSONString(object) {
    if (object == null)
        return "";
    var strJsonData = '';
    var itemCount = 0;
    for (var item in object) {
        if (itemCount > 0) {
            strJsonData += ', ';
        }
        temp = object[item];
        if (typeof (temp) == 'object') {
            s = toJSONString(temp);
        } else {
            s = '"' + temp + '"';
        }
        strJsonData += '"' + item + '":' + s;
        itemCount++;
    }
    strJsonData = '{' + strJsonData + '}';
    return strJsonData;
}

/*********************************************************************
'***    Function: toJSONString
'***
'***    Parameters: selector - jQuery element(s) selector
'***                
'***    Returns: void
'***
'***    Remarks: updates fields tabindex property in sequential order
'***
'***    Created by: niloa
'***    Changed by: 
'***    Last change: 06/27/11
'*********************************************************************/ 
function updateFieldsTabIndex(selector) {
    selector = selector || "input,select";
    var tabindex = 1;
    jQuery(selector).each(function () {
        if (this.type != "hidden") {
            jQuery(this).attr("tabindex", tabindex);
            tabindex++;
        }
    });
    return;
}
