function getBodyScrollTop(){
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
};
function getBodyScrollLeft(){
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
};

function trimString(str){str=this!=window?this:str;return str.replace(/^\s+/g,'').replace(/\s+$/g,'');}
function trimStringUrl(str){str=this!=window?this:str;return str.replace(/http:\/\//g,'').replace(/https:\/\//g,'').replace(/(\/\w+)/g,'').replace(/\/+$/g,'');}
function str_replace(search,replace,subject){return subject.split(search).join(replace);}
function isInteger(s){var i;for (i=0;i<s.length;i++){var c=s.charAt(i);if ((c<"0")||(c>"9")) return false;};return true;}
function is_array(value){var s=typeof value;if(s==='object'){if(value){if(value instanceof Array){s='array';}else{s='not array';};}else{s='null';};};return s;}

function getRadioGroupValue(radioGroupObj){for(var i=0;i<radioGroupObj.length;i++){if(radioGroupObj[i].checked)return radioGroupObj[i].value;};return null;}

function tplnewXMLHttpRequest(){var xmlreq=false;if(window.XMLHttpRequest){xmlreq=new XMLHttpRequest();}else{try{if(window.ActiveXObject){try{xmlreq=new ActiveXObject("Msxml2.XMLHTTP");}catch(e1){try{xmlreq=new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){}}};}catch(e0){}}return xmlreq;}

function newXMLHttpRequest() {
var xmlreq = false; 
if (window.XMLHttpRequest) {
	// Create XMLHttpRequest object in non-Microsoft browsers 
	xmlreq = new XMLHttpRequest();
} else {
	try {
		if (window.ActiveXObject) {
			// Create XMLHttpRequest via MS ActiveX
			try {
				// Try to create XMLHttpRequest in later versions // of Internet Explorer
				xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e1) {
				// Failed to create required ActiveXObject
				try {
					// Try version supported by older versions // of Internet Explorer
					xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e2) {
					// Unable to create an XMLHttpRequest with ActiveX
				}
			}
		}
	} catch (e0) {}
}
return xmlreq;
};

function parseCookie(name){
	var cnt = 0;
	var cookieArray = new Array();
	var cookieList = document.cookie.split("; ");

	for (var i = 0; i < cookieList.length; i++) {
		if (cookieList[i].indexOf(name)==0) {
			var prodval = cookieList[i].split("=");
			cookieArray[cnt] = unescape(prodval[1]);
			cnt++;
		};
	};//for
	return cookieArray;
};
function setCartCntProds(currid,lng){
	$.get('/_ajax.cart-cntprods.php', { 'addtocartid[]':[currid]}, function(data,textStatus)
	{
		if (data != "undefined" && data != null && data.length>0 && textStatus=='success')
		{
			var imgaltlng;
			if (lng==1) imgaltlng='Добавление товара в корзину';
			if (lng==2) imgaltlng='Додавання товару в корзину';
			if (lng==3) imgaltlng='Adding products to cart';

			$("#headcartcount").empty();
			$('<a name="load" style="text-decoration: none;">&nbsp;</a><img src="/images/spinner.gif" width="16" height="16" alt="'+imgaltlng+'" />').appendTo("#headcartcount");
			$("#headcartcount").empty();
			$(data).appendTo("#headcartcount");
			//var arr_cartprodsumall = parseCookie('ddtcrtd');
			//var cartprodsumall = arr_cartprodsumall.length;
			//if (cartprodsumall>0) $('<span> ('+cartprodsumall+')</span>').appendTo("#headcartcount");
		};
	});
};
