/* chizh */
var loadingLinesInterval = undefined;
var loadingPercentInterval = 0;
var loadingPercentNum = [];
var loadingPercentStopNum = 0;
var loadingPercentStep = 0;
var loadingPercentElem = 0;
var sexMale = undefined;

statusLines = [];


var menuArray = [
	'Первый день',
		'Первый день',
			'Первый день',
	'Второй день',
	'Второй день',
		'Второй день',
'Третий день',
'Третий день',
'Третий день',
'Четвертый день',
'Четвертый день',
'Четвертый день',

'Пятый день',
'Пятый день',
'Пятый день',

'Шестой день',
'Шестой день',
'Шестой день',

'Седьмой день',
'Седьмой день',
'Седьмой день'

];
var daysArray = [
'сухарик с чаем или черным кофе',	
'2 яйца, сваренных вкрутую, 80 г, заправленного ложечкой масла, шпината и помидор',	
'одна котлета и 150 г салата из помидоров и зеленого лука с небольшим количеством масла',	
'чай или кофе',	
'200 г морковки варенной и одно яйцо, сваренное вкрутую',	
'250 г салата из мандарина, груши, яблока, банана или иных фруктов',	
'стакан яблочного сока натурального',	
'250 г рыбы, отварной или жаренной, 1 яблоко, 1 помидор',	
'одна мясная котлета с гарниром',	
'стакан сока морковного',	
'100 г салата из зелени, 200 г жареной курицы',	
'2 яйца сваренных вкрутую, 100 г, заправленной маслом, тертой морковки',
'сухарик с чаем без сахара',
'200 г жареного мяса и 150 г, заправленного лимонным соком, салата из капусты',	
'150 г сыра и 100 г, заправленной маслом, тертой моркови',	
'стакан сока морковного',
'200 г курицы, отварной или жареной',	
'300 г различных фруктов'	
	
];


nextStatusLine = function( SLIndex ){
	var next = Math.round( Math.random() * statusLines[SLIndex].array.length );
	jQuery( statusLines[SLIndex].elem ).text( statusLines[SLIndex].array[next] );
}

startStatusLine = function( element, actArray ){
	statusLines.push({
		elem: element,
		array: actArray,
		interval: false
	});
	var statusLineIndex = statusLines.length - 1;
	statusLines[statusLineIndex].interval = setInterval( function(){ nextStatusLine(statusLineIndex); }, 30 );
	
	return statusLineIndex;
}
stopStatusLine = function( SLIndex ){
	jQuery( statusLines[SLIndex].elem ).hide(0);
	clearInterval( statusLines[SLIndex].interval );
}
pauseStatusLine = function( SLIndex ){
	clearInterval( statusLines[SLIndex].interval );
}

