// NuRide_3_2_20.js 
//
// This is a set of functions shared for the NuRide site
//

function submitSurveyUserInput()
{
	var user_input=1;
	for (i=0;i<document.forms['sponsorshipsurveyform'].options.length;i++) {
		if (document.forms['sponsorshipsurveyform'].options[i].checked) {
			user_input = document.forms['sponsorshipsurveyform'].options[i].value;
			break;
		}
	}
	return user_input;
}

function MM_callJS(jsStr) {
	return eval(jsStr)
}

function MM_openBrWindow(theURL,winName,features) {
	var w = window.open(theURL, winName, features);
	if(w==null)
		alert('NuRide is trying to open a pop-up window so you can continue.  Please select the option above and allow pop-ups for this site.');
	else
		w.focus();
	return w;
}

function MM_goToURL() {
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function handleSubmit(field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		submitForm();
		return false;
	}
	return true;
}

var validnuridernamemsg = "Please enter a valid NuRider name. A valid name is 6-16 characters in length and only contains the following characters: A to Z, 0 to 9, dot, hyphen, underscore.";
function checkRiderName(fld) {
	var v = fld.value;
	if (isWhitespace(v)) {
		return warnInvalid(fld, validnuridernamemsg);
	}
	if (hasCharsInBag(v, '" !@#$%^&*()=;:<>/?|\'\\')) {
		return warnInvalid(fld, validnuridernamemsg);
	}
	if (checkLengthBogus(fld, 6, validnuridernamemsg) == false) return false;
	return true;
}

function checkRiderPassword(fld)
{
	var v = fld.value;
	if (isWhitespace(v)) {
		return warnInvalid(fld, 'Please enter your NuRider password.');
	}
	if (hasCharsInBag(v, '" !#%^*()=;:<>/?|\'\\')) {
		return warnInvalid(fld, 'Please enter your NuRider password.');
	}
	if (checkLengthBogus(fld, 4, 'Please enter your valid NuRider password.') == false) return false;
	return true;
}

function setVisibility(szDivID, iState) // 1 visible, 0 hidden
{
   var obj = document.layers ? document.layers[szDivID] :
   document.getElementById ?  document.getElementById(szDivID).style :
   document.all[szDivID].style;
   obj.visibility = document.layers ? (iState ? "show" : "hide") :
   (iState ? "visible" : "hidden");
}
