function pashow(p1){
 document.getElementById('big').src=p1;
 document.getElementById('thumbs').style.display='none';
 document.getElementById('show').style.display='block';
 return false;
}

function pahide(){
 document.getElementById('show').style.display='none';
 document.getElementById('thumbs').style.display='block';
 return false;
}

function Asc(CHARACTER){
 return CHARACTER.charCodeAt(0)
}

function CBool(VALUE){
 VALUE=new String(VALUE);
 VALUE=VALUE.toLowerCase();
 if(VALUE== '1' || VALUE=='-1' || VALUE=='true' || VALUE=='yes'){
  return true;
 }else{
  return false;
 }
}

function Chr(CHARACTER_CODE){
 return String.fromCharCode(CHARACTER_CODE);
}

function CInt(number){
 return parseInt(number);
}

function CStr(VALUE){
return VALUE.toString();
}

function CSng(number){
return parseFloat(number);
}

function CDbl(number){
return parseFloat(number);
}

function CreateObject(STRING){
 var MY_OBJECT=new ActiveXObject(STRING);
 return MY_OBJECT
}

function editcity(t,s,z,n){
 t.value=pcase(t.value);
 var zip=t.value.substr(0,5);
 if(isNumeric(zip)){
  document.getElementsByTagName('body')[0].style.cursor='wait';
  document.getElementById('getscript').src='http://uwtke.com/ajax.php?action=getcity&zip='+zip+'&slit='+s+'&zlit='+z+'&nlit='+n;
 }
}

function Eval(STRING){
 eval(STRING);
}

function FormatCurrency(FIGURE){
 if(!FIGURE||FIGURE==''){
  return '0.00';
 }
 var strTemp=FIGURE.toString();
 while(strTemp.indexOf(',') > -1){
  strTemp=strTemp.replace(',','');
 }
 strTemp=parseFloat(strTemp);
 FIGURE=Round(FIGURE,2);
 FIGURE=FIGURE.toString();
 var Place=FIGURE.indexOf('.');
 if(Place >-1){
  if((FIGURE.length - Place)==2){
   FIGURE+='0';
  }
 }else{
  FIGURE+='.00';
 }
 if(FIGURE=='0.00'){
  return'';
 }
 return FIGURE;
}

function FormatDate(DateToFormat,FormatAs){
 if(DateToFormat==''){return'';}
 if(!FormatAs){FormatAs='dd/mm/yyyy';}
 var strReturnDate;
 FormatAs=FormatAs.toLowerCase();
 DateToFormat=DateToFormat.toLowerCase();
 var arrDate
 var arrMonths=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
 var strMONTH;
 var Separator;

 while(DateToFormat.indexOf('st')>-1){
  DateToFormat=DateToFormat.replace('st','');
 }

 while(DateToFormat.indexOf('nd')>-1){
  DateToFormat=DateToFormat.replace('nd','');
 }

 while(DateToFormat.indexOf('rd')>-1){
  DateToFormat=DateToFormat.replace('rd','');
 }

 while(DateToFormat.indexOf('th')>-1){
  DateToFormat=DateToFormat.replace('th','');
 }

 if(DateToFormat.indexOf('.')>-1){
  Separator='.';
 }

 if(DateToFormat.indexOf('-')>-1){
  Separator='-';
 }

 if(DateToFormat.indexOf('/')>-1){
  Separator='/';
 }

 if(DateToFormat.indexOf(' ')>-1){
  Separator=' ';
 }

 arrDate=DateToFormat.split(Separator);
 DateToFormat='';
  for(var iSD=0;iSD < arrDate.length;iSD++){
   if(arrDate[iSD]!=''){
   DateToFormat+=arrDate[iSD]+Separator;
   }
  }
 DateToFormat=DateToFormat.substring(0,DateToFormat.length-1);
 arrDate=DateToFormat.split(Separator);

 if(arrDate.length < 3){
  return '';
 }

 var DAY=arrDate[0];
 var MONTH=arrDate[1];
 var YEAR=arrDate[2];

if(parseFloat(arrDate[1]) > 12){
 DAY=arrDate[1];
 MONTH=arrDate[0];
}

if(parseFloat(DAY) && DAY.toString().length==4){
 YEAR=arrDate[0];
 DAY=arrDate[2];
 MONTH=arrDate[1];
}

for(var iSD=0;iSD < arrMonths.length;iSD++){
 var ShortMonth=arrMonths[iSD].substring(0,3).toLowerCase();
 var MonthPosition=DateToFormat.indexOf(ShortMonth);
	if(MonthPosition > -1){
	 MONTH=iSD+1;
		if(MonthPosition==0){
		 DAY=arrDate[1];
		 YEAR=arrDate[2];
		}
	 break;
	}
}

var strTemp=YEAR.toString();
if(strTemp.length==2){
	if(parseFloat(YEAR)>40){
	 YEAR='19'+YEAR;
	}else{
	 YEAR='20'+YEAR;
	}
}

	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
	 MONTH='0'+MONTH;
	}
	if(parseInt(DAY)< 10 && DAY.toString().length < 2){
	 DAY='0'+DAY;
	}
	switch (FormatAs){
	case 'dd/mm/yyyy':
	 return DAY+'/'+MONTH+'/'+YEAR;
	case 'mm/dd/yyyy':
	 return MONTH+'/'+DAY+'/'+YEAR;
	case 'dd/mmm/yyyy':
	 return DAY+' '+arrMonths[MONTH -1].substring(0,3)+' '+YEAR;
	case 'mmm/dd/yyyy':
	 return arrMonths[MONTH -1].substring(0,3)+' '+DAY+' '+YEAR;
	case 'dd/mmmm/yyyy':
	 return DAY+' '+arrMonths[MONTH -1]+' '+YEAR;	
	case 'mmmm/dd/yyyy':
	 return arrMonths[MONTH -1]+' '+DAY+' '+YEAR;
	}
 return DAY+'/'+strMONTH+'/'+YEAR;
}