function loadingLineMove( loadingLines ){
	if (!jQuery.browser.msie){
		var posXBg = parseInt( jQuery(loadingLines).css('top') );
		if ( posXBg <= -144 ){
			jQuery(loadingLines).css({'top':'0px'});
		}else{
			jQuery(loadingLines).css({'top':posXBg-16+'px'});
		}
	}
	//jQuery(loadingLines).animate( { 'backgroundPosition': '27px 4px' }, 1000, 'linear', function(){ loadingLineMove( loadingLines ); } );
}
function loadingPercentSet(indexLPN){
	loadingPercentNum[indexLPN].num++;
	if ( loadingPercentNum[indexLPN].stopNum <= loadingPercentNum[indexLPN].num ){
		clearInterval(loadingPercentNum[indexLPN].interval);
		jQuery(loadingPercentNum[indexLPN].elem).text(loadingPercentNum[indexLPN].stopNum);
	}else{
		jQuery(loadingPercentNum[indexLPN].elem).text(loadingPercentNum[indexLPN].num);
	}
}
function loadingPercentStart(elem, startNum, stopNum, delay){
	//clearInterval(loadingPercentInterval);
	loadingPercentNum.push({
		elem: elem,
		startNum: startNum,
		stopNum: stopNum,
		interval: false,
		num: startNum
	});
	var indexLPN = loadingPercentNum.length - 1;
	var nums = stopNum - startNum;
	var loadingPercentStep = Math.round( delay / nums );
	
	loadingPercentNum[indexLPN].interval = setInterval( function(){ loadingPercentSet(indexLPN) }, loadingPercentStep );
	return indexLPN;
}
function makeDietAnimate(){
	jQuery('div.alltest:first').hide(0);
	jQuery('#mphStep2').slideDown(500);
	var loadingLines = jQuery('#afterTestScene .loadingLine .line');
	loadingLinesInterval = setInterval( function(){ loadingLineMove( loadingLines ); }, 50 );
	var elem = jQuery('#afterTestScene>div.step1>div.loadingPercent>span.num');
	var elem2 = jQuery('#afterTestScene>div.step2>div.loadingPercent>span.num');
	var elem3 = jQuery('#afterTestScene>div.step3>div.loadingPercent>span.num');
	
	loadingPercentStart(elem, 0, 10, 500);
	jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'10%'}, 500, 'linear');
	
	
	setTimeout( function(){
		var inputVal = parseInt( jQuery('input:checked[name="dinamikavesa"]').attr('value') );
		switch( inputVal ){
			case 1:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 3кг</strong></p>');
			break;
			case 2:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 5 кг</strong></p>');
			break;
			case 3:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 10 кг</strong></p>');
			break;
			case 4:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 20 кг</strong></p>');
			break;
			case 5:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 30 кг</strong></p>');
			break;
			case 6:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Ваш излишний вес: <strong>до 30 кг</strong></p>');
			break;
		}
		loadingPercentStart(elem, 10, 20, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'20%'}, 500, 'linear');
	}, 500 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('input:checked[name="pol"]').attr('value') );
		switch( inputVal ){
			case 1:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный пол: <strong>женский</strong></p>');
				sexMale = false;
			break;
			case 2:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный пол: <strong>мужской</strong></p>');
				sexMale = true
			break;
		}
		loadingPercentStart(elem, 20, 30, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'30%'}, 500, 'linear');
	}, 1000 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('select[name="vozrast"]').attr('value') );
		switch( inputVal ){
			case 17:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный возраст: <strong>менее 18 лет</strong></p>');
			break;
			case 71:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный возраст: <strong>более 70 лет</strong></p>');
			break;
			default:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный возраст: <strong>'+inputVal+' лет</strong></p>');
		}
		loadingPercentStart(elem, 30, 40, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'40%'}, 500, 'linear');
	}, 1500 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('select[name="ves"]').attr('value') );
		switch( inputVal ){
			case 39:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный вес: <strong>менее 40 кг</strong></p>');
			break;
			case 121:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный вес: <strong>более 120 кг</strong></p>');
			break;
			default:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный вес: <strong>'+inputVal+' кг</strong></p>');
		}
		loadingPercentStart(elem, 40, 50, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'50%'}, 500, 'linear');
	}, 2000 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('select[name="visota"]').attr('value') );
		switch( inputVal ){
			case 149:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный рост: <strong>менее 150 см</strong></p>');
			break;
			case 201:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный рост: <strong>более 200 см</strong></p>');
			break;
			default:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранный рост: <strong>'+inputVal+' см</strong></p>');
		}
		loadingPercentStart(elem, 50, 60, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'60%'}, 500, 'linear');
	}, 2500 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('input:checked[name="gruppakrovi"]').attr('value') );
		switch( inputVal ){
			case 5:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранная группа крови: <strong>не известна</strong></p>');
			break;
			default:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Выбранная группа крови: <strong>'+inputVal+' группа</strong></p>');
		}
		loadingPercentStart(elem, 60, 70, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'70%'}, 500, 'linear');
	}, 3000 );
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('input:checked[name="allerg"]').attr('value') );
		switch( inputVal ){
			case 1:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Есть ли пищевые аллергии: <strong>есть, незначительная</strong></p>');
			break;
			case 2:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Есть ли пищевые аллергии: <strong>есть</strong></p>');
			break;
			case 3:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Есть ли пищевые аллергии: <strong>есть, много на что</strong></p>');
			break;
			default:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Есть ли пищевые аллергии: <strong>нет</strong></p>');
		}
		loadingPercentStart(elem, 70, 80, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'80%'}, 500, 'linear');
	}, 3500 );
	
	setTimeout( function(){
		if( !sexMale ){
			var inputVal = parseInt( jQuery('select[name="berem"]').attr('value') );
			switch( inputVal ){
				case 0:
					jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Были ли беременны: <strong>нет</strong></p>');
				break;
				case 1:
					jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Были ли беременны: <strong>да</strong></p>');
				break;
			}
		}
		loadingPercentStart(elem, 80, 90, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'90%'}, 500, 'linear');
	}, 4500 );
	
	setTimeout( function(){ 
		var inputVal = parseInt( jQuery('select[name="zabolevanie"]').attr('value') );
		switch( inputVal ){
			case 0:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Наличие заболеваний щитовидной железы: <strong>нет</strong></p>');
			break;
			case 1:
				jQuery('#afterTestScene .step1 .infoOfStage').append('<p>Наличие заболеваний щитовидной железы: <strong>да</strong></p>');
			break;
		}
		loadingPercentStart(elem, 90, 100, 500);
		jQuery('#afterTestScene>div.step1>div.loadingLine div.line').animate({'width':'100%'}, 500, 'linear', function(){
			setTimeout(function(){
				step2();
			}, 2000);
		});
	}, 5000 );
}
function step2(){
	var elem = jQuery('#afterTestScene>div.step1>div.loadingPercent>span.num');
	var elem2 = jQuery('#afterTestScene>div.step2>div.loadingPercent>span.num');
	var elem3 = jQuery('#afterTestScene>div.step3>div.loadingPercent>span.num');
	var stLineWr1 = jQuery('#afterTestScene>div.step2 div.subInfo1');
	var stLineWr2 = jQuery('#afterTestScene>div.step2 div.subInfo2');
	var stLineElem1 = jQuery('#afterTestScene>div.step2 div.subInfo1 span.stateText:first');
	var stLineElem2 = jQuery('#afterTestScene>div.step2 div.subInfo2 span.stateText:first');
	var stLine1Int = undefined;
	var stLine2Int = undefined;
	
	jQuery('#afterTestScene .step1').slideUp(500);
	jQuery('#afterTestScene .step2').slideDown(500);
	loadingPercentStart(elem2, 0, 20, 2000);
	jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'20%'}, 2000, 'linear');
	jQuery('#afterTestScene>div.step3 div.subInfo1').hide();
	jQuery('#afterTestScene>div.step3 div.subInfo2').hide();
	jQuery(stLineWr1).hide();
	jQuery(stLineWr2).hide();
	
	setTimeout( function(){
		var tEl = jQuery('<p>Подбор конкретных продуктов питания</p>');
		jQuery('#afterTestScene .step2 .infoOfStage').append(tEl);
		setTimeout(function(){ jQuery(tEl).addClass('done'); }, 1500);
		loadingPercentStart(elem2, 21, 40, 2000);
		jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'40%'}, 2000, 'linear');
	}, 2000 );
	setTimeout( function(){
		var tEl = jQuery('<p>Подбор подходящего режима питания</p>');
		jQuery('#afterTestScene .step2 .infoOfStage').append(tEl);
		setTimeout(function(){ jQuery(tEl).addClass('done'); }, 1500);
		loadingPercentStart(elem2, 38, 60, 2000);
		jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'60%'}, 2000, 'linear');
	}, 4000 );
	setTimeout( function(){ 
		var tEl = jQuery('<p>Расчет интервалов приёма пищи</p>');
		jQuery('#afterTestScene .step2 .infoOfStage').append(tEl);
		setTimeout(function(){ jQuery(tEl).addClass('done'); }, 1500);
		loadingPercentStart(elem2, 66, 70, 2000);
		jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'70%'}, 2000, 'linear');
	}, 6000 );
	setTimeout( function(){ 
		var tEl = jQuery('<p>Подбираем оптимальный срок диеты</p>');
		jQuery('#afterTestScene .step2 .infoOfStage').append(tEl);
		setTimeout(function(){ jQuery(tEl).addClass('done'); }, 1500);
		loadingPercentStart(elem2, 83, 88, 2000);
		jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'88%'}, 2000, 'linear');
	}, 10000 );
	setTimeout( function(){ 
		var tEl = jQuery('<p><strong>Составление рациона на основе всех данных</strong></p>');
		jQuery('#afterTestScene .step2 .infoOfStage').append(tEl);
		setTimeout(function(){ jQuery(tEl).addClass('done'); }, 1500);
		loadingPercentStart(elem2, 88, 100, 2000);
		jQuery('#afterTestScene>div.step2>div.loadingLine div.line').animate({'width':'100%'}, 2000, 'linear');
	}, 13000 );
	setTimeout( function(){
		jQuery(stLineWr1).show();
		stLine1Int = startStatusLine( stLineElem1, menuArray );
		setTimeout(function(){
			jQuery(stLineWr1).addClass('done').find('img').attr({'src': 'images/icon_1.png'});
			stopStatusLine(stLine1Int);
		}, 1500);
	}, 16000 );
	setTimeout( function(){
		jQuery(stLineWr2).show();
		stLine2Int = startStatusLine( stLineElem2, daysArray );
		setTimeout(function(){
			jQuery(stLineWr2).addClass('done').find('img').attr({'src': 'images/icon_2.png'});
			stopStatusLine(stLine2Int);
			setTimeout(function(){ step3(); }, 2000);
		}, 1500);
	}, 18000 );
}

