//------------------------------------------------------------------------------

var numberOfCircles = 6;
var circles = new Array();
var paper;
var p;
var radius = 7;
var circleXpos = 214;
var circleYpos = 52

function animateRadioWaves() {
	for(i=0;i<numberOfCircles+1;i++) {
		if(i!=numberOfCircles) {
			circles[i].animateWith(circles[numberOfCircles],{r: circles[i].attr('r')+radius}, 2000);
		} else {
			circles[numberOfCircles].animate({r: ((numberOfCircles+1)*radius)+1, opacity: 0}, 2000, function(){
				circles.pop();
				circles.unshift( paper.circle(circleXpos, circleYpos, (0*radius)+1).attr("stroke", "#fff") );
				setTimeout(animateRadioWaves,1);
//				animateRadioWaves();
			});
		} // if..else
	} // for
} // function..animateRadioWaves

//------------------------------------------------------------------------------

//-- THANKS! - http://stackoverflow.com/questions/654112/how-do-you-detect-support-for-vml-or-svg-in-a-browser
function supportsNativeSvg() {
    return window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1");
} // function..supportsNativeSvg

window.addEvent('domready', function() {
	if(supportsNativeSvg()) {
		paper = Raphael("radiowavesContainer", 320, 177);
		for(i=0;i<numberOfCircles+1;i++) {
			circles[i] = paper.circle(circleXpos, circleYpos, (i*radius)+1).attr("stroke", "#fff");
		} // for
		animateRadioWaves();
	} // if..IE < 9

	//-- Nit picky CSS font corrections for Mac users
	if(Browser.Platform.mac) {
		$$('.commentballon strong').setStyle('padding','14px 0 0 3px');
	} // if

	//-- apply smooth scrolling to inner anchor tags
	var mySmoothScroll = new SmoothScroll({ links: '.bvSmoothAnchor' });

	$$('.bvEmailAddressField').each( function(el) {
		el.onfocus = function() {
			this.value = (this.value=='Enter email address') ? '' : this.value;
		} // onfocus

		el.onblur = function() {
			this.value = (this.value=='') ? 'Enter email address' : this.value;
		} // onfocus
	}); // bvEmailAddressField

	//-- provide XHTML valid method for target=_blank for <a>'s
	$$('.bvLinkTargetBlank').each( function(el) {
		el.onclick = function() {
			var newWindow = window.open(this.getAttribute('href'), '_blank');
			newWindow.focus();
			return false;
		};
	}); // bvLinkTargetBlank

	//-- service emailSignupForm form
	$$('#emailSignupForm').set({'events': {
		'submit' : function(event) {
			$('moxysubmit').setStyle('display','none');
			$('wait').setStyle('display','block');
			var myRequest = new Request.JSON({
				url: '/gsbs/_ws/maillist/action.php',
				onSuccess: function(jsonResult, wsResult){
					$('moxysubmit').setStyle('display','block');
					$('wait').setStyle('display','none');

					$$('.bvFieldMessage').empty();
					if(jsonResult.success) {
						$('emailSignupForm').set('html',jsonResult.messages['submit']);
					} else {
						for(var messageId in jsonResult.messages) {
							if(messageId!='dummy') $(messageId+'Message').set('html',jsonResult.messages[messageId]).highlight();
						} // for
					} // if..else
				} // onSuccess
				,
				onFailure: function(){
					$('emailSignupForm').set('html','<div class="criticalError">There was an error processing the form.  Please refresh your browser and try again.  Or contact us directly at <a href="mailto:info@gsdesign.com">info@gsdesign.com</a>.</div>');
				} // onFailure
			}).post($('emailSignupForm'));
			event.stop();
		} // onclick..signupSubmit
	}}); // emailSignupForm
}); // domready

//------------------------------------------------------------------------------
