function doLoad(id_body,value) {
    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT become responseJS).
            document.getElementById(id_body).innerHTML = req.responseJS.res;

            // Write debug information too (output become responseText).
            if (document.getElementById('debug'))
            document.getElementById('debug').innerHTML = req.responseText;
        }
    }
    //document.getElementById(id_body).innerHTML+='<img src="/lib/loading.gif">';
    // Prepare request object (automatically choose GET or POST).
    req.open('POST', '/_include/xml_test.php?hach='+Math.random(), true);
    // Send data to backend.
    req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    // Send data to backend.
    req.send( { q: value } );
}


function doLoad_old(id_body,value) {
    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT become responseJS).
            document.getElementById(id_body).innerHTML = req.responseJS.res;

            // Write debug information too (output become responseText).
            if (document.getElementById('debug'))
            document.getElementById('debug').innerHTML = req.responseText;
        }
    }
    //document.getElementById(id_body).innerHTML+='<img src="/lib/loading.gif">';
    // Prepare request object (automatically choose GET or POST).
    req.open(POST, '/_include/xml_test.php', true);
    // Send data to backend.
    req.send( { q: value } );
}

function chose(act){
	for (var i=1; i<=4; i++)
	document.getElementById("t"+i).style.display="none";
  	document.getElementById("t"+act).style.display="block";
}

function man_time(x) {
if (x>60){
var min=Math.floor(x/60);
var m=Math.floor(x/60)+' мин. ';
var sec=(x-min*60)+' сек.';
var ret=m+sec;
} else {
var sec=x+' сек.';
var ret=sec;
}
return ret;
}

function check_out_q(){
	window.scrollBy(0,0);
	var h=0;
	for (var i=0; i<document.getElementById('f').length; i++){
		if (document.getElementById('f').elements[i].checked==true && (document.getElementById('f').elements[i].name=='a[]' || document.getElementById('f').elements[i].name=='a')){
		h=1;
		break;
		}
	}

	if (h==1) doLoad('id_body',document.getElementById('f'));
	else {
    	if (confirm('Вы не выбрали ответ. Продолжить?')) {
    		document.getElementById('f').innerHTML='<input name="a" type="hidden" value="-1">';
    		doLoad('id_body',document.getElementById('f'));
    	}
    	else {  };
	}
}

function bold_auth(){
if (document.getElementById('auth_link').style.fontWeight!='bold')
document.getElementById('auth_link').style.fontWeight='bold';
else
document.getElementById('auth_link').style.fontWeight='normal';
}

function MM_jumpMenu(){
if (document.getElementById('jumpMenu').value!="")
location="/test/"+document.getElementById('jumpMenu').value;
}




function input_login_pass_t(train_or_sert) {
	scroll(0,0);
	var api = $('#authorization_form').expose({maskId:'mask', api: true}).load();
	switch(train_or_sert)
		{
		case 'training':
		$("#destination_after_login").val(window.location);
		break;

		case 'sertification':
		$("#destination_after_login").val(window.location);
		break;

		case 'company_add':
		$("#destination_after_login").val('/company/add_company/');
		break;
		}

}

function confirmation(message)
	{
	if(window.confirm(message))
		{
		return true;
		}
	else
		{
		window.event.returnValue =  false;
		}
	}

/*
$(document).ready(function()
		{
		if($(".user_info_link_notreg").length)
		{
			$(".user_info_link_notreg").click(function(){

			input_login_pass_t();
			return false;
			});
			}
		});
*/

function put_rate_filter(test_id)
	{
	var location = 	'/rate/?test_id='+test_id;
	window.location = location;
	}





     if (navigator.userAgent.indexOf ("MSIE 6") != -1)
     var brows_ver=6;


    if (brows_ver!=6) {
	$(document).ready(function(){
    $("#left-figures a").hover(

	function() {

			$(this).css({'z-index' : '10'});


            var width= parseInt( $(this).find('img').stop().attr('startwidth'));
            var height= parseInt( $(this).find('img').stop().attr('startheight'));

			var top= height/2;
            var left= width/2;

			$(this).find('img').stop()
			.animate(
						{

						width: width + Math.round(width/10),
						height: height + Math.round(height/10)
						}
						, 400

					);},
		function()
		{
		$(this).css({'z-index' : '0'});
            var width= $(this).find('img').stop().attr('startwidth');
            var height= $(this).find('img').stop().attr('startheight');

			var top= height/2;
            var left= width/2;



			$(this).find('img').stop()
			.animate(
						{
						width: width ,
						height: height
						}
						, 400

					);
        $(this).find('span').remove();
    });


	  $("#right-figures a").hover(

	function() {

			$(this).css({'z-index' : '10'});


            var width= parseInt( $(this).find('img').stop().attr('startwidth'));
            var height= parseInt( $(this).find('img').stop().attr('startheight'));

			var top= height/2;
            var left= width/2;



			$(this).find('img').stop()
			.animate(
						{

						width: width + Math.round(width/10),
						height: height + Math.round(height/10)
						}
						, 400

					);

        },

	function()
		{
		$(this).css({'z-index' : '0'});
            var width= $(this).find('img').stop().attr('startwidth');
            var height= $(this).find('img').stop().attr('startheight');

			var top= height/2;
            var left= width/2;



			$(this).find('img').stop()
			.animate(
						{

						width: width ,
						height: height
						}
						, 400

					);
        $(this).find('span').remove();
    });




	$(".hover_photo").hover(
							function()
								{
								    
								    
								if ($(this).data('std_width')==undefined)
								{    
								width = $(this).width();
								height = $(this).height();
								x = ($(this).css('left'));
								y = ($(this).css('top'));
								x=x.substr(0,x.length -2 );
								if(parseInt(x)!=x) x=0;								
								y=y.substr(0,y.length -2 );
								if(parseInt(y)!=y) y=0;
								
								$(this).data('std_width',width);
								$(this).data('std_height',height);
								$(this).data('std_x',x);
								$(this).data('std_y',y);
								}
								else
								{
								width=$(this).data('std_width');
								height=$(this).data('std_height');
								x=$(this).data('std_x');
								y=$(this).data('std_y');    
								    
								}
								new_width = Math.round(width*1.1);
								new_height = Math.round(height*1.1);														
							    
								
								x_indent = Math.round(x-(new_width  - width)/2);
								y_indent = Math.round(y-(new_height - height)/2);								
																	
								
								$(this).stop().animate({'width': new_width, 'height': new_height, 'top':y_indent, 'left':x_indent},200)
								}
							,
							function()
								{
								$(this).stop().animate({'width': $(this).data('std_width'), 'height':$(this).data('std_height'), 'top':$(this).data('std_y'), 'left':$(this).data('std_x')},200)
								}
							)

});
    }
