function change_country(domain) {

   var ctrl_name = document.forms['form1'].elements['hid_ucl_enquiry_name'].value;
	 var dd = document.forms['form1'].elements[ctrl_name + '$dd_country'];
	 var dd_state = document.forms['form1'].elements[ctrl_name + '$dd_state'];
	 var phone = document.getElementById(ctrl_name + '_lbl_telephone');
	 var cell = document.getElementById(ctrl_name + '_lbl_cell_phone');
	 var fax = document.getElementById(ctrl_name + '_lbl_fax');
	 var txt_phone = document.getElementById(ctrl_name + '_txt_telephone');
	 var txt_cell = document.getElementById(ctrl_name + '_txt_cell_phone');
	 var txt_fax = document.getElementById(ctrl_name + '_txt_fax');	 	 	  
   var url_states = domain + 'countries/states-' + dd.options[dd.selectedIndex].value + '.html';
	 var url_dialingcode = domain + 'countries/dialingcode-' + dd.options[dd.selectedIndex].value + '.html';
	 
	 // fills state dd
   Http.get(
      {url: url_states, callback: fill_states, cache: Http.Cache.Get}, 
	    [dd_state, phone, cell, fax, txt_phone, txt_cell, txt_fax]);
			
}





function fill_states(xml, dd, phone, cell, fax, txt_phone, txt_cell, txt_fax) {

   if (xml.status == Http.Status.OK)
   {
      var resp = xml.responseText;
      var arr = resp.split("|");
			var max_textbox_size = 272;
			var prefix_margin = 0;
			var textbox_size;
			
      dd.length = 1;
      dd.length = arr.length;
   
	    // the country has states
	    for (o=0; o < arr.length; o++)
      {
			   
			   var arr_element = arr[o].split(":");
			   var code = arr_element[0];				 
			   var descr = arr_element[1];
				 var dial = arr_element[2];
				 
				 // dial code
				 if (dial)
				 {
				    if (dial.length > 0)
				    {
				       dial = dial + '&nbsp;'
				    }
				 }
				 
				 // states
         dd.options[o + 1]=new Option(descr, code);
				 
				 // dialing codes
				 if (o == 2)
				 {
				    if (phone)
						{
               phone.innerHTML = dial;
							 textbox_size = max_textbox_size - prefix_margin - phone.offsetWidth;
							 txt_phone.style.width = textbox_size + 'px';
						}
				    if (cell)
						{						
			         cell.innerHTML = dial;
							 textbox_size = max_textbox_size - prefix_margin - cell.offsetWidth;
							 txt_cell.style.width = textbox_size + 'px';							 							 
						}
				    if (fax)
						{
			         fax.innerHTML = dial;
							 textbox_size = max_textbox_size - prefix_margin - fax.offsetWidth;
							 txt_fax.style.width = textbox_size + 'px';							 
						}	
				 }
				 				 
      }
			
 		  // the country doesn't have states
			if (o == 1)
			{
			   var dial = resp;
				 
				 // dial code
				 if (dial.length > 0)
				 {
				    dial = dial + '&nbsp;'
				 }				 

				 // dialing codes
				 if (phone)
				 {
            phone.innerHTML = dial;
					  textbox_size = max_textbox_size - prefix_margin - phone.offsetWidth;
					  txt_phone.style.width = textbox_size + 'px';
				 }
				 if (cell)
				 {						
            cell.innerHTML = dial;
						textbox_size = max_textbox_size - prefix_margin - cell.offsetWidth;
						txt_cell.style.width = textbox_size + 'px';			
				 }
				 if (fax)
				 {
			      fax.innerHTML = dial;
						textbox_size = max_textbox_size - prefix_margin - fax.offsetWidth;
						txt_fax.style.width = textbox_size + 'px';
				 }
			}
			
   }
	 
   dd_state_show();	 
	
}





function dd_state_show() {
   
   var ctrl_name = document.forms['form1'].elements['hid_ucl_enquiry_name'].value;
   var dd = document.forms['form1'].elements[ctrl_name + '$dd_state'];
   var txt = document.forms['form1'].elements[ctrl_name + '$txt_state'];
	 
	 // class
	 if (dd.length > 2)
	 {
			txt.className = 'txt_state_hidden'	 
	    dd.className = 'dd_state_visible'
	 }
	 else
	 {
	    dd.className = 'dd_state_hidden'
			txt.className = 'txt_state_visible'
	 }	  
	 
	 // value
   dd.selectedIndex = 0;
	 txt.value = '';	 
	 
}