function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0]==variable) {
			return pair[1];
		}
	}
	return ""
}	
//******************************** 
//Get Node Path Text from Treeview
//********************************
function getPathText(node)
{
    var strText = "";
    var tmpNode;
    strText = node.getAttribute("TEXT");
    tmpNode = node.getParent();
    while (tmpNode!=null)
    {
        strText =strText+ " - " + tmpNode.getAttribute("TEXT");
        tmpNode = tmpNode.getParent();
    }
    return strText;
}

function getPathText_LF(node)
{
    var strText = "";
    var tmpNode;
    strText = node.getAttribute("TEXT");
    if (node.getParent()==null) return strText;
    tmpNode = node;
    while (tmpNode.getParent()!=null)
    {
        tmpNode = tmpNode.getParent();
    }
    strText =strText+ " - " + tmpNode.getAttribute("TEXT");
    return strText;
}

// Replace Function
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

//Format Date Text
function formatDateText(dateTextId)
{
	var txtDate=document.getElementById(dateTextId);
	var dateText=txtDate.value;
	if ((dateText.length!=8) || (dateText.indexOf('/')>=0)) return;
    txtDate.value = dateText.substring(0,2)+'/'+dateText.substring(2,4)+'/'+dateText.substring(4,8);
    
}
function check_int_input()
{
	if (window.event.keyCode>=48 && window.event.keyCode<=57)
		return true;
	else
		return false;
}
function check_real_input()
{
	if ((window.event.keyCode>=48 && window.event.keyCode<=57)||window.event.keyCode==46)
		return true;
	else
		return false;
}
function check_date_input()
{
	if ((window.event.keyCode>=48 && window.event.keyCode<=57)||window.event.keyCode==47)
		return true;
	else
		return false;
}