﻿var map = null;

  $(document).ready(function(){
    $("#opportunityform").validate();
    
    
    $("#oppsub").bind("click", function(){
          //$("#opportunityform").validate().form();
         if($("#opportunityform").validate())
         {
             $.post(BaseURL + "/opportunities/contact", { firstname: $('#firstname').attr('value'),
                                            lastname: $('#lastname').attr('value'),
                                            email: $('#email').attr('value'),
                                            phone: $('#phone').attr('value'),
                                            street1: $('#street1').attr('value'),
                                            street2: $('#street2').attr('value'),
                                            number: $('#number').attr('value'),
                                            city: $('#city').attr('value'),
                                            state: $('#state').attr('value'),
                                            zip: $('#zip').attr('value')}, function(xml) {
                                            
               // format and output result
               if(xml.toString().indexOf('true') > -1)
               {
                     $("#oppform").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                     $('#results').html('<p>Thank you for your interest in Anytime Fitness!<br /><b>Please check your email,</b> your confirmation should arrive shortly!</p><iframe src="content/conversion/franchise.aspx" width="50" height="10" frameborder="0"></iframe>');
                     $('#results').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
                     if ($.browser.msie) 
                         this.style.removeAttribute('filter'); 
                      });  
                      
                      //setTimeout('cancelall()', 5000);
               }
               else
               {
                    $("#oppform").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                    $('#resultserror').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
                     if ($.browser.msie) 
                         this.style.removeAttribute('filter'); 
                      });  
                      
                      setTimeout('expandoppform()', 4000);
                      
                      
               }
               
             });
         }
    });
  });


function expandoppform()
 {
     $('html, body').animate({ scrollTop: 0 }, 400);
    $('#resultserror').animate({ height: 'hide', opacity: 'hide' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
         this.style.removeAttribute('filter'); 
      });  

     $('#oppform').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
         this.style.removeAttribute('filter'); 
      });  

}

function cancelall()
 {
     $("#oppform").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     $("#results").hide();
     $("#resultserror").hide();

}