function FormatPercent(number,PLACES){
	number=number*100
	if(PLACES){
	 number=Round(number,PLACES);
	}else{
	 number=Round(number,2);
	 number=FormatCurrency(number);
	}
	number+='%';
return number;
}

function GetDate(FORMAT){
 var m_TODAY=new Date();
 var m_Day=m_TODAY.getDate();
 var m_Month=(m_TODAY.getMonth()+1)
 var MY_DATE=m_Day+'/'+m_Month+'/'+m_TODAY.getYear();

 if(!FORMAT){
  FORMAT='mm/dd/yyyy';
  MY_DATE=m_Month+'/'+m_Day+'/'+m_TODAY.getYear();
 }
 MY_DATE=FormatDate(MY_DATE,FORMAT);
 return MY_DATE;
}

function IsArray(MY_ARRAY){
 MY_ARRAY=MY_ARRAY.constructor.toString();
 if(InStr(MY_ARRAY,'Array') > 0){
  return true;
 }else{
  return false;
 }
}

function IsNull(ITEM){
 if(ITEM==null || ITEM==undefined){
  return true;
 }
 return false;
}

function Join(ARRAY,DELIMITER){
 ARRAY=ARRAY.toString();
 if(DELIMITER){
  ARRAY=Replace(ARRAY,',',DELIMITER);
 }else{
  ARRAY=Replace(ARRAY,',',' ');
 }
 return ARRAY;
}

function Now(){
 var NOW=new Date().toString();
 var arrNOW=NOW.split('UTC')
 NOW=arrNOW[0];
 return NOW;
}

function pcase(p1){
 // alert('pcase called, p='+p1)
 if(p1.toUpperCase()==p1){p1=p1.toLowerCase();}
	var strReturn_Value='';
	var iTemp=p1.length;
	if(iTemp==0){return '';}
	var UcaseNext=false;
	strReturn_Value+=p1.charAt(0).toUpperCase();
	for(var iCounter=1;iCounter < iTemp;iCounter++){
 	if(UcaseNext==true){
	  strReturn_Value+=p1.charAt(iCounter).toUpperCase();
	 }else{
	  // strReturn_Value+=p1.charAt(iCounter).toLowerCase();
	  strReturn_Value+=p1.charAt(iCounter);
	 }
	 var iChar=p1.charCodeAt(iCounter);
	 if(iChar==32 || iChar==45 || iChar==46){
	  UcaseNext=true;
	 }else{
	  UcaseNext=false
	 }
	 if(iChar==99 || iChar==67){
	  if(p1.charCodeAt(iCounter-1)==77 || p1.charCodeAt(iCounter-1)==109){
	   UcaseNext=true;
	  }
  }
 } // end for
 return strReturn_Value;
} // end function

