<!--

function FrontPage_Form1_Validator(theForm)
{
	


  var memtype_sel = 0;
  var i = 0;
 

 // if (theForm.internal.value == "1") {
//	return(true);
 // }

  if (theForm.fmfirstname.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.fmfirstname.focus();
    return (false);
  }

  if (theForm.fmfirstname.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    theForm.fmfirstname.focus();
    return (false);
  }

  if (theForm.fmfirstname.value.length > 45)
  {
    alert("Please enter at most 45 characters in the \"First Name\" field.");
    theForm.fmfirstname.focus();
    return (false);
  }
  
  if (theForm.fmlastname.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.fmlastname.focus();
    return (false);
  }

  if (theForm.fmlastname.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    theForm.fmlastname.focus();
    return (false);
  }

  if (theForm.fmlastname.value.length > 45)
  {
    alert("Please enter at most 45 characters in the \"Last Name\" field.");
    theForm.fmlastname.focus();
    return (false);
  }

  if (theForm.fmstreet1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.fmstreet1.focus();
    return (false);
  }

  if (theForm.fmstreet1.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Address\" field.");
    theForm.fmstreet1.focus();
    return (false);
  }

  if (theForm.fmstreet1.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Address\" field.");
    theForm.fmstreet1.focus();
    return (false);
  }

  if (theForm.fmcity.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.fmcity.focus();
    return (false);
  }

  if (theForm.fmcity.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"City\" field.");
    theForm.fmcity.focus();
    return (false);
  }

  if (theForm.fmcity.value.length > 45)
  {
    alert("Please enter at most 45 characters in the \"City\" field.");
    theForm.fmcity.focus();
    return (false);
  }

  /*if (theForm.fmstate.value =="")
  {
    alert("Please select one of the \"State/Province\" options.");
    theForm.fmstate.focus();
    return (false);
  }*/
 


/*//////////////////
  if (theForm.fmstate.selectedIndex == 0)
  {
    alert("The first \"State/Province\" option is not a valid selection.  Please choose one of the other options.");
    theForm.fmstate.focus();
    return (false);
  }
////////////////////*/


if (theForm.fmzip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field. Enter five zeros if your address doesn't have Zip code");
    theForm.fmzip.focus();
    return (false);
  }

  if (theForm.fmzip.value.length < 5)
  {
    alert("Please enter at least 5 digits in the \"Zip\" field. If your Zip code has less than 5 digits, add one or more zeros at the begining to complete five digits");
    theForm.fmzip.focus();
    return (false);
  }

  if (theForm.fmzip.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Zip\" field.");
    theForm.fmzip.focus();
    return (false);
  }

/*  //////
  if (validate_zip() == false) {
	alert("Please enter a valid Zip/Postal code");
        theForm.fmzip.focus();
        return (false);
  }
////////////////*/


  if (theForm.fmcountry.selectedIndex < 0)
  {
    alert("Please select one of the \"Country\" options.");
    theForm.fmcountry.focus();
    return (false);
  }

  if (theForm.fmcountry.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    theForm.fmcountry.focus();
    return (false);
  }

  if (theForm.fmphone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.fmphone.focus();
    return (false);
  }

  if (validate_phonenum(theForm) == false) {
	alert("Please enter a valid phone number");
        theForm.fmphone.focus();
        return (false);
  }
	

  if (theForm.fmemail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.fmemail.focus();
    return (false);
  }

  if (validate_email(theForm) == false) {
	alert("Please enter a valid Email id");
        theForm.fmemail.focus();
        return (false);
  }


 
/* if (theForm.fmenrmember_type[1].checked || theForm.fmenrmember_type[2].checked) {
      for(i=0; i < theForm.fmmember_type.length; i++) {
	  if (theForm.fmmember_type[i].checked)
		break;
      }
      if (i == theForm.fmmember_type.length) {
	  alert("You haven't selected Membership Type you are interested in");
	  theForm.fmmember_type[0].focus()
	  return(false)
      }
  } */

/*if(theForm.fmmember_type[0].checked==false)
{
		alert("You haven't selected Membership Type you are interested in");
	  theForm.fmmember_type[0].focus()
	  return(false)
}*/



