﻿var map = null;

  $(document).ready(function(){
    $("#opportunityform").validate();
    
    
    $("#oppsub").bind("click", function(){
          $("#opportunityform").validate().form();
         if($("#opportunityform").valid())
         {
             $.post(BaseURL + "/opportunities/internationalrequest", { firstname: $('#firstname').attr('value'),
                                            lastname: $('#lastname').attr('value'),
                                            email: $('#email').attr('value'),
                                            phone: $('#phone').attr('value'),
                                            country: $('#country').attr('value'),
                                            additional: $('#additional').attr('value')
                                             }, function(xml) {
                                            
               // format and output result
               if(xml.toString().indexOf('true') > -1)
               {
                     $("#purpleblock").animate({ height: '125px'}, 'slow');
                     $("#oppform").animate({ height: 'hide', opacity: 'hide' }, 'slow');
                     $('#results').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
                     if ($.browser.msie) 
                         this.style.removeAttribute('filter'); 
                      });  
                      
                      setTimeout('cancelall()', 5000);
               }
               else
               {
                    $("#purpleblock").animate({ height: '100px'}, 'slow');
                    $("#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);
     $("#purpleblock").animate({ height: '340px'}, 'slow');
     $("#cancel").animate({ height: 'show', opacity: 'show' }, 'slow');
     $("#seplink").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     $("#phonenumber").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     
     $('#opplink').animate({ height: 'hide', opacity: 'hide' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
         this.style.removeAttribute('filter'); 
      });  
      
    $('#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()
 {
     $("#area").show();
     $("#cancel").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     $("#purpleblock").animate({ height: '35px'}, 'slow');
     $("#oppform").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     $("#results").hide();
     $("#resultserror").hide();

          $('#opplink').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
         this.style.removeAttribute('filter'); 
      });  
                $('#phonenumber').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
         this.style.removeAttribute('filter'); 
      });  
     $("#seplink").animate({ height: 'show', opacity: 'show' }, 'slow');
}

function resetfromvideo()
{
  	$("#videoblock").html('');
  	$("#videoblock").hide();
  	$("#videocancel").hide();
  	cancelall();
}
