function toggle(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}
function hide(obj) {
	var el = document.getElementById(obj);
	el.style.display = 'none';
}
function show(obj) {
	var el = document.getElementById(obj);
	el.style.display = '';
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function toggleNav(obj) {
	var infonav = new Array("payinfo","cancelinfo","hotelinfo","transinfo");
	for (x in infonav) {
  	  var divid = infonav[x]; 
  	  if (obj == divid){
  	  	toggle(divid);	
  	  } else { 
	    hide(divid);	   	
	  }//if
	}//for
}
function showChoice(obj)
{
  var sel = document.getElementById(obj);
  var choiceid = sel.options[sel.selectedIndex].value;
  var choice = trim(choiceid);
  var sessdiv = 'sess'+choice;
  var sesslink = document.getElementById(sessdiv);
  var sessions = new Array ("None","1A","2A","3A","4A","5A","6A","7A","8A","9A","10A","11B","12B","13B","14B","15B","16B","17B","18B","19B","20B","21C","22C","23C","24C","25C","26C","27C","28C","29C","30C","31D","32D","33D","34D","35D","36D","37D","38D","39D","40D","41E","42E","43E","44E","45E","46E","47E","48E","49E","50E","51F","52F","53F","54F","55F");
  for (x in sessions) {
  	  var divname = 'sess'+sessions[x];
	  if(divname != sessdiv) { 
	   hide(divname);
	  }else{
	   	show(divname);
	  }//if
	}//for
}  

function setSessionChoice(obj)
{
  var sel = document.getElementById(obj);
  var choice = sel.options[sel.selectedIndex].value;
  var re=/choice/;
  var info = obj.replace(re,"info");
  var infolink = document.getElementById(info);
  infolink.href = '#info'+choice;
  infolink.style.display = '';
}  

function toggleBilling(show_state) {
	var ele = document.getElementById("billing_address_section");
	if(show_state == "Yes") {
    	ele.style.display = "none";
  	}
	else {
		ele.style.display = "block";
	}
} 

function padout(number) { return (number < 10) ? '0' + number : number; }

function setPhone(phonetype)
{
  var phoneus = document.getElementById('phoneus');
  var phoneint = document.getElementById('phoneint');
  var faxus = document.getElementById('faxus');
  var faxint = document.getElementById('faxint');
  switch (phonetype)
  {
   case "US":
     phoneus.style.display='block';
     phoneint.style.display='none';
     faxus.style.display='block';
     faxint.style.display='none';
     break
   case "INT":
     phoneus.style.display='none';
     phoneint.style.display='block';
     faxus.style.display='none';
     faxint.style.display='block';
     break
   default:
     phoneus.style.display='block';
     phoneint.style.display='none';
     faxus.style.display='block';
     faxint.style.display='none';
   }

  }
  
function setAmount(enrollment)
{
  var amount;
  var sym_price;
  var pre_price;
  pre_price = document.regform.preconf_price.value - 0;
  sym_price = document.regform.sym_price.value - 0;
  var preconf = document.getElementById('preconf');
  var symposium = document.getElementById('symposium');
  switch (enrollment)
  {
   case "preconference":
     amount = pre_price;
     preconf.style.display='block';
     symposium.style.display='none';
     break
   case "symposium":
     amount = sym_price;
     preconf.style.display='none';
     symposium.style.display='block';
     break
   case "both":
     amount = pre_price + sym_price; 
     preconf.style.display='block';
     symposium.style.display='block';
     break
   default:
     amount=666
     preconf.style.display='block';
     symposium.style.display='block';
   }
   document.regform.amount_due.value=amount;
  }

function removeOptions(obj1,obj2) 
{
 var source = document.getElementById(obj2);
 var target = document.getElementById(obj1);
  var text = source.options[source.selectedIndex].value;
  
  if (text != "None") 
  {
  target.options.length = source.options.length;
  for (var i = 0; i < source.options.length; i++) 
  {
      target.options[i].value = source.options[i].value;
      target.options[i].text = source.options[i].text;
  }
  target.options[0].selected = true;
  
  for (var j = target.options.length-1; j>=0; j--) 
  {
    if (target.options[j].text == text) 
    {
      target.options[j] = null;
    }
  }
 
  if (source.name == "sessiona_choice1")
   {
    if (document.regform.sessionb_choice1.options.length == "")
    {

      document.regform.sessionb_choice1.options.length = sessionsB.length;
      for (var m = 0; m < sessionsB.length; m++) 
      {
       document.regform.sessionb_choice1.options[m].value = sessionsB[m];
       document.regform.sessionb_choice1.options[m].text = sessionsB[m];
      }
      document.regform.sessionb_choice1.options[0].selected = true;
    }
  } 

  for (var k = 0; k < doubleSessions.length; k++) 
  {
//	alert( "in doubleSessions . len is "+doubleSessions.length+"; testing "+doubleSessions[k]);
    if (source.options[source.selectedIndex].value == doubleSessions[k]) 
    {   
        // hardcoding session B to 20B here. Make this a more general solution.  MEI 11/25/09
		document.regform.sessionb_choice1.options[10].selected = true;
		//document.regform.sessionb_choice1.options.length=0;

    }
  }
  }
}

function removeSessions(obj) 
{  
var source = document.getElementById(obj);
  if (document.regform.sessionb_choice2.options.length == "")
  {
    document.regform.sessionb_choice2.options.length = sessionsB.length;
    for (var m = 0; m < sessionsB.length; m++) 
    {
     document.regform.sessionb_choice2.options[m].value = sessionsB[m];
     document.regform.sessionb_choice2.options[m].text = sessionsB[m];
    }
     document.regform.sessionb_choice2.options[0].selected=true;
  }

  for (var k = 0; k < doubleSessions.length; k++) 
  {
    if (source.options[source.selectedIndex].value == doubleSessions[k]) 
    {   
      document.regform.sessionb_choice2.options.length = 0;
    }
  }
}

function setStates()
{  
  var ustext   = new Array("-- select state --","Alabama","Alaska","American Samoa","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Federated States of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virgin Islands","Virginia","Washington","West Virginia","Wisconsin","Wyoming","Armed Forces Africa","Armed Forces Americas","Armed Forces Canada","Armed Forces Europe","Armed Forces Middle East","Armed Forces Pacific");
  var usvalues = new Array("","AL","AK","AS","AZ","AR","CA","CO","CT","DE","DC","FM","FL","GA","GU","HI","ID","IL","IN","IA","KS","KY","LA","ME","MH","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PW","PA","PR","RI","SC","SD","TN","TX","UT","VT","VI","VA","WA","WV","WI","WY","AE","AA","AE","AE","AE","AP");

  var catext   = new Array("-- select state --","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Nova Scotia","Northwest Territories","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
  var cavalues = new Array("","AB","BC","MB","NB","NF","NS","NT","NU","ON","PE","QC","SK","YT");

  document.regform.state1.options.length = 0;
  
  if (document.regform.country.options[document.regform.country.selectedIndex].value == "CA" )
  {
    document.getElementById('state1').style.display='inline';
    document.regform.state1.options.length = cavalues.length;
    for (var m = 0; m < cavalues.length; m++) 
    {  
     document.regform.state1.options[m].value = cavalues[m];
     document.regform.state1.options[m].text = catext[m];  
    }
  }
  else if (document.regform.country.options[document.regform.country.selectedIndex].value == "US" )
  {
	document.getElementById('state1').style.display='inline';
    document.regform.state1.options.length = usvalues.length;
    for (var m = 0; m < usvalues.length; m++) 
    {
     document.regform.state1.options[m].value = usvalues[m];
     document.regform.state1.options[m].text = ustext[m];  
    }
  } 
  else
  {
  	document.getElementById('state1').style.display='none';
  }
}
 

function setBillingStates()
{

  var ustext   = new Array("-- Select State --","Alabama","Alaska","American Samoa","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Federated States of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virgin Islands","Virginia","Washington","West Virginia","Wisconsin","Wyoming"); 
  var usvalues = new Array("","AL","AK","AS","AZ","AR","CA","CO","CT","DE","DC","FM","FL","GA","GU","HI","ID","IL","IN","IA","KS","KY","LA","ME","MH","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PW","PA","PR","RI","SC","SD","TN","TX","UT","VT","VI","VA","WA","WV","WI","WY");

  var catext   = new Array("-- Select Province --","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Nova Scotia","Northwest Territories","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
  var cavalues = new Array("","AB","BC","MB","NB","NF","NS","NT","NU","ON","PE","QC","SK","YT");
	
  document.regform.billing_state.options.length = 0;
  
  if (document.regform.billing_country.options[document.regform.billing_country.selectedIndex].value == "CA" )
  {

	document.regform.billing_state.options.length = cavalues.length;
    for (var m = 0; m < cavalues.length; m++) 
    {  
     document.regform.billing_state.options[m].value = cavalues[m];
     document.regform.billing_state.options[m].text = catext[m];  
    }
  }
  
  if (document.regform.billing_country.options[document.regform.billing_country.selectedIndex].value == "US" )
  {
    document.regform.billing_state.options.length = usvalues.length;
    for (var m = 0; m < usvalues.length; m++) 
    {
     document.regform.billing_state.options[m].value = usvalues[m];
     document.regform.billing_state.options[m].text = ustext[m];  
    }
  }
}

