String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function toggleFeaturedRankingsAccordian() {
	
	//new Effect.toggle('featured-ranking-accordian','blind',{duration: .2});
	$('featured-ranking-accordian').style.display = 'block';
}

function checkCommentFields() {
	errs = '';
	if ($('commentName').value.trim().length < 1) {
		errs = errs + 'Your name.\n';
	}
	if ($('commentData').value.trim().length < 1) {
		errs = errs + 'Your comments.';
	}
	if (errs.length > 0) {
		alert('Before you can post a comment you must provide the following: \n\n'+errs);
		return false;
	} else {
		return true;
	}
}

function checkEmail(email) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) {
		return true;   // valid email
	} else {
		return false;  // invalid email
	}
}

function ts(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function emailSubscribe() {
	if (checkEmail(ts($('emailSignup').value))) {	
		var url = 'ajax_email_subscribe.php';
		var pars = 'email='+ts($('emailSignup').value);
		var target = "subscribe-div";
		var ajaxSendEmail = new Ajax.Updater(target, url, { 
		method: 'post', 
		parameters: pars,
		evalScripts: true,
		asynchronous:true
		});
		
	} else {		
		alert('Please provide a valid email address.');
	}
}

function radioPopup() {
	window.open ("radioPopup.php","mywindow","menubar=1,resizable=1,width=230,height=125"); 
}
