// Country auto select arrays
var states = new Array();
var none = new Array();
var can = new Array();

none['Outside of US and Canada']=1;
states['Alabama']=1;
states['Alaska']=1;
can['Alberta']=1;
states['American Samoa']=1;
states['Arizona']=1;
states['Arkansas']=1;
states['Armed Forces Americas']=1;
states['Armed Forces Europe']=1;
states['Armed Forces Pacific']=1;
can['British Columbia']=1;
states['California']=1;
states['Colorado']=1;
states['Connecticut']=1;
states['Delaware']=1;
states['District of Columbia']=1;
states['Florida']=1;
states['Georgia']=1;
states['Guam']=1;
states['Hawaii']=1;
states['Idaho']=1;
states['Illinois']=1;
states['Indiana']=1;
states['Iowa']=1;
states['Kansas']=1;
states['Kentucky']=1;
states['Louisiana']=1;
states['Maine']=1;
can['Manitoba']=1;
states['Maryland']=1;
states['Massachusetts']=1;
states['Michigan']=1;
states['Minnesota']=1;
states['Mississippi']=1;
states['Missouri']=1;
states['Montana']=1;
states['Nebraska']=1;
states['Nevada']=1;
can['New Brunswick']=1;
states['New Hampshire']=1;
states['New Jersey']=1;
states['New Mexico']=1;
states['New York']=1;
can['Newfoundland']=1;
states['North Carolina']=1;
states['North Dakota']=1;
states['Northern Mariana Is']=1;
can['Northwest Territories']=1;
can['Nova Scotia']=1;
states['Ohio']=1;
states['Oklahoma']=1;
can['Ontario']=1;
states['Oregon']=1;
states['Palau']=1;
states['Pennsylvania']=1;
can['Prince Edward Island']=1;
can['Province du Quebec']=1;
states['Puerto Rico']=1;
states['Rhode Island']=1;
can['Saskatchewan']=1;
states['South Carolina']=1;
states['South Dakota']=1;
states['Tennessee']=1;
states['Texas']=1;
states['Utah']=1;
states['Vermont']=1;
states['Virgin Islands']=1;
states['Virginia']=1;
states['Washington']=1;
states['West Virginia']=1;
states['Wisconsin']=1;
states['Wyoming']=1;
can['Yukon Territory']=1;



// country auto select function
function csc(type)
{
	var selectbox = document.getElementById(type);
    var selection = selectbox.value;
	//is this an IE browser
	var notIE = (window.ActiveXObject) ? false : true;
	
    //If type == 'state', look up the state value and snap the correct country value in place.
    if(type == 'frmState')
    {	
		var c = document.getElementById('frmCountry');	
		if(states[selection])
		{
			c.value = 'United States';	
			if (notIE){
				for(var i=0;i<c.options.length;i++){
			 	if(c.options[i].value != 'United States')
					c.options[i].disabled=true;
				 else
			 		c.options[i].disabled = false;
				}
			}
		}
		else if(can[selection])
		{
			c.value = 'Canada';
			if (notIE){
				for(var i=0;i<c.options.length;i++){
			 	if(c.options[i].value != 'Canada')
					c.options[i].disabled=true;
			 	else
			 		c.options[i].disabled = false;
				}
			}
		}
		else
		{
			if (notIE){
				for(var i=0;i<c.options.length;i++)
					c.options[i].disabled=false;
			}
		}
		
		if(selectbox.options[0].label == "default")
			selectbox.remove(0);
    }
	else if(type == 'frmCountry') 
    {
		var s = document.getElementById('frmState');
	    //Clear existing options
    	if (notIE)
		{
			s.options.length = 0;
	    	s.options[0] = new Option("... Please select ...","... Please select ...");
			s.options[1] = new Option("Outside of US and Canada","Outside of US and Canada");
		
			if(selection == "United States")
			{
			var state;
			var i=2;
			for(state in states)
				s.options[i++] = new Option(state,state);	
			}

			else if(selection == "Canada")
			{
			var province;
			var i=2;
			for(province in can)
				s.options[i++] = new Option(province,province);	
			}
		
			// select the fist state/province for US or Canada		
			if(s.options.length > 2)
			{
	        	s.value = s.options[2].value;
			}
			else
			{
				s.value = s.options[1].value;
			}		
				
				
			 
		}else{
			// if IE select Outside of US and Canada
			if((selection != "United States") && (selection != "Canada")){
				var c = document.getElementById('frmState');
				c.value = 'Outside of US and Canada';	
			}	
		}
    }
}

/*
else{
			
*/
