$(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 < (sal.length); 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,doms3:document.sea.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  align=\"left\" 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 align=\"left\"  class=\"quest_h\" style=\"padding-left: 25px;color:#878787\">")+ carr[2] + (carr[5] != "4" ?
		(carr[0] != "" ? "<TABLE  style=\"margin-bottom:0px;margin-left:-2px;\" BORDER=0 class=\"quest_tbl\" ><TR><TD align=\"left\" 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 hi_window(page)
        {
        var url=page;
        var settt=window.open( url, "tokareliaaliance-proru" ,"toolbar=no,directories=no,scrollbars=yes,status=yes,resizable=yes,width=600,height=500");
        }


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 GC(obj)
	{
		if (obj.style.backgroundColor=='')
		{obj.style.backgroundColor='#FFFFCC';}
		else
		{obj.style.backgroundColor='';}
	}

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 disp_inline(id_obj)
{
var dsp =document.getElementById(id_obj).style;
var himg =document.getElementById('himg'+id_obj);
//dsp.className = (dsp.className != 'info_box' ? 'info_box' : 'info_box_n');
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 makeRequest(url) 
	{
	document.getElementById('res_div').innerHTML = "Подождите, производится проверка технической возможности подключения ADSL на номер"
	var http_request = false;
	if (window.XMLHttpRequest) 
		{ // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
			{
			http_request.overrideMimeType('text/html; charset=windows-1251');
			}
		} else if (window.ActiveXObject) 
		{ // IE
		try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e) 
			{
			try 
				{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}

		if (!http_request) 
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}
		http_request.onreadystatechange = function() { alertContents(http_request); };
		http_request.open('GET', url, true);
		http_request.send(null);
	}

function alertContents(http_request) 
	{
	if (http_request.readyState == 4) 
		{
		if (http_request.status == 200) 
			{
			document.getElementById('res_div').innerHTML = http_request.responseText;
			} else 
			{
			alert('There was a problem with the request.'+http_request.status);
			}
		}
	}


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 gr_icon_(id_icon,act)
{
	var cObs=document.getElementById(id_icon);
	var vAls=cObs.src.substr(cObs.src.indexOf(id_icon)+32,3);
	cObs.src=cObs.src.replace(id_icon+vAls,id_icon+'0'+((vAls==24 || vAls==50) ? vAls/1+1:vAls/1-1));
}


var useRedirect = true; 
// #############################################
// System globals
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var maxVersion = 7;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

var isIE = ((navigator.appVersion.indexOf("MSIE") != -1) && (navigator.appVersion.indexOf("MSIE") == navigator.appVersion.lastIndexOf("MSIE"))) ? true : false; // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

function detectSpecialFlash(requiredVersion,flashcode,noflash) {

if (isIE && (navigator.appVersion.indexOf("MSIE 5.") != -1 || navigator.appVersion.indexOf("MSIE 6.") != -1) && !window.opera){
    //alert(navigator.appVersion);
    detectFlash(requiredVersion,flashcode,noflash);
} else document.write(noflash); 

}

function detectFlash(requiredVersion,flashcode,noflash) { 
    
if(isIE && isWin){
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');
    document.write('jsVersion = 1.0 \n');
    document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
    document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
    document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
    document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n'); 
    document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n'); 
    document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n'); 
    document.write('</SCR' + 'IPT\> \n'); 
}

if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
    || navigator.plugins["Shockwave Flash"]) {

        var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
        var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
        var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
        flash2Installed = flashVersion == 2; 
        flash3Installed = flashVersion == 3;
        flash4Installed = flashVersion == 4;
        flash5Installed = flashVersion == 5;
        flash6Installed = flashVersion >= 6;
        flash7Installed = flashVersion >= 7;
    }
}

for (var i = 2; i <= maxVersion; i++) { 
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
}

    //alert("version detected: " + actualVersion);
    if (actualVersion < requiredVersion) {
        document.write(noflash);
        return 0;
    }
    else {
        document.write(flashcode);
        return 1;
    }

}

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'));
}
}


