function conf()
{
  if( confirm( 'Are you sure?' ) ) return true
  else return false;
}

function openAWindow2( pageToLoad, winName, width, height, center){

xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) &&(center)){
 xposition = (screen.width - width) / 8;
 yposition = (screen.height - height) / 3;
}

args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=1,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only

window.open( pageToLoad, winName, args );

}

function openAWindow( pageToLoad, winName, width, height, center){

xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) &&(center)){
 xposition = (screen.width - width) / 8;
 yposition = (screen.height - height) / 3;
}

args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only

window.open( pageToLoad, winName, args );

}

function void_() {
}

function xget(id) {
	if(document.getElementById) return document.getElementById(id);
	if(document.all) return document.all[id];
	return null;
}

function detect_user_agent(){
	navigator.DOM=!!(document.getElementById?1:0);
	navigator.OPERA=!!(window.opera);
	navigator.OPERA5=!!(navigator.OPERA&&navigator.userAgent.indexOf("pera 5")>0);
	navigator.OPERA6=	!!(navigator.OPERA&&navigator.userAgent.indexOf("pera 6")>0);
	navigator.IE8=		!!(navigator.appVersion.indexOf("IE 8")>0&&navigator.DOM&&!navigator.OPERA?1:0);
	navigator.IE7=		!!(navigator.appVersion.indexOf("IE 7")>0&&navigator.DOM&&!navigator.OPERA?1:0);
	navigator.IE6=		!!(navigator.appVersion.indexOf("IE 6")>0&&!navigator.IE7&&!navigator.IE8&&navigator.DOM&&!navigator.OPERA?1:0);
	navigator.IE5=		!!(navigator.appVersion.indexOf("IE 5")>0&&navigator.DOM&&!navigator.OPERA?1:0);
	navigator.IE4=		!!(document.all&&!navigator.DOM?1:0);
	navigator.IE=		!!(navigator.IE4||navigator.IE5||navigator.IE6);
	navigator.MAC=		!!(navigator.userAgent.indexOf("Mac")>0);
	navigator.NS6=		!!(navigator.DOM && parseInt(navigator.appVersion)>4?1:0);
	navigator.NS4=		!!(document.layers && !navigator.DOM?1:0);
	navigator.DOMCORE1=	!!(typeof(document.getElementsByTagName)!='undefined' && typeof(document.createElement)!='undefined');
	navigator.DOMCORE2=	!!(navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined');
	navigator.DOMHTML=	!!(navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined');
	navigator.DOMCSS1=	!!(navigator.NS6||navigator.IE)	;
	if(navigator.DOMCORE1&&!navigator.OPERA)
	{	var check_element=document.createElement('p');
		navigator.DOMCSS2=!!(typeof(check_element)=='object');
	} else	navigator.DOMCSS2=!!(false)
	navigator.DETECTED=	(	navigator.OPERA||navigator.OPERA6||navigator.OPERA5||navigator.IE||navigator.IE6||navigator.IE5||navigator.IE4||navigator.MAC||navigator.NS6||navigator.NS4||navigator.DOM||navigator.DOMHTML||navigator.DOMCORE1||navigator.DOMCORE2||navigator.DOMCSS1||navigator.DOMCSS2	);
	}


function setf(id1,v1) {
	if (xget(id1)) xget(id1).value=v1;
	if (xget('arrFilter_form')) {xget('arrFilter_form').submit()};
	return false;
}
function setf2(id1,v1,id2,v2) {
	if (xget(id1)) xget(id1).value=v1;
	if (xget(id2)) xget(id2).value=v2;
	if (xget('arrFilter_form')) xget('arrFilter_form').submit();
	return false;
}
function fdel(id1) {
	if (xget(id1)) xget(id1).value='';
	if (xget('arrFilter_form')) xget('arrFilter_form').submit();
	return false;
}
function fdel2(id1,id2) {
	if (xget(id1)) xget(id1).value='';
	if (xget(id2)) xget(id2).value='';
	if (xget('arrFilter_form')) xget('arrFilter_form').submit();
	return false;
}

function setcompare(id1,v1) {
	if (xget(id1)) xget(id1).value=v1;
	if (xget('arrFilter_form')) xget('arrFilter_form').submit();
	return false;
}

function makeHttpRequest(url, callback_function, return_xml) {
  var http_request = false;

  if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType && return_xml == 'xml') {
			 http_request.overrideMimeType('text/xml');
		}
  } 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('Unfortunately your browser doesn\'t support this feature.');
		return false;
  }

  http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			 if (http_request.status == 200) {
				  if (return_xml == 'xml') {
						eval(callback_function + '(http_request.responseXML)');
				  } else {
						eval(callback_function + '(http_request.responseText)');
				  }
			 } else {
				  alert('There was a problem with the request. (Code: ' + http_request.status + ')');
			 }
		}
  }
  http_request.open('GET', url, true);
  http_request.send(null);
}

