<!--
var itemCount=0;
var primary_map_id = "region_map_pri";
var secondary_map_id = "region_map_sec";
function setRegionMapOverlay(s) {
if(iObj = elementExist("region_map")) {
iObj.src = s;
}
}
function checkPreMarked() {
itemCount = 0;
var frmObj = document.forms['module_form'];
with(frmObj) {
stnum1.value = "";
stnum3.value = "";
for(var x=0;x<frmObj.elements.length;x++) {
if(frmObj.elements[x].checked) {
frmObj.elements[x].onclick();
}
}
}
}
function checkForDisabled() {
var frmObj = document.forms['module_form'];
for(var x=0;x<frmObj.elements.length;x++) {
if(frmObj.elements[x].type=="checkbox") {
switch(itemCount) {
case 2:
if(!frmObj.elements[x].checked) {
frmObj.elements[x].disabled = true;
}
break;
default:
frmObj.elements[x].disabled = false;
break;
}
}
}
if(!itemCount) {
setPrimaryRegion("","","");
setSecondaryRegion("","","");
}
}
function checkMapSwap(rCode) {
var st1,st3;
with(document.forms['module_form']) {
st1 = parseInt(stnum1.value,10)%1000;
st3 = parseInt(stnum3.value,10)%1000;
if((st1>0&&st3>0)) {
/* County vs. County */
if(st1<st3&&primary_map_id=="region_map_pri") {
swapMapIDs();
} else if(st1>st3&&primary_map_id=="region_map_sec") {
swapMapIDs();
}
} else if(st1==0&&st3==0) {
/* State vs. State */
if(parseInt(stnum1.value,10)<parseInt(stnum3.value,10)&&primary_map_id=="region_map_pri") {
swapMapIDs();
} else if(parseInt(stnum1.value,10)>parseInt(stnum3.value,10)&&primary_map_id=="region_map_sec") {
swapMapIDs();
}
} else if((st1==0&&st3>0)||(st1>0&&st3==0)) {
/* County vs. State */
if(st1==0&&primary_map_id!="region_map_pri") {
swapMapIDs();
} else if(st3==0&&primary_map_id!="region_map_sec") {
swapMapIDs();
}
}
/* KY TEMP MSA Workaround */
if(rCode=="KY") {
if((parseInt(stnum1.value,10)>21700&&parseInt(stnum1.value,10)<21904)||(parseInt(stnum3.value,10)>21700&&parseInt(stnum3.value,10)<21904)) {
setBackgroundMap('/img/maps/KY_21952_C3.gif');
} else {
setBackgroundMap('/img/maps/KY.gif');
}
}
}
}
function swapMapIDs() {
var tempID = primary_map_id;
primary_map_id = secondary_map_id;
secondary_map_id = tempID;
if(pObj=elementExist(primary_map_id)) {
if(sObj=elementExist(secondary_map_id)) {
var bckImage = pObj.style.backgroundImage;
pObj.style.backgroundImage = sObj.style.backgroundImage;
sObj.style.backgroundImage = bckImage;
}
}
}
function checkItem(obj,fip,rName,rCode) {
obj.checked = (obj.checked) ? 0 : 1;
selectItem(obj,fip,rName,rCode);
}
function selectItem(obj,fip,rName,rCode) {
var primaryObj = elementExist("selection_primary");
var secondaryObj = elementExist("selection_secondary");
if(obj.checked) {
itemCount++;
if(itemCount>2) {
alert("Only two regions may be selected to compare.\nPlease uncheck one item before selecting another.");
itemCount--;
obj.checked = 0;
return;
}
if(itemCount==1) {
setPrimaryRegion(fip,rName,rCode);
} else {
if(document.forms['module_form'].stnum1.value=="") {
setPrimaryRegion(fip,rName,rCode);
} else if(document.forms['module_form'].stnum3.value=="") {
setSecondaryRegion(fip,rName,rCode);
}
}
window.status=rName+' selected.';
} else {
itemCount--;
if(document.forms['module_form'].stnum1.value==fip) {
setPrimaryRegion("","",rCode);
}
if(document.forms['module_form'].stnum3.value==fip) {
setSecondaryRegion("","",rCode);
}
window.status=rName+' unselected.';
}
checkForDisabled();
checkMapSwap(rCode);
}
function setPrimaryRegion(fip,rName,rCode) {
with(document.forms['module_form']) {
stnum1.value=fip;
stnam1.value=rName;
if(primaryObj = elementExist("selection_primary")) {
primaryObj.innerHTML = (rName=="") ? "none" : rName;
}
if(iObj = elementExist(primary_map_id)) {
iObj.style.backgroundImage = (rName=="") ? "none" : "url(/img/maps/"+rCode+"_"+fip+"_c1.gif)";
}
}
}
function setSecondaryRegion(fip,rName,rCode) {
with(document.forms['module_form']) {
stnum3.value=fip;
stnam3.value=rName;
if(sObj = elementExist("selection_secondary")) {
sObj.innerHTML = (rName=="") ? "none" : rName;
}
if(iObj = elementExist(secondary_map_id)) {
iObj.style.backgroundImage= (rName=="") ? "none" : "url(/img/maps/"+rCode+"_"+fip+"_c2.gif)";
}
}
}
function validate() {
if(itemCount==2) {
showProcPleaseWait();
var st1,st3;
with(document.forms['module_form']) {
st1 = parseInt(stnum1.value,10)%1000;
st3 = parseInt(stnum3.value,10)%1000;
if(st1==0&&st3>0) {
tFip = stnum1.value;
tName = stnam1.value;
stnum1.value = stnum3.value;
stnam1.value = stnam3.value;
stnum3.value = tFip;
stnam3.value = tName;
}
}
setTimeout("document.forms[\"module_form\"].submit();",1000);
} else {
alert("Please select two regions to compare before submitting.");
}
}
var resetModuleForm = function resetModuleForm() {
if(formObj=elementExist("module_form")) {
formObj.reset();
itemCount=0;
checkForDisabled();
}
}
var showProcPleaseWait = function showProcPleaseWait() {
var mObj;
var pObj;
if(mObj=elementExist("module_form_cntnr")) {
if(pObj=elementExist("proc_please_wait")) {
mObj.style.visibility = "hidden";
pObj.style.display = "block";
pObj.style.position = "absolute";
moveElementTo(pObj,getPositionX(mObj),parseInt(mouseY-(getElementHeight(pObj)/2),10));
}
}
if(iObj = elementExist("region_image")) {
if(mObj = elementExist("region_map_cntnr")) {
moveElementTo(iObj,getPositionX(iObj),getPositionY(mObj));
}
}
}
var startMapFollow = function startMapFollow() {
if(mapResetTimeout) {
clearTimeout(mapResetTimeout);
}
if(mapResetInterval) {
clearInterval(mapResetInterval);
}
if(!mapStartInterval) {
mapResetInterval = null;
if(iObj = elementExist("region_image")) {
if(mObj = elementExist("region_map_cntnr")) {
mObj.style.backgroundImage = "none";
mObj.style.minHeight = (getElementHeight(iObj)+2)+"px";
iObj.style.marginTop = "0px";
moveElementTo(iObj,getPositionX(iObj),getPositionY(iObj));
iObj.style.position = "absolute";
mapStartInterval = setInterval("mapMove(mouseY)",move_interval);
}
}
}
}
var mapMove = function mapMove(y_pos) {
if(iObj = elementExist("region_image")) {
if(mObj = elementExist("region_map_cntnr")) {
ydif = (getPositionY(iObj)+parseInt(getElementHeight(iObj)/2,10)) - y_pos;
if(Math.abs(ydif)>0) {
y_interval = (Math.abs(ydif)<=pixel_interval) ? 1 : pixel_interval;
y_interval *= (ydif/Math.abs(ydif));
if((parseInt(getPositionY(iObj),10)-y_interval)>=getPositionY(mObj)) {
if(frmObj = elementExist("module_form_cntnr")) {
if(parseInt(getPositionY(iObj)-y_interval,10)<=(getPositionY(frmObj)+getElementHeight(frmObj)-getElementHeight(iObj))) {
moveElementTo(iObj,getPositionX(iObj),(parseInt(getPositionY(iObj),10)-y_interval));
}
}
} else if(mapResetInterval) {
mObj.style.backgroundImage = iObj.style.backgroundImage;
}
}
}
}
}
var mapReset = function mapReset() {
if(mapStartInterval) {
clearInterval(mapStartInterval);
mapStartInterval = null;
}
if(!mapResetInterval) {
if(iObj = elementExist("region_image")) {
if(mObj = elementExist("region_map_cntnr")) {
mapResetInterval = setInterval("mapMove("+(getPositionY(mObj)+parseInt(getElementHeight(iObj)/2,10))+")",move_interval);
}
}
}
}
var checkMapLayout = function checkMapLayout() {
if(iObj = elementExist("region_image")) {
if(mObj = elementExist("module_form_cntnr")) {
if(!isMousedOver(mObj)) {
if(mapStartInterval) {
clearInterval(mapStartInterval);
mapStartInterval = null;
}
if(mapResetInterval) {
clearInterval(mapResetInterval);
mapResetInterval = null;
}
iObj.style.position = "static";
} else {
iObj.style.position = "static";
iObj.style.position = "absolute";
}
}
}
}
window.onload = new Function(getCombinedFunctionCode(window.onload,checkPreMarked));
window.onresize = checkMapLayout;
//-->
