var req = Create();
var q;

	num = parseInt(num);
	if (num > 10)
	{
		setTimeout(data1, 2000);
        setTimeout(q1, 3000);
        setTimeout(q2, 5000);
        setTimeout(q3, 7000);
        setTimeout(q4, 9000);
        setTimeout(q5, 11000);
        setTimeout(q6, 13000);
        setTimeout(q7, 15000);
        setTimeout(q8, 17000);
        setTimeout(q9, 19000);
        setTimeout(q10, 21000);
        setTimeout(data1_end, 23000);

        setTimeout(data2, 24000);
        setTimeout(create, 24000);
        setTimeout(dieta1, 25000);
        setTimeout(line1, 25000);
        setTimeout(dieta1_1, 26000);

        setTimeout(dieta2, 27000);
        setTimeout(line2, 27000);
        setTimeout(dieta2_1, 28000);

        setTimeout(dieta3, 29000);
        setTimeout(line3, 29000);
        setTimeout(dieta3_1, 30000);

        setTimeout(dieta4, 31000);
        setTimeout(line4, 31000);
        setTimeout(dieta4_1, 32000);

        setTimeout(dieta5, 33000);
        setTimeout(line5, 33000);
        setTimeout(dieta5_1, 36000);

        setTimeout(save, 37000);
        setTimeout(line_save, 37000);
        setTimeout(saving, 46000);
        setTimeout(final, 46000);	
	}



function data1()
{
	document.getElementById("data1").innerHTML = '<strong style="color:#233a9c">Получаем данные: </strong>'; 
	
		$(document).ready(function(){
	$("#answer").removeClass("answer");
    $("#answer").addClass("answer_dis");
	});
	
	return;  
}

function q1()
{ 	
	document.getElementById("q1").innerHTML = 'Ваш излишний вес: <strong>' + myArray[1] + '</strong>'; 
	return;   	
}

function q2()
{
 	document.getElementById("q2").innerHTML = 'Выбранный пол: <strong>' + myArray[2] + '</strong>'; 
	return;   	
}

function q3()
{
 	document.getElementById("q3").innerHTML = 'Выбранный возраст: <strong>' + myArray[3] + '</strong>'; 
	return;   	
}

function q4()
{
 	document.getElementById("q4").innerHTML = 'Выбранный вес(кг): <strong>' + myArray[4] + '</strong>'; 
	return;   	
}

function q5()
{
 	document.getElementById("q5").innerHTML = 'Выбранный рост(см): <strong>' + myArray[5] + '</strong>'; 
	return;   	
}

function q6()
{
 	document.getElementById("q6").innerHTML = 'Выбранная группа крови: <strong>' + myArray[6] + '</strong>'; 
	return;   	
}

function q7()
{
 	document.getElementById("q7").innerHTML = 'Есть ли пищевые аллергии: <strong>' + myArray[7] + '</strong>'; 
	return;   	
}

function q8()
{
 	document.getElementById("q8").innerHTML = 'Есть ли физические нагрузки: <strong>' + myArray[8] + '</strong>'; 
	return;   	
}

function q9()
{
 	document.getElementById("q9").innerHTML = 'Были ли беременны: <strong>' + myArray[9] + '</strong>'; 
	return;   	
}

function q10()
{
 	document.getElementById("q10").innerHTML = 'Наличие заболеваний щитовидной железы: <strong>' + myArray[10] + '</strong>'; 
	return;   	
}

function data1_end()
{
    $(document).ready(function(){						   
		$("#sms").animate({ opacity: 'hide' }, "fast");
	});
}

function data2()
{
    $(document).ready(function(){						   
		$("#sms1").animate({ opacity: 'show' }, "fast");
	});
}

function create()
{
	document.getElementById("data2").innerHTML = '<strong style="color:#233a9c">Составляем диету: </strong>'; 
	return;  
}

function dieta1()
{
    document.getElementById("dieta1").innerHTML = 'Подбор конкретных продуктов питания: '; 
	return;
}

function line1()
{
	$(document).ready(function(){
		$("#line1").animate({ opacity: 'show' }, "fast");					   
	    $("#line1").animate({width: "100px"}, 1000);		
	});
	return;
}