function Round(number,PLACES){
 if(!isNumeric(number)){
  return '0';
 }
 number=CStr(number);
 arrnumber=number.split('.');
 if(arrnumber.length==1){return number;}
 if(PLACES){
  number=Math.round(number*Math.pow(10,PLACES))/Math.pow(10,PLACES);
 }else{
  number=Math.round(number);
 }
 return number;
}

function IsDate(DateToCheck){
 if(DateToCheck==''){return true;}
 var m_strDate=FormatDate(DateToCheck);
 if(m_strDate==''){
  return false;
 }
 var m_arrDate=m_strDate.split('/');
 var m_DAY=m_arrDate[0];
 var m_MONTH=m_arrDate[1];
 var m_YEAR=m_arrDate[2];
 if(m_YEAR.length > 4){return false;}
 m_strDate=m_MONTH+'/'+m_DAY+'/'+m_YEAR;
 var testDate=new Date(m_strDate);
 if(testDate.getMonth()+1==m_MONTH){
  return true;
 }else{
  return false;
 }
} //end function

function isNumeric(VALUE){
 for(var ivA=0; ivA < VALUE.length;ivA ++){
  if(VALUE.charCodeAt(ivA) < 48 || VALUE.charCodeAt(ivA) > 57){
	  if(VALUE.charCodeAt(ivA) != 46 && VALUE.charCodeAt(ivA) != 32 && VALUE.charAt(ivA) != ','){
	   return false;
	  }
  }																					
 }
 return true;
}

function TitleCase(STRING){
 var Exceptions='About/about|Above/above|Across/across|After/after|Against/against|Around/around|At/at|Before/before|Behind/behind|Below/below|Beneath/beneath|Beside/beside|Besides/besides|Between/between|Beyond/beyond|By/by|Down/down|During/during|Except/except|For/for|From/from|In/in|Inside/inside|Into/into|Like/like|Near/near|Of/of|Off/off|On/on|Out/out|Outside/outside|Over/over|Since/since|Through/through|Throughout/throughout|Till/till|To/to|Toward/toward|Under/under|Until/until|Up/up|Upon/upon|With/with|Without/without';var arrExceptions=Exceptions.split('|');STRING=pcase(STRING);var arrExValues;
 for(var iEx=0; iEx < arrExceptions.length;iEx++){
  arrExValues=arrExceptions[iEx].split('/');
  var SearchThisValue=' '+arrExValues[0]+' ';
  var ReplaceThisValue=' '+arrExValues[1]+' ';
  while(STRING.indexOf(SearchThisValue)>-1){
   STRING=STRING.replace(SearchThisValue,ReplaceThisValue);
  }
 }
 return STRING;
} //End Function


function InStr(STRING,SUBSTRING,COMPARE,START){
 if(START){
  STRING=STRING.substring(START,STRING.length);
 }
 if(CBool(COMPARE) || COMPARE ==undefined){
  STRING=STRING.toLowerCase();
  SUBSTRING=SUBSTRING.toLowerCase();
 }
 if(STRING.indexOf(SUBSTRING) > -1){
  return STRING.indexOf(SUBSTRING)
 }else{
  return 0;
 }
}

function LCase(STRING){
 return STRING.toLowerCase();
}

function left(STRING,CHARACTER_COUNT){
 return STRING.substring(0,CHARACTER_COUNT);
}

function Len(STRING){
 return STRING.length;
}

function Mid(STRING,START,END){
 if(!START){START=0};
 if(!END || END > STRING.length){END=STRING.length};
 if(END!=STRING.length){END=START+END};
 return STRING.substring(START,END);
}

function Replace(STRING,REPLACE_THIS,REPLACE_WITH){
 while(STRING.indexOf(REPLACE_THIS) > -1){
  STRING=STRING.replace(REPLACE_THIS,REPLACE_WITH);
 }
 return STRING;
}

function Right(STRING,CHARACTER_COUNT){
 return STRING.substring((STRING.length - CHARACTER_COUNT),STRING.length);
}

