1 var debug = 0; // To trigger alerts for debugging, set equal to 1 2 3 //5.27.09 RRW - Added Guam and Virgin Islands to states array... 4 var states = new Array ("Alabama", 5 "Alaska", 6 "Arizona", 7 "Arkansas", 8 "California", 9 "Colorado", 10 "Connecticut", 11 "Delaware", 12 "DC", 13 "Florida", 14 "Georgia", 15 "Hawaii", 16 "Idaho", 17 "Illinois", 18 "Indiana", 19 "Iowa", 20 "Kansas", 21 "Kentucky", 22 "Louisiana", 23 "Maine", 24 "Maryland", 25 "Massachusetts", 26 "Michigan", 27 "Minnesota", 28 "Mississippi", 29 "Missouri", 30 "Montana", 31 "Nebraska", 32 "Nevada", 33 "New Hampshire", 34 "New Jersey", 35 "New Mexico", 36 "New York", 37 "North Carolina", 38 "North Dakota", 39 "Northern Mariana Islands", 40 "Ohio", 41 "Oklahoma", 42 "Oregon", 43 "Pennsylvania", 44 "Rhode Island", 45 "South Carolina", 46 "South Dakota", 47 "Tennessee", 48 "Texas", 49 "Utah", 50 "Vermont", 51 "Virginia", 52 "Washington", 53 "West Virginia", 54 "Wisconsin", 55 "Wyoming", 56 "Guam", 57 "Virgin Islands"); 58 59 // 10.8.09 RRW - loadDistricts populates the claim_county and stateremoval_co pulldowns based on district selection... 60 /** 61 * Populates the claim_county and stateremoval_co pulldowns based on district selection... 62 * @param formname The main form (cover.html) 63 * @param district The selected filing district 64 */ 65 function loadDistricts(formname,district){ 66 //alert("loadDistricts(): formname = " + formname.name + " and district = " + district.value); 67 68 var browser=navigator.appName; 69 var b_version=navigator.appVersion; 70 var version=parseFloat(b_version); 71 //alert("Browser name: "+ browser + "Browser version: " + version); 72 73 var selbox = formname.claim_county; 74 var selbox2 = formname.stateremoval_co; 75 76 selbox.options.length = 0; 77 selbox2.options.length = 0; 78 79 state = getState(district); // Process the state from selected filing district... 80 state = state.toUpperCase(); // ...and convert it to uppercase. 81 //alert("State upper cased = " + state); 82 83 var filePath = "Data/COUNTIES/" + state + ".XML"; 84 //alert("loadDistricts() File Path = " + filePath); 85 86 if(browser == "Microsoft Internet Explorer") 87 { 88 89 var countyxml = new ActiveXObject("Microsoft.XMLDOM"); 90 //if(countyxml)alert("Active X Object is legit"); 91 countyxml.async="false"; 92 countyxml.load(filePath); 93 94 }else{ // If Netscape or Firefox 95 96 var countyxml = new XMLHttpRequest() 97 countyxml.open("GET",filePath,false); 98 countyxml.send(""); 99 countyxml=countyxml.responseXML; 100 101 } 102 103 var x = countyxml.getElementsByTagName("COUNTY"); 104 105 //if(x != null) alert("countyxml childNodes loaded properly"); 106 107 for(var i=0;i<x.length;i++) 108 { 109 if (x[i].nodeType==1){ 110 111 //Process only element(nodeType 1) nodes and show the node name... 112 //alert("The node name is: " + x[i].nodeName); 113 114 //Show the node value... 115 var county = x[i].childNodes[0].nodeValue; 116 117 //Populate the County menu based on Filing District state selected... 118 119 selbox.options[selbox.options.length] = new Option(county, county); 120 selbox2.options[selbox2.options.length] = new Option(county, county); 121 } 122 } 123 124 125 } 126 // 5.19.09 RRW - loadDistricts2 populates the county and state pulldown on the add form based on filing district... 127 /** 128 * Populates the county and state pulldown on the add form based on filing district... 129 * @param formname add_form 130 * @param district Selected filing district 131 * @param curtype Type of client (plaintiff,defendant) 132 */ 133 function loadDistricts2(formname,district,curtype){ 134 //console.log("Inside loadDistricts2" + formname.name); 135 var browser=navigator.appName; 136 137 state = getState2(district, curtype); // Process the state from selected filing district... 138 state = state.toUpperCase(); // ...and convert it to uppercase. 139 140 var filePath = "Data/COUNTIES/" + state + ".XML"; 141 //alert("loadDistricts2() filepath is " + filePath); 142 143 // DEBUG SECTION //////////////////////////////////////////////////// 144 145 146 //alert("loadDistricts2(): formname: " + formname.name + "; # of elements: " + formname.elements.length + " and district = " + district); 147 /* 148 var x = formname; 149 for (var i=0;i<x.length;i++) 150 { 151 if(i == 7){ 152 if(debug) alert("Field " + i + "; Field Name = " + x.elements[i].name + "; Type = " + x.elements[i].type +"; Value = " + x.elements[i].value); 153 if(debug) alert("Field is " + x.elements[i].options.length); 154 } 155 } 156 */ 157 158 //if(debug) alert("loadDistricts: district = " + district); 159 //alert("loadDistricts2(): district = " + district); 160 161 //////////////////////////////////////////////////////////////////////// 162 163 if(browser == "Microsoft Internet Explorer") 164 { 165 166 var countyxml = new ActiveXObject("Microsoft.XMLDOM"); 167 //if(countyxml)alert("Active X Object is legit"); 168 countyxml.async="false"; 169 countyxml.load(filePath); 170 171 }else{ // If Netscape or Firefox 172 173 var countyxml = new XMLHttpRequest() 174 countyxml.open("GET",filePath,false); 175 countyxml.send(""); 176 countyxml=countyxml.responseXML; 177 178 } 179 180 //alert("current ID is " + curtype); 181 182 var x = countyxml.getElementsByTagName("COUNTY"); 183 //alert("Length: " + x.length); 184 185 for(var i=0;i<x.length;i++){ 186 //alert("In the for loop"); 187 if(x[i].nodeType==1){ 188 189 //Process only element (nodeType 1) nodes and show the node name... 190 //alert(x[i].nodeName + ": "); 191 192 var county = x[i].childNodes[0].nodeValue; 193 if(debug) alert("County = " + county); 194 195 //Populate the County menu based on Filing District state selected... 196 197 //5.26.09 RRW - Code to build dropdown menu in popup window 198 199 if(!newWin.document.getElementById('county')){ 200 //alert("No county element ID"); 201 return; 202 }else{ 203 204 if(i == 0){ 205 var opt = newWin.document.createElement("option"); 206 newWin.document.getElementById('county').appendChild(opt); 207 opt.text = "Outside This District"; 208 opt.value = "Outside This District"; 209 var opt = newWin.document.createElement("option"); 210 newWin.document.getElementById('county').appendChild(opt); 211 opt.text = county; 212 opt.value = county; 213 }else{ 214 var opt = newWin.document.createElement("option"); 215 newWin.document.getElementById('county').appendChild(opt); 216 opt.text = county; 217 opt.value = county; 218 219 } 220 221 } 222 223 } // End of if node.type = 1... 224 225 }// End of for loop 226 227 228 } 229 function xmlLoaded(){ 230 // NOTE: Need to move pulldown load routine here 231 alert("The XML file is loaded"); 232 } 233 /** 234 * Parses selected filing district to remove region/district 235 * @param dist Selected filing district 236 * @returns state State after parsing to remove district/region 237 * @see loadDistricts() 238 */ 239 function getState(dist){ 240 var district = dist; 241 if(debug) alert("getState(): district = " + district.value); 242 //alert("district = " + district.value); 243 244 if(district.value.match(/Northern/g)){ 245 var state = district.value.split(' Northern'); 246 if(debug) alert("The region is Northern and the state is " + state[0]); 247 state = state[0]; 248 } 249 else if(district.value.match(/Southern/g)){ 250 var state = district.value.split(' Southern'); 251 if(debug) alert("The region is Southern and the state is " + state[0]); 252 state = state[0]; 253 } 254 else if(district.value.match(/Eastern/g)){ 255 var state = district.value.split(' Eastern'); 256 if(debug) alert("The region is Eastern and the state is " + state[0]); 257 state = state[0]; 258 } 259 else if(district.value.match(/Western/g)){ 260 var state = district.value.split(' Western'); 261 if(debug) alert("The region is Western and the state is " + state[0]); 262 state = state[0]; 263 } 264 else if(district.value.match(/Central/g)){ 265 var state = district.value.split(' Central'); 266 if(debug) alert("The region is Central and the state is " + state[0]); 267 state = state[0]; 268 } 269 else if(district.value.match(/Middle/g)){ 270 var state = district.value.split(' Middle'); 271 if(debug) alert("The region is Middle and the state is " + state[0]); 272 state = state[0]; 273 } 274 else if(district.value == "") 275 {alert("Please Select a Filing District."); return;} 276 else if(district.value == "District of Columbia" || district.value == "Guam" || district.value == "Northern Mariana Islands" || district.value == "Puerto Rico" || district.value == "Virgin Islands") 277 { 278 state = district.value; 279 //return; 280 } 281 else{ 282 if(debug) alert("There is no region or region is Unknown"); 283 var state = district.value; 284 if(debug) alert("The state is " + state); 285 //return; 286 } 287 return state; 288 } 289 /** 290 * Parses selected filing district to remove region/district 291 * @param dist Selected filing district 292 * @param type Client type (plaintiff, defendant) 293 * @returns state State after parsing to remove region/district 294 * @see loadDistricts2() 295 */ 296 function getState2(dist, type){ 297 298 var district = dist; 299 var curtype = type; 300 301 if(district.match(/Northern/g)){ 302 var state = district.split(' Northern'); 303 if(debug) alert("The region is Northern and the state is " + state[0]); 304 state = state[0]; 305 } 306 else if(district.match(/Southern/g)){ 307 var state = district.split(' Southern'); 308 if(debug) alert("The region is Southern and the state is " + state[0]); 309 state = state[0]; 310 } 311 else if(district.match(/Eastern/g)){ 312 var state = district.split(' Eastern'); 313 if(debug) alert("The region is Eastern and the state is " + state[0]); 314 state = state[0]; 315 } 316 else if(district.match(/Western/g)){ 317 var state = district.split(' Western'); 318 if(debug) alert("The region is Western and the state is " + state[0]); 319 state = state[0]; 320 } 321 else if(district.match(/Central/g)){ 322 var state = district.split(' Central'); 323 if(debug) alert("The region is Central and the state is " + state[0]); 324 //alert("The region is Central and the state is " + state[0]); 325 state = state[0]; 326 } 327 else if(district.match(/Middle/g)){ 328 var state = district.split(' Middle'); 329 if(debug) alert("The region is Middle and the state is " + state[0]); 330 state = state[0]; 331 } 332 else if(district == "") 333 { 334 alert("Please Select a Filing District."); 335 return; 336 } 337 else if(district.value == "District of Columbia" || district.value == "Guam" || district.value == "Northern Mariana Islands" || district.value == "Puerto Rico" || district.value == "Virgin Islands") 338 { 339 340 var state = district; 341 //alert("Selected state is " + state); 342 if(state == "District of Columbia")state = "DC"; 343 if(formname.name == "add_form"){ 344 345 if(curtype.match(/Attorney/g)){ 346 347 for (var i=0;i<states.length;i++){ 348 349 if (state == states[i]){ 350 //formname.state.selectedIndex = i; 351 //formname.state.disabled = true; 352 //alert("Selected state is " + state + " to populate " + formname.state.selectedIndex); 353 //formname.state.selectedIndex.value = state; 354 } 355 } 356 }else{ 357 358 for (var i=0;i<states.length;i++){ 359 360 if (state == states[i]){ 361 //formname.sor.selectedIndex = i+1; 362 //formname.sor.disabled = true; 363 //alert("Selected state is " + state + " to populate " + formname.sor.selectedIndex); 364 //formname.sor.selectedIndex.value = state; 365 } 366 } 367 } 368 } 369 return; 370 }else{ 371 372 if(debug) alert("There is no region or region is Unknown"); 373 var state = district; 374 if(debug) alert("The state is " + state); 375 //return; 376 } 377 378 // Determine if attorney, or plaintiff | defendant // 379 380 381 if(curtype.match(/Attorney/g)){ 382 383 for (var i=0;i<states.length;i++){ 384 385 if (state == states[i]){ 386 //formname.state.selectedIndex = i; 387 //formname.state.disabled = true; 388 //alert("Selected " + curtype + " state is " + state + " to populate " + formname.state.selectedIndex); 389 //formname.state.selectedIndex.value = state; 390 } 391 } 392 }else{ 393 for (var i=0;i<states.length;i++){ 394 395 if (state == states[i]){ 396 //formname.sor.selectedIndex = i+1; 397 //formname.sor.disabled = true; 398 //alert("Selected " + curtype + " state is " + state + " to populate " + formname.sor.selectedIndex); 399 //formname.sor.selectedIndex.value = state; 400 } 401 } 402 } 403 404 return state; 405 } 406 /** 407 * Parses selected filing district to remove region/district 408 * @param district Selected filing district 409 * @returns state State after parsing to remove region/district 410 * @see countyIndex2() 411 */ 412 function getState3(district){ 413 414 //alert("getState3() district = " + district); 415 if(district.match(/Northern/g)){ 416 var state = district.split(' Northern'); 417 if(debug) alert("The region is Northern and the state is " + state[0]); 418 state = state[0]; 419 } 420 else if(district.match(/Southern/g)){ 421 var state = district.split(' Southern'); 422 if(debug) alert("The region is Southern and the state is " + state[0]); 423 state = state[0]; 424 } 425 else if(district.match(/Eastern/g)){ 426 var state = district.split(' Eastern'); 427 if(debug)alert("The region is Eastern and the state is " + state[0]); 428 state = state[0]; 429 } 430 else if(district.match(/Western/g)){ 431 var state = district.split(' Western'); 432 if(debug) alert("The region is Western and the state is " + state[0]); 433 state = state[0]; 434 } 435 else if(district.match(/Central/g)){ 436 var state = district.split(' Central'); 437 if(debug) alert("The region is Central and the state is " + state[0]); 438 //alert("The region is Central and the state is " + state[0]); 439 state = state[0]; 440 } 441 else if(district.match(/Middle/g)){ 442 var state = district.split(' Middle'); 443 if(debug) alert("The region is Middle and the state is " + state[0]); 444 state = state[0]; 445 } 446 else if(district == "District of Columbia" || district == "Guam" || district == "Virgin Islands"){ 447 var state = district; 448 if(state == "District of Columbia")state = "DC"; 449 if(debug) alert("There are no regions for " + state); 450 state = state[0]; 451 } 452 else{ 453 if(debug) alert("There is no region or region is Unknown"); 454 var state = district; 455 if(debug) alert("The state is " + state); 456 //return; 457 } 458 return state; 459 460 } 461 462 /** 463 * Dynamically populates county dropdowns based on Javascript arrays 464 * @param text Plaintiff/Defendant county value 465 * @param state State of Residence value 466 */ 467 function countyIndex2(text,state) { 468 469 var browser=navigator.appName; 470 471 //var ctyndx_xml = new ActiveXObject("MSXML2.DOMDocument.3.0"); 472 473 //alert("countyIndex2(): County = " + text); 474 //alert("countyIndex2(): State = " + state.toUpperCase()); 475 476 var districts = document.getElementById('districts').value; 477 //alert("countyIndex2() Filing district = " + districts); 478 var statestrip = getState3(districts); 479 //alert("countyIndex2() State after strip = " + statestrip); 480 481 //Open county file based on value of 'state'... 482 if(state == "DC" || state == "Guam" || state == "Virgin Islands" || state == "") state = statestrip; 483 state = state.toUpperCase(); 484 485 var filePath = "Data/COUNTIES/" + state + ".XML"; 486 //alert("File Path = " + filePath); 487 //ctyndx_xml.load(filePath); 488 489 if(browser == "Microsoft Internet Explorer") 490 { 491 492 var ctyndx_xml = new ActiveXObject("Microsoft.XMLDOM"); 493 //if(ctyndx_xml)alert("Active X Object is legit"); 494 ctyndx_xml.async="false"; 495 ctyndx_xml.load(filePath); 496 497 }else{ // If Netscape or Firefox 498 499 var ctyndx_xml = new XMLHttpRequest() 500 ctyndx_xml.open("GET",filePath,false); 501 ctyndx_xml.send(""); 502 ctyndx_xml=ctyndx_xml.responseXML; 503 504 } 505 506 507 508 //var x = ctyndx_xml.documentElement.childNodes; 509 var x = ctyndx_xml.getElementsByTagName("COUNTY"); 510 //alert("getState3() x length: " + x.length); 511 512 //if(text == "Outside This District"){ 513 // alert("County is outside this district..."); 514 // return i; 515 516 //}else{ 517 518 for (var i=0;i<x.length;i++) 519 { 520 if (x[i].nodeType==1) 521 { 522 //Process only element (nodeType 1) nodes 523 //Show the node name... 524 //document.write(x[i].nodeName + ": "); 525 //Show the node value... 526 527 var county = x[i].childNodes[0].nodeValue; 528 //alert("Text = " + text + "County = " + county); 529 530 if (county == text){ 531 //alert("countyIndex2(): County = " + county + " and text = " + text + " and i = " + i); 532 return i+1; // Might have to use this to account for "Outside this district!! 533 //return i; 534 } 535 //else{ 536 // return x.length+1; 537 //} 538 } 539 //} 540 541 /* 542 for (var i=0;i<del_counties.length;i++){ 543 if (del_counties[i] == text){ 544 if(debug) alert("countyIndex2(): Delaware county = " + del_counties[i] + " and text = " + text + " and i = " + i); 545 return i+1; 546 547 } 548 } 549 */ 550 } 551 552 return 0; 553 } 554 /** 555 * @param state 556 * @returns countyarray County array 557 */ 558 function editCounty(state) { 559 var editcty_xml = new ActiveXObject("MSXML2.DOMDocument.3.0"); 560 var county_array = new Array(); 561 562 if(debug) alert("editCounty(): State = " + state.toUpperCase()); 563 564 //Open county file based on value of 'state'... 565 state = state.toUpperCase(); 566 567 var filePath = "Data/COUNTIES/" + state + ".XML"; 568 if(debug) alert("File Path = " + filePath); 569 editcty_xml.load(filePath); 570 var x = editcty_xml.documentElement.childNodes; 571 572 for (var i=0;i<x.length;i++) 573 { 574 if (x[i].nodeType==1) 575 { 576 //Process only element (nodeType 1) nodes 577 //Show the node name... 578 //document.write(x[i].nodeName + ": "); 579 //Show the node value... 580 581 var county = x[i].childNodes[0].nodeValue; 582 county_array[i] = county; // Build the county array... 583 if(debug)alert("County Array = " + county_array[i]); 584 585 } 586 } 587 return county_array; 588 } 589 /** 590 * @param formname 591 * @param district 592 * @param curtype 593 */ 594 function loopCounties(){ 595 var list = document.getElementById('county'); 596 for(var i = 0; i < list.options.length; ++i) 597 if(debug) alert("loopCounties90: " + list.options[i].value); 598 } 599 /** 600 * 601 * 602 */ 603 function showCounty(str){ 604 605 // "text" returns the value; "value" returns the index number 606 607 var countyname = str.options[str.selectedIndex].text; 608 //document.write("The selected county is " + countyname); 609 610 } 611 612 /** 613 * 614 * 615 */ 616 function changeText(last,first,mid,ctz,st,cty){ 617 //var strx = str2; 618 var lname = str2; 619 var newtext2 = document.more_plaintiffs.lname.value 620 //document.write("Last Name = " + document.more_plaintiffs.lname.value); 621 //document.getElementById('listOfFolks').innerHTML += 'This is a test'; 622 document.getElementById('listOfFolks').innerHTML += newtext2 + "<br>"; 623 624 625 //document.getElementById('listOfFolks').innerHTML = spacePrint(str2); 626 } 627