function dieta1_1()
{
	document.getElementById("block1").innerHTML = '<strong style="color:#802d42;">Ок</strong>'; 
	return;
}

function dieta2()
{
    document.getElementById("dieta2").innerHTML = 'Подбор подходящего режима питания:';
	return;
}

function line2()
{
	$(document).ready(function(){
		$("#line2").animate({ opacity: 'show' }, "fast");					   
	    $("#line2").animate({width: "100px"}, 1000);		
	});
	return;
}

function dieta2_1()
{
	document.getElementById("block2").innerHTML = '<strong style="color:#802d42;">Ок</strong>'; 
	return;
}

function dieta3()
{
    document.getElementById("dieta3").innerHTML = 'Расчет интервалов приёма пищи:';
	return;
}

function line3()
{
	$(document).ready(function(){
		$("#line3").animate({ opacity: 'show' }, "fast");					   
	    $("#line3").animate({width: "100px"}, 1000);		
	});
	return;
}

function dieta3_1()
{
	document.getElementById("block3").innerHTML = '<strong style="color:#802d42;">Ок</strong>'; 
	return;
}

function dieta4()
{
    document.getElementById("dieta4").innerHTML = 'Подбираем оптимальный срок диеты:';
	return;
}

function line4()
{
	$(document).ready(function(){
		$("#line4").animate({ opacity: 'show' }, "fast");					   
	    $("#line4").animate({width: "100px"}, 1000);		
	});
	return;
}

function dieta4_1()
{
	document.getElementById("block4").innerHTML = '<strong style="color:#802d42;">Ок</strong>'; 
	return;
}

function dieta5()
{
    document.getElementById("dieta5").innerHTML = '<strong>Составление рациона на основе данных:</strong>';
	return;
}

function line5()
{
	$(document).ready(function(){
		$("#line5").animate({ opacity: 'show' }, "fast");					   
	    $("#line5").animate({width: "100px"}, 3000);		
	});
	return;
}

function dieta5_1()
{
	document.getElementById("block5").innerHTML = '<strong style="color:#802d42;">Ок</strong>'; 
	return;
}

function save()
{
	document.getElementById("save").innerHTML = '<br /><strong style="color:#233a9c">Сохраняем диету: </strong>'; 
	return;  
}

function saving()
{
	document.getElementById("saving").innerHTML = ''; 
	return;
}

function line_save()
{
	$(document).ready(function(){
		$("#line_save").animate({ opacity: 'show' }, "fast");					   
	    $("#line_save").animate({width: "300px"}, 8000);		
	});
	return;
}

function final()
{
 	document.getElementById("loader").innerHTML = ''; 
	document.getElementById("download").innerHTML = '<br /><strong>Готово! Можете скачать Вашу диету</strong>'; 
	
	$(document).ready(function(){
	$("#final").removeClass("final_dis");
    $("#final").addClass("final");
	});
	return;   	
}

function check_response()
{
	if (document.getElementById("name").value == "")
	    document.getElementById("err").innerHTML = '<strong style="color:#bc4e60;">Не введено имя</strong>';
	else if (document.getElementById("email").value == '')
	    document.getElementById("err").innerHTML = '<strong style="color:#bc4e60;">Не введен email</strong>';
	else if (document.getElementById("d_code").value == '')
	    document.getElementById("err").innerHTML = '<strong style="color:#bc4e60;">Не введен код</strong>';
	else if (document.getElementById("r_text").value == '')
	    document.getElementById("err").innerHTML = '<strong style="color:#bc4e60;">Не введен текст отзыва</strong>';
	else
	    document.getElementById("err").innerHTML = '<strong style="color:#20e599;">Ваше сообщение отправлено на модерацию</strong>';
}




function Create()
{  
    if(navigator.appName == "Microsoft Internet Explorer"){  
        req = new ActiveXObject("Microsoft.XMLHTTP");  
    }else{  
        req = new XMLHttpRequest();  
    }  
    return req;  
}  