function Split(STRING,CHARACTER){
 return STRING.split(CHARACTER);
}

function strComp(STRING1,STRING2,COMPARE){
 if(IsNull(COMPARE)){
  COMPARE=1;
 }
 if(CBool(COMPARE)){
  STRING1=STRING1.toLowerCase();
  STRING2=STRING2.toLowerCase();
 }

 if(STRING1==STRING2){
  return true;
 }else{
  return false;
 }
}

function Sqr(number){
 return number*number
}

function Trim(STRING){
 STRING=LTrim(STRING);
 return RTrim(STRING);
}

function RTrim(STRING){
 while(STRING.charAt((STRING.length -1))==' '){
  STRING=STRING.substring(0,STRING.length-1);
 }
 return STRING;
}

function LTrim(STRING){
 while(STRING.charAt(0)==' '){
  STRING=STRING.replace(STRING.charAt(0),'');
 }
 return STRING;
}

function UBound(ARRAY){
 if(IsArray(ARRAY)){
  return ARRAY.length;
 }else{
  return;
 }
}

function UCase(STRING){
 return STRING.toUpperCase();
}

function UNESCAPE(U_VALUE){
 U_VALUE=unescape(U_VALUE);
 while(U_VALUE.indexOf('+') > -1){
  U_VALUE=U_VALUE.replace('+',' ');
 }
 return U_VALUE;
}

var vbCrLf=String.fromCharCode(13)+String.fromCharCode(10);
var vbTab='	'; // change this syntax!

// If you have PHP you can set the post values like this
//var postState = '<?= $_POST['state'] ?>';
//var postCountry = '<?= $_POST['country'] ?>';
var postState='';
var postCountry='';

