   /*script functions*/
   //limits textbox input to whole numbers
    function onlyNumeric()
    {
        if (event.keyCode < 48 || event.keyCode > 57)
        {
            if(event.keyCode != 45)
                event.returnValue = false; 
        }
    }
    
    //displays an alert when the cancel button is clicked to make sure that is the intended action
    function AreYouSure() {
        return confirm("Are you sure you wish to cancel, you will lose all information you have entered thus far?");
    }
    
    function clickButton2(e, buttonid)
	{ 
		var bt = document.getElementById(buttonid); 
		if (typeof bt == 'object')
		{ 
			if(navigator.appName.indexOf("Netscape")>(-1))
			{ 
				if (e.keyCode == 13)
				{ 
					bt.click(); 
					return false; 
				} 
			} 
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
			{ 
				if (event.keyCode == 13)
				{ 
					bt.click(); 
					return false; 
				} 
			} 
		} 
	}
	function NextPage(cFrom,c2)
    {
        var con1 = document.getElementById(cFrom);
        var con2 = document.getElementById(c2);
        con1.style.display='none';
        con2.style.display='';
        return false;
    }
    //this function is called from the usercontrol as an attribute 
    //that has been added to the code textbox in the onload event
    function EnableNext(ctl)
    {
        var txt = document.getElementById(ctl+'_txtPC');
        var ddl = document.getElementById(ctl+'_ddlMod');
        if (txt)
            txt.disabled=false;
        if (ddl)
            ddl.disabled=false; 
    }
    function CheckDDLText(source, arguments)
    {
        if (arguments.Value < 1)
        {
            arguments.IsValid = false;
        }
        else
        {
            arguments.IsValid = true;
        }
    }
    function CheckClick(source, args)
    {
        arguments.IsValid = false;
    }
    function retract(ddl,v)
    {
        var i;
        for (i=0;i<ddl.length;i++)
        {
            if (ddl.options[i].value==v)
                break;
        }
        if (i == ddl.length)
            i = -1;
        ddl.selectedIndex = i;
    }
    function IsReasonGiven(txt)
    {
        var otxt = document.getElementById(txt);
        if (!otxt)
        {
            alert('A reason for denial is required');
            return false;
        }
        if (otxt.value.length > 0)
            return true;
        else
        {
            alert('A reason for denial is required');
            return false;
        }
    }
    function ShowHideElement(objS, objH, cID)
    {
        var oShow = document.getElementById(objS);
        var oHide = document.getElementById(objH);
        var expand = 'false';
        var dv = oShow.parentNode;
        var img = document.getElementById(cID);
        img.click();
        ShowHide(oShow, oHide, dv);
        return false;
        if (objS.indexOf("DetailTemplateDiv")>-1)
        {
            expand='true';
        }
        else
            if ( document.forms[0].elements[pnlID+'_State']!=null )
            {
                if (document.forms[0].elements[pnlID+'_State'].value=='Expanded')
                {
                    expand='false';
                    ShowHide(oShow, oHide, dv)
                }
                else
                {
                    expand='false';
                    ShowHide(oShow, oHide, dv)
                    img.click();
                }
            }
            else
            {
                expand='false';
                ShowHide(oShow, oHide, dv)
                img.click();
            }
            
        if (expand=='true')
        {
            img.click();
            //setTimeout(function(){ShowHide(oShow, oHide, dv)},1000);
            ShowHide(oShow, oHide, dv);
        }
        
       return false;
    }
    function ShowHide(os, oh, dv)
    {
        if (os)
        {         
            os.style.display='';
        }
        if (oh)
        {
            oh.style.display='none';
        }
        dv.style.height= "100%";
    }
    function HideExtender()
    {
        if(AjaxControlToolkit.ValidatorCalloutBehavior._currentCallout != null)
        {
            AjaxControlToolkit.ValidatorCalloutBehavior._currentCallout.hide();
        }
    }
    function HideAndReturn(flag, idee)
    {
        HideExtender();
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(idee, "", false, "", "", false, flag));
    }
    function CloseAndfocus(el, val)
    {
        var v = document.getElementById(val);
        v.isvalid = true;
        HideExtender();
    }
    function disableAnchor(objid, disable)
    {
        var obj = document.getElementById(objid);
        if (obj)
        {
            if(disable)
            {
                var href = obj.getAttribute("href");
                if(href && href != "" && href != null)
                {
                   obj.setAttribute('href_bak', href);
                }
                obj.removeAttribute('href');
                obj.style.color="gray";
            }
            else
            {
                obj.setAttribute('href', obj.attributes['href_bak'].nodeValue);
                obj.style.color="black";
            }
        }
    }
