// :: AXAHDETILE ===========================================================================================================
var interval;

function getAXAH(url,dWindow,elementContainer){
	var loading = '<table><tr><td colspan="3" height="20">&nbsp;</td></tr><tr>';
        loading+= '<td>&nbsp;</td><td><div class="br_a"></div><table><tr><td class="load">';
        loading+= '<b>Загрузка</b></td><td class="krest" onclick="CloseDetile(\'detile_window\');return false;">&nbsp;</td></tr></table>';
        loading+= '<div class="br_a"></div></td><td>&nbsp;</td></tr></table>';
	document.getElementById(elementContainer).innerHTML = loading;
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
    theHttpRequest.open("GET", url);
    theHttpRequest.send(false);

        function processAXAH(elementContainer){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                   document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
				   var Window = document.getElementById (dWindow)
				   interval = setInterval("TopCorrect('"+dWindow+"')",300);
               } else {
                   document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message: " + theHttpRequest.statusText +"<\/p>";
               }
           }
        }

}

function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

function OpenDetile(url, dWindow, elementContainer)
{
	clearInterval(interval);
	var loading = '<table><tr><td colspan="3" height="20">&nbsp;</td></tr><tr>';
        loading+= '<td>&nbsp;</td><td><div class="br_a"></div><table><tr><td class="load">';
        loading+= '<b>Загрузка</b></td><td class="krest" onclick="CloseDetile(\'detile_window\');return false;">&nbsp;</td></tr></table>';
        loading+= '<div class="br_a"></div></td><td>&nbsp;</td></tr></table>';
	var Content = document.getElementById (elementContainer);
	var Window = document.getElementById (dWindow)
	Content.innerHTML = loading;
	Window.style.display = "block";
	Window.style.left = Math.ceil((screenSize().Width/2) - (Window.offsetWidth/2));
	Window.style.top = document.body.scrollTop - Window.offsetHeight +'px';
	interval = setInterval("OpenLoad('"+url+"', '"+dWindow+"', '"+elementContainer+"')",15);
	//
	//
}

function OpenLoad(url, dWindow, elementContainer)
{
	var Window = document.getElementById (dWindow)
	Window.style.top = Window.offsetTop + 10 + 'px';
	if (Window.offsetTop >= document.body.scrollTop + 30 - 10)
	{	
		Window.style.top = document.body.scrollTop + 30 + 'px';
		getAXAH(url, dWindow, elementContainer);
		clearInterval(interval);
	}
}

function TopCorrect(dWindow)
{
	var Window = document.getElementById (dWindow)
	document.body.offsetHeight
	if (Window.offsetTop > document.body.scrollTop + Math.ceil((screenSize().Height/2) - (Window.offsetHeight/2)) + 10 )
	{	
		Window.style.top = Window.offsetTop - 10 + 'px';
	}
	else
	if (Window.offsetTop < document.body.scrollTop + Math.ceil((screenSize().Height/2) - (Window.offsetHeight/2)) - 10 )
	{	
		Window.style.top = Window.offsetTop + 10 + 'px';
	}
	//Window.style.top =  document.body.scrollTop + Math.ceil((screenSize().Height/2) - (Window.offsetHeight/2))
}

function CloseDetile(dWindow)
{
	var Window = document.getElementById (dWindow)
	clearInterval(interval);
	Window = document.getElementById (dWindow);
	Window.style.display = "none";
}

function screenSize()
{
     var Width, Height; // Объявляем переменные, w - длина, h - высота
     Width = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
     Height = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
      return {Width:Width, Height:Height};
}

// :: FLASH ==========================================================================================================
function flashVersion() 
{
	// Отдельно определяем Internet Explorer
	var ua = navigator.userAgent.toLowerCase();
	var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1);
	// Стартовые переменные
	var version = 0;
	var lastVersion = 20; // На момент 2007 года с запасом
	var i;
	if (isIE) 
	{ // browser == IE
		try 
		{
			for (i = 3; i <= lastVersion; i++) 
			{
				if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+i+'")')) 
				{
					version = i;
    			}
   			}
  		} catch(e) {}
 	} 
 	else 
 	{ // browser != IE
  		for (i = 0; i < navigator.plugins.length; i++) 
  		{
   			if (navigator.plugins[i].name.indexOf('Flash') > -1) 
   			{
    			version = (parseInt(navigator.plugins[i].description.charAt(16)) > version) ? parseInt(navigator.plugins[i].description.charAt(16)) : version;
   			}
  		}
 	}
 	return version;
}

function insFlash(path,fileid,filename,variabili,larghezza,altezza,colore,trasparente)
{
	var flashObject = "<object type=\"application/x-shockwave-flash\" data=\"" + path + filename + "\" id=\"" + fileid + "\" width=\"" + larghezza + "\" height=\"" + altezza + "\">";
	var flashVars = "    <param name=\"flashVars\" value=\"" + variabili +"\">";
	var movie = "    <param name=\"movie\" value=\"" +  path + filename + "\" />";
	var nome = "    <param name=\"name\" value=\"" + fileid + "\" />";

	document.writeln(flashObject);
	document.writeln(movie); 
	document.writeln(flashVars); 
	document.writeln("    <param name=\"loop\" value=\"false\" />");
	document.writeln("    <param name=\"menu\" value=\"false\" />"); 
	document.writeln("    <param name=\"quality\" value=\"high\" />"); 
	document.writeln("    <param name=\"bgcolor\" value=\"#" + colore + "\" />");
	document.writeln(nome);
	if (trasparente == true) 
	{
		document.writeln("    <param name=\"wmode\" value=\"transparent\">");
		var traspEmbed = " wmode=\"transparent\""
	} 
	else 
	{
		var traspEmbed = ""
	}
	var EMBED = "<EMBED src=\"" + path + filename + "\" flashVars=\"" + variabili + "\" loop=\"false\" menu=\"false\" quality=\"high\" bgcolor=\"" + colore + "\" WIDTH=\"" + larghezza + "\" HEIGHT=\"" + altezza + "\" NAME=\"" + fileid + "\"" + traspEmbed + " ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>";
	document.writeln (EMBED);
	document.writeln("</object>"); 
}

function mRandom(byte)
{
	result='';
	for (i=0;i<byte;i++)
		result+=Math.ceil(Math.random()*10)+'';
	return result;
}
//-----------------------------------------------------------------------------------------
function Mot(eld)
{
	eld.style.backgroundColor='#dbdbdb';
}

function Mor(eld)
{
	eld.style.backgroundColor='#b6c5d1';
}

function Mot2(eld)
{
	eld.style.backgroundColor='#8A0B02';
}

function Mor2(eld)
{
	eld.style.backgroundColor='#b3180d';
}
//-----------------------------------------------------------------------------------------

function show_block(id)
{
	v1 = document.getElementById (id);
	v1.style.display = "block";
}

function hide_block(id)
{
	v1 = document.getElementById (id);
	v1.style.display = "none";
}