function step3(){
	var elem = jQuery('#afterTestScene>div.step1>div.loadingPercent>span.num');
	var elem2 = jQuery('#afterTestScene>div.step2>div.loadingPercent>span.num');
	var elem3 = jQuery('#afterTestScene>div.step3>div.loadingPercent>span.num');

	jQuery('#afterTestScene .step2>.loadingLine').slideUp(100);
	jQuery('#afterTestScene .step2>.loadingPercent').slideUp(100);
	
	// Заполнение верхней полосы
	var time1 = 7000;
	
	// Заполнение второй полосы
	var time2 = Math.floor( time1 / 3 );
	
	// Заполнение 3-ей полосы, начинается после второй полосы
	var time3 = 8500;
	
	//jQuery('#afterTestScene .step2').slideUp(500);
	jQuery('#afterTestScene .step3').slideDown(500);
	
	loadingPercentStart(elem3, 0, 100, time1);
	jQuery('#afterTestScene>div.step3>div.loadingLine div.line').animate({'width':'100%'}, time1, 'linear');
	
	
	setTimeout( function(){
		jQuery('#afterTestScene .step3>.loadingLine').slideUp(100);
		jQuery('#afterTestScene .step3>.loadingPercent').slideUp(100);
		jQuery('#afterTestScene .step3>.subInfoOfStage').slideUp(100);
		jQuery('#afterTestScene .step3 .hiddened').show(300);
	}, time1 );
}
/* chizh */
function ctestname()
{
	var testname = 'locationpath';
	testname = testname.substr(testname.lastIndexOf('/')+1);
	testname = testname.substr(testname.lastIndexOf('-')+1);
	testname = testname.substr(0,testname.lastIndexOf('.'));
	return testname;
}
//alert(ctestname());
var i=0; var max=0;
            function next_q() {
                jQuery('div.question#'+(i-1)).hide();
                jQuery('div.question#'+i).show();
                jQuery('#qcurrent').text(i);
				if ( i == 3 ){
					var inputVal = parseInt( jQuery('input:checked[name="pol"]').attr('value') );
					switch( inputVal ){
						case 1:
							sexMale = false;
							var html = jQuery('div.toVarQue>div.girl').html();
							jQuery('div.question.variableQue').html(html);
						break;
						case 2:
							sexMale = true;
							var html = jQuery('div.toVarQue>div.man').html();
							jQuery('div.question.variableQue').html(html);
						break;
					}
				}
				/*
				if ( i == 9 && sexMale){
					savedata(i-1);
					i++;
					next_q();
					return;
				}
				*/
				savedata(i-1);
                i++;
                if(i > max) {
					//alert('!');
					//window.scrollTo(0,0);
					
					jQuery('#afterTestScene .step2').slideUp(0);
					jQuery('#afterTestScene .step3').slideUp(0);
					jQuery('#afterTestScene .step3 .hiddened').hide(0);
					makeDietAnimate();
					init();
                }
            }

