﻿// JScript File

//This function is not currently used, leaving it in place
//  _until we know the popdown solution will work for what we need
function OpenCipHelpPopup(surl, sname, soptions)
{   //open the requested help popup
    var HelpWindow = window.open(surl,sname,soptions);
    if(HelpWindow) { HelpWindow.focus(); }
    return false;
}

//Check all-for the search box
//sAllCheckboxID=id of the "check all" checkbox
//sTargetCheckboxList=comma separated list of checkbox ids for those affected by the "check all"
//**check-all put on hold for now
function SearchBox_SelectAll(sAllCheckboxID, sTargetCheckboxList)
{   //get the current check/uncheck status
    var bStatus = document.getElementById(sAllCheckboxID).checked;
    //loop through the target checkboxes and check/uncheck them
    var sAryCheckboxes=sTargetCheckboxList.split(",");
    for(var i=0;i<sAryCheckboxes.length;i++)
    {   document.getElementById(sAryCheckboxes[i]).checked=bStatus;
    }
    //alert("hello");
}

function setupCrosswalkSearchForm(sender, selectList, textBox){
    
    if (sender=="rb1"){
        document.getElementsByName(selectList)[0].disabled="disabled";
        document.getElementsByName(textBox)[0].disabled="disabled";
        //alert("rb1");
    }else if(sender=="rb2"){
        document.getElementsByName(selectList)[0].disabled="";
        document.getElementsByName(textBox)[0].disabled="disabled";
       //alert("rb2");
    }else if(sender=="rb3"){
        document.getElementsByName(selectList)[0].disabled="disabled";
        document.getElementsByName(textBox)[0].disabled=false;
        //alert("rb3");
    }
}

//Make sure the textbox contains input if it is visible
function crosswalk_CheckRequiredTextbox(sTextboxId, sErrorMessageId)
{   var oTextBox = document.getElementById(sTextboxId);
    var oErrorMessage = document.getElementById(sErrorMessageId);
    if(oTextBox)
    {   if(oTextBox.disabled==false)
        {   //textbox is visible, see if text was entered
            if(oTextBox.value.replace(/ /g,'')=='')
            {   //the user did not enter text, show message
                oErrorMessage.innerHTML='*<b>Required</b>';
                alert('Please enter a single CIP number to filter on.');
                return false;
            }
            else //visible, with text, allow user to continue
            {   return true;
            }
        }
    }
    return true;
}

//=====================================================================
//cip detail expand/collapse sections
//Modify the image to be the Open or Closed version
function CipDetail_ModifyImage(sImageId, bOpen)
{   var oImage = document.getElementById(sImageId);
    if(oImage)
    {   if(bOpen)
        {   //show the opened version
            oImage.src="images/icon_arrowright.gif";
            oImage.alt="Open panel";
            oImage.title="Open panel";
        }
        else
        {   //show the closed version
            oImage.src="images/icon_arrowdown.gif";
            oImage.alt="Close panel";
            oImage.title="Close panel";
        }
    }
}
//expand/collapse the section
function CipDetail_ToggleSection(sImageId, sTargetSection)
{   
var oCurrentStyle = document.getElementById(sTargetSection).style;
	if(oCurrentStyle.display=="")
	{   //currently visible, hide it
	    oCurrentStyle.display="none";
	    CipDetail_ModifyImage(sImageId, true);
	}
	else
	{   //currently hidden, show it
	    oCurrentStyle.display="";
	    CipDetail_ModifyImage(sImageId, false);
	}
}