function Request(query) 
{ 
	var rand = Math.floor( Math.random( ) * (5000+1) );

	req.open('post', 'select.php?'+rand , true ); 
    req.onreadystatechange = Refresh; 
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
    req.send(query);              
}


function Refresh() 
{ 	
    num = parseInt(num);
	
	if( req.readyState == 4  && req.status == 200 && num > 10)
	{ 
		setTimeout(data1, 2000);
        setTimeout(q1, 3000);
        setTimeout(q2, 5000);
        setTimeout(q3, 7000);
        setTimeout(q4, 9000);
        setTimeout(q5, 11000);
        setTimeout(q6, 13000);
        setTimeout(q7, 15000);
        setTimeout(q8, 17000);
        setTimeout(q9, 19000);
        setTimeout(q10, 21000);
        setTimeout(data1_end, 23000);

        setTimeout(data2, 24000);
        setTimeout(create, 24000);
        setTimeout(dieta1, 25000);
        setTimeout(line1, 25000);
        setTimeout(dieta1_1, 26000);

        setTimeout(dieta2, 27000);
        setTimeout(line2, 27000);
        setTimeout(dieta2_1, 28000);

        setTimeout(dieta3, 29000);
        setTimeout(line3, 29000);
        setTimeout(dieta3_1, 30000);

        setTimeout(dieta4, 31000);
        setTimeout(line4, 31000);
        setTimeout(dieta4_1, 32000);

        setTimeout(dieta5, 33000);
        setTimeout(line5, 33000);
        setTimeout(dieta5_1, 36000);

        setTimeout(save, 37000);
        setTimeout(line_save, 37000);
        setTimeout(saving, 46000);
        setTimeout(final, 46000);		
	}
	
    if( req.readyState == 4  && req.status == 200)
	{     			   
	   document.getElementById('ajax').innerHTML = req.responseText;
	   document.getElementById('waiting').innerHTML = '';
	   $(document).ready(function() {                                              
       $("#answer").removeClass("answer_dis");
       $("#answer").addClass("answer"); 
       });	
	}
    else
	document.getElementById('waiting').innerHTML = '<img src="/skins/default/images/loader.gif" />';
}

function Send_ajax(radio)
{
	for (Count = 0; Count < radio; Count++) 
	{
		if (document.myform.rad[Count].checked)
		{
		   $(document).ready(function() {                                              
           $("#answer").removeClass("answer");
           $("#answer").addClass("answer_dis"); 
           });	
		   num = parseInt(num) + 1;

           var txt = encodeURIComponent(document.myform.rad[Count].value);

           var query = 'txt='+txt;
	       myArray[num-1] = document.myform.rad[Count].value;
           Request(query);
		  <!-- document.myform.rad[Count].checked = false;-->
		   break;
		}   
	}
	if (Count == radio)
	{
	    alert ('Выберите вариант ответа');	
	}
}

function Send() 
{      
	q = 'q' + num;
	
    if (num == 3 || num == 4 || num == 5 || num == 9 || num == 10)
	{
	    if (document.getElementById(q).value == '')
		{
			alert ('Выберите вариант ответа');
		}
		else
		{	   
		   $(document).ready(function() {                                              
           $("#answer").removeClass("answer");
           $("#answer").addClass("answer_dis"); 
           });	
		   
		   num = parseInt(num) + 1;

           var txt = encodeURIComponent(document.getElementById(q).value); 
           var query = 'txt='+txt;
	       myArray[num-1] = document.getElementById(q).value;
           Request(query);
		}
	}
	else
	{
        radio = document.myform.rad.length;
        Send_ajax(radio);
	}
}

function Send1() 
{      
    var txt = encodeURIComponent(document.getElementById('activation').value); 
    var query = 'txt='+txt;
    Request1(query);
}

function Request1(query) 
{ 
	req.open('post', 'checking.php' , true ); 
    req.onreadystatechange = Refresh1; 
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
    req.send(query);              
}


function Refresh1() 
{ 	
	if( req.readyState == 4  && req.status == 200)
    {     			   
         if (req.responseText == 1)
		     location.href = "/prog/dieta_and_3_bonuses.zip";
	     else
		     document.getElementById('err_code').innerHTML = req.responseText;
    }
}