//****************************************************************
//Sliding Div taken from http://firblitz.com/2007/3/6/re-how-to-create-digg-comment-style-sliding-divs-with-javascript-and-css
//4-05-08
//****************************************************************

var slidesInUse = new Array();

function SlideIt(objId, options) 
{
    this.obj = document.getElementById(objId);
    this.duration = 1;  
    this.height = parseInt(this.obj.offsetHeight);

    if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
    if(this.options.duration) { this.duration = this.options.duration; }
		
    this.up = function() {
            
        this.curHeight = this.height;
        this.newHeight = '1';
        if(slidesInUse[objId] != true) {
            var finishTime = this.slide();
            window.setTimeout("SlideIt('"+objId+"').finishup("+this.height+");",finishTime);
        }
    }
	
    this.down = function() {
        this.newHeight = this.height;
        this.curHeight = '1';
        if(slidesInUse[objId] != true) {
            this.obj.style.height = '1px';
            this.obj.style.display = '';
            this.slide();
        }
    }
	
    this.slide = function() {
        slidesInUse[objId] = true;
        var frames = 30 * duration; // Running at 30 fps
        var tIncrement = (duration*1000) / frames;
        tIncrement = Math.round(tIncrement);
        var sIncrement = (this.curHeight-this.newHeight) / frames;

        var frameSizes = new Array();
        for(var i=0; i < frames; i++) {
            if(i < frames/2) {
	            frameSizes[i] = (sIncrement * (i/frames))*4;
            } else {
	            frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
            }
        }
		
        for(var i=0; i < frames; i++) {
            this.curHeight = this.curHeight - frameSizes[i];
            window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
        }
		
        window.setTimeout("delete(slidesInUse['"+objId+"']);",tIncrement * i);
		
        if(this.options.onComplete) {
            window.setTimeout(this.options.onComplete, tIncrement * i);
        }
		
        return tIncrement * i;
    }
	
    this.finishup = function(height) {
        this.obj.style.display = 'none';
        this.obj.style.height = height + 'px';
    }

    return this;
}

function ResetValidators(divID)
{
    var DivObj= document.getElementById(divID);
    var spans = DivObj.getElementsByTagName('span');
    if(spans)
    {
     for(var j = 0; j < spans.length; j++) 
    {
       
       spans[j].style.display='none'; 
    }
  } 
} 
        
//Reset all the fields before displaying the page
function clearAll(divID)
 {
 
  var DivObj= document.getElementById(divID);
  var Nodes = DivObj.getElementsByTagName('INPUT');
  var dropDown = DivObj.getElementsByTagName('Select');
  for(var k = 0; k <dropDown.length ; k++) 
   {
      if(dropDown[k].options.length > 0)
      dropDown[k].options[0].selected = true;
   }
   for(var j = 0; j < Nodes.length; j++) 
   {
      var input = Nodes[j];
      inputType = input.type;      
      if(inputType == 'text') 
      {
       input.value = "";
      }
      else if(inputType == 'checkbox')
      {
      input.checked = false;
      }
      else if(inputType == 'select-one')
      {
      input.selectedIndex = -1;
      }
      else if(inputType == 'select-multiple')
      {
      input.selectedIndex = -1;
      }
      else if(inputType == 'select')
      {
      input.selectedIndex = -1;
      }
      else if(inputType == 'radio')
      {
      if(input.value== "0")
      input.checked = true;
      }
    } 
}
function Cancel(divID)
{ 
    var obj = document.getElementById(divID);
    var elms = obj.getElementsByTagName("*");
    for (var i=0; i<elms.length;i++)
    {
        var ele =elms[i];
        if (ele.type == 'text')
            ele.value = '';
        if (ele.type == 'select-one')
        {
            ele.selectedIndex=0;
        }

    }
    ResetValidators(divID);
    return false;
}
//*************************************************************************************************