/*for(i=0; i < theForm.fmmember_type.length; i++) {
	  if (theForm.fmmember_type[i].checked)
		break;
      }
      if (i == theForm.fmmember_type.length) {
	  alert("You haven't selected Membership Type you are interested in");
	  theForm.fmmember_type[0].focus()
	  return(false)
      }
*/
/*
 if (theForm.fm_i_agree.checked==false)
  {
    alert("You must agree to ICDL's privacy policy");
    theForm.fm_i_agree.focus();
    return (false);
  }
*/
  

  return (true);
}



var member_type = -1;
var enrmember = -1;


function cal_total(FrontPage_Form1)
{
	

var membership_fee  = new Array(
50,
35,
35,
80,
200,
200
);

registration_fee = new Array(
345,
310,
395,

425,
350,
450,

450,
370,
490
);

workshops_mfee = new Array(
 0,
 95,
 95,
 175,
 95,
 175,
 95,
 95,
 95,
 175,
 175,
 175,
 95,
 95,
 95,
 95,
 95,
 95,
 95
);

workshops_nmfee = new Array(
 0,
 105,
 105,
 200,
 105,
 200,
 105,
 105,
 105,
 200,
 200,
 200,
 105,
 105,
 105,
 105,
 105,
 105,
 105
);

var member = 0; 
var nmember = 0; 
var rnmember = 0; 
var student = 0; 
var nonmember = 0; 
var early_bird = 0;
var onsite = 0;
var regular = 1;
var offset = 0;
var mem_fee = 0; 
var reg_fee = 0; 
var pconf_fee = 0; 



// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < FrontPage_Form1.fmmember_type.length; counter++)
{
     if (FrontPage_Form1.fmmember_type[counter].checked) {
		  
	 for (i=counter+1; i < FrontPage_Form1.fmmember_type.length; i++){
	      /* If anything else is checked ..make that the checked one */
              if (FrontPage_Form1.fmmember_type[i].checked) {
		  if (i == member_type) {
			FrontPage_Form1.fmmember_type[i].checked = false;
		  }
		  else {
			FrontPage_Form1.fmmember_type[counter].checked = false;
			counter = i;
		  }
		  break;
	      }
	 }

	 member_type = counter;

         mem_fee = membership_fee[counter];
		 // updating the field in the form with the membership amt ********** arun
		
		FrontPage_Form1.mem_total.value=mem_fee;
		grand_tot(FrontPage_Form1)
		
	 member = 1;
	 break;
     }
}



return (true); 
}

function don_tot(obj,FrontPage_Form1)
{
	//alert(eval(obj).value);
		isNumber(eval(obj).value,obj);
		FrontPage_Form1.donation_total.value=Number(FrontPage_Form1.don_web.value)+Number(FrontPage_Form1.don_train.value)+Number(FrontPage_Form1.don_network.value)+Number(FrontPage_Form1.don_pub.value)+Number(FrontPage_Form1.don_res.value)+Number(FrontPage_Form1.don_infant.value);
		grand_tot(FrontPage_Form1)
}



function grand_tot(FrontPage_Form1)
{
		FrontPage_Form1.grand_total.value=Number(FrontPage_Form1.mem_total.value)+Number(FrontPage_Form1.donation_total.value);
}

function hidden_form_update(FrontPage_Form1,obj,hidden_field,amt)
{
	FrontPage_Form1.prof.value="0";
		FrontPage_Form1.parent.value="0";
		FrontPage_Form1.student.value="0";
		FrontPage_Form1.prof_plus.value="0";
		FrontPage_Form1.supporting.value="0";
		FrontPage_Form1.org.value="0";
	//alert("working" + obj +" "+ hidden_field +" "+ amt )
	//alert(FrontPage_Form1.fmmember_type[obj-1].checked + " " + obj )
	if(FrontPage_Form1.fmmember_type[obj-1].checked)
	{
		eval("FrontPage_Form1."+ hidden_field).value=amt;
		//alert(amt);
		//alert("working" + Number(obj-1) +" "+ hidden_field +" "+ amt )
		//FrontPage_Form1.prof.value=amt;
		
	}
	

}


function mem_validate()
{

  var i =0;

  if (FrontPage_Form1.fmmember[2].checked)
  {
     for (i = 0; i < FrontPage_Form1.fmmember_type.length; i++) {
          FrontPage_Form1.fmmember_type[i].checked=false;
     }

     FrontPage_Form1.fmregtype_id[0].checked=false;
     FrontPage_Form1.fmregtype_id[1].checked=false;
     FrontPage_Form1.fmregtype_id[2].checked=true;
     cal_total();
  }

  return (true);

}

