$(document).ready(function(){




    var blc=$("#quest").html();
	if ($("#quest").attr("id"))
	$.getJSON("/quest",{test:document.sea.test.value,doms:document.sea3.test.value},datev);
	function datev(sal)
		{
		var alltext = "";
		var cquest = "";
		for (n = 0; n < 1; n++)
			{
			cursel = sal[n];
			alltext = alstr(alltext,cursel);
			if (cursel[5] == "4") cquest = cursel[1];
			}
		if (cquest != "")
			{
			$("#quest").fadeOut("fast",function(){$("#quest").attr("style","margin:16px 0 26px 0px;padding-bottom:6px;border:1px solid #cccccc; width:260px;background: url(/ptsn/img/risu660BE394E788405B99E1DBFA3D38D03A.jpg);background-position: top right;background-repeat:no-repeat; ");$("#quest").html(alltext);$("#quest").fadeIn();});
			}


  $("#clc").live('click', function() {
    $("#quest").html(blc);
    $("#quest").css({'background' : 'none', 'border' : '0'});
    });


      $('.ref').live('mouseover mouseout', function(event) {
  if (event.type == 'mouseover') {
    $(this).css({'color' : '#1936A1', 'text-decoration' : 'underline', 'background-image' : 'url(/ptsn/img/risuD6BDC146D5694E449B8C7DB9FF5989A3.gif)'});

  } else {
   $(this).css({'color' : '#383838', 'text-decoration' : 'none',  'background-image' : 'url(/ptsn/img/risu5BAC90BE29E44C7BAAB90D012627986D.gif)'});

  }
});



            $('.ref').live('click', function(event)
			{
			$("#quest").slideToggle();
			$.getJSON("/quest",{test:document.sea.test.value,doms:document.sea3.test.value, act_tip:$(this).attr("rel"), cquest:cquest},datev1);
			function datev1(sal1)
				{
				for (n = 0; n < (sal1.length); n++)
					{
					cursel = sal1[n];
					alltext = alstr(alltext,cursel);
					}
				$("#quest").html(alltext);
				$("#quest").slideToggle("slow");
				}
			});
		};


});


$(function() {
  $('.flashobj').each(function() {
    var params = $(this).attr("rel").split(":");
	$reg = (!params[0]?params[0]:$(this).attr("rel"));
	$wi = $(this).width();
	$he = $(this).height();
	flashMovieWithVars = $.flash.create(
	{
		swf: ''+$reg+'',
		width: $wi,
		height: $he,
		allowFullScreen: true,
		wmode: 'transparent'
//,
//		flashvars: {
//			battleMode: true,
//			computer: true,
//			players: 2
//		}
	});
	if ($.flash.available) $(this).html(flashMovieWithVars);
	});
});



function alstr(allt,carr)
		{
		return (carr[5] != "4" ? allt + "<div style=\"clear:both;\" class="+ (carr[0] != "" ? "pas_ref":"ref") + " rel=\"" + carr[1] + "\">" : "<div class=\"quest_div\" style=\"\" align=\"center\" >Поучаствуй в опросе!<IMG hspace=0  align=\"right\" width=20 height=20 SRC=\"/i/0.gif\" BORDER=0 id=\"clc\" style=\"cursor: pointer;position:relative; top:-25px; right:3px;\"></div><h2 class=\"quest_h\">")+ carr[2] + (carr[5] != "4" ?
		(carr[0] != "" ? "<TABLE  style=\"margin-bottom:0px;\" BORDER=0 class=\"quest_tbl\" ><TR><TD class=info_box style=\"padding:0px;margin:0px;"+ carr[10] +";font-size:60%\" NOWRAP>"+
		(carr[9] != "0.00" ? "&nbsp;" + carr[9] : "&nbsp;0")
		+"&#37;&nbsp;</td><td  style=\"padding-left:4px;\">" + carr[7] + "</td></tr></table>":"")
		+ "</div>" : "</h2>");
		}

	function show(obj,obj2) {
		var block = document.getElementById(obj);

		if (obj) {
			block.innerHTML = obj2;
		}
	}
	function unshow(obj,obj2) {
		var block = document.getElementById(obj);

		if (obj) {
			block.innerHTML = obj2;
		}
	}


function hi_window(page)
        {
        var url=page;
        var settt=window.open( url, "his" ,"toolbar=no,directories=no,scrollbars=yes,status=yes,resizable=yes,width=500,height=400");
        }


function hiza()
        {
        window.open( "/new.htm", "ahis" ,"toolbar=no,directories=no,scrollbars=no,status=no,resizable=no,width=400,height=200");
        }


function tumbpre(ids,met)
        {
if (met==500)
{        
var siz=(ids.src.substring(ids.src.length-7,ids.src.length-4)==200 ? '200':'0');
ids.outerHTML='<IMG vspace=6 vspace=6 ALIGN=TOP ALT=\"Уменьшить\" class=hlan SRC=/tumb/icons/'+ids.id+'500.jpg id=\"'+ids.id+'\" OnClick=\"tumbpre(this,'+siz+');\">';
}
else
{        
var siz=(met==0 ? '':'200');
ids.outerHTML='<IMG vspace=6 vspace=6 ALIGN=absmiddle ALT=\"Увеличить\" class=hlan SRC=/tumb/icons/'+ids.id+siz+'.jpg id=\"'+ids.id+'\" OnClick=\"tumbpre(this,500);\">';}
       }

function nxtl(elm,nexta,cods)
{
	if (navigator.appName=="Microsoft Internet Explorer")
		{
		if (elm.value.length>=elm.maxLength && cods!=8 && cods!=46 && cods!=9 && cods!=16)
			{
			var oForm=elm.form;
			oForm[nexta].focus();
			return false;
			}
		}
}

function disp(id_obj)
{
var dsp =document.getElementById(id_obj).style;
var himg =document.getElementById('himg'+id_obj);
dsp.display = (dsp.display != 'block' ? 'block' : 'none');
if (himg!=null){
himg.src = (himg.src.indexOf('gr_pl') != -1 ? himg.src.replace('gr_pl','gr_mn') : himg.src.replace('gr_mn','gr_pl'));
}
}

function gr_icon_(id_icon,act)
{
	var cObs=document.getElementById(id_icon);
	var vAls=cObs.src.substr(cObs.src.indexOf(id_icon.substr(0,32))+32,3);
	cObs.src=cObs.src.replace(id_icon.substr(0,32)+vAls,id_icon.substr(0,32)+'0'+((vAls==24 || vAls==50) ? vAls/1+1:vAls/1-1));
}

