var spellUrl = 'SELF'; // URL to spell_checker.php
var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf("msie") != -1);
var is_ie5 = (agt.indexOf("msie 5") != -1);

function checkUserAvailability_cb(new_data)
{
	document.getElementById("info").innerHTML = new_data;
}

function checkUserAvailability()
{
	var query;
	query = document.frmSignup.txtUserName.value;
	cpaint_call(spellUrl, 'POST', 'checkUserAvailability', query, checkUserAvailability_cb);
	return false;
}

function calculateUserTime_cb(new_data)
{
	document.getElementById("info").innerHTML = new_data;
}

function calculateUserTime()
{
	var query;
	var doc = document.conf;
	query = doc.month.value + '##' + doc.day.value + '##' + doc.year.value + '##' + doc.hour.value + '##' + doc.minute.value + '##' + doc.ap.value + '##' + doc.timezone.value;
	cpaint_call(spellUrl, 'POST', 'calculateUserTime', query, calculateUserTime_cb);
	//return false;
}

function getCities_cb(new_data)
{
	//alert(new_data);
	document.getElementById("cities").innerHTML = "";
	document.getElementById("cities").innerHTML = new_data;
}

function getCities(city)
{
	var country;
	country = document.frmSignup.cmbCountry.value;
	// alert (country)
	if(country == "USA" || country == "Canada")
	{
		if(country == "USA")
		{
			document.frmSignup.currency.selectedIndex = 0;
			//document.frmSignup.timezone.selectedIndex = 3;		
			//document.frmSignup.currency.value = "USD";
		}
		else if(country == "Canada")
		{
			document.frmSignup.currency.selectedIndex = 2;
			//document.frmSignup.timezone.selectedIndex = 3;
		}
		if(is_ie || is_ie5)	
		{
			document.all.divCities.style.display = "none";
			document.all.zipCode.style.display="block";
		}
		else
		{
			
			// DataTR.style.visibility='hidden';
			document.getElementById("zipCode").style.visibility='visible';
			document.getElementById("zipCode").style.position='relative';

			document.getElementById("divCities").style.visibility='hidden';
			document.getElementById("divCities").style.position='absolute';
			
		}
	}
	else
	{
		document.frmSignup.currency.selectedIndex = 1;		
		if(is_ie || is_ie5)	
		{
			document.all.zipCode.style.display = "none";
			document.all.divCities.style.display="block";
			
		}
		else
		{
			// hiding zip code in case of united kingdom
			document.getElementById("zipCode").style.visibility='hidden';
			document.getElementById("zipCode").style.position='absolute';
			// showing cities in case of UK
			document.getElementById("divCities").style.visibility='visible';
			document.getElementById("divCities").style.position='relative';
		}
		if(country == "UK")
		{
			document.frmSignup.timezone.selectedIndex = 10;				
		}
		else
		{
			//document.frmSignup.timezone.selectedIndex = 11;
		}
		country = document.frmSignup.cmbCountry.value + '::' + city;
		cpaint_call(spellUrl, 'POST', 'getCities', country, getCities_cb);
		return false;
	}
}