function GetCity(ProvinceID) {

    document.body.style.cursor='wait';

    var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
    var sURL = "GetCity.asp?ProvinceID=" + ProvinceID;
    oXMLHTTP.open( "POST", sURL, false );
    oXMLHTTP.send();
   
    if (oXMLHTTP.responseText == "-")
    {  
       document.getElementById("cmbCity").value='';
       document.getElementById("cmbCity").label='';
	}
	else
	{
        var myString = oXMLHTTP.responseText;
        var mySplitResult = myString.split(",");
		var myBranch = document.getElementById("cmbBranch");
		var myBranchLength = myBranch.length
		for (iBranch = 0; iBranch <= myBranchLength; iBranch++)
			myBranch.remove(0);

		var myCity = document.getElementById("cmbCity");
		var myCityLength = myCity.length
		for (iCity = 0; iCity <= myCityLength; iCity++)
			myCity.remove(0);
		
		for (idx = 0; idx <= (mySplitResult.length) - 2; idx++)
		{
			var myOption = document.createElement('option');
			if (idx == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if (idx % 2 == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if ((idx == 0) || (idx % 2 == 0))
			try
			{
				myCity.add(myOption, null);
			}
			catch(ex)
			{
				myCity.add(myOption);
			}			
		}
    }

	document.body.style.cursor='auto';
}

function GetBranch(CityID) {
  
    document.body.style.cursor='wait';

    var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
    var sURL = "GetBranch.asp?ProvinceID=" + document.getElementById("cmbProvince").value + "&CityID=" + CityID;
    oXMLHTTP.open( "POST", sURL, false );
    oXMLHTTP.send();
   
    if (oXMLHTTP.responseText == "-")
    {  
       document.getElementById("cmbBranch").value='';
       document.getElementById("cmbBranch").label='';
	}
	else
	{
        var myString = oXMLHTTP.responseText;
        var mySplitResult = myString.split(",");

		var myBranch = document.getElementById("cmbBranch");
		var myBranchLength = myBranch.length
		for (iBranch = 0; iBranch <= myBranchLength; iBranch++)
			myBranch.remove(0);
		
		for (idx = 0; idx <= (mySplitResult.length) - 2; idx++)
		{
			var myOption = document.createElement('option');
			if (idx == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if (idx % 2 == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if ((idx == 0) || (idx % 2 == 0))
			try
			{
				myBranch.add(myOption, null);
			}
			catch(ex)
			{
				myBranch.add(myOption);
			}			
		}
    }

	document.body.style.cursor='auto';
}

function GetCityBirth(ProvinceID) {
  
    document.body.style.cursor='wait';

    var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
    var sURL = "GetCity.asp?ProvinceID=" + ProvinceID;
    oXMLHTTP.open( "POST", sURL, false );
    oXMLHTTP.send();
   
    if (oXMLHTTP.responseText == "-")
    {  
       document.getElementById("cmbCityBirth").value='';
       document.getElementById("cmbCityBirth").label='';
	}
	else
	{
        var myString = oXMLHTTP.responseText;
        var mySplitResult = myString.split(",");

		var myCity = document.getElementById("cmbCityBirth");
		var myCityLength = myCity.length
		for (iCity = 0; iCity <= myCityLength; iCity++)
			myCity.remove(0);
		
		for (idx = 0; idx <= (mySplitResult.length) - 2; idx++)
		{
			var myOption = document.createElement('option');
			if (idx == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if (idx % 2 == 0)
			{
				myOption.value = mySplitResult[idx];
				myOption.text = unescape(mySplitResult[idx + 1]);
			}
			if ((idx == 0) || (idx % 2 == 0))
			try
			{
				myCity.add(myOption, null);
			}
			catch(ex)
			{
				myCity.add(myOption);
			}			
		}
    }

	document.body.style.cursor='auto';
}
function ValidateNationalCode(nationalcode)
{
	if
	(
		(nationalcode == null) ||
		(nationalcode.length < 10) ||
		(nationalcode == '0000000000') ||
		(nationalcode == '1111111111') || 
		(nationalcode == '2222222222') ||
		(nationalcode == '3333333333') ||
		(nationalcode == '4444444444') ||
		(nationalcode == '5555555555') ||
		(nationalcode == '6666666666') ||
		(nationalcode == '7777777777') ||
		(nationalcode == '8888888888') ||
		(nationalcode == '9999999999')
	)
	return false;
	
	var N, R, C;
	C = parseInt(nationalcode.substr(9, 1));
	N = parseInt(nationalcode.substr(0, 1)) * 10 +
		parseInt(nationalcode.substr(1, 1)) *  9 +
		parseInt(nationalcode.substr(2, 1)) *  8 +
		parseInt(nationalcode.substr(3, 1)) *  7 +
		parseInt(nationalcode.substr(4, 1)) *  6 +
		parseInt(nationalcode.substr(5, 1)) *  5 +
		parseInt(nationalcode.substr(6, 1)) *  4 +
		parseInt(nationalcode.substr(7, 1)) *  3 +
		parseInt(nationalcode.substr(8, 1)) *  2;
	R = N - parseInt(N / 11) * 11;
	if ((R == 0 && R == C) || (R == 1 && C == 1) || (R > 1 && C == 11 - R)) return true;
	else return false;
}
