window.addEvent('domready', function() {   
        
        
 if ($('caform')) {        
         
$('caform').addEvent('submit', function(e) {
    /**
     * Prevent the submit event
     */
    new Event(e).stop();
 
    /**
     * This empties the log and shows the spinning indicator
     */
    var log = $('error').empty().addClass('ajax-loading');
 
    /**
     * send takes care of encoding and returns the Ajax instance.
     * onComplete removes the spinner from the log.
     */
     
    this.send({
        update: log,
        onComplete: function(response) {
            if(response.replace(/^\s+|\s+$/g,"") == 'OK') {  
                 setTimeout('go_to_private_page()', 100);
                 $('id').setStyle('display','none'); 
                 $('error').setStyle('display','none'); 
             }
             else { 
                 $('submitter').setStyle('display','block'); 
             }
            log.removeClass('ajax-loading');
            
        }
    });
});
 }
 
 
 if ($('addfirm')) {        
         
$('addfirm').addEvent('submit', function(e) {
    /**
     * Prevent the submit event
     */
    new Event(e).stop();
 
    /**
     * This empties the log and shows the spinning indicator
     */
    var log = $('error').empty().addClass('ajax-loading');
 
    /**
     * send takes care of encoding and returns the Ajax instance.
     * onComplete removes the spinner from the log.
     */
     
    this.send({
        update: log,
        onComplete: function(response) {
            if(response == 'OK') {  
                 /*$('id').setStyle('display','none');  */
                 $('error').setStyle('display','none'); 
                 setTimeout('go_to_page()', 10);
             }
             else if(response == 'OKK') {  
                  $('error').setStyle('display','none'); 
                 setTimeout('go_to_page2()', 10);   
             }
             else { 
                /* $('edit_company').setStyle('display','block');     */
             }
            log.removeClass('ajax-loading');
            
        }
    });
});
 } 
 
 
  if ($('addadress')) {        
         
$('addadress').addEvent('submit', function(e) {
    /**
     * Prevent the submit event
     */
    new Event(e).stop();
 
    /**
     * This empties the log and shows the spinning indicator
     */
    var log = $('error').empty().addClass('ajax-loading');
 
    /**
     * send takes care of encoding and returns the Ajax instance.
     * onComplete removes the spinner from the log.
     */
     
    this.send({
        update: log,
        onComplete: function(response) {
            if(response == 'Done') {  
                 /*$('id').setStyle('display','none');  */
                 $('error').setStyle('display','none'); 
                 setTimeout('go_to_page_address()', 10);
             }
             else { 
                /* $('edit_company').setStyle('display','block');     */
             }
            log.removeClass('ajax-loading');
            
        }
    });
});
 } 
 
 
  if ($('contact_form')) {        
         
$('contact_form').addEvent('submit', function(e) {
    /**
     * Prevent the submit event
     */
    new Event(e).stop();
 
    /**
     * This empties the log and shows the spinning indicator
     */
    var log = $('error').empty().addClass('ajax-loading');
 
    /**
     * send takes care of encoding and returns the Ajax instance.
     * onComplete removes the spinner from the log.
     */
     
    this.send({
        update: log,
        onComplete: function(response) {
            if(response == 'OK') {  
                 /*$('id').setStyle('display','none');  */
               /*  $('error').setStyle('display','none');   */
                 setTimeout('go_to_page_contact()', 10);
             }
             else { 
                /* $('edit_company').setStyle('display','block');     */
             }
            log.removeClass('ajax-loading');
            
        }
    });
});
 }  
 
/* 
   if ($('rma_form')) {        
        
$('rma_form').addEvent('submit', function(e) {
    new Event(e).stop();

    var log = $('error').empty().addClass('ajax-loading');
   
    this.send({
        update: log,
        onComplete: function(response) {
            if(response == 'OK') {  
                 //setTimeout('go_to_page_rma_form()', 10);
                 $('rma_form').send();
             }
             else { 
             }
            log.removeClass('ajax-loading');  
        }
    });
});
 }
*/ 
 
 /*
 $('submit_rma').addEvent( 'click', function(evt){
    // Stops the submission of the form.
    new Event(evt).stop();
    var log = $('error').empty().addClass('ajax-loading'); 
      $('rma_form').send({
        update: log,
        onComplete: function(response) {
        if(response == 'OK') {     
       // $('rma_form').send();
        }
        
            
        }
    // Sends the form to the action path,
    // which is 'script.php'
    
} );
*/ 
 
 
        }); 

function go_to_private_page()
{
window.location = '/checkout/'; // Members Area
}

function go_to_page()
{
window.location = '/?a=account&sa=add_firm'; // adauga firma
}

function go_to_page2()
{
window.location = '/checkout/'; // adauga firma
}

function go_to_page_address()
{
window.location = '/?a=account&sa=add_adress'; // adauga adresa
}

function go_to_page_contact()
{
window.location = '?a=etc&sa=contact'; // adauga firma
}

function go_to_page_rma_form()
{
window.location = '?a=etc&sa=contact'; // formular
}


/*
// Preload Images
img1 = new Image(16, 16);  
img1.src="images/spinner.gif";

img2 = new Image(220, 19);  
img2.src="images/loader-bar.gif";


    window.addEvent('domready', function() {
           
    $('login').addEvent('submit', function(e) {
        // Prevents the default submit event from loading a new page.
        e.stop();

        // Show the spinning indicator when pressing the submit button...
        $('ajax_loading').setStyle('display','block');

        // Hide the submit button while processing...
        $('submit').setStyle('display','none');

        // Set the options of the form's Request handler.
        // ("this" refers to the $('login') element).
        this.set('send', { onComplete: function(response) {
            $('ajax_loading').setStyle('display','none');

    if(response == 'OK')
            {
              $('status').set('html', '<div id="logged_in">You are now logged it! <br />' +
              '<img align="absmiddle" src="images/loader-bar.gif">' +
              '<br /> Please wait while we redirect you to your private page...</div>');

            setTimeout('go_to_private_page()', 3000);
            }
            else
            {
              $('login_response').set('html', response);
              // Show the login button
              $('submit').setStyle('display','block');
            }
        }});

        // Send the form.
        this.send();
    });
});

function go_to_private_page()
{
window.location = 'private.php'; // Members Area
}
*/
