var nn4 = (document.layers) ? true : false;
var ie4 = (document.all) ? true : false;
var dom = (document.createTextNode)? true : false; 

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = winW;
	var winHeight = winH;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'auto'
	if (nn4 || ie4 || dom) {
		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes' }
		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes' }
		posX = Math.round((screen.width - winWidth) / 2);
		//alert([screen.width, winWidth, posX]);
		posY = Math.round((screen.height - winHeight) / 2);
		//posCode = (nn4 || dom)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
		posCode = "left="+posX+",top="+posY;
	} else {
		posCode = "";
	}
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=no,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}

function showImage(image, w, h, title)
{
	//var im = new Image();
	//im.src = image;

	var w = Math.min(Math.ceil(screen.availWidth * 2 / 3), w);
	var h = Math.min(Math.ceil(screen.availHeight * 2 / 3), h);
    
	var x = Math.ceil((screen.availWidth - w) / 2);
	var y = Math.ceil((screen.availHeight - h) / 2);
    	
	var newwindow = window.open('', 'mywin', 'resizable=1, menubar=0, status=0, width='+w+', height='+h+', top='+y+', left='+x);
	newwindow.document.write('<html><head><title>'+title+'</title></head>');
	newwindow.document.write('<body style="margin:0;padding:0" onclick="window.close();"><a href="javascript:void(0);"><img src="'+image+'" border="0" title="Закрыть окно"></a></body></html>');
	newwindow.document.close();
}


		function showhideitems(tdiv)
		{
				if(document.getElementById(tdiv).style.display == "none")
				{
					document.getElementById(tdiv).style.display = "block";
				}
				else
				{
					document.getElementById(tdiv).style.display = "none";
				}
		}
        
        function setNewsHeaderWidth() {
            return;
            var agent = navigator.userAgent;
            if(agent.indexOf('Firefox')>-1) {
                document.getElementById('news-header').style.width = '519px';
            }
            if(agent.indexOf('Opera')>-1) {
                document.getElementById('news-header').style.width = '519px';
            }
        }
        
        function showHideSubs(id)
        {
            var item = document.getElementById(id);
            try {
                if (item.style.display == 'none') {
                    if (navigator.appName.indexOf('Explorer') != -1) {
                        item.style.display = 'block';
                    } else {
                        item.style.display = 'table-row';
                    }
                } else {
                    item.style.display = 'none';
                }
            } catch(e){}
        }


function generateFlash(movie, width, height, id, align)
{
  document.write('<object type="application/x-shockwave-flash" data="'+movie+(width==0 ? '' : '" width="'+width)+(height==0 ? '' : '" height="'+height)+'" id="'+id+'" align="'+align+'">');
  document.write('<param name="movie" value="'+movie+'" />');
  document.write('<param name="wmode" value="opaque" />');
  document.write('<param name="autoStart" value="-1" />');
  document.write('</object>');
}


function openFeedbackDialog(code, damaged)
{
	var x = Math.ceil((screen.availWidth - 500) / 2);
	var y = Math.ceil((screen.availHeight - 300) / 2);
    var w = window.open('/price/report/?code='+code+'&damaged='+damaged, 'report', 'left='+x+',top='+y+',width=500,height=300,menubar=0,toolbar=0,location=0,status=0,resizable=0,scrollbars=0');
}
