/*///////////
allows clearing of inputs after clicking
///////////*/

function clearwidgit(elem){
	elem.value="";
	elem.className+=" widgit-cleared";
}
/**
 *  Email List Submission Handling 
 */
/*
function email_list_init()
{
    $(document).ready(function()
    {
        
        //form id 
        $('#email_list').submit(function(e)
        {
            
          if($('#email_address').val())
          {
              var val = $(this).val(); 
              if(val != 'youremail@yourdomain.com')
                  {
                      
                  }
              $.post('/default/index/form-email-list/format/html', { ajax_email:$('#email_address').val()}, function(data)
              {
                 if(data.length > 0)
                 {
                    alert(data); 
                 }
              });
              
              
              
           }else{
               alert('Please enter your email'); 
                return false; 
           }
         
        })
        if ($('body').hasClass('language_fr')){
            $('.email-list-title').html('Rejoignez notre liste denvoi');
        } else {
        }
        return false; 
    });
}

email_list_init(); 

*/


function email_list_init()
{
    $(document).ready(function()
    {
        
        //form id 
        $('#emailSubmit').submit(function(e)
        {
           
           var elementValue = $('#email_address').val(); 
           var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
           
           var isValid = emailPattern.test(elementValue);
           
           
          if(elementValue == '' || elementValue == 'youremail@yourdomain.com')
          {
                if ($('html').attr('lang') == 'en'){
                    alert('Please enter your email');
                     
                } else {

                    alert('Veuillez fournir votre address électronique');
                }
                return false; 
          }
          else if(!isValid)
          {
            
             if($('html').attr('lang')=='en')
             {
                   alert('That email is invalid'); 
             }else{
                 alert("Cet email est inadmisible"); 
             }
              
              return false; 
          }
         
          else
          {
             
             if($('html').attr('lang')=='en')
             {
                   alert('Email Submitted Successfully'); 
             }else{
                 alert("L'email a soumis avec succès"); 
             }
                 
            
            
         
              
          }
          
        })
    });
}

email_list_init(); 
