// JavaScript Document
var isIE = document.attachEvent != null;
var isGe = !document.attachEvent && document.addEventListener;

function $(id)
{
	return document.getElementById(id);
}

function $S(id)
{
	return document.getElementById(id).style;
}

function backgroundColor(oId, color)
{
	$S(oId).backgroundColor=color;
}

function rep_over(oId)
{
	$S(oId).color="#ffffff";
}
	
function rep_out(oId)
{
	$S(oId).color="#fff";
}

function locto(oId)
{
	location.href=$(oId).href;
}

function show(oId)
{
	$S(oId).display='block';
}

function screenWidth()
{
	if(isIE)
	{
		var width = (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
	}

	if(isGe)
	{
		var width = (document.documentElement.scrollWidth > document.documentElement.offsetWidth)?document.documentElement.scrollWidth:document.documentElement.offsetWidth;
	}
		
	return width;
}

function screenHeight()
{
	if(isIE)
	{
		var height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	}

	if(isGe)
	{
		var height = (document.documentElement.scrollHeight > document.documentElement.offsetHeight)?document.documentElement.scrollHeight:document.documentElement.offsetHeight;
	}
	return height;
}

function hide(oId)
{
	$S(oId).display='none';
}


var zaglushka=new Object();
zaglushka.on=function()
{
	var z=$S('zaglushka');
	z.width=screenWidth()+'px';
	z.height=screenHeight()+'px';
	z.display='block';
}

zaglushka.off=function()
{
	var z=$S('zaglushka');
	z.display='none';
}


function authWindow(oId)
{
	if($('mm6').innerHTML!='Выход')
	{
		zaglushka.on();
		var w=screenWidth()/2-150;
		$S(oId).left=w+'px';
		$S(oId).zIndex=1000;
		show(oId);
	}
	else
	{
		document.forms[0].submit();	
	}
}

function authWindowClose(oId)
{
	zaglushka.off();
	hide(oId);
}

//id out functions
function ow(url, param, w, h)
{
var e; 
var posX = (screen.width - w) / 2;
var posY = (screen.height - h) / 2;
e=window.open(url+param, 'Pic', 'scrollbars=yes,width=' + w + ',height=' + h +",top=" + posY + ",left=" + posX);
if (window.focus) { e.focus(); }
}

function img_preview(id)
{
	var img=new Image();
	img=document.getElementById(id);
	var g;
	g='?src='+img.src;
	ow('catalog/preview/',g, 450, 350);
}

function to_img(id)
{
var img=new Image();
img=document.getElementById('im_win1');
var fild=new Image();
fild=document.getElementById(id);
img.src=fild.src;
}

function videoInstrWindow()
{
	var win=document.getElementById('videocont');
	if(win.style.display=='none')
		{
			win.style.display='block';
		}
		else
		{
			
			win.style.display='none';
		}
		
}


function createCSS(selector, declaration) {
        // test for IE
        var ua = navigator.userAgent.toLowerCase();
        var isIE = (/msie/.test(ua)) && !(/opera/.test(ua)) && (/win/.test(ua));

        // create the style node for all browsers
        var style_node = document.createElement("style");
        style_node.setAttribute("type", "text/css");
        style_node.setAttribute("media", "screen");

        // append a rule for good browsers
        if (!isIE) style_node.appendChild(document.createTextNode(selector + " {" + declaration + "}"));

        // append the style node
        document.getElementsByTagName("head")[0].appendChild(style_node);

        // use alternative methods for IE
        if (isIE && document.styleSheets && document.styleSheets.length > 0) {
                var last_style_node = document.styleSheets[document.styleSheets.length - 1];
                if (typeof(last_style_node.addRule) == "object") last_style_node.addRule(selector, declaration);
        }
};
//end
