<!--




function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


function removeFilter(moduleID, strGroupID) {
	
	var selDis = document.getElementById(strGroupID + "filterShow"+moduleID);
	var selPost = document.getElementById(strGroupID + "filterValues"+moduleID);
  	var i;
    var intRemoved = 0;
  	
	for (i = selDis.length - 1; i>=0; i--) {
    	if (selDis.options[i].selected) {
      		selDis.remove(i);
			selPost.remove(i);
			intRemoved = 1;
    	}
 	}
	if (intRemoved==0)
		alert("Please select a filter to remove from the list.");
}

function splitValue(strValue, intType) {  //0-value;1-text

  	var i;

	for (i = 0; i <= strValue.length-1; i++) {
		if (Mid(strValue,i,1)=='|') {
			if (intType==1) 
				return Right(strValue,strValue.length-i-1)
			else
				return Left(strValue,i)			
		}
	}	
	
}

function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
}
	



function formatRange(moduleID, strType, strGroupID) {
	
	var strValue = document.getElementById(strGroupID+strType+moduleID).value;
	var intPass = 0;
	
	
	if (strValue != "") {

		if (Left(document.getElementById(strGroupID + "filterField"+moduleID).value,1) == 'd'){
		
			formatDates(moduleID, strType);
	
		}
		else
			intPass = 1;
	

		if ((strType == 'filterRangeFrom') && (intPass==1)) {
			if (document.getElementById(strGroupID+'filterRangeTo'+moduleID).value=='') {
				document.getElementById(strGroupID+'filterRangeTo'+moduleID).value = document.getElementById(strGroupID+strType+moduleID).value;
			}
		}
	}

}

	
function addFilter(moduleID, strGroupID) {
	
	var optValue = document.getElementById(strGroupID+"filterField"+moduleID).value;
	var rangeFrom = document.getElementById(strGroupID+'filterRangeFrom'+moduleID).value;
	var rangeTo = document.getElementById(strGroupID+'filterRangeTo'+moduleID).value;
	var optValueOnly = Right(optValue,optValue.length-1);
	var txtDis = splitValue(optValueOnly,1);
	var txtPost = splitValue(optValueOnly,0);
	var fT = Left(optValue,1);
	var intPass = 1;
	

    if(optValue=="")
		alert("Please select a column to filter.");
	else {
		if(fT=='d') {
			if ((rangeFrom=="") || (rangeTo=="")) {
					alert("Please enter a date range.");
					intPass = 0;
			} else {
				txtDis = txtDis + " from " + rangeFrom + " to " + rangeTo; 
				txtPost = "(" + txtPost + ">=`" + rangeFrom + "` AND " + txtPost + "<=`" + rangeTo + "`)"; 
				document.getElementById(strGroupID+'filterRangeFrom'+moduleID).value = "";
				document.getElementById(strGroupID+'filterRangeTo'+moduleID).value = "";
			}
		}
		else if(fT=='n') {
			txtDis = txtDis + " from " + rangeFrom + " to " + rangeTo; 
			txtPost = "(" + txtPost + ">=" + rangeFrom + " AND " + txtPost + "<=" + rangeTo + ")";		
			document.getElementById(strGroupID+'filterRangeFrom'+moduleID).value = "";
			document.getElementById(strGroupID+'filterRangeTo'+moduleID).value = "";
		}
		else if(fT=='b') {
			txtDis = txtDis + " is " + document.getElementById(strGroupID+'filterBoolean'+moduleID).value; 
			txtPost = "(" + txtPost + "=" + document.getElementById(strGroupID+'filterBoolean'+moduleID).value + ")"; 
			document.getElementById(strGroupID+'filterBoolean'+moduleID).value = "";
		}
		else if(fT=='s') {
			txtDis = txtDis + " from " + rangeFrom + " to " + rangeTo; 
			txtPost = "(" + txtPost + ">=~" + ReplaceChars(rangeFrom) + "~ AND " + txtPost + "<=~" + ReplaceChars(rangeTo) + "~)";		
			document.getElementById(strGroupID+'filterRangeFrom'+moduleID).value = "";
			document.getElementById(strGroupID+'filterRangeTo'+moduleID).value = "";
		}	
		
		if (intPass==1) {
			var to = document.getElementById(strGroupID+"filterShow"+moduleID);
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			var options = new Object();
			to.options[index] = new Option(txtDis, txtDis, false, false);
			
			to = document.getElementById(strGroupID+"filterValues"+moduleID);
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			to.options[index] = new Option(txtPost, txtPost, false, false);
				
			document.getElementById(strGroupID+"filterField"+moduleID).value = "";
		}

	
	}
	
}

function ReplaceChars(oldstring) {
	
	var newstring = oldstring.replace(/é/, "&#233;");
	return newstring.replace(/'/, "&#39;");
	
}


function getList(strList, intSuffix) {
	

	var strTxtList = "";
	var strRegoClass = "";
	var strSep;
	
	if (Left(strList,12)=='filterValues')
		strSep = " OR ";
	else
		strSep = ",";
			

	for (var i=0;i<document.getElementById(strList).options.length;i++) {
		if (i==0)
			strTxtList = document.getElementById(strList).options[i].value;
		else
			strTxtList = strTxtList + strSep + document.getElementById(strList).options[i].value;

	}
	
	
	if (Right(strList,strList.length-12) == '20' || Right(strList,strList.length-12) == '5') {
	
		for (var i=1; i<=document.getElementById('totalregoclass'+intSuffix).value;i++) {
	
		
			strRegoClass = strRegoClass + document.getElementById('class'+intSuffix+i).value;
			
		}
		
		for (var i=1; i<=16-document.getElementById('totalregoclass'+intSuffix).value;i++) {
			
			strRegoClass = strRegoClass + '2';
		}
	}
	

	return strTxtList + strRegoClass;
}



function getFilterOptions(moduleID,strGroupID) {
	
	var filterType = document.getElementById(strGroupID+"filterField"+moduleID).value;	
	var fT = Left(filterType,1);
	
	if (fT=='b') {
		toggleBox('b'+moduleID,1);
		toggleBox('r'+moduleID,0);
		document.getElementById(strGroupID+"filterName"+moduleID).innerHTML = "Boolean Value"; 
	}
	//else {
	//	toggleBox('r'+moduleID,1);
	//	toggleBox('b'+moduleID,0);
	//	document.getElementById("filterName"+moduleID).innerHTML = "Range"; 
	//}	

}



-->
