function windowOpen( url, windowWidth, windowHeight, isScrollBars )
{

	var sParams = new Array(6);
	var scrollBars;

	sParams[2] = "no";
	sParams[3] = "no";
	sParams[4] = "no";
	if ( isScrollBars == "1" )
		scrollBars = "yes";
	else
		scrollBars = "no";
	sParams[5] = "yes";
	sDesrc = "width=" + windowWidth + ", height=" + windowHeight +
		", status=" + sParams[2] + ", toolbar=" + sParams[3] +
		", menubar=" + sParams[4] + ", scrollbars=" + scrollBars;
	window.open( url , "displayWindow", sDesrc );
}

function toggleList( list )
{

	var children = list.parentNode;
	var ul = children.getElementsByTagName( "ul" )[ 0 ];
	displayValue = getElementComputedStyle( ul, "display" );

	if ( displayValue != "none" )
		ul.style.display = "none";
	else
		ul.style.display = "block";
}

// заимствованная функция
function getElementComputedStyle(elem, prop) 
{ 
  if (typeof elem!="object") elem = document.getElementById(elem); 
  
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+ 
  if (document.defaultView && document.defaultView.getComputedStyle) 
  { 
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase(); 
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop); 
  } 
  
  // external stylesheet for Explorer and Opera 9 
  if (elem.currentStyle) 
  { 
    var i; 
    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2); 
    return elem.currentStyle[prop]; 
  } 
  
  return "";
 }
// end
 
 function GoAndClose( url ) 
{
	window.opener.document.location=url;
	window.close();
}

 function GoNewAndClose( url ) 
{
	windowOpen( url, 1000, 300, 1 );
	window.close();
}

function AddBoxProdCount( prodCount )
{
	var elem = document.getElementById( "boxProdCount" );
	var currProdCount = elem.firstChild.nodeValue ;
	
	if ( currProdCount == "—" )
		currProdCount = 0;
	
	elem.firstChild.nodeValue = String( Number( currProdCount ) + Number( prodCount ) );
}

function AddBoxProdTotalCost( prodCost )
{
	var elem = document.getElementById( "boxProdTotalCost" );
	var currProdTotalCost = elem.firstChild.nodeValue ;

	var newTotalCost = parseFloat( prodCost ) + parseFloat( currProdTotalCost );
	newTotalCost.toFixed( 2 );
	
	elem.firstChild.nodeValue = String( newTotalCost );
}

function AddProdToBoxAndOpenWindow( prodCost, url )
{
	AddBoxProdCount( 1 );
	AddBoxProdTotalCost( prodCost );
	windowOpen( url, 620, 220, 1 )
	
}

function ConfirmDeleteComment( url )
{
	isConfirmed = window.confirm( "Вы действительно хотите удалить этот комментарий?" );
	if ( isConfirmed )
		location.href = url;
}

function AddEmoticon( text )
{
	document.commentForm.userText.value +=" " + text;
}

function IsValidRadio( radio )
{
	var valid = false;
	for ( var currRadioIndex = 0; currRadioIndex < radio.length; currRadioIndex++ )
	{
		if ( radio[ currRadioIndex ].checked )
		{
			return true;
		}
	}
	return false;
}

function ValidateOrderFormStep2( form )
{
	if ( IsValidRadio( form.order ) )
	{
		form.submit.disabled = true;
		return true;
	}
	else
		alert( 'Выберите способ оплаты' );
	return false;
}

function popScreenshotImage(imageURL, imageTitle)
{
        PositionX = 100;
        PositionY = 100;

        defaultWidth  = 500;
        defaultHeight = 500;

        var AutoClose = true;

        // Do not edit below this line...
        // ================================
        if (parseInt(navigator.appVersion.charAt(0))>=4)
        {
                var isNN = (navigator.appName=="Netscape") ? 1 : 0;
                var isOpera = (navigator.appName=="Opera") ? 1 : 0;
                var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
        }

        var optNN = 'scrollbars=no,width=' + defaultWidth + ',height=' + defaultHeight + ',left=' + PositionX + ',top=' + PositionY;
        var optIE = 'scrollbars=no,width=150,height=100,left=' + PositionX + ',top=' + PositionY;
        var optOpera = optNN;

        if (isNN)
        {
			imgWin = window.open('about:blank','',optNN);
        }

		if (isOpera)
		{
			imgWin = window.open('about:blank','',optOpera);
		}

        if (isIE)
        {
			imgWin = window.open('about:blank','',optIE);
        }

        with (imgWin.document)
        {
                writeln('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /><title>Loading...</title><style>body{margin:0px;}</style>');
                writeln('<sc'+'ript>');
                writeln('var isNN,isOpera,isIE;');
                writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
                writeln('isNN=(navigator.appName=="Netscape")?1:0;');
                writeln('isOpera=(navigator.appName=="Opera")?1:0;');
                writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
                writeln('function reSizeToImage(){');
                writeln('if (isIE || isOpera){');
                writeln('window.resizeTo(300,300);');
                writeln('width=300-(document.body.clientWidth-document.images[0].width);');
                writeln('height=300-(document.body.clientHeight-document.images[0].height);');
                writeln('window.resizeTo(width,height);}');
                writeln('if (isNN){');
                writeln('window.innerWidth=document.images["George"].width;');
                writeln('window.innerHeight=document.images["George"].height;}}');
                writeln('function doTitle(){document.title="' + imageTitle + '";}');
                writeln('</sc'+'ript>');

                if (!AutoClose)
                        writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onclick="self.close()">')
                else
                        writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onclick="self.close()" onblur="self.close()">');

                writeln('<img name="George" src='+imageURL+' style="display:block" title="Нажмите левой кнопкой мыши, чтобы закрыть"></body></html>');
                close();
        }
}
function popUp(URL, width, height, left, top)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('" + URL + "', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");
//	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");
}

