 
function opacer(el,times,curTime) {
if(curTime<times) {	
curTime++;
opacity = 1;
if(curTime%2) { opacity = 0.4; }
  jQuery(el).animate({ 
    opacity: opacity
  }, 100, function(){
	  opacer(el,20,curTime);
	  }); 
 } 
}

jQuery(document).ready(function(){
 
 
jQuery('.txtF').click(function(el){
		jQuery('.ferr').hide('slow');								   									
											})
                           .focus(function(el){
		jQuery('.ferr').hide('slow');											   								
											});

								
 					
	
jQuery('#sSubmit').click(function(){
 sValidation();
 return false;	
});	
	

	
});   

function sValidation()
{
	error = 0;
    badWords = new Array('Your Name','Your Phone','Your Email');
	badLength = badWords.length;
  
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = jQuery('#sEmail').val();
	
	
	jQuery('#shortForm .required').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').show();
				opacer('#'+jQuery(this).attr('id')+'_err',11,0);
                return false;
            }
        }
      
    });
	 
	if ( !error ) {	
     if ( reg.test(address) == false ) {
               error = 1;
                jQuery('#sEmail_err').focus();
				jQuery('#sEmail_err').show();
				jQuery('#sEmail_err').html('Unreal email address!');
				opacer('#sEmail_err',11,0);
            }
	}		
    if ( !error ) {
        contactSubmit2();
    }
}
 

 var ajaxObj = new XMLHTTP("/mybic_server.php");
	ajaxObj.debug=0;
	
function contactSubmit2() {
	
	var formVars = ajaxObj.getForm('shortForm');
	ajaxObj.call('action=quote'+formVars, contactSubmitResp2);
}

function contactSubmitResp2(resp) {

	if (resp.errors) {
	    alert('Form is not work');
		return;
	}
	
 document.location.href = "/thank-you";	
}
 
