 
								
function opacer2(el,times,curTime) {
if(curTime<times) {	
curTime++;
opacity = 1;
if(curTime%2) { opacity = 0.4; }
  jQuery(el).animate({ 
    opacity: opacity
  }, 100, function(){
	  opacer2(el,20,curTime);
	  }); 
 } 
}

jQuery(document).ready(function(){
 
 
jQuery('.nslTxt').click(function(el){
		jQuery('.err').css('display','none');								   								
}).focus(function(el){
		jQuery('.err').css('display','none');									   								
});
 				
	
jQuery('.bott').click(function(){
 nValidation();
 return false;	
});	
	

	
});   

function nValidation()
{
	error = 0;
    badWords = new Array('Your Email Address');
	badLength = badWords.length;
  
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = jQuery('#nEmail').val();
	
	
	jQuery('#newsletterform .nslTxt').each(function(){
        
        checkVal = jQuery(this).val();
        
        for ( i=0; i < badLength; i++ ) {
            
            if ( (checkVal.length<2) || (checkVal==badWords[i]) ) {   
                error = 1;
                jQuery('#'+jQuery(this).attr('id')+'Err').focus();
				jQuery('#'+jQuery(this).attr('id')+'Err').css('display','block');
				opacer2('#'+jQuery(this).attr('id')+'Err',11,0);
                return false;
            }
        }
      
    });
	 
	if ( !error ) {	
     if ( reg.test(address) == false ) {
               error = 1;
                jQuery('#nEmailErr').focus();
				jQuery('#nEmailErr').css('display','block');
				jQuery('#nEmailErr').html('Please enter a valid email address!');
				opacer2('#nEmailErr',11,0);
            }
	}		
    if ( !error ) {
		jQuery('.bott').hide();
		jQuery('#eStatus').show();
        newsletterSubmit();
    }
}
 

 var ajaxObj = new XMLHTTP("/mybic_server.php");
	ajaxObj.debug=0;
	
function newsletterSubmit() {
	
	var formVars = ajaxObj.getForm('newsletterform');
	ajaxObj.call('action=newsletter_subscribe'+formVars, newsletterSubmitResp);
}

function newsletterSubmitResp(resp) {

	if (resp.errors) {
$('#eStatus').hide();
$('.bott').show();
$('#eThanks').html('<div class="error">'+resp.errors.msg+'</div>');
$('#tLink').click(); 
		return;
	}
$('#eStatus').hide();
$('.bott').show();
$('#eThanks').html('<strong>Thank you!</strong><br />'+jQuery('#nEmail').val()+' was added to Dr. John Izzo mailing list!')
$('#tLink').click(); 
}
 
