// JavaScript Document

var detect = navigator.userAgent.toLowerCase();
var slct, isIE,isFFX, isChrome;

function set_url(s)
{
var a_url = document.getElementById('a_url');
if(typeof state != 'undefined' && state != '')
{
   var state_url = state_websites[state];
   if(typeof state_url != 'undefined' &&  state_url != '')
      s = state_url;
}
a_url.innerHTML = s;
a_url.href = 'http://'+s;

}

function checkIt(string)
{
	return detect.indexOf(string) + 1;
}

isFFX = checkIt('firefox');
isIE = checkIt('msie');
isChrome = checkIt('chrome');

function option_add(s)
{
	slct.options.add(new Option(s));
}

function end_populate()
{
	slct.options[0] = new Option('Please Select');
	slct.selectedIndex=0;
}

function poplt()
{
var countryId = document.getElementById('country').value;
var state = document.getElementById('state').value;
if(countryId == 182)
{
  document.getElementById('stateRow').style.display='';
}
else
{
document.getElementById('stateRow').style.display='none';
state='';
}


if(state=='All' || state=='Please Select')
   state='';



	slct = document.getElementById('city');
	var k = slct.length;
	//remove all cities in the list
	for(i=0; i<=k; i++)
	{
		slct.remove(0);
	}


var a_url = document.getElementById('a_url');
a_url.innerHTML = '';
a_url.href = '';

	slct.options.add(new Option('Loading...'));
	slct.options.add(new Option('All'));
	if(!(isFFX || isIE || isChrome))
	{
		document.addressForm.submit()
	}
	
	if(isIE || !document.getElementById('populate').src)
	{
		document.getElementById('populate').src='citiess.js?country='+countryId + '&state=' + state;
	}
	else if(!document.getElementById('populate1').src)
	{
		document.getElementById('populate1').src='citiess.js?country='+countryId + '&state=' + state;
	}
	else if(!document.getElementById('populate2').src)
	{
		document.getElementById('populate2').src='citiess.js?country='+countryId + '&state=' + state;
	}
	else if(!document.getElementById('populate3').src)
	{
		document.getElementById('populate3').src='citiess.js?country='+countryId + '&state=' + state;
	}
	else
	{
		document.addressForm.submit()
	}
}
			