function init() {
			//makeDietAnimate();
			
            jQuery('div.question').hide();
			//jQuery('div.question select').each(function(){if (this.id!='country_select') this.selectedIndex=-1});
            max=1;
            jQuery('div.question').each(function() {
                this.id = max;
                max++;
            });
            jQuery('#qmax').text(max-1);
            i=1;
			//i=loadall(i);

            next_q();
            
            jQuery('#test_next_image').click(pressbtn);
			jQuery('#country_select').change(function() {
            var id = jQuery('#country_select').val();
            if(!id) jQuery('#sms_inp').hide();
            else jQuery('#sms_inp').show();
        });

			}
    
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	//alert(c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()));
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function isselected()
{
	var a=false;
	if (jQuery('input', jQuery('div.question#'+(i-1))).length>0) jQuery('input', jQuery('div.question#'+(i-1))).each(
	function(){
		if((this.type=='checkbox')||(this.type=='radio'))a|=this.checked;
		if((this.type=='text'))a|=(this.value.length > 0);
	});
	if (jQuery('select', jQuery('div.question#'+(i-1))).length>0) a = (jQuery('select', jQuery('div.question#'+(i-1)))[0].selectedIndex!=-1);
	if (jQuery('textarea', jQuery('div.question#'+(i-1))).length>0) jQuery('textarea', jQuery('div.question#'+(i-1))).each(function(){
		a|=(this.value.length > 0);
	});
	return a;
}

