<!--
	// This javascript is common functions used within the application

	// Parse the url querystring for the specified parameter
	function PageQuery(q, delimiter)
	{
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		if(q)
		{
			for(var i=0; i < this.q.split(delimiter).length; i++)
			{
				this.keyValuePairs[i] = this.q.split(delimiter)[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s)
		{
			for(var j=0; j < this.keyValuePairs.length; j++)
			{
				if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function()
		{
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++)
			{
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; } 
	}
	
	// get the url query string key value
	function queryString(key)
	{
		var page = new PageQuery(window.location.search, '&'); 
		return unescape(page.getValue(key)); 
	}
	
	// get the query string parameter (or any other key=value string) key value
	function queryParameter(query, key)
	{
		var page = new PageQuery(query, ' ');
		return unescape(page.getValue(key));
	}
	
	
	// Get the active radWindow
	function GetRadWindow() {
	    var oWindow = null;
	    if (window.radWindow) oWindow = window.radWindow;
	    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
	    return oWindow;
    }
    
    
	// Close the active radWindow
	function CloseWin()
	{
		var oWindow = GetRadWindow();			
		oWindow.Close();
	}


	// Get the check box control from the specified radGrid column control
    function GetCheckBox(control)
    {
        if (!control)
            return;

        for (var i = 0; i < control.childNodes.length; i++)
        {
            if (!control.childNodes[i].tagName)
                continue;

			if(control.childNodes[i].tagName == "SPAN")
            {
              if((control.childNodes[i].childNodes[0].tagName.toLowerCase() == "input") &&
                (control.childNodes[i].childNodes[0].type.toLowerCase() == "checkbox"))
              {
                return control.childNodes[i].childNodes[0];
              }
            }
            else if ((control.childNodes[i].tagName.toLowerCase() == "input") &&
                (control.childNodes[i].type.toLowerCase() == "checkbox"))
            {
                return control.childNodes[i];
            }
        }
	}
	
	
	// Get the img element from the specified radGrid column control
    function GetImgElement(control)
    {
        if (!control)
            return;

        for (var i = 0; i < control.childNodes.length; i++)
        {
            if (!control.childNodes[i].tagName)
                continue;
			if(control.childNodes[i].tagName.toLowerCase() == "span")
            {
              if((control.childNodes[i].childNodes[0].tagName.toLowerCase() == "img"))
              {
                return control.childNodes[i].childNodes[0];
              }
            }
            else if ((control.childNodes[i].tagName.toLowerCase() == "img"))
            {
                return control.childNodes[i];
            }
        }
	}  
    
    
    // Get the radio button control from the specified radGrid column control
    function GetRadioButton(control)
    {
        if (!control)
            return;

        for (var i = 0; i < control.childNodes.length; i++)
        {
            if (!control.childNodes[i].tagName)
                continue;

			if(control.childNodes[i].tagName == "SPAN")
            {
              if((control.childNodes[i].childNodes[0].tagName.toLowerCase() == "input") &&
                (control.childNodes[i].childNodes[0].type.toLowerCase() == "radio"))
              {
                return control.childNodes[i].childNodes[0];
              }
            }
            else if ((control.childNodes[i].tagName.toLowerCase() == "input") &&
                (control.childNodes[i].type.toLowerCase() == "radio"))
            {
                return control.childNodes[i];
            }
        }
    }

	
	// Get the selected HTML radio option value
	function getSelectedRadioValue(rb)
	{
		var rbVal;
		for (var i = 0; i < rb.length; i++)
		{
			if (rb[i].checked)
			{
				rbVal = rb[i].value;
				break;
			}
		}
		return rbVal;
	}
	
	// Set the specified HTML radio option to the specified value
	function setSelectedRadioValue(rb, rbVal)
	{
		for (var i = 0; i < rb.length; i++)
		{
			if (rb[i].value == rbVal)
			{
				rb[i].checked = true;
				break;
			}
		}
	}

	
	// Replace a string within a string - does not use regex
	// and will replace characters such as + that the javacript replace will not.
	function replaceSubstring(inputString, fromString, toString) {
		var temp = inputString;
		if (fromString == "") {
			return inputString;
		}
		if (toString.indexOf(fromString) == -1) { 
			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 { 
			var midStrings = new Array("~", "`", "_", "^", "#");
			var midStringLen = 1;
			var midString = "";

			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;
					}
				}
			}
			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;
			}
			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;
			}
		} 
		return temp; 
	} 
	
	// Executes a button click when the user presses the Enter button in a textbox
	// To use this, assign the keypess event to the textbox, and specify the button to click
	// i.e. Me.TextBox1.Attributes.Add("onkeypress", "return clickButton(event,'" + Me.Button1.ClientID + "')")
	function clickButton(e, buttonid)
	{ 
		var bt = document.getElementById(buttonid); 
		if (typeof bt == 'object'){
			if(navigator.appName.indexOf("Netscape")>(-1)){
					if (e.keyCode == 13){
					    window.location = document.getElementById(buttonid).href;
						// bt.click(); 
						return false; 
					} 
			} 
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
					if (event.keyCode == 13){ 
						bt.click(); 
						return false; 
					} 
			} 
		} 
	}
	
	
	// Sets the focus on an object
	// Call this method in javascript or set it in code behind as follows:
	// Page.ClientScript.RegisterStartupScript(Me.GetType(), "focus", String.Format("setFocus('{0}');", Me.txtBox.ClientID.ToString()), True)
	function setFocus(objId)
	{
	    var obj = document.getElementById(objId);
	    if (obj)
	        obj.focus();
	}
	
	
	function setFocus2(objId)
	{
	    var obj = $find(objId);
	    if (obj)
	        obj.focus();
	}
	
	
	//change the opacity for different browsers 
    function changeOpac(opacity, id)
    { 
        var object = document.getElementById(id).style; 
        object.opacity = (opacity / 100); 
        object.MozOpacity = (opacity / 100); 
        object.KhtmlOpacity = (opacity / 100); 
        object.filter = "alpha(opacity=" + opacity + ")"; 
    } 

	
	// pauses or waits the specified milliseconds before continuing
	function pausecomp(millis) 
	{
		var date = new Date();
		var curDate = null;

		do { curDate = new Date(); } 
		while(curDate-date < millis);
	}
	
	
	// set the tooltip options
	// Options:
	//    ele - the control element to display tooltip. Required.
	//    fgcolor - the foreground color of the tooltip window. Default if empty is the current page text color.
	//    bgcolor - the background color of the tooltip window. Default if empty is the current page background color.
	//    width - the width of the tooltip window. Default if zero is width of message, but if it's a long message, you may want to set the width
	//    offdelay - the delay in milliseconds to turn off the tooltip. Default if zero is no turn off until mouse off.
	// Usage: <img src="..." onmouseover="setToolTipOpts(this, '#ffffff', '#cccccc', 210, 1000); return escape('it\'s my tooltip');">    <<< set options
	//    or  <img src="..." onmouseover="setToolTipOpts(this, '', '', 0, 0); return escape('it\'s my tooltip');">    <<< all default options
	// Note: the message text must consist of "\'" instead of "'" or """.
	function setToolTipOpts(ele, fgcolor, bgcolor, width, offdelay)
	{
	    if (width > 0)
	        ele.T_WIDTH=width;
	    else
	        ele.T_WIDTH=0;

        if (fgcolor.length > 0)
            ele.T_FONTCOLOR='fgcolor';
            
        if (bgcolor.length > 0)
            ele.T_BGCOLOR='bgcolor';
            
        if (offdelay > 0)
            ele.T_TEMP=offdelay;
    }
   
   
    // set the tooltip text and options >>> Not used and does not work with return escape
	// Options:
	//    ele - the control element to display tooltip. Required.
	//    msg - the text message to display in the tooltip. Required.
	//    fgcolor - the foreground color of the tooltip window. Default if empty is the current page text color.
	//    bgcolor - the background color of the tooltip window. Default if empty is the current page background color.
	//    width - the width of the tooltip window. Default if zero is width of message up to approx 40 chars (210).
	//    offdelay - the delay in milliseconds to turn off the tooltip. Default if zero is no turn off until mouse off.
	// Usage: <img src="..." onmouseover="setToolTip(this, 'it\'s my tooltip', '#ffffff', '#cccccc', 210, 1000)">
	//    or  <img src="..." onmouseover="setToolTip(this, 'it\'s my tooltip', '', '', 0, 0)">
	// Note: the message text must consist of "\'" instead of "'" or """.
   	function setToolTip2(ele, msg, fgcolor, bgcolor, width, offdelay)
	{
	    if (msg.length = 0)
	        return;
	        
	    if (width > 0)
	        ele.T_WIDTH=width;
	    else if (msg.length > 40)
	        ele.T_WIDTH=210;
	    else
	        ele.T_WIDTH=0;

        if (fgcolor.length > 0)
            ele.T_FONTCOLOR='fgcolor';
            
        if (bgcolor.length > 0)
            ele.T_BGCOLOR='bgcolor';
            
        if (offdelay > 0)
            ele.T_TEMP=offdelay;
        
        return escape('msg');
    }
   
    
    //  >>> Not used and does not work with return escape
    function setToolTip3(msg, fgcolor, bgcolor, width, offdelay)
	{
	    if (msg.length = 0)
	        return;
	        
	    var opts = '';
	    if (width > 0)
	        opts = "this.T_WIDTH=" + width + ";";
	    else if (msg.length > 40)
	        opts = "this.T_WIDTH=210;";
	    else
	        opts = "this.T_WIDTH=0;";

        if (fgcolor.length > 0)
            opts += "this.T_FONTCOLOR='" + fgcolor + "';";
            
        if (bgcolor.length > 0)
            opts += "this.T_BGCOLOR='" + bgcolor + "';";
            
        if (offdelay > 0)
            opts += "this.T_TEMP=" + offdelay + ";";
       
        return opts + " return escape('" + msg.replace("'", "\'") + "');";
    }
            

//-->