function openDisclosure() {
	var disText = document.getElementById('disclosureTextId').value;
	var disWin = window.open("","disclosurePage","width=600,height=400,scrollbars=1,resizable=0")
	
	disWin.document.open();
	disWin.document.write('<html><link type="text/css" rel="stylesheet" href="../cms/cda/styles/styles.css"><body><table class = "mainContainer"><tr><td class= "contentContainer"><div class = "contentSection">');
	disWin.document.write(disText);
	disWin.document.write('</div></td></tr></table></body></html>');
	disWin.document.close();

}

function searchOnLoad() {
	var searchElement = document.getElementById('searchValue');
	var searchValue;
	if(searchElement != '' && searchElement != null){
		searchValue = searchElement.value;
		if(searchValue == null || searchValue == "") {
			document.getElementById('searchName').value = document.getElementById('searchText').value;
		} else {
			document.getElementById('searchName').value = searchValue
		}
	}
}

function toggleSearchBox() {

	if(document.getElementById('searchValue').value == "" && (document.getElementById('searchName').value == document.getElementById('searchText').value)) {
		document.getElementById('searchName').value = ""
	}
}

function refillSearchBox() {

	if((document.getElementById('searchValue').value == "") && (document.getElementById('searchName').value == "")) {
		document.getElementById('searchName').value =  document.getElementById('searchText').value;
	}
}

function sortHyperLinks(a,b,order) {
	var aDiv = document.createElement("div");
    aDiv.innerHTML = a;
	if (document.all) // IE Stuff
    {
    	a= aDiv.innerText;
    } else // Mozilla does not work with innerText
    {
    	a= aDiv.textContent;
    }      
	a = trim(a);
	a = a.toLowerCase();
	
	var bDiv = document.createElement("div");
    bDiv.innerHTML = b;
	if (document.all) // IE Stuff
    {
    	b= bDiv.innerText;
    }   
    else // Mozilla does not work with innerText
    {
    	b= bDiv.textContent;
    }      
	b = trim(b);
	b = b.toLowerCase();
			
	if (order=="asc") {
    	return (a>b?1:-1);
	} else {
     	return (a<b?1:-1);
	}
}		

function sortDecimals(a, b, order) {
	var decimalSeparatorElement = document.getElementById("nfdecimalSeparator");
	var naTextElement = document.getElementById("naText");

	var aDiv = document.createElement("div");
	var aDecimalPlaces = 0;
	var aNumericData;
	aDiv.innerHTML = a;
	if (document.all) // IE Stuff
    {
       	a = aDiv.innerText;
    } else // Mozilla does not work with innerText
    {
    	a = aDiv.textContent;
    }      
	
	a = trim(a);	
	if (a==trim(naTextElement.value)) {
		aNumericData = -99999999999999;
	} else {		
		if (decimalSeparatorElement!=null & decimalSeparatorElement.value!="") {
			aDecimalPlaces = a.indexOf(decimalSeparatorElement.value);
			if (aDecimalPlaces > -1) {
				aDecimalPlaces = a.length - aDecimalPlaces - 1;
			}
		}												
		aNumericData = parseFloat(a.toString().replace(/[^0-9]*/g, ""));		
		if(!isNaN(aNumericData)) {
			if (a.toString().substr(0, 1) == "-") {
				aNumericData = aNumericData * -1;
			}	
			if (aDecimalPlaces > 0) {
				aNumericData = aNumericData / Math.pow(10, aDecimalPlaces);
			}
		} else {
			aNumericData = -99999999999998;
		}	
	}
					
	var bDiv = document.createElement("div");
	var bDecimalPlaces = 0;
	var bNumericData;

    bDiv.innerHTML = b;
	if (document.all) // IE Stuff
    {
       	b = bDiv.innerText;
    } else // Mozilla does not work with innerText
    {
        b = bDiv.textContent;
    }      
	
	b = trim(b);
	if (b==trim(naTextElement.value)) {
		bNumericData = -99999999999999;
	} else {
		if (decimalSeparatorElement!=null & decimalSeparatorElement.value!="") {
			bDecimalPlaces = b.indexOf(decimalSeparatorElement.value);
			if (bDecimalPlaces > -1) {
				bDecimalPlaces = b.length - bDecimalPlaces - 1;
			}
		}	
		bNumericData = parseFloat(b.toString().replace(/[^0-9]*/g, ""));		
		if(!isNaN(bNumericData)) {
			if (b.toString().substr(0, 1) == "-") {
				bNumericData = bNumericData * -1;
			}
			if (bDecimalPlaces > 0) {
				bNumericData = bNumericData / Math.pow(10, bDecimalPlaces);
			}
		} else {
			bNumericData = -99999999999998;
		}	
	}							

	if(aNumericData==bNumericData) {
		return 0;
	}
	if (order=="asc") {
    	return (aNumericData>bNumericData?1:-1);
	} else {
     	return (aNumericData<bNumericData?1:-1);
	}
}

function trim(inputString) {
	inputString = inputString.replace('\n', '', 'g');
	var retValue = inputString.replace(/^(\s)*/, '');
    retValue = inputString.replace(/(\s)*$/, '');
   		
    return retValue; // Return the trimmed string back to the user
}

function sortStrings(a, b, order) {
	var naTextElement = document.getElementById("naText");
	a = trim(a);
	if (a==trim(naTextElement.value)) {
		a = "";
	} else {
		a = a.toLowerCase();
	}
					      
	b = trim(b);
	if (b==trim(naTextElement.value)) {
		b = "";
	} else {
		b = b.toLowerCase();
	}
			
	if (order=="asc") {
 				return (a>b?1:-1);
	} else {
  				return (a<b?1:-1);
	}
}
