function brandJump(letter)
{
	var scroll_elem = document.getElementById('brand-nav');
	document.getElementById('last-letter').focus(); /*goto bottom*/
	document.getElementById('first-letter-'+letter).focus(); /*first letter at top*/
	scroll_elem.innerHTML = scroll_elem.innerHTML.replace("<strong>","");
	scroll_elem.innerHTML = scroll_elem.innerHTML.replace("</strong>","");
	scroll_elem.innerHTML = scroll_elem.innerHTML.replace(">"+letter,"><strong>"+letter+"</strong>");
}
function ctf(theText) 
{
	if(theText.value==theText.defaultValue) 
	{
		theText.value = "";
		theText.style.color = "#000000";
	}
}
function rtf(theText) 
{
	if(theText.value=="") 
	{
		theText.value = theText.defaultValue;
		theText.style.color = "#cbcbcb";
	}
}
function l2s(theForm) 
{
	if(theForm.q.value==theForm.q.defaultValue || theForm.q.value=='') 
	{
		theForm.q.focus();
		return false;
	}
	return true;
}
function isValidEmail(the_email) 
{
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\'\>\,\;\:\\\/\"\[\]]/;
	return (emailFilter.test(the_email) && !the_email.match(illegalChars));
}

function validateShort(formElem) 
{
	var inputElem = null;
	var why = '';
	
	inputElem = formElem.email;
	if( inputElem ) 
	{
		if(!isValidEmail(inputElem.value)) 
		{
			why += " * Your Email Address\n";
			inputElem.style.borderColor = '#E53F76';
		}
		else 
		{
			inputElem.style.borderColor = '#ffffff';
		}
	}
	
	if( why != "" ) 
	{
		why = "There is an error with your request.\n\nPlease fill out the following required fields:\n" + why;
		alert(why);
		return false;
	}
	
	return true;
}

//Browser Support Code
function getLetter(letter,gender){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 1)
		{
		var ajaxDisplay = document.getElementById('brand-scroll');
		ajaxDisplay.innerHTML = "<div id='ajax-loading'><img src='/img/ajax-loader.gif'><p>Loading...</p></div>";
		}
		else if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('brand-scroll');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var queryString = "?letter=" + letter;
	if(gender == 'W'){ajaxRequest.open("GET", "/inc/sidebar-f.php" + queryString, true);}
	else if(gender == 'M'){ajaxRequest.open("GET", "/inc/sidebar-m.php" + queryString, true);}
	else{ajaxRequest.open("GET", "/inc/sidebar.php" + queryString, true);}
	ajaxRequest.send(null); 
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