// State table
//
// To edit the list, just delete a line or add a line. Order is important.
// The order displayed here is the order it appears on the drop down.
//
var state='\
US:AK:Alaska|\
US:AL:Alabama|\
US:AR:Arkansas|\
US:AS:American Samoa|\
US:AZ:Arizona|\
US:CA:California|\
US:CO:Colorado|\
US:CT:Connecticut|\
US:DC:D.C.|\
US:DE:Delaware|\
US:FL:Florida|\
US:FM:Micronesia|\
US:GA:Georgia|\
US:GU:Guam|\
US:HI:Hawaii|\
US:IA:Iowa|\
US:ID:Idaho|\
US:IL:Illinois|\
US:IN:Indiana|\
US:KS:Kansas|\
US:KY:Kentucky|\
US:LA:Louisiana|\
US:MA:Massachusetts|\
US:MD:Maryland|\
US:ME:Maine|\
US:MH:Marshall Islands|\
US:MI:Michigan|\
US:MN:Minnesota|\
US:MO:Missouri|\
US:MP:Marianas|\
US:MS:Mississippi|\
US:MT:Montana|\
US:NC:North Carolina|\
US:ND:North Dakota|\
US:NE:Nebraska|\
US:NH:New Hampshire|\
US:NJ:New Jersey|\
US:NM:New Mexico|\
US:NV:Nevada|\
US:NY:New York|\
US:OH:Ohio|\
US:OK:Oklahoma|\
US:OR:Oregon|\
US:PA:Pennsylvania|\
US:PR:Puerto Rico|\
US:PW:Palau|\
US:RI:Rhode Island|\
US:SC:South Carolina|\
US:SD:South Dakota|\
US:TN:Tennessee|\
US:TX:Texas|\
US:UT:Utah|\
US:VA:Virginia|\
US:VI:Virgin Islands|\
US:VT:Vermont|\
US:WA:Washington|\
US:WI:Wisconsin|\
US:WV:West Virginia|\
US:WY:Wyoming|\
US:AA:Military Americas|\
US:AE:Military Europe/ME/Canada|\
US:AP:Military Pacific|\
CA:AB:Alberta|\
CA:MB:Manitoba|\
CA:AB:Alberta|\
CA:BC:British Columbia|\
CA:MB:Manitoba|\
CA:NB:New Brunswick|\
CA:NL:Newfoundland and Labrador|\
CA:NS:Nova Scotia|\
CA:NT:Northwest Territories|\
CA:NU:Nunavut|\
CA:ON:Ontario|\
CA:PE:Prince Edward Island|\
CA:QC:Quebec|\
CA:SK:Saskatchewan|\
CA:YT:Yukon Territory|\
AU:AAT:Australian Antarctic Territory|\
AU:ACT:Australian Capital Territory|\
AU:NT:Northern Territory|\
AU:NSW:New South Wales|\
AU:QLD:Queensland|\
AU:SA:South Australia|\
AU:TAS:Tasmania|\
AU:VIC:Victoria|\
AU:WA:Western Australia|\
BR:AC:Acre|\
BR:AL:Alagoas|\
BR:AM:Amazonas|\
BR:AP:Amapa|\
BR:BA:Baia|\
BR:CE:Ceara|\
BR:DF:Distrito Federal|\
BR:ES:Espirito Santo|\
BR:FN:Fernando de Noronha|\
BR:GO:Goias|\
BR:MA:Maranhao|\
BR:MG:Minas Gerais|\
BR:MS:Mato Grosso do Sul|\
BR:MT:Mato Grosso|\
BR:PA:Para|\
BR:PB:Paraiba|\
BR:PE:Pernambuco|\
BR:PI:Piaui|\
BR:PR:Parana|\
BR:RJ:Rio de Janeiro|\
BR:RN:Rio Grande do Norte|\
BR:RO:Rondonia|\
BR:RR:Roraima|\
BR:RS:Rio Grande do Sul|\
BR:SC:Santa Catarina|\
BR:SE:Sergipe|\
BR:SP:Sao Paulo|\
BR:TO:Tocatins|\
NL:DR:Drente|\
NL:FL:Flevoland|\
NL:FR:Friesland|\
NL:GL:Gelderland|\
NL:GR:Groningen|\
NL:LB:Limburg|\
NL:NB:Noord Brabant|\
NL:NH:Noord Holland|\
NL:OV:Overijssel|\
NL:UT:Utrecht|\
NL:ZH:Zuid Holland|\
NL:ZL:Zeeland|\
UK:AVON:Avon|\
UK:BEDS:Bedfordshire|\
UK:BERKS:Berkshire|\
UK:BUCKS:Buckinghamshire|\
UK:CAMBS:Cambridgeshire|\
UK:CHESH:Cheshire|\
UK:CLEVE:Cleveland|\
UK:CORN:Cornwall|\
UK:CUMB:Cumbria|\
UK:DERBY:Derbyshire|\
UK:DEVON:Devon|\
UK:DORSET:Dorset|\
UK:DURHAM:Durham|\
UK:ESSEX:Essex|\
UK:GLOUS:Gloucestershire|\
UK:GLONDON:Greater London|\
UK:GMANCH:Greater Manchester|\
UK:HANTS:Hampshire|\
UK:HERWOR:Hereford & Worcestershire|\
UK:HERTS:Hertfordshire|\
UK:HUMBER:Humberside|\
UK:IOM:Isle of Man|\
UK:IOW:Isle of Wight|\
UK:KENT:Kent|\
UK:LANCS:Lancashire|\
UK:LEICS:Leicestershire|\
UK:LINCS:Lincolnshire|\
UK:MERSEY:Merseyside|\
UK:NORF:Norfolk|\
UK:NHANTS:Northamptonshire|\
UK:NTHUMB:Northumberland|\
UK:NOTTS:Nottinghamshire|\
UK:OXON:Oxfordshire|\
UK:SHROPS:Shropshire|\
UK:SOM:Somerset|\
UK:STAFFS:Staffordshire|\
UK:SUFF:Suffolk|\
UK:SURREY:Surrey|\
UK:SUSS:Sussex|\
UK:WARKS:Warwickshire|\
UK:WMID:West Midlands|\
UK:WILTS:Wiltshire|\
UK:YORK:Yorkshire|\
EI:CO ANTRIM:County Antrim|\
EI:CO ARMAGH:County Armagh|\
EI:CO DOWN:County Down|\
EI:CO FERMANAGH:County Fermanagh|\
EI:CO DERRY:County Londonderry|\
EI:CO TYRONE:County Tyrone|\
EI:CO CAVAN:County Cavan|\
EI:CO DONEGAL:County Donegal|\
EI:CO MONAGHAN:County Monaghan|\
EI:CO DUBLIN:County Dublin|\
EI:CO CARLOW:County Carlow|\
EI:CO KILDARE:County Kildare|\
EI:CO KILKENNY:County Kilkenny|\
EI:CO LAOIS:County Laois|\
EI:CO LONGFORD:County Longford|\
EI:CO LOUTH:County Louth|\
EI:CO MEATH:County Meath|\
EI:CO OFFALY:County Offaly|\
EI:CO WESTMEATH:County Westmeath|\
EI:CO WEXFORD:County Wexford|\
EI:CO WICKLOW:County Wicklow|\
EI:CO GALWAY:County Galway|\
EI:CO MAYO:County Mayo|\
EI:CO LEITRIM:County Leitrim|\
EI:CO ROSCOMMON:County Roscommon|\
EI:CO SLIGO:County Sligo|\
EI:CO CLARE:County Clare|\
EI:CO CORK:County Cork|\
EI:CO KERRY:County Kerry|\
EI:CO LIMERICK:County Limerick|\
EI:CO TIPPERARY:County Tipperary|\
EI:CO WATERFORD:County Waterford|\
';

