	function nav_overs(elem)
	{
		var pnav = document.getElementById(elem);

		var nav_items = pnav.getElementsByTagName('li');
		for(i=0;i<nav_items.length;i++){
			//dont try to make rollovers for images with no_rollover class
			if(nav_items[i].className != 'act' && nav_items[i].className != 'actpg'){
				nav_items[i].onmouseover=function(){this.className = 'act';}
				nav_items[i].onmouseout=function(){this.className = '';}
			}

		}



	}
	//function to show/hide top 10 FAQs
	function toggleFaq(elem){
		$j("#"+elem).slideToggle("normal", function(){
			var currstate = $j("#"+elem).css("display");
			if(currstate == 'block'){ $j("#"+elem+"_toggle").text('hide answer');}else{$j("#"+elem+"_toggle").text('view answer');}
		});

	}

	//age check
	function twoDigits(dig){
		var str = dig.toString();
		var digit = (str.length == 2) ? str : '0'+str;
		return digit;
	}


	function realMonth(mm){
		var realmonth = (mm < 12) ? mm + 1 : mm = 1;
		return realmonth;
	}

	// returns true if the string is a US phone number formatted as...
	// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
	function isPhoneNumber(str){
		var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
		return re.test(str);
	}

	// returns true if the string only contains characters A-Z, a-z or 0-9 or . or #
	function isAddress(str){
		var re = /[^a-zA-Z0-9\#\.]/g
		if (re.test(str)) return true;
		return false;
	}

	// returns true if the string is 5 digits
	function isZip(str){
		var re = /\d{5,}/;
		if(re.test(str)) return true;
		return false;
	}

// returns true if the string only contains characters A-Z or a-z
function noSpaces(str){
	var re = /[' ']/g
	if (re.test(str)) return false;
	return true;
}


// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
	var re = /[^a-zA-Z-\s]/g
	if (re.test(str)) return false;
	return true;
}

// returns true if the string only contains characters A-Z or a-z or 0-9
function isAlphaNumeric(str){
	var re = /[^a-zA-Z0-9]/g
	if (re.test(str)) return false;
	return true;
}

// returns true if the string only contains characters 0-9
function isNumeric(str){
	var re = /[^0-9]/g
	if (re.test(str)) return false;
	return true;
}

function isEmpty(str){
	if(str == null || str.length == 0){
		return true;
	}else{
		return false;
	}
}

function isEmail(str){
if(str == '') return false;
var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
return re.test(str);
}

function stripWhitespace(str, replacement){
	if (replacement == null) replacement = '';
	var result = str;
	var re = /\s/g
	if(str.search(re) != -1){
		result = str.replace(re, replacement);
	}
	return result;
}

//function to remove error class on focus
function tryAgain(id){
	$j(id).removeClass('errors');
	var ttl = $j(id).attr('title');
	var vlu = $j(id).val();
	if(ttl == vlu){$j(id).val('');}
}

//function to replace field values if blank
function fieldNames(id){
	var ttl = $j(id).attr('title');
	var vlu = $j(id).val();
	if($j(id).val() == '') {$j(id).val(ttl) }
}

//function for coloring the fields with errors
function hasErrors(fieldID, err){
	if(err){
		$j(fieldID).addClass('errors');
	}else{
		$j(fieldID).removeClass('errors');
	}
}

//function for coloring text with errors
function hasErrorsText(fieldID, err){
	if(err){
		$j(fieldID).addClass('errortext');
	}else{
		$j(fieldID).removeClass('errortext');
	}
}


		function validateForm(){

    			var this_form = document.registernow;
    			var err_count = 0;

    			var fn = $j("#firstname").val();
    			var ln = $j("#lastname").val();
    			var em = $j("#email").val();


    			if(isEmpty(fn) || fn == 'First Name'){
    				err_count++;

    				hasErrors('#firstname', true);
    			}

    			if(isEmpty(ln) || ln == 'Last Name'){
    				err_count++;

    				hasErrors('#lastname', true);
    			}

    			if(isEmpty(em) || !isEmail(em)){
                    // err_count++;
    				hasErrors('#email', true);
    			}

    			if(err_count == 0){
    				return true;
    			}else{
    				return false;
    			}
		}

		function validateJoinForm(){
			var this_form = document.join;
			var err_count = 0;

			var fn = $j("#fname").val();
			var ln = $j("#lname").val();
			var em = $j("#emailad").val();
			var ph = $j("#phone").val();
			var ad = $j("#address").val();
			var ci = $j("#city").val();
			var st = $j("#state").val();
			var zp = $j("#zip").val();


			if(isEmpty(fn)){
				err_count++;
				hasErrors('#fname', true);
			}

			if(isEmpty(ln)){
				err_count++;
				hasErrors('#lname', true);
			}

			if(isEmpty(em) || !isEmail(em)){
				err_count++;
				hasErrors('#emailad', true);
			}

			if(isEmpty(ph) || !isPhoneNumber(ph)){
				err_count++;
				hasErrors('#phone', true);
			}

			if(isEmpty(ad) || !isAddress(ad)){
				err_count++;
				hasErrors('#address', true);
			}

			if(isEmpty(ci)){
				err_count++;
				hasErrors('#city', true);
			}

			if(isEmpty(st)){
				err_count++;
				hasErrors('#state', true);
			}

			if(isEmpty(zp) || !isZip(zp)){
				err_count++;
				hasErrors('#zip', true);
			}


			if (!$j("#optin").attr("checked")){
				hasErrorsText('#optintext', true);
			}

			if(err_count == 0){
				return true;
			}else{
				return false;
			}

		}


timer = null;

function fadeInOpts(id){
	if(timer) clearTimeout(timer);
	$j('.subnav').not(id+'subnav').fadeOut('fast');
	$j('.jump').not(id).removeClass('over');
	$j(id+'subnav').fadeIn(0);
	$j(id).addClass('act');
}

function fadeOutOpts(id){
	timer = setTimeout("doFade('"+id+"')",100);
}

function doFade(id){
	$j(id+'subnav').hide();
	$j(id).removeClass('act');
}


$(document).ready(function(){
	nav_overs('nav');
	$j('.jump').hover(function(){ fadeInOpts('#'+this.id); },function (){ fadeOutOpts('#'+this.id); });
	$j('.subnav li').hover(function(){ $j(this).addClass('act'); },function (){ $j(this).removeClass('act'); });
});
