//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function frmsubmit(obForm) {

	var reEmail 	= /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/;		

	with(obForm){
		

		if ( !validatefield( AreaOfInterest,  			AreaOfInterest.value.length == '', 			'Area Of Interest') 			) return false;
		
		if ( !validatefield( first_name,  				first_name.value.length == '', 				'First Name') 					) return false;
		if ( !validatefield( last_name,  				last_name.value.length == '', 				'Last Name') 					) return false;
		
		
		if ( !validatefield( company,  					company.value.length == '', 				'Company') 						) return false;
				
		if ( !validatefield( email,  					email.value.match(reEmail) == null, 		'Contact email') 				) return false;
		
		if ( usstate.disabled ){
				//if ( !validatefield( otherstate,  	otherstate.value.length == '', 				'State/Province') 				) return false;
		} else if ( otherstate.disabled ) {
				if ( !validatefield( usstate,  			usstate.value.length == '', 				'State/Province') 				) return false;
		}
		
		if ( !validatefield( country,  					country.value.length == '', 				'Country') 						) return false;
		
		if ( !validatefield( description,  				description.value.length == '', 			'Questions/Comment') 			) return false;
		
		
//		if ( !validatefield( example,  					example.value.length == '', 				'example') 						) return false;
		
													
	}

	return true;
	
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validatefield( obField, evField, stMsg ){
	if ( evField ){
		obField.setAttribute('autocomplete','off');
		obField.focus();
		alert('Error: ' + stMsg);
		return false;
	} else {
		return true;
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function updateSelect(stSelId,inSelVal){
	var obSel = document.getElementById(stSelId);
	for (var i=0; i<obSel.options.length;  i++ ){
		if (obSel.options[i].value == inSelVal){	
			obSel.options[i].selected = true;
		}
	}	
	obSel.onchange();	
}			

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function countryselect(){
	var country = document.getElementById('Country').options[document.getElementById('Country').selectedIndex].text;
	if(country == 'US'){
		showtab('divusstate');
		document.getElementById('usstate').disabled = '';
		document.getElementById('otherstate').disabled = 'disabled';
	} else{
		showtab('divotherstate');
		document.getElementById('otherstate').disabled = '';
		document.getElementById('usstate').disabled = 'disabled';	
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function showtab( tabname ) {
	
		var obTab 	= document.getElementById(tabname);
		var obUS	= document.getElementById('divusstate')
		var obOther = document.getElementById('divotherstate')
		
		obUS.style.display = 'none';
		obOther.style.display = 'none';
	
		obTab.style.display = '';
}