<!--
var mapZips = new Array()
mapZips[0]="89004"
mapZips[1]="89005"
mapZips[2]="89011"
mapZips[3]="89012"
mapZips[4]="89014"
mapZips[5]="89015"
mapZips[6]="89030"
mapZips[7]="89031"
mapZips[8]="89032"
mapZips[10]="89052"
mapZips[11]="89074"
mapZips[12]="89084"
mapZips[13]="89086"
mapZips[14]="89101"
mapZips[15]="89102"
mapZips[16]="89103"
mapZips[17]="89104"
mapZips[18]="89106"
mapZips[19]="89107"
mapZips[20]="89108"
mapZips[21]="89109"
mapZips[22]="89110"
mapZips[23]="89113"
mapZips[24]="89115"
mapZips[25]="89117"
mapZips[26]="89118"
mapZips[27]="89119"
mapZips[28]="89120"
mapZips[29]="89121"
mapZips[30]="89122"
mapZips[31]="89123"
mapZips[32]="89124"
mapZips[33]="89128"
mapZips[34]="89129"
mapZips[35]="89130"
mapZips[36]="89131"
mapZips[37]="89134"
mapZips[38]="89135"
mapZips[39]="89138"
mapZips[40]="89139"
mapZips[41]="89141"
mapZips[42]="89142"
mapZips[43]="89143"
mapZips[44]="89144"
mapZips[45]="89145"
mapZips[46]="89146"
mapZips[47]="89147"
mapZips[48]="89148"
mapZips[49]="89149"
mapZips[50]="89156"
mapZips[51]="89191"
mapZips[52]="89178"

//var selectedList;
//var availableList;
//var addIndex;
//var selIndex;

function createListObjects(){
   // availableList = document.getElementById("nvZips");
    selectedList = document.getElementById("selZips");
}

// function addAttribute()
// {
// 	availableList = document.getElementById("nvZips");
// 	selectedList = document.getElementById("selZips");
//     var addIndex = availableList.selectedIndex;
//     if(addIndex < 0)
//         return;
// 
//     selectedList.appendChild(availableList.options.item(addIndex));
//     selectNone2(selectedList,availableList);
//     UpdateHiddenareaField2();
// }

function addZip(zStr){
    var newZip = zStr.substring(0,5)
	selectedList = document.getElementById("selZips");
    var nxtIdx = selectedList.length
    for(var i=0; i < selectedList.length; i++)
    {
        if(selectedList.options[i].value == newZip)
            return;
    }
    selectedList.options[nxtIdx] = new Option(zStr,newZip,false,false);
    selectNone2();
    UpdateHiddenareaField2();
}

function delAttribute()
{
	//availableList = document.getElementById("nvZips");
	selectedList = document.getElementById("selZips");
	var isMapZip = false;
	var selIndex = selectedList.selectedIndex;
	//alert(selIndex);
	if(selIndex < 0) { return; }
	var delText  = selectedList.options[selIndex].text;
	//alert(delText);
	if(selIndex < 0) { return; }
	// scan array to see if it's a map zip or not
	for(i=0; i < mapZips.length; i++)
	{
		if(mapZips[i] == selectedList.value)
			isMapZip = true;
	}
	if(isMapZip == true){
	// Just remove from selectedList
	//selectedList.options.remove(selIndex);
	selectedList.options[selIndex] = null;
	} 
// 	else {
// 	// Insert to and Re-sort availableList here
// 	insertSortedLb(delText,'nvZips');
// 	//selectedList.options.remove(selIndex);
// 	selectedList.options[selIndex] = null;
// 	}
	selectNone2();
	UpdateHiddenareaField2();
}

function insertSortedLb(sVal,lName) {
var lb = document.getElementById(lName);

oOption = document.createElement("OPTION");
oOption.text = '';
oOption.value = '';
oOption.selected = false;
//alert(lb.length);
if(lb.length)
{
	lb.options[lb.length] = oOption;
	//alert(i1);
	/*for(i1=lb.length-1; i1>0; i1--)  
	{
	  if (lb.options[i1-1].text == sVal) 
	  {
		  return true;
	  }
	}*/
	for(i1=lb.length-1; i1>0; i1--)  
	{
	  if (lb.options[i1-1].text < sVal) 
	  {
		oOption = document.createElement("OPTION");
		oOption.text = sVal;
		oOption.value = sVal.substring(0,5);
		oOption.selected = false;
		lb.options[i1] = oOption;
		break;
	  }
	  else if(i1 == 1)
	  {
		lb.options[i1].text = lb.options[i1-1].text;
		lb.options[i1].value = lb.options[i1-1].value;  
		oOption = document.createElement("OPTION");
		oOption.text = sVal;
		oOption.value = sVal.substring(0,5);
		oOption.selected = false;
		lb.options[i1-1] = oOption;
	  }
	  else 
	  {
		lb.options[i1].text = lb.options[i1-1].text;
		lb.options[i1].value = lb.options[i1-1].value;
	  }
	} // for
}
else
{
	//lb.options[0] = oOption;
	oOption = document.createElement("OPTION");
	oOption.text = sVal;
	oOption.value = sVal.substring(0,5);
	oOption.selected = false;
	lb.options[0] = oOption;
}
return true;
} // end of insertSortedLb()

function selectNone2(){
    //document.searchForm.nvZips.selectedIndex = -1;
    document.searchForm.selZips.selectedIndex = -1;
    addIndex = -1;
    selIndex = -1;
}

function UpdateHiddenareaField2(){
    f = document.searchForm;
    c = f.zpl;
    c.value = '';
    cc = f.selZips;
    for (var i = 0; i < cc.length; i++) {
    c.value = c.value + cc.options[i].value + ',' ;
    }
}
//-->


/*GNU GPL*/ 