// Country data table
//
// To edit the list, just delete a line or add a line. Order is important.
// The order displayed here is the order it appears on the drop down.
//
var country='\
AF:Afghanistan|\
AL:Albania|\
DZ:Algeria|\
AS:American Samoa|\
AD:Andorra|\
AO:Angola|\
AI:Anguilla|\
AQ:Antarctica|\
AG:Antigua and Barbuda|\
AR:Argentina|\
AM:Armenia|\
AW:Aruba|\
AU:Australia|\
AT:Austria|\
AZ:Azerbaijan|\
AP:Azores|\
BS:Bahamas|\
BH:Bahrain|\
BD:Bangladesh|\
BB:Barbados|\
BY:Belarus|\
BE:Belgium|\
BZ:Belize|\
BJ:Benin|\
BM:Bermuda|\
BT:Bhutan|\
BO:Bolivia|\
BA:Bosnia And Herzegowina|\
XB:Bosnia-Herzegovina|\
BW:Botswana|\
BV:Bouvet Island|\
BR:Brazil|\
IO:British Indian Ocean Territory|\
VG:British Virgin Islands|\
BN:Brunei Darussalam|\
BG:Bulgaria|\
BF:Burkina Faso|\
BI:Burundi|\
KH:Cambodia|\
CM:Cameroon|\
CA:Canada|\
CV:Cape Verde|\
KY:Cayman Islands|\
CF:Central African Republic|\
TD:Chad|\
CL:Chile|\
CN:China|\
CX:Christmas Island|\
CC:Cocos (Keeling) Islands|\
CO:Colombia|\
KM:Comoros|\
CG:Congo|\
CD:Congo, The Democratic Republic O|\
CK:Cook Islands|\
XE:Corsica|\
CR:Costa Rica|\
CI:Cote d` Ivoire (Ivory Coast)|\
HR:Croatia|\
CU:Cuba|\
CY:Cyprus|\
CZ:Czech Republic|\
DK:Denmark|\
DJ:Djibouti|\
DM:Dominica|\
DO:Dominican Republic|\
TP:East Timor|\
EC:Ecuador|\
EG:Egypt|\
SV:El Salvador|\
GQ:Equatorial Guinea|\
ER:Eritrea|\
EE:Estonia|\
ET:Ethiopia|\
FK:Falkland Islands (Malvinas)|\
FO:Faroe Islands|\
FJ:Fiji|\
FI:Finland|\
FR:France (Includes Monaco)|\
FX:France, Metropolitan|\
GF:French Guiana|\
PF:French Polynesia|\
TA:French Polynesia (Tahiti)|\
TF:French Southern Territories|\
GA:Gabon|\
GM:Gambia|\
GE:Georgia|\
DE:Germany|\
GH:Ghana|\
GI:Gibraltar|\
GR:Greece|\
GL:Greenland|\
GD:Grenada|\
GP:Guadeloupe|\
GU:Guam|\
GT:Guatemala|\
GN:Guinea|\
GW:Guinea-Bissau|\
GY:Guyana|\
HT:Haiti|\
HM:Heard And Mc Donald Islands|\
VA:Holy See (Vatican City State)|\
HN:Honduras|\
HK:Hong Kong|\
HU:Hungary|\
IS:Iceland|\
IN:India|\
ID:Indonesia|\
IR:Iran|\
IQ:Iraq|\
IE:Ireland|\
EI:Ireland (Eire)|\
IL:Israel|\
IT:Italy|\
JM:Jamaica|\
JP:Japan|\
JO:Jordan|\
KZ:Kazakhstan|\
KE:Kenya|\
KI:Kiribati|\
KP:Korea, Democratic People\'S Repub|\
KW:Kuwait|\
KG:Kyrgyzstan|\
LA:Laos|\
LV:Latvia|\
LB:Lebanon|\
LS:Lesotho|\
LR:Liberia|\
LY:Libya|\
LI:Liechtenstein|\
LT:Lithuania|\
LU:Luxembourg|\
MO:Macao|\
MK:Macedonia|\
MG:Madagascar|\
ME:Madeira Islands|\
MW:Malawi|\
MY:Malaysia|\
MV:Maldives|\
ML:Mali|\
MT:Malta|\
MH:Marshall Islands|\
MQ:Martinique|\
MR:Mauritania|\
MU:Mauritius|\
YT:Mayotte|\
MX:Mexico|\
FM:Micronesia, Federated States Of|\
MD:Moldova, Republic Of|\
MC:Monaco|\
MN:Mongolia|\
MS:Montserrat|\
MA:Morocco|\
MZ:Mozambique|\
MM:Myanmar (Burma)|\
NA:Namibia|\
NR:Nauru|\
NP:Nepal|\
NL:Netherlands|\
AN:Netherlands Antilles|\
NC:New Caledonia|\
NZ:New Zealand|\
NI:Nicaragua|\
NE:Niger|\
NG:Nigeria|\
NU:Niue|\
NF:Norfolk Island|\
MP:Northern Mariana Islands|\
NO:Norway|\
OM:Oman|\
PK:Pakistan|\
PW:Palau|\
PS:Palestinian Territory, Occupied|\
PA:Panama|\
PG:Papua New Guinea|\
PY:Paraguay|\
PE:Peru|\
PH:Philippines|\
PN:Pitcairn|\
PL:Poland|\
PT:Portugal|\
PR:Puerto Rico|\
QA:Qatar|\
RE:Reunion|\
RO:Romania|\
RU:Russian Federation|\
RW:Rwanda|\
KN:Saint Kitts And Nevis|\
SM:San Marino|\
ST:Sao Tome and Principe|\
SA:Saudi Arabia|\
SN:Senegal|\
XS:Serbia-Montenegro|\
SC:Seychelles|\
SL:Sierra Leone|\
SG:Singapore|\
SK:Slovak Republic|\
SI:Slovenia|\
SB:Solomon Islands|\
SO:Somalia|\
ZA:South Africa|\
GS:South Georgia And The South Sand|\
KR:South Korea|\
ES:Spain|\
LK:Sri Lanka|\
NV:St. Christopher and Nevis|\
SH:St. Helena|\
LC:St. Lucia|\
PM:St. Pierre and Miquelon|\
VC:St. Vincent and the Grenadines|\
SD:Sudan|\
SR:Suriname|\
SJ:Svalbard And Jan Mayen Islands|\
SZ:Swaziland|\
SE:Sweden|\
CH:Switzerland|\
SY:Syrian Arab Republic|\
TW:Taiwan|\
TJ:Tajikistan|\
TZ:Tanzania|\
TH:Thailand|\
TG:Togo|\
TK:Tokelau|\
TO:Tonga|\
TT:Trinidad and Tobago|\
XU:Tristan da Cunha|\
TN:Tunisia|\
TR:Turkey|\
TM:Turkmenistan|\
TC:Turks and Caicos Islands|\
TV:Tuvalu|\
UG:Uganda|\
UA:Ukraine|\
AE:United Arab Emirates|\
UK:United Kingdom|\
GB:Great Britain|\
US:United States|\
UM:United States Minor Outlying Isl|\
UY:Uruguay|\
UZ:Uzbekistan|\
VU:Vanuatu|\
XV:Vatican City|\
VE:Venezuela|\
VN:Vietnam|\
VI:Virgin Islands (U.S.)|\
WF:Wallis and Furuna Islands|\
EH:Western Sahara|\
WS:Western Samoa|\
YE:Yemen|\
YU:Yugoslavia|\
ZR:Zaire|\
ZM:Zambia|\
ZW:Zimbabwe|\
';