function other_source()
{
  if (FrontPage_Form1.fmorigin.value == "Other")
      FrontPage_Form1.fmorigin_other.style.visibility = "";
  else
      FrontPage_Form1.fmorigin_other.style.visibility = "hidden";
}

/*****************/
/* Combo box */
var fActiveMenu = false;
var oOverMenu = false;

function mouseSelect(e)
{
	if (fActiveMenu)
	{
		if (oOverMenu == false)
		{
			oOverMenu = false;
			document.getElementById(fActiveMenu).style.display = "none";
			fActiveMenu = false;
			return false;
		}
		return false;
	}
	return true;
}

function menuActivate(idEdit, idMenu, idSel)
{
	if (fActiveMenu) return mouseSelect(0);

	oMenu = document.getElementById(idMenu);
	oEdit = document.getElementById(idEdit);
	nTop = oEdit.offsetTop + oEdit.offsetHeight;
	nLeft = oEdit.offsetLeft;
	while (oEdit.offsetParent != document.body)
	{
		oEdit = oEdit.offsetParent;
		nTop += oEdit.offsetTop;
		nLeft += oEdit.offsetLeft;
	}
	oMenu.style.left = nLeft;
	oMenu.style.top = nTop;
	oMenu.style.display = "";
	fActiveMenu = idMenu;
	document.getElementById(idSel).focus();
	return false;
}

function textSet(idEdit, text)
{
	document.getElementById(idEdit).value = text;
	oOverMenu = false;
	mouseSelect(0);
	document.getElementById(idEdit).focus();
}

function comboKey(idEdit, idSel)
{
	if (window.event.keyCode == 13 || window.event.keyCode == 32)
		textSet(idEdit,idSel.value);
	else if (window.event.keyCode == 27)
	{
		mouseSelect(0);
		document.getElementById(idEdit).focus();
	}
}

document.onmousedown = mouseSelect;

var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function formatPhone(num)
{ 
  var _return=false;
  /*
   * 7181238748 to 1(718)123-8748
   */ 
  if(num.length != 10)
  { 
    /* 
     * if user did not enter 10 digit phone number then simply print whatever user entered 
     */ 
	_return=num;
  } 
  else
  { 
    /* formating phone number here */ 
	_return="(";
	var ini = num.substring(0,3);
	_return+=ini+")";
	var st = num.substring(3,6);
	_return+=st+"-";
	var end = num.substring(6,10);
	_return+=end;
  }
  return (_return); 
} 


function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) 
		{
			
			return (false);
			
		}
    }
    // All characters are numbers.
    return (true);
}

function isNumber(s,Obj)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9") ) )
		{
		//	if(c != ".")
		//	{

			eval(Obj).value="";
			return (false);
		//	}
			
		}
    }
    // All characters are numbers.
    return (true);
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
	 // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return (returnString);
}

function checkInternationalPhone(FrontPage_Form1,strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	ret = isInteger(s) && s.length >= minDigitsInIPhoneNumber;
	if (ret == true) 
	{
		FrontPage_Form1.fmphone.value = formatPhone(s);
	} 

return (ret);
}

function validate_phonenum(FrontPage_Form1)
{
	var Phone=FrontPage_Form1.fmphone;
	
	if ((Phone.value.length < 4) || (Phone.value.length > 14))
	{
		return (false);
	}
	if ((Phone.value==null)||(Phone.value==""))
	{
		return (false);
	}
	if (checkInternationalPhone(FrontPage_Form1,Phone.value)==false)
	{
		return (false);
	}
	return (true);
}





/* Validate Email address */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function validate_email(FrontPage_Form1){
	var emailID=FrontPage_Form1.fmemail;
	
	if ((emailID.value==null)||(emailID.value=="")){
		return false
	}
	if (echeck(emailID.value)==false){
		return false
	}
	return true
 }

/********* Validate Zip ***********/
function validate_zip() 
{
     var s = FrontPage_Form1.fmzip;
 
     // Check for correct zip code
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
 
     if (!reZip.test(s)) {
          return false;
     }
 
     return true;
}


// If you have PHP you can set the post values like this
var postState = '<?= $_POST["fmstate"] ?>';
var postCountry = '<?= $_POST["fmcountry"] ?>';
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", "fmstate");
    inputEl.setAttribute("size", 20);
    inputEl.setAttribute("value", postState);
    parentObj.appendChild(inputEl) ;
  }
}

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

-->