function getTestimonial() {
	var coll = document.getElementsByTagName('INPUT');
	var k=0;
	var cv="";
	if (coll!=null) {
		for (i=0; i<coll.length; i++)
		{
			if (coll[i].id.search(/compare_/i)==0 && coll[i].value.length>0)
			{
				if (coll[i].checked){
					cv=coll[i].value;
					makeHttpRequest(coll[i].value, 'displayTestimonial', 'text');
					k=1;
				}
			}
		}
	}
	if (cv.length>0) makeHttpRequest(cv, 'displayTestimonial2', 'text');
}
function displayTestimonial(text) {
}
function displayTestimonial2(text) {
	//window.open('/catalog/compare.php');
}


function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return "";
}

function setfavorite (id) {
pathname = location.pathname;
myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime()+ 60 * 1000 * 60 * 60 * 24);
SetCookie('favorites',GetCookie('favorites')+id+'-|-',largeExpDate,'/');

alert('Этот товар сохранён в Ваших закладках.');
}

function setfavorites (id) {
pathname = location.pathname;
myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime()+ 60 * 1000 * 60 * 60 * 24);
SetCookie('favorites',GetCookie('favorites')+id+'-|-',largeExpDate,'/');
}

function showcount (id) {
	var coll = document.getElementsByTagName('DIV');
	if (coll!=null) {
		for (i=0; i<coll.length; i++)
		{
			if (coll[i].id.search(/count_div_/i)==0)
			{
				coll[i].style.display='none';
			}
		}
	}
	if (xget("count_div_"+id))
	{
		xget("count_div_"+id).style.display='block';
	}
}
function addcart (id) {
	if (xget("count_"+id+"_qty") && xget("count_"+id+"_url"))
	{
		var s=xget("count_"+id+"_url").value+'&qty='+xget("count_"+id+"_qty").value;
		location.href=s;
	}
}

function cptRefresh() {
      var countOfexec = 0;
      var code = $("#sid").val();

           $.get("/captcha/captcha.php", function(data){
              $("#sid").val(data);
              $('#code').attr("src", "/bitrix/tools/captcha.php?captcha_sid="+data);
           });


//           var timestamp = new Date();
//           $('#code').attr("src", "/bitrix/tools/captcha.php?captcha_sid="+code+"&timestamp="+timestamp.getTime());

return false;
}
//var refresh = cptRefresh();


function EnsureNumeric(evt)
{
    var evt = window.event || evt;
//	alert(evt.keyCode);
    if ((evt.keyCode!=8 && evt.keyCode!=45 && evt.keyCode!=16 && evt.keyCode!=37 && evt.keyCode!=38 && evt.keyCode!=39 && evt.keyCode!=40 && evt.keyCode!=45 && evt.keyCode!=46 && evt.keyCode!=13 && evt.keyCode!=17 && evt.keyCode!=18 && evt.keyCode <48) || evt.keyCode >57)
    {
		evt.returnValue=false; //for IE
		if(evt.preventDefault)  //for FF
		{
			evt.preventDefault();
			evt.stopPropagation();
		}
    }
}

function showDivSendMessage(id,name)
{
	jQuery('div.popup').css('top',jQuery(document).scrollTop()+100);
	jQuery('.oneService').show();jQuery('.manyServices').hide();
	jQuery('.oneServiceCompany').html(name);jQuery('.oneIdServiceCompany').val(id);
	jQuery('div.popup').fadeIn(300);return false;
}

function showOrderManyServices()
{
	jQuery('div.popup').css('top',jQuery(document).scrollTop()+100);
	jQuery('.oneService').hide();jQuery('.manyServices').show();
	jQuery('.oneIdServiceCompany').val("");
	jQuery('.manyServices > p > .list').html("");
	jQuery('input[name=SERVICEORDERID]:checked').each(function(){
		jQuery('.oneIdServiceCompany').val(jQuery(this).val()+'|'+jQuery('.oneIdServiceCompany').val());
		jQuery('.manyServices > p > .list').html(' - '+jQuery(this).attr('title')+"<br/>"+jQuery('.manyServices > p > .list').html());
	});
	if(jQuery('.manyServices > p > .list').html()==""){
		alert("Выберите услуги для заказа");
		return false;
	}
	jQuery('div.popup').fadeIn(300);return false;	
}

function hideDivSendMessage()
{
	jQuery('div.popup').fadeOut(300);return false;
}
