/* Alert for TBM Languages */
function language_unavailable(){
	alert('This language is not yet available');
	return false;
}



/* Home page rotator */
	var timerset = (1000 * 6.5);
	var rotator = '';
	Event.observe(window, 'load', function() {
		initiate_mouseovers(1);initiate_mouseovers(2);initiate_mouseovers(3);initiate_mouseovers(4);initiate_mouseovers(5);
		//rotator = setInterval ( "loop_rotate()", timerset );
	});
	
//	function loop_rotate(){
//		if($$('#ban-nav .current')){
//			$$('#ban-nav .current').each(function(a){
//				if($(a).next(0)){
//					$(a).next(0).addClassName('current');
//					var newstyle = $(a).next(0).identify();
//				} else {
//					$(a).up().firstDescendant().addClassName('current');
//					var newstyle = $(a).up().firstDescendant().identify();
//				}
//				$(a).removeClassName('current');
//				$('banner-home').className = '';
//				$('banner-home').addClassName('style-'+newstyle);
//			});
//		} else {
//			$('ban-nav').firstDescendant().addClassName('current');
//		}
//	}
//	
	function initiate_mouseovers(id){

		Event.observe($('ban-nav-0'+id), 'mouseover', function() {
			rotator = window.clearInterval(rotator);
			$$('#ban-nav .current').each(function(s){
				$(s).removeClassName('current');
			});
			$('ban-nav-0'+id).addClassName('current');
			$('banner-home').className = '';
			$('banner-home').addClassName('style-ban-nav-0'+id);
			
		});
		Event.observe($('ban-nav-0'+id), 'mouseout', function() {
			//rotator = setInterval ( "loop_rotate()", timerset );
		});
	}
/* end home page rotator */


Event.observe(window, 'load', function() {
	$$('form.formonfly').each(function(a){
									   
		new Validation(a.identify(),{stopOnFirst:false, useTitles:true});
		Validation.addAllThese([
			['validate-phone-us', 'Please enter a valid US Phone Number. (xxx)xxx-xxxx', function(v,elm) {
				var regex = /^(\()?(\d{3})([\)-\. ])?(\d{3})([-\. ])?(\d{4})$/;
				return Validation.get('IsEmpty').test(v) || regex.test(v);
			}],
			['validate-us-ca-postal', 'Please enter a valid US zip code or Canadian postal code.', function(v,elm) {
				v = v.toUpperCase();
				var regex = /((^\d{5}([- |]\d{4})?$)|(^[A-Z]\d[A-Z][- |]\d[A-Z]\d$))/;
				if(Validation.get('IsEmpty').test(v) ||  regex.test(v)){
					$(elm).value = v;
					return true;
				}
				return false;
			}],
			['validate-us-ca-postal', 'Please enter a valid US zip code or Canadian postal code.', function(v,elm) {
				v = v.toUpperCase();
				var regex = /((^\d{5}([- |]\d{4})?$)|(^[A-Z]\d[A-Z][- |]\d[A-Z]\d$))/;
				if(Validation.get('IsEmpty').test(v) ||  regex.test(v)){
					$(elm).value = v;
					return true;
				}
				return false;
			}],
			['validate-alphanumsp', 'Please use only letters (a-z), numbers (0-9), spaces and simple punctuation (.!?,-()$#%@) only in this field. No other characters are allowed.', function(v) {
				var regex = /^[a-zA-Z0-9,-@ \&#\%\$\(\)\.\!\?]+$/;
				return Validation.get('IsEmpty').test(v) ||  regex.test(v);
			}],
			['validate-numbersp', 'Please use only numbers (0-9), spaces and simple punctuation (.!?,-()$#%@) only in this field. No letters or other characters are allowed.', function(v) {
				var regex = /^[0-9,-@ \&#\%\$\(\)\.\!\?]+$/;
				return Validation.get('IsEmpty').test(v) ||  regex.test(v);
			}],
			['validate-alphasp', 'Please use only letters (a-z), spaces and simple punctuation (.!?,-()$#%@) only in this field. No numbers or other characters are allowed.', function(v) {
				var regex = /^[a-zA-Z,-@ \&#\%\$\(\)\.\!\?]+$/;
				return Validation.get('IsEmpty').test(v) ||  regex.test(v);
			}],
			['validate-spchar', 'Please spaces and simple punctuation (.!?,-()$#%@) only in this field. No numbers, letters or other characters are allowed.', function(v) {
				var regex = /^[,-@ \&#\%\$\(\)\.\!\?]+$/;
				return Validation.get('IsEmpty').test(v) ||  regex.test(v);
			}]
		]);
	 });
});


var state = 'none';

function showhide(layer_ref) {

if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}

