//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function setBgsex() {
	if (document.QuickSearchForm.seeking.selectedIndex == 1
	|| document.QuickSearchForm.seeking.selectedIndex == 3
	|| document.QuickSearchForm.seeking.selectedIndex == 5
	|| document.QuickSearchForm.seeking.selectedIndex == 7) {
		SetCookie("bgsex", "m", null);
	} else { 
		SetCookie("bgsex", "f", null);
	}
}

function search() {
	var validSearch = "yes";
	
	if (document.QuickSearchForm.desireageFrom.selectedIndex > document.QuickSearchForm.desireageTo.selectedIndex ) { 
		alert("Please choose Valid Age Range");
		document.QuickSearchForm.desireageTo.focus();
		var validSearch = "no";
	}	 
	
	for (var i=0; i < document.QuickSearchForm.areacode.length; i++) {  
		if (!isWhitespace (document.QuickSearchForm.areacode[i].value)
		&& !isaNum (document.QuickSearchForm.areacode[i].value)) {
			var validSearch = "no";
			alert("If entered, Area Code must be numeric.");
			document.QuickSearchForm.areacode[i].focus();
			document.QuickSearchForm.areacode[i].select();
		}
	}	
		
	if (validSearch == "yes") {  
		document.QuickSearchForm.submit()
	}
}
