function changeCountry(selCountry,selProvince)
{
	
   if(!iCountry)
      fillVars();

	if(!selCountry && iCountry.selectedIndex == 0)
		return;

   for(var i=1,n=iCountry.options.length; i<n;i++)
   {
      if(iCountry.options[i].value==selCountry)
      {
         iCountry.options.selectedIndex=i;
         break;
      }
   }

//   iCountry.selectedIndex = 1;

	iProvince.options.length=1;

	var req = getRequestObj();

	if(!selCountry)
		selCountry=iCountry.value;

   req.open('GET', path+'province-get.php?id='+selCountry, true);

	req.onreadystatechange = function()
	{
		if((req.readyState == 4) && (req.status == 200))
		{
			var items=eval( 'new Array('+req.responseText+')' );
			var o;
			for(var n=0; n<items.length; n+=2)
			{
				o = new Option( items[n+1] );
				o.value = items[n];
				iProvince.options[(n/2)+1] = o;
				if(selProvince && o.value == selProvince)
					iProvince.options.selectedIndex = (n/2)+1;
			}
		}
	}
	req.send(null);
}

function changeProvince(selProvince,selCity)
{
	if(!selProvince && iProvince.selectedIndex == 0)
		return;

	iCity.options.length=1;

	var req = getRequestObj();

	if(!selProvince)
		selProvince=iProvince.value;

	req.open('GET', path+'city-get.php?id='+selProvince, true);

	req.onreadystatechange = function()
	{
		if((req.readyState == 4) && (req.status == 200))
		{
			var items=eval( 'new Array('+req.responseText+')' );
			var o;
			for(var n=0; n<items.length; n+=2)
			{
				o = new Option( items[n+1] );
				o.value = items[n];
				iCity.options[(n/2)+1] = o;
				if(selCity && o.value == selCity)
					iCity.options.selectedIndex = (n/2)+1;
			}
		}
	}
	req.send(null);
}

function fillVars()
{
	iCountry=findObj('iCountry');
	dProvince=findObj('dProvince');
	iProvince=findObj('iProvince');
	dCity=findObj('dCity');
	iCity=findObj('iCity');
}

var iCountry, dProvince, iProvince, dCity, iCity, path='../';


function $m(id) {
	return document.getElementById(id);
}
function clrJSSearchOption(form_obj) {
	
	var i =0;
	
	var cbox_obj = form_obj.getElementsByTagName('input');//	get html input control
	var slt_obj = form_obj.getElementsByTagName('select');//	get html select control
	
	for(i=0; i<cbox_obj.length; i++) {
		
		if(cbox_obj[i].type == "checkbox")
			cbox_obj[i].checked = false;
		else if(cbox_obj[i].type == "text")			
			cbox_obj[i].value = "";
	}//	end for
	
	for(i=0; i<slt_obj.length; i++) {
		
		slt_obj[i].selectedIndex = 0;
		
		if(slt_obj[i].name == 'province' || slt_obj[i].name == 'city')
				slt_obj[i].length = 1;
	}//	end for
	
	
}