function sortup() {
	if (document.getElementById("CLpaginationArea")) {
		var old_results = document.getElementById("CLsearchResultsArea");
		aTables = old_results.getElementsByTagName("TABLE");
		old_tbl = aTables[1];
		for (i = 1; i < old_tbl.rows[0].cells.length; i++) {
			aContents = cleanCell(getCellValue(old_tbl.rows[0].cells[i]));
			if (aContents[1] != "") {
				if  (i == 9) {
					displayProcessing();
					gosort("field_4506123", "asc");
				}
				if  (i == 11) {
					displayProcessing();
					gosort("field_4506122", "asc");
				}
				if  (i == 10) {
					displayProcessing();
					gosort("field_4506124", "asc");
				}
				if ((i != 9) && (i != 11) && (i != 10)) {
				 	changeClassName("customTopPagination", "block");
				 	changeClassName("customBottomPagination", "block");
					formatResults();
					getPageSize();
				}
			}
		}
	}
}

function init() {
	 if (GetCookie("goToDetails") == "1") {
	 	changeClassName("customSearch", "noDisplay");
		SetCookie("goToDetails", 0, null, "/");
		window.location="/site/c.iqLRI2OzGlF/b.3949357/apps/ka/ct/contactcustom.asp";
	}
	else {
		var aPs = document.getElementById("standardSearch").getElementsByTagName("P");
		if (aPs[0]) {
			if (aPs[0].innerHTML.indexOf("No records found") > -1) {
				if (GetCookie("clearSearch") == "1") {
					SetCookie("clearSearch", 0, null, "/");
				}
				else {
					changeClassName("noResultsHalf", "block");
				}
			}
		}	
		if (document.getElementById("CLpaginationArea")) {
			var old_results = document.getElementById("CLsearchResultsArea");
			aTables = old_results.getElementsByTagName("TABLE");
			old_tbl = aTables[1];
			for (i = 1; i < old_tbl.rows[0].cells.length; i++) {
				aContents = cleanCell(getCellValue(old_tbl.rows[0].cells[i]));
				if (aContents[1] != "") {
					if ((i == 9) && (aContents[1].indexOf("SortDesc") > -1)) {
						alert(aContents[1]);
						alert('sortup');
						sortup();
						break;
					}
					if  (i == 9) {
						displayProcessing();
						gosort("field_4506123", "desc");
					}
					if  (i == 11) {
						displayProcessing();
						gosort("field_4506122", "desc");
					}
					if  (i == 10) {
						displayProcessing();
						gosort("field_4506124", "desc");
					}
					if ((i != 9) && (i != 11) && (i != 10)) {
					 	changeClassName("customTopPagination", "block");
					 	changeClassName("customBottomPagination", "block");
						formatResults2();
						getPageSize();
					}
				}
			}
		}
		createGradient();
	}
}
window.addEventListener ? window.addEventListener("load", init, false) : window.attachEvent("onload", init);
