var isWorking = false;
var http = false;
var timeOutMillisecondTime = 50;
var CBPWebServiceUrl = "xmlhttpcbp.aspx";
var VBPWebServiceUrl = "xmlhttpvbp.aspx";
var RequestContentType = "application/x-www-form-urlencoded; charset=UTF-8";
var HTTPMethod = "POST";
var debugString = "";
var CommandQueue = Array();
var MAX_RETRIES = 5;
var AJAX_ERROR_MSG = "Unfortunately our site has encountered an error, and we apologize for the inconvenience. Please call our Customer Service at 1-866-559-9633 and we would be glad to assist you in whatever manner possible.";
var AJAX_TIME_OUT_IN_SECONDS = 6;
var DROPDOWN_TIMEOUT_DELAY = 250;
var pleaseWaitString = "Please Wait...";
var selectString = "Select...";
var notapplicableString = "Not Applicable";
var debugString = "";
var CommandQueue = Array();
var RedirectInProcess = false;
function ShowCertTypeChecks(selection)
{
var checkblock = document.getElementById(ClientID.replace("$", "_").replace("$", "_") + "checkblock");
if(selection == 'Birth')
{
checkblock.style.display = '';
}
else
{
checkblock.style.display = 'none';
}
}
function closeMsg()
{
document.getElementById('NoDocsMsg_container').style.display = 'none';
document.getElementById('DivShim').style.display = 'none';
}
function viewAgency()
{
document.getElementById('NoDocsMsg_container').style.display = 'none';
document.getElementById('DivShim').style.display = 'none';
document.location.href='http://www.vitalchek.com/agency_listing.aspx';
}
/* general use functions */
function appendDebug(d)
{
//uncomment these lines below to turn the debug lines on
//var debugCtrl = document.getElementById("debug");
//debugCtrl.innerHTML = debugCtrl.innerHTML + d + "
";
}
function isValueinArray(value,values)
{
return (indexOfValueInArray(value,values) != -1);
}
function indexOfValueInArray(value,values) {
var index = -1;
for(i=0; i < values.length; i++)
{
if (value == values[i])
{
index = i;
return index;
}
}
return index;
}
function isSelected(ControlID)
{
var element = document.getElementById(ClientID + ControlID);
if (element.options) {
return ((element.value != "") && (element.value != "ALL"));
}
else
{
var att;
att = element.getAttribute("type");
var isSel = false;
//window.alert(att);
//if it's a hidden field, it's selected cause it's probably got a value already set.
if (att == "hidden")
{
isSel = true;
}
//if it's the text area, don't sweat it, blow it away.
if (att == "text")
{
isSel = false;
}
return isSel;
//it has no options, so it's selected!
//return ((element.value != "") && (element.value != "[Type City Here]"));
//return true;
}
}
// Function to hide and show content and make header tab active / inactive
function changeContent(x) {
var infoMenuGroup = document.getElementById('info_menu');
var infoMenuGroupArray = infoMenuGroup.getElementsByTagName('a');
var infoMenuGroupLength = infoMenuGroupArray.length;
for (i = 0; i < infoMenuGroupLength; i++) {
infoMenuGroupArray[i].setAttribute("class", "");
infoMenuGroupArray[i].setAttribute("className", "");
}
var activeURL = document.getElementById('info_menu_item' + x);
activeURL.setAttribute("class", "active");
activeURL.setAttribute("className", "active");
var changeURL = document.getElementById('info_text');
var changeURLdivArray = changeURL.getElementsByTagName('div');
var changeURLdivLength = changeURL.getElementsByTagName('div').length;
for (i = 0; i < changeURLdivLength; i++) {
changeURLdivArray[i].style.display="none";
}
document.getElementById('info_menu_item' + x + '_content').style.display = "block";
}
/* date controls related stuff */
function loadMonthDays(month, day, year)
{
//window.alert(year + "-" + month + "-" + day );
var days;
if (isLeapYear(year))
{
days = Array(31,29, 31,30, 31,30, 31,31, 30,31, 30,31);
}
else
{
days = Array(31,28, 31,30, 31,30, 31,31, 30,31, 30,31);
}
//clear months and
eventDay = document.getElementById(ClientID + "eventday");
eventDay.options.length = 0;
eventDay.options[0] = new Option("", "");
var rid;
var reason;
for(n = 1; n <= days[month-1]; n++)
{
// prepend with 0 for days < 10
if(n < 10)
{
var n2 = '0' + n;
eventDay.options[n ] = new Option(n2,n2);
}
else
{
eventDay.options[n ] = new Option(n,n);
}
if ((n - day) == 0) {
eventDay.options[n ].selected = true;
}
}
}
function isLeapYear(year)
{
if ((year % 4) == 0)
{
if ((year % 100) == 0)
{
if ((year % 400) == 0)
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
else
{
return false;
}
}
/* reason-related stuff */
function reason_onChangeEvent()
{
var reasonSelect = document.getElementById(ClientID + "reason");
var reasonHidden = document.aspnetForm.reasontext;
reasonHidden.value = reasonSelect.options[reasonSelect.options.selectedIndex].text;
}
function shouldReasonChange()
{
//check out:
//certtype
//stateselect
//cityselect
//countyselect
//eventyear
//eventmonth
//eventday
//reason
var elementsToCheck = Array();
//certtype
if (document.getElementById(ClientID + "certtype"))
{
elementsToCheck.push(document.getElementById(ClientID + "certtype").value);
}
//stateselect
elementsToCheck.push(document.getElementById(ClientID + "stateselect").value);
// Bug 9212 - Make city/county checks optional based on checkbox
var elem = document.getElementById('chkUnknownLocation');
if (elem == null || elem.checked == false)
{
//End 9212
//cityselect
if(document.getElementById(ClientID + "stateselect").value != "YC")
elementsToCheck.push(document.getElementById(ClientID + "cityselect").value);
//countyselect
elementsToCheck.push(document.getElementById(ClientID + "countyselect").value);
}
//eventyear
elementsToCheck.push(document.getElementById(ClientID + "eventyear").value);
//eventmonth
elementsToCheck.push(document.getElementById(ClientID + "eventmonth").value);
//eventday
elementsToCheck.push(document.getElementById(ClientID + "eventday").value);
var allNonEmpty=true;
for(i=0; i< elementsToCheck.length; i++) {
allNonEmpty = allNonEmpty && (elementsToCheck[i] != "");
}
if (allNonEmpty)
{
var pageLoadedWithProviderLocked = document.getElementById("ProviderLocked").value;
//if we have a provider_id then
if (pageLoadedWithProviderLocked == 'True')
{
PopulateReasonsByProviderID();
//load reasons with the provider id
//window.alert ("all non empty, use provider id!");
document.getElementById(ClientID + "reason").disabled = false;
}
else
{
PopulateReasonsByLocation();
//load the reasons by the location
//window.alert ("all non empty, use location!");
document.getElementById(ClientID + "reason").disabled = false;
}
} else {
document.getElementById(ClientID + "reason").disabled = true;
// do nothing, we can't load the reason without all this info
}
}
/* popup related stuff */
/* label changing stuff */
//Bug 9212
function SetCityCountyText(checkBox_label_ctrl, location_ctrl, checked, location_name)
{
//If the box is checked, remove the appropriate required flag
if (checked)
{
if (checkBox_label_ctrl.innerText)
{
if (checkBox_label_ctrl.innerText.indexOf(location_name) > -1)
{
location_ctrl.innerText = location_ctrl.innerText.replace("*", "");
}
}
else
{
if (checkBox_label_ctrl.firstChild.nodeValue.indexOf(location_name) > -1)
{
location_ctrl.firstChild.nodeValue = location_ctrl.firstChild.nodeValue.replace("*", "");
}
}
}
//If the box isn't checked, always restore the required flag if there isn't one
else
{
if (location_ctrl.innerText)
{
if (location_ctrl.innerText.indexOf("*") == -1)
{
location_ctrl.innerText += "*";
}
}
else
{
if (location_ctrl.firstChild.nodeValue.indexOf("*") == -1)
{
location_ctrl.firstChild.nodeValue += "*";
}
}
}
}
function PopulateSelectLabelsByLocation()
{
//we used to use AJAX for this.. but now this code is defined in agency_locator.asp
ChangeLabels();
}
//End 9212
function makeElementBoldAndRed(elementID)
{
var el;
el = document.getElementById(elementID);
el.style.fontWeight = "bold";
el.style.color = "red";
}
function makeElementNormalAndBlack(elementID)
{
var el;
el = document.getElementById(elementID);
el.style.fontWeight = "normal";
el.style.color = "black";
}
function testsstate_onSubmit()
{
var isValid = true;
var sMsg = "";
var errorSeparator = "\n\t";
var firstInvalidFieldName = "";
if (document.getElementById(ClientID + "certtype"))
{
if ( document.getElementById(ClientID + "certtype").value != "" ) {
isValid = isValid && true;
makeElementNormalAndBlack("certlist_label");
} else {
sMsg = sMsg + "Type of Event (Birth, Death, Marriage, Divorce)" + errorSeparator;
firstInvalidFieldName = ClientID + "certtype";
isValid = isValid && false;
makeElementBoldAndRed("certlist_label");
}
}
if ( document.getElementById(ClientID + "stateselect").value != "" ) {
isValid = isValid && true;
makeElementNormalAndBlack("primary_location");
makeElementNormalAndBlack("stateprov_verbiage_label");
} else { // ATJ - 05/18/2007 - AL-5
sMsg = sMsg + "State where " + SelectedCertTypeLowerCase + " occurred" + errorSeparator;
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "stateselect";
isValid = isValid && false;
makeElementBoldAndRed("primary_location");
makeElementBoldAndRed("stateprov_verbiage_label");
}
//Bug 9212
var elem = document.getElementById('chkUnknownLocation');
var cityRequired = FieldIsRequired("secondary_location");
var countyRequired = FieldIsRequired("tertiary_location");
if(document.getElementById(ClientID + "stateselect").value == "YC")
cityRequired = false;
document.getElementById("cityRequired").value = cityRequired;
document.getElementById("countyRequired").value = countyRequired;
if (cityRequired)
{
//End 9212
if ( document.getElementById(ClientID + "cityselect").value != "" ) {
isValid = isValid && true;
makeElementNormalAndBlack("secondary_location");
} else {
//sMsg = sMsg + "City" + errorSeparator;
sMsg = sMsg + GetLocationLabel(1) + errorSeparator;
isValid = isValid && false;
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "cityselect";
makeElementBoldAndRed("secondary_location");
}
//Bug 9212
}
else
{
makeElementNormalAndBlack("secondary_location");
}
if (countyRequired)
{
//End 9212
if ( document.getElementById(ClientID + "countyselect").value != "" ) {
isValid = isValid && true;
makeElementNormalAndBlack("tertiary_location");
} else {
//sMsg = sMsg + "County" + errorSeparator;
sMsg = sMsg + GetLocationLabel(2) + errorSeparator;
isValid = isValid && false;
makeElementBoldAndRed("tertiary_location");
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "countyselect";
}
// Bug 9212
}
//End 9212
var dateValid = true;
if ( document.getElementById(ClientID + "eventmonth").value != "" ) {
isValid = isValid && true;
} else {
//sMsg = sMsg + "Month" + errorSeparator;
isValid = isValid && false;
dateValid = false;
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "eventmonth";
}
if ( document.getElementById(ClientID + "eventday").value != "" ) {
isValid = isValid && true;
} else {
//sMsg = sMsg + "Day" + errorSeparator;
isValid = isValid && false;
dateValid = false;
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "eventday";
}
if ( document.getElementById(ClientID + "eventyear").value != "" ) {
isValid = isValid && true;
} else {
//sMsg = sMsg + "Year" + errorSeparator;
isValid = isValid && false;
dateValid = false;
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "eventyear";
}
if (!dateValid)
{ // ATJ - 05/18/2007 - AL-7
sMsg = sMsg + "Date of " + SelectedCertTypeLowerCase + " (Month, Day, Year)" + errorSeparator;
makeElementBoldAndRed("date_label");
}
else
{
makeElementNormalAndBlack("date_label");
}
if ( document.getElementById(ClientID + "reason").value != "" ) {
isValid = isValid && true;
makeElementNormalAndBlack("reason_label");
} else {
sMsg = sMsg + "Reason for Request";
isValid = isValid && false;
makeElementBoldAndRed("reason_label");
if (firstInvalidFieldName == "")
firstInvalidFieldName = ClientID + "reason";
}
if (isValid) {
document.aspnetForm.submit();
} else {
//VERBIAGE HERE
var verbiage = "In order to locate the agency, we still need the following fields selected:\n";
window.alert(verbiage + "\n\t" + sMsg);
//window.alert(firstInvalidFieldName);
if (firstInvalidFieldName != "" && document.getElementById(firstInvalidFieldName).disabled != true)
{
document.getElementById(firstInvalidFieldName).focus();
}
}
}
function GetLocationLabel(lblIndex)
{
var selectedState = escape( document.getElementById(ClientID + "stateselect").value );
StateCodesArray = eval("[" + StateCodesArrayAsString + "]");
SelectLabelsArray = eval("[" + SelectLabelsArrayAsString + "]");
var found=false;
for(i=0;i < SelectLabelsArray.length;i++)
{
if (selectedState == StateCodesArray[i])
{
found=true;
labels = SelectLabelsArray[i];
i=SelectLabelsArray.length; //exit loop
}
}
if (found==false)
{
labels = "State,City,County";
}
//change the LABELS here
var labels_array=labels.split(",");
return labels_array[lblIndex];
}
function FieldIsRequired(fldName)
{
var req;
location_ctrl = document.getElementById(fldName);
if (location_ctrl.innerText)
{
if (location_ctrl.innerText.indexOf("*") > -1)
{
req = true;
}
else
{
req = false;
}
}
else
{
if (location_ctrl.firstChild.nodeValue.indexOf("*") > -1)
{
req = true;
}
else
{
req = false;
}
}
return req;
}
function ChangeLabels()
{
var selectedState = escape( document.getElementById(ClientID + "stateselect").value );
var SelectLabelsArray = Array();
var StateCodesArray = Array();
var labels;
var found = false;
StateCodesArray = eval("[" + StateCodesArrayAsString + "]");
SelectLabelsArray = eval("[" + SelectLabelsArrayAsString + "]");
for(i=0;i < SelectLabelsArray.length;i++)
{
if (selectedState == StateCodesArray[i])
{
found=true;
labels = SelectLabelsArray[i];
i=SelectLabelsArray.length; //exit loop
}
}
if (found==false)
{
labels = "State,City,County";
}
//change the LABELS here
var labels_array=labels.split(",");
var primary_location_ctrl,secondary_location_ctrl,tertiary_location_ctrl;
primary_location_ctrl = document.getElementById("primary_location");
secondary_location_ctrl = document.getElementById("secondary_location");
tertiary_location_ctrl = document.getElementById("tertiary_location");
if (primary_location_ctrl.innerText)
{
primary_location_ctrl.innerText = labels_array[0];
secondary_location_ctrl.innerText = labels_array[1] + "*";
tertiary_location_ctrl.innerText = labels_array[2] + "*";
}
else
{
primary_location_ctrl.firstChild.nodeValue = labels_array[0];
secondary_location_ctrl.firstChild.nodeValue = labels_array[1] + "*";
tertiary_location_ctrl.firstChild.nodeValue = labels_array[2] + "*";
}
}
/* unknown field related stuff */
function chkUnknownLocation_onChangeEvent(checked)
{
chkUnknownLocation_ctrl = document.getElementById("chkUnknownLocation");
lblUnknownLocation_ctrl = document.getElementById("lblUnknownLocation");
if (chkUnknownLocation_ctrl != null)
{
chkUnknownLocation_ctrl.checked = checked;
}
secondary_location_ctrl = document.getElementById("secondary_location");
tertiary_location_ctrl = document.getElementById("tertiary_location");
SetCityCountyText(lblUnknownLocation_ctrl, secondary_location_ctrl, checked, "City");
SetCityCountyText(lblUnknownLocation_ctrl, tertiary_location_ctrl, checked, "County");
if (checked)
{
makeElementNormalAndBlack("secondary_location");
}
shouldReasonChange();
}
//return the cert value depending on whether it is a radio group or a drop down
function getSelectedCertValue()
{
if (document.getElementById(ClientID + "certtype"))
{
return document.getElementById(ClientID + "certtype").value;
}
else
{
if (document.getElementById(ClientID +"deathRadio").checked)
{
return document.getElementById(ClientID +"deathRadio").value;
}
if (document.getElementById(ClientID +"marriageRadio").checked)
{
return document.getElementById(ClientID +"marriageRadio").value;
}
if (document.getElementById(ClientID +"divorceRadio").checked)
{
return document.getElementById(ClientID +"divorceRadio").value;
}
return document.getElementById(ClientID +"birthRadio").value;
}
}
/* redirect users stuff */
function CheckSpecialRedirect()
{
var state = document.getElementById(ClientID + 'stateselect').value;
var city = document.getElementById(ClientID + 'cityselect').value;
var county = document.getElementById(ClientID + 'countyselect').value;
var certtype=getSelectedCertValue();
switch(state)
{
// if customer selects Massachusetts, present pop-up and transfer them to USCerts
case 'MA':
RedirectUsers("&state=MA&type=" + certtype + "&county=" + county + "&city=" + city);
return false;
// if customer selects New Hampshire and any city except Dover or Nashua, present pop-up and transfer them to USCerts
case 'NH':
if (city != 'Nashua' && city != 'Dover' && city != 'Derry')
{
RedirectUsers("&state=NH&type=" + certtype + "&county=" + county + "&city=" + city);
return false;
}
}
return true;
}
function RedirectUsers(parms)
{
var DivRef = document.getElementById('Redirect_container');
var IfrRef = document.getElementById('DivShim');
DivRef.style.position = 'absolute';
DivRef.style.left = '140px';
DivRef.style.top = '50px';
DivRef.style.display = 'block';
IfrRef.style.width = DivRef.offsetWidth;
IfrRef.style.height = DivRef.offsetHeight;
IfrRef.style.top = DivRef.style.top;
IfrRef.style.left = DivRef.style.left;
IfrRef.style.border='3px';
IfrRef.style.zIndex = DivRef.style.zIndex - 1;
IfrRef.style.display = 'block';
RedirectInProcess = true;
manualUrl = 'http://www.uscerts.com/uscerts/certificates?p_action=fromVitalChek' + parms;
window.setTimeout("window.location='" + manualUrl + "'", 7000);
}
/* load condition and init functions */
function processLoadConditions(selectedCertType, selectedState, selectedCity, selectedCounty, selectedYear, selectedMonth, selectedDay, selectedReason)
{
if(document.getElementById(ClientID + "stateselect").value == 'MA')
{
var certtype = getSelectedCertValue();
RedirectUsers("&state=MA&type=" + certtype + "&county=&city=");
return false;
}
addCommand("isProviderLocked();");
var cntySel = document.getElementById(ClientID + "countyselect");
if (cntySel.options)
{
if (cntySel.options.length > 1)
{
cntySel.disabled = false;
}
else
{
//cntySel.disabled = true;
}
}
else
{
//document.testsstate.countyselect.disabled = true;
}
var citySel = document.getElementById(ClientID + "cityselect");
if (citySel.options)
{
if (citySel.options.length > 1)
{
citySel.disabled = false;
}
else
{
citySel.disabled = true;
}
}
else
{
//document.testsstate.cityselect.disabled = true;
}
var reas = document.getElementById(ClientID + "reason");
reas.disabled = true;
var CertType = "";
var State = "";
var City = "";
//Load the cert value depending on whether it is a radio group or a drop down
var cert = document.getElementById(ClientID + "certtype");
if (cert)
{
//We are using old school drop downs
if (cert.options)
{
cert.selectedIndex = 0;
}
if (cert.tagName == "INPUT")
{
CertType = cert.value;
}
else
{
if (selectedCertType != "")
{
for(i=0; i< cert.options.length;i++) {
if (cert.options[i].value.toLowerCase() == selectedCertType.toLowerCase()) {
cert.options[i].selected=true;
}
}
certtype_onChangeEvent();
CertType = cert.value;
}
if (selectedReason != "") {
for(i=0; i< reas.options.length;i++) {
if (reas.options[i].value == selectedReason) {
reas.options[i].selected=true;
}
}
//make sure to set the hidden value
document.getElementById(reasontext).value = selectedReason;
reason_onChangeEvent()
}
}
}
else
{
//we are using radio buttons
document.getElementById(ClientID +"birthRadio").checked=true;
if (document.getElementById(ClientID +"deathRadio").value==selectedCertType)
{
document.getElementById(ClientID +"deathRadio").checked=true;
}
if (document.getElementById(ClientID +"marriageRadio").value==selectedCertType)
{
document.getElementById(ClientID +"marriageRadio").checked=true;
}
if (document.getElementById(ClientID +"divorceRadio").value==selectedCertType)
{
document.getElementById(ClientID +"divorceRadio").checked=true;
}
certtype_onChangeEvent();
if (selectedReason != "") {
for(i=0; i< reas.options.length;i++) {
if (reas.options[i].value == selectedReason) {
reas.options[i].selected=true;
}
}
//make sure to set the hidden value
document.getElementById(reasontext).value = selectedReason;
reason_onChangeEvent()
}
}
var stateSel = document.getElementById(ClientID + "stateselect");
if (stateSel.tagName == "INPUT")
{
State = stateSel.value;
//if state is an INPUT, not a select,
//it was navigated to already in a sense, so
//boom, push it on.
controlsNavigated.push("stateselect");
}
else
{
if (selectedState != "")
{
controlsNavigated.push("stateselect");
initState(selectedState);
}
else
{
stateSel.options[0].selected = true;
}
}
if (cntySel.tagName == "INPUT")
{
//if county is an INPUT, not a select,
//it was navigated to already in a sense, so
//boom, push it on.
controlsNavigated.push("countyselect");
}
else
{
//window.alert(selectedCounty);
//setTimeout("true;", timeOutMillisecondTime*2);
if (selectedCounty != "")
{
controlsNavigated.push("countyselect");
initCounty(selectedCounty);
}
}
doCommand();
if (citySel.tagName == "INPUT")
{
City = document.getElementById(ClientID + "cityselect").value;
//controlsNavigated.push("stateselect");
//if city is an INPUT, not a select,
//it was navigated to already in a sense, so
//boom, push it on.
controlsNavigated.push("cityselect");
}
else
{
if (selectedCity != "")
{
controlsNavigated.push("cityselect");
initCity(selectedCity);
}
}
var evYr = document.getElementById(ClientID + "eventyear")
var evMo = document.getElementById(ClientID + "eventmonth")
var evDa = document.getElementById(ClientID + "eventday")
if (selectedYear != "")
{
for(i=0; i< evYr.options.length;i++) {
if (evYr.options[i].value == selectedYear) {
evYr.options[i].selected=true;
}
}
}
else
{
evYr.options[0].selected = true;
}
if (selectedMonth != "")
{
for(i=0; i< evMo.options.length;i++) {
if (evMo.options[i].value == selectedMonth) {
evMo.options[i].selected=true;
}
}
}
else
{
evMo.options[0].selected = true;
}
var month;
var day;
var year;
month = evMo.value;
day = evDa.value;
year = evYr.value;
loadMonthDays(month, day, year);
if (selectedDay != "")
{
for(i=0; i< evDa.options.length;i++) {
if (evDa.options[i].value == selectedDay) {
evDa.options[i].selected=true;
}
}
}
else
{
evDa.options[0].checked = true;
}
shouldReasonChange();
if ( (stateSel.selectedIndex > 0) || (stateSel.tagName == "INPUT") )
{
PopulateSelectLabelsByLocation();
}
return true;
}
function initState(State)
{
var selState = document.getElementById(ClientID + "stateselect");
for(i=0; i< selState.options.length;i++) {
if (selState.options[i].value == State) {
selState.options[i].selected=true;
}
}
appendDebug("state selected");
}
function initCounty(County)
{
var selCounty = document.getElementById(ClientID + "countyselect");
for(i=0; i< selCounty.options.length;i++) {
if (selCounty.options[i].value == County) {
selCounty.options[i].selected=true;
}
}
appendDebug("county selected");
}
function initCity(City)
{
var selCity = document.getElementById(ClientID + "cityselect");
for(i=0; i< selCity.options.length;i++) {
if (selCity.options[i].value == City) {
selCity.options[i].selected=true;
}
}
appendDebug("city selected");
}
/* UI Control code for chaining multiple loading events */
var controlsInvolved = new Array("stateselect","countyselect","cityselect");
var controlsNavigated = new Array();
function handleNavigation(ControlID)
{
var index = indexOfValueInArray(ControlID,controlsNavigated);
//window.alert("'"+ControlID+"' and: '"+ controlsNavigated +"' found at: "+index);
if(index >= 0)
{
//if it's not, pop off all our navigations until that one
var childControl = controlsNavigated.pop();
//window.alert("found it");
while (childControl != ControlID)
{
//set the selectedIndex to 0 so it looks unselected.
document.getElementById(ClientID + childControl).selectedIndex = 0;
//pop the control off our navigation history
childControl = controlsNavigated.pop();
}
//since we pulled it off, we need to throw it back on
//for it to remain in the history
controlsNavigated.push(ControlID);
}
else
{
//we've navigated this control, so push it on.
controlsNavigated.push(ControlID);
}
//window.alert(controlsNavigated);
//now we populate our kids
switch (ControlID)
{
case "stateselect":
{
makeElementNormalAndBlack("primary_location");
makeElementNormalAndBlack("stateprov_verbiage_label");
makeElementNormalAndBlack("secondary_location");
makeElementNormalAndBlack("tertiary_location");
makeElementNormalAndBlack("date_label");
makeElementNormalAndBlack("reason_label");
//do county
populateControlWithFilterCriteria("countyselect", controlsNavigated);
//do city
if(document.getElementById(ClientID + "stateselect").value != "YC")
populateControlWithFilterCriteria("cityselect", controlsNavigated);
break;
}
case "cityselect":
{
//do county
populateControlWithFilterCriteria("countyselect", controlsNavigated);
break;
}
case "countyselect":
{
//do city
if(document.getElementById(ClientID + "stateselect").value != "YC")
populateControlWithFilterCriteria("cityselect", controlsNavigated);
break;
}
}
}
function populateControlWithFilterCriteria(ControlID, FilterCriteria)
{
//window.alert("c: " + ControlID + " filtering with: " + FilterCriteria);
if (!isSelected(ControlID)) {
switch (ControlID) {
case "stateselect":
{
var countyfound = isValueinArray("countyselect",FilterCriteria);
var cityfound = isValueinArray("cityselect",FilterCriteria);
if (cityfound && countyfound) {
//call the function that populates the
//state box with both city and county known
//*** don't support this now.
}
else
{
if (cityfound && !countyfound)
{
//call the function that populates the
//state box with just city known
//*** don't support this now.
}
else
{
if (!cityfound && countyfound)
{
//call the function that populates the
//state box with just county known
//*** don't support this now.
}
else
{ //(!cityfound && !countyfound) == true
//call the function that populates the
//state box with nothing known
//*** this happens server side right now
}
}
}
break;
}
case "countyselect":
{
var statefound = isValueinArray("stateselect",FilterCriteria);
var cityfound = isValueinArray("cityselect",FilterCriteria);
if (cityfound && statefound) {
//call the function that populates the
//county box with both state and city known
var cityValue = document.getElementById(ClientID + "cityselect").value;
var stateValue = document.getElementById(ClientID + "stateselect").value;
var categoryValue = getSelectedCertValue();
if (cityValue != "") {
PopulateCountyListWithStateCity(stateValue,cityValue,categoryValue);
} else {
PopulateCountyList(stateValue,categoryValue);
}
}
else
{
if (cityfound && !statefound)
{
//call the function that populates the
//county box with just city known
//*** don't support this now.
}
else
{
if (!cityfound && statefound)
{
//call the function that populates the
//county box with just state known
var stateValue = document.getElementById(ClientID + "stateselect").value;
var categoryValue = getSelectedCertValue();;
//window.alert("hey?" + stateValue);
PopulateCountyList(stateValue, categoryValue);
}
else
{ //(!cityfound && !statefound) == true
//call the function that populates the
//county box with nothing known
//*** don't support this now.
}
}
}
break;
}
case "cityselect":
{
var statefound = isValueinArray("stateselect",FilterCriteria);
var countyfound = isValueinArray("countyselect",FilterCriteria);
//window.alert(statefound + " " + countyfound);
if (countyfound && statefound) {
//call the function that populates the
//city box with both state and county known
var countyValue = document.getElementById(ClientID + "countyselect").value;
var stateValue = document.getElementById(ClientID + "stateselect").value;
var categoryValue = getSelectedCertValue();;
if (countyValue != "") {
PopulateCityListByStateAndCounty(stateValue,countyValue, categoryValue);
} else {
PopulateCityListByState(stateValue, categoryValue);
}
}
else
{
if (countyfound && !statefound)
{
//call the function that populates the
//city box with just county known
//*** don't support this now.
}
else
{
if (!countyfound && statefound)
{
//call the function that populates the
//city box with just state known
var stateValue = document.getElementById(ClientID + "stateselect").value;
var categoryValue = getSelectedCertValue();;
PopulateCityListByState(stateValue, categoryValue);
}
else
{ //(!countyfound && !statefound) == true
//call the function that populates the
//city box with nothing known
//*** don't support this now.
}
}
}
break;
}
}
}
else
{
//window.alert("is selected. "+ eval("document.testsstate."+ControlID +".value"));
}
}
function addCommand(command)
{
CommandQueue.push(command);
}
function doCommand()
{
if (CommandQueue.length > 0) {
eval(CommandQueue.shift());
}
}
function handlePleaseWaitMessage()
{
var cityLoaded = false;
var countyLoaded = false;
var citySel = document.getElementById(ClientID + "cityselect")
var cntySel = document.getElementById(ClientID + "countyselect")
if (citySel.options.length > 1)
{
cityLoaded = true;
}
if (cntySel.options.length > 1)
{
countyLoaded = true;
}
if (cityLoaded && countyLoaded)
{
citySel.options[0].text = selectString;
cntySel.options[0].text = selectString;
}
else
{
//we may think our county list isn't loaded, but BC has no county list.
//also check for notapplicableString, "ALL"
if (cityLoaded && (cntySel.options[0].text == notapplicableString))
{
citySel.options[0].text = selectString;
}
if (countyLoaded && (citySel.options[0].text == notapplicableString))
{
cntySel.options[0].text = selectString;
}
}
}
/* event handlers */
function certtype_onChangeEvent()
{
var CertType = getSelectedCertValue();
if ((!CertType)||(CertType == "")) CertType = "Birth";
var certimg=document.getElementById("certImage");
if (certimg)
{
if (CertType=="Birth"){certimg.src="images/icons/birth_cert_pic.gif"}
if (CertType=="Death"){certimg.src="images/icons/death_cert_pic.gif"}
if (CertType=="Marriage"){certimg.src="images/icons/marriage_cert_pic.gif"}
if (CertType=="Divorce"){certimg.src="images/icons/divorce_cert_pic.gif"}
}
if (document.getElementById(ClientID + "stateselect").visible == true)
{
var selList = document.getElementById(ClientID + "stateselect");
//Special handling for NYC. Remove NYC if cert type is 'Divorce'. Add it back if not.
if (CertType != "")
{
if (CertType == "Divorce")
{
for(i=0; i< selList.options.length;i++)
{
if (selList.options[i].value.toLowerCase() == 'yc')
{
//preserve the selected index - if > NYC index, decrement by 1
var idx = selList.selectedIndex;
if (idx == i) idx = -1;
if (idx > i) idx = idx - 1;
//clear NYC
selList.options[i] = null;
selList.selectedIndex = idx;
break;
}
}
}
else
{
var bFound = false;
for(i=0; i< selList.options.length;i++)
{
if (selList.options[i].value.toLowerCase() == 'yc')
{
bFound = true;
}
if (selList.options[i].value.toLowerCase() == 'ny')
{
if (!bFound) //NYC is not in the list
{
//preserve the selected index
var idx = selList.selectedIndex;
if (idx >= i) idx = idx + 1;
//shuffle the list down by 1
for (var j = selList.length - 1; j >= i; j--)
{
selList.options[j+1] = new Option(selList.options[j].text, selList.options[j].value);
}
//insert NYC
selList.options[i] = new Option('New York City', 'YC');
selList.selectedIndex = idx;
break;
}
}
}
}
}
}
//end Special handling for NYC.
//ShowReasons(CertType);
ShowCertTypeChecks(CertType);
shouldReasonChange();
var stateCtl = document.getElementById("stateprov_verbiage_label")
var dateCtl = document.getElementById("date_label")
if (stateCtl.innerText)
{
stateCtl.innerText = " where " + CertType.toLowerCase() + " occurred *";
dateCtl.innerText = "Date of " + CertType + " *";
}
else
{
stateCtl.firstChild.nodeValue = " where " + CertType.toLowerCase() + " occurred *";
dateCtl.firstChild.nodeValue = "Date of " + CertType + " *";
}
//window.alert(CertType.value)
}
function adoptedcheck_onClick()
{
if (!document.getElementById(ClientID + "reason").disabled)
{
PopulateReasonsByLocation();
}
}
function namechangecheck_onClick()
{
if (!document.getElementById(ClientID + "reason").disabled)
{
PopulateReasonsByLocation();
}
}
var StateSelectChangeID=0;
function stateselect_onChangeEvent()
{
StateSelectChangeID++;
setTimeout("stateselected_change(" + StateSelectChangeID + ")", DROPDOWN_TIMEOUT_DELAY);
}
function stateselected_change(ui_change_id)
{
if (ui_change_id == StateSelectChangeID)
{
// if customer selects Massachusetts, present pop-up and transfer them to USCerts
if(document.getElementById(ClientID + "stateselect").selectedIndex == 23)
{
CheckSpecialRedirect();
}
var cntySel = document.getElementById(ClientID + "countyselect");
var citySel = document.getElementById(ClientID + "cityselect");
//enable the selects
cntySel.disabled = false;
citySel.disabled = false;
// if customer selects New York City, disable the city dropdown and set it to not-applicable
if(document.getElementById(ClientID + "stateselect").value == "YC")
{
citySel.options.length = 0;
citySel.options[0] = new Option(notapplicableString, "");;
}
else
{
citySel.options[0] = new Option(pleaseWaitString, "");
}
//set the message option to say the please wait string
cntySel.options[0] = new Option(pleaseWaitString, "");
//select the first option... the message one
cntySel.options[0].selected = true;
citySel.options[0].selected = true;
//shorten the list length to 1
cntySel.length = 1;
citySel.length = 1;
//handle the loading
handleNavigation("stateselect");
PopulateSelectLabelsByLocation();
shouldReasonChange();
//Bug 9212
chkUnknownLocation_onChangeEvent(false);
GetStateOptions();
//End 9212
}
return true;
}
var CitySelectChangeID=0;
function cityselect_onChangeEvent()
{
CitySelectChangeID++;
setTimeout("cityselected_change(" + CitySelectChangeID + ")", DROPDOWN_TIMEOUT_DELAY);
}
function cityselected_change(ui_change_id)
{
if (ui_change_id == CitySelectChangeID)
{
handleNavigation("cityselect");
//Check for special redirect - initiallly implemented for New Hampshire
CheckSpecialRedirect();
shouldReasonChange();
}
return true;
}
var CountySelectChangeID=0;
function countyselect_onChangeEvent()
{
CountySelectChangeID++;
setTimeout("countyselected_change(" + CountySelectChangeID + ")", DROPDOWN_TIMEOUT_DELAY);
}
function countyselected_change(ui_change_id)
{
if (ui_change_id == CountySelectChangeID)
{
handleNavigation("countyselect");
shouldReasonChange();
}
return true;
}
function eventdate_onChangeEvent(source)
{
var month;
var year;
var day;
month = document.getElementById(ClientID + "eventmonth").value;
day = document.getElementById(ClientID + "eventday").value;
year = document.getElementById(ClientID + "eventyear").value;
//window.alert(year + "-" + month + "-" + day );
//load month days if year or month get changed.
if (source != "eventday")
{
loadMonthDays(month, day, year);
}
shouldReasonChange();
}
function HandleSessionProviderLocked(type, data, evt)
{
var pageLoadedWithProviderLocked = document.getElementById("ProviderLocked").value;
var locked = eval(data);
if ((locked == "true" ) && (pageLoadedWithProviderLocked=='False')) {
document.location = document.location;
}
isWorking = false;
doCommand();
}
function FillCountyDropdown(type, data, evt)
{
var clist = eval('(' + data + ')');
var countySel = document.getElementById(ClientID + "countyselect");
if (countySel.options.length != 1)
countySel.options.length = 1;
//countySel.options[0] = new Option("", "");
var countyname;
for(n = 0; n < clist.length; n++)
{
countyname = clist[n];
countySel.options[n + 1] = new Option(countyname, countyname);
}
handlePleaseWaitMessage();
if (clist.length == 1) {
controlsNavigated.push("countyselect");
countySel.options[1].selected=true;
shouldReasonChange();
}
isWorking = false;
doCommand();
}
function FillCityDropdown(type, data, evt)
{
var clist = eval('(' + data + ')');
//window.alert('(' + data + ')');
var citySel = document.getElementById(ClientID + "cityselect");
if (citySel.options.length = 1)
citySel.options.length = 1;
//citySel.options[0] = new Option("", "");
var cityname;
for(n = 0; n < clist.length; n++)
{
cityname = clist[n];
citySel.options[n + 1] = new Option(cityname, cityname);
}
handlePleaseWaitMessage();
if (clist.length == 1) {
controlsNavigated.push("cityselect");
cityElement.options[1].selected=true;
shouldReasonChange();
}
isWorking = false;
doCommand();
}
function ApplyStateContent(type, data, evt)
{
var StateContent = eval('(' + data + ")");
StateContent.allowUnknownLocation = StateContent.allowUnknownLocation.replace(" ", "");
var UnknownLocationDesc;
if (StateContent.allowUnknownLocation.length == 0 )
{
document.getElementById(ClientID + "UnknownLocationBlock").style.display = 'none';
}
else
{
document.getElementById(ClientID + "UnknownLocationBlock").style.display = 'block';
switch (StateContent.allowUnknownLocation)
{
case "city":
UnknownLocationDesc = "City";
break;
case "city ":
UnknownLocationDesc = "City";
break;
case "county":
case "county ":
UnknownLocationDesc = "County";
break;
default:
UnknownLocationDesc = "City/County";
break;
}
var elem = document.getElementById("lblUnknownLocation");
elem.innerHTML = UnknownLocationDesc + " is unknown or not found in the list.
You will be given an opportunity to enter this information during the ordering process.";
}
document.getElementById("AllowUnknownLocation").value = StateContent.allowUnknownLocation;
isWorking = false;
doCommand();
}
function addOverlay()
{
var body = document.getElementsByTagName("body")[0];
var divElement= document.createElement("div");
div.id='Anchor';
body.
el = document.getElementById("overlay");
el.style.width=(window.innerWidth) ? window.innerWidth : document.body.offsetWidth-20;
el.style.height=(window.innerHeight) ? window.innerHeight : document.body.offsetHeight-20;
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
function FillReasonDropDown(type, data, evt)
{
//window.alert(data);
var reasonSel = document.getElementById(ClientID + "reason");
var reason_list = eval ( '(' + data + ')' );
//window.alert(reason_list.length);
if (reason_list.length != 0 ) {
reasonSel.options.length = 0;
reasonSel.options[0] = new Option(selectString, "");
var rid;
var reason;
for(n = 0; n < reason_list.length; n++)
{
reasonSel.options[n + 1] = new Option(reason_list[n].reason_text, reason_list[n].reason_id);
}
if (reason_list.length == 1) {
reasonSel.options[1].selected=true;
}
}
else
{
if (!RedirectInProcess)
{
reasonSel.options.length = 0;
reasonSel.options[0] = new Option(selectString, "");
reasonSel.disabled = true;
if (document.getElementById('NoDocsContent'))
{
//addOverlay();
var certType=getSelectedCertValue();
var buf='
The '+certType+' Certificate you are requesting is not available through our online service. Please verify that the information you have entered for this certificate is correct(i.e. date, location, event type).'; buf=buf+'
To correct any of the information for this '+certType+' Certificate, please select the Change Order Information button and make any corrections necessary.
'; buf=buf+'If the '+certType+' Certificate information is correct, it is possible that the official government agencies available through our network do not maintain the records to fulfill your request. For a listing of record types and dates available, as well as ordering methods and other important information, please select the View Agency Information button below and select the state of the event.
'; document.getElementById('NoDocsContent').innerHTML=buf; } strOptions="resizable,height=463,width=588"; var DivRef = document.getElementById('NoDocsMsg_container'); var IfrRef = document.getElementById('DivShim'); DivRef.style.position = 'absolute'; DivRef.style.left = '140px'; DivRef.style.top = '50px'; DivRef.style.display = 'block'; IfrRef.style.width = DivRef.offsetWidth; IfrRef.style.height = DivRef.offsetHeight; IfrRef.style.top = DivRef.style.top; IfrRef.style.left = DivRef.style.left; IfrRef.style.border='3px'; IfrRef.style.zIndex = DivRef.style.zIndex - 1; IfrRef.style.display = 'block'; } } isWorking = false; doCommand(); }