function TrimString(sInString) {
  if ( sInString ) {
    sInString=sInString.replace( /^\s+/g, '' );// strip leading
    return sInString.replace( /\s+$/g, '' );// strip trailing
  }
}

// Populates the country selected with the counties from the country list
function populateCountry(defaultCountry) {
  if ( postCountry != '' ) {
    defaultCountry=postCountry;
  }
  var countryLineArray=country.split('|');  // Split into lines
  var selObj=document.getElementById('countrySelect');
  selObj.options[0]=new Option('Select Country','');
  selObj.selectedIndex=0;
  for (var loop=0; loop < countryLineArray.length; loop++) {
    lineArray=countryLineArray[loop].split(':');
    countryCode =TrimString(lineArray[0]);
    countryName =TrimString(lineArray[1]);
    if ( countryCode != '' ) {
      selObj.options[loop+1]=new Option(countryName, countryCode);
    }
    if ( defaultCountry == countryCode ) {
      selObj.selectedIndex=loop+1;
    }
  }
}

function populateState() {
  var selObj=document.getElementById('stateSelect');
  var foundState=false;
  // Empty options just in case new drop down is shorter
  if ( selObj.type == 'select-one' ) {
    for (var i=0; i < selObj.options.length; i++) {
      selObj.options[i]=null;
    }
    selObj.options.length=null;
    selObj.options[0]=new Option('Select State','');
    selObj.selectedIndex=0;
  }
  // Populate the drop down with states from the selected country
  var stateLineArray=state.split('|');  // Split into lines
  var optionCntr=1;
  for (var loop=0; loop < stateLineArray.length; loop++) {
    lineArray=stateLineArray[loop].split(':');
    countryCode =TrimString(lineArray[0]);
    stateCode   =TrimString(lineArray[1]);
    stateName   =TrimString(lineArray[2]);
  if (document.getElementById('countrySelect').value == countryCode && countryCode != '' ) {
    // If it's a input element, change it to a select
      if ( selObj.type == 'text' ) {
        parentObj=document.getElementById('stateSelect').parentNode;
        parentObj.removeChild(selObj);
        var inputSel=document.createElement('SELECT');
        inputSel.setAttribute('name','state');
        inputSel.setAttribute('id','stateSelect');
        parentObj.appendChild(inputSel) ;
        selObj=document.getElementById('stateSelect');
        selObj.options[0]=new Option('Select State','');
        selObj.selectedIndex=0;
      }
      if ( stateCode != '' ) {
        selObj.options[optionCntr]=new Option(stateName, stateCode);
      }
      // See if it's selected from a previous post
      if ( stateCode == postState && countryCode == postCountry ) {
        selObj.selectedIndex=optionCntr;
      }
      foundState=true;
      optionCntr++
    }
  }
  // If the country has no states, change the select to a text box
  if ( ! foundState ) {
    parentObj=document.getElementById('stateSelect').parentNode;
    parentObj.removeChild(selObj);
  // Create the Input Field
    var inputEl=document.createElement('INPUT');
    inputEl.setAttribute('id', 'stateSelect');
    inputEl.setAttribute('type', 'text');
    inputEl.setAttribute('name', 'state');
    inputEl.setAttribute('size', 20);
    inputEl.setAttribute('value', postState);
    parentObj.appendChild(inputEl) ;
  }
}

function initCountry(country) {
 populateCountry(country);
 populateState();
}

// --------------------------------------------
//                  setfocus
// Jun 2005: discovered that reason IE wasn't setting focus was
// due to an IE timing bug. Added 0.1 sec delay to fix.
// Delayed focus setting to get around IE bug
// --------------------------------------------

function setFocusDelayed(){
 global_valfield.focus();
}

function setfocus(valfield){
 // save valfield in global variable so value retained when routine exits
 global_valfield=valfield;
 setTimeout( 'setFocusDelayed()', 100 );
}

// alert('js loaded');