function pressbtn()
{
	if (isselected()){
		next_q();
	} else {
		alert('Нет выбранного ответа!');
	}
}

function savedata(idx)
{
	var vls='';
	if (jQuery('input', jQuery('div.question#'+(idx))).length>0) jQuery('input', jQuery('div.question#'+(i-1))).each(
	function(){
		vls = ";"+this.checked?'1':'0';
	});
	if (jQuery('select', jQuery('div.question#'+(idx))).length>0) vls = ";"+this.selectedIndex;
	if (jQuery('textarea', jQuery('div.question#'+(idx))).length>0) jQuery('textarea', jQuery('div.question#'+(i-1))).each(function(){
		vls = ";"+this.value;
	});	
	//alert(ctestname()+'_'+i.toString()+' : '+vls.substr(1));
	setCookie(ctestname()+i.toString(),vls.substr(1),7);
}

function savedata(idx)
{
	if (idx==0) return;
	var vls='';
	if (jQuery('input', jQuery('div.question#'+(idx))).length>0) jQuery('input', jQuery('div.question#'+(idx))).each(
	function(){
		if ((this.type=='checkbox')||(this.type=='radio'))
		{
			vls += "_"+(this.checked?'1':'0');
		} else if ((this.type=='text')){
			vls += "_"+this.value;
		}
	});
	if (jQuery('select', jQuery('div.question#'+(idx))).length>0) vls = ";"+jQuery('select', jQuery('div.question#'+(idx)))[0].selectedIndex;
	if (jQuery('textarea', jQuery('div.question#'+(idx))).length>0) jQuery('textarea', jQuery('div.question#'+(idx))).each(function(){
		vls = ";"+this.value;
	});	
	//alert(ctestname()+'_'+idx.toString()+' : '+vls.substr(1));
	setCookie(ctestname()+'_'+idx.toString(),vls.substr(1),7);
}

function loaddata(idx)
{
	if (idx==0) return;
	var vls = getCookie(ctestname()+'_'+idx.toString());
	if (jQuery('input[type=text]', jQuery('div.question#'+(idx))).length>0)
	{
		jQuery('input[type=text]', jQuery('div.question#'+(idx)))[0].value = vls;
	}
	if (jQuery('textarea', jQuery('div.question#'+(idx))).length>0)
	{
		jQuery('textarea', jQuery('div.question#'+(idx)))[0].value = vls;
	}
	if (jQuery('input[type=radio]', jQuery('div.question#'+(idx))).length+jQuery('input[type=checkbox]', jQuery('div.question#'+(idx))).length>0){
			 
		vls = vls.split('_');
		var items = jQuery('input', jQuery('div.question#'+(idx)));
		for (var j=0; j<vls.length; j++)
		{
			 items[j].checked = parseInt(vls[j])!=0;
		}
	}
	
	if (jQuery('select', jQuery('div.question#'+(idx))).length>0) {
		jQuery('select', jQuery('div.question#'+(idx)))[0].selectedIndex = vls;
	}
	
	//alert(ctestname()+'_'+idx.toString()+' : '+vls.substr(1));
}

function loadall(i)
{
	while (getCookie(ctestname()+'_'+i.toString()) && (getCookie(ctestname()+'_'+i.toString())!=''))
	{
		loaddata(i);
		i++;
	}
	return i;
}
jQuery(document).ready(function(){
	jQuery('#mphStep2').slideUp(0);
	init();
});