function activate()
{
   if(!$('#num').val()) { alert('Введите номер карты'); $('#num').focus(); return ;}
   if(!$('#pin').val()) { alert('Введите пинкод'); $('#pin').focus(); return ;}

   $('.activationblock').prepend('<img src="/images/ajaxloader.gif" style="margin-left: 15px;">');

   $.jsHttpRequest({
            url: '/ajax.php', 
            data: { 'num' : $('#num').val(), 'pin' : $('#pin').val(), 'fio': $('#fio').val() },
            onReady: function(result, text) {
                   $('.activationblock img').remove();
                   if(text){
					   alert(text);
                   }else{
	                   if(result.isActivate){
	                       $('#message').remove();
	                       if($('#actbutton').attr('mode') == 'activate'){
		                       var message = '<p style="text-align: center; color: red; font-size: 16px;" id="message">Карта уже была активирована ' + result.CardActivateDate + '.';
		                       if(result.CardHolderName) message += ' на имя ' + result.CardHolderName + '.</p>';
		                       message += ' <a href="http://www.dsbw.ru" style="color: #500E00; ">Перейти к бронированию тура.</a>';
		                       $('.activationblock').prepend( message );
		                       $('.activationblock').css('height', '530px');
	                       }else{
			               	   $('.activationblock').html('<p style="text-align: center; font-size: 20px; ">Карта номер ' + $('#num').val() + '. Была активирована ' + result.CardActivateDate + '. <br /><a href="http://www.dsbw.ru" style="color: #500E00; ">Перейти к бронированию тура.</a></p>');
	                           $('.activationblock').css('height', '180px');
	                       }
	                   }else{
			               $('.activationblock').html("<p style='text-align: center; font-size: 20px; '>Карта номер <span style='color: red;'>" + $('#num').val() + "</span> успешно активирована " + result.date + ".  <br />Получатель подарка " + $('#fio').val() + ". <br />На счет путевки зачислено " + result.ineuro + " евро (" + result.nominal + " рублей по курсу ЦБ РФ +1% на " + result.date + ")<br /><a href='http://www.dsbw.ru' style='color: red;'>Перейти в выбору тура</a></p>");
		                   $('.activationblock').css('height', '350px');
	                   }                     
                   } 
            }
    });
}

function changeMode(elem)
{
    $('#message').remove();
    if($(elem).attr('class') == 'active') return;
    
    
    $('div.navblock a').each(
       function(e){
          $(this).removeClass('active');
       }
    );
    $(elem).addClass('active');
    
    if($(elem).attr('type') == 'order'){
        $('#actbutton').attr('mode', '');
        $('.activationblock').css('height', '320px');
        $('#fioblock').hide();
        $('#actbutton').attr('value', 'Бронировать');
    }else{
        $('#actbutton').attr('mode', 'activate');
        $('.activationblock').css('height', '430px');
        $('#fioblock').show(); 
        $('#actbutton').attr('value', 'Активировать');
    }
}