if(!window.mmpa){
    window.mmpa={
		domain:'price.ua',   
		server: 'cg2.maxymiser.com/alpha2/productassist.ashx',
	    cookie_domain:'',	    
	    tpixel:false,
	    cprefix:'mm',

		SetPurchase:function(orderid, productid, count, amount, currency){this._purchases.push({order_id:orderid,product_id:productid,count:count,amount:amount,currency:currency});},
		SetRating:function(prod_or_attr, type_id, ratetype, rating){this._ratings.push({prod_or_attr:prod_or_attr,type_id:type_id,rate_type:ratetype,rating:rating});},
		SetRule:function(attr1, attr2, is_inclusion){this._filters.push({attr1:attr1,attr2:attr2,is_inclusion:is_inclusion?1:0});},		
		SetMethod:function(method, num_recs, array, fields){this._methods.push({method:method,num_recs:num_recs,array:typeof array=='undefined'?'recommendation':array,fields:typeof fields=='undefined'?'id':fields});},
    	PARequest:function(callback){var _t=this;_t._callback[++_t._request_id]=callback;_t._Tag(_t._TagUri());_t._Clear();},
	    SetCookie:function(n,v,d){var exp=new Date(),_t=this,_h=_t._Host();exp.setTime(exp.getTime()+d*86400000);
		_t._d.cookie=escape(_t._PN(n))+'='+escape(v)+(_h.length?';domain='+_h:'')+';path=/'+(d>0?(';expires='+exp.toGMTString()):'')},
		GetCookie:function(n){var _t=this;return unescape(_t._ValByKey(_t._d.cookie,escape(_t._PN(n)),'=',';'))},
		// tools for ajax call
		CreateXmlRequest:function(){	
			try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e){}
			try{return new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
			try{return new XMLHttpRequest();}catch(e){}
		    this.error+='Ajax is not supported by your browser.';
			return null;},
		GetAjaxContent:function(url){	
			try {var xml_req = this.CreateXmlRequest();xml_req.open('GET',url,false);
			xml_req.send(null);if(xml_req.status<400)return xml_req.responseText;
			else return undefined;}catch(e){return undefined;}
			return undefined;},

		//PRIVATE:	
		_jsver:'1.0',
		_fv:{},
		_methods:[],
		_purchases:[],_ratings:[],_filters:[],		 
		_callback:{},
		_request_id:0,
		_async:true,
		_debug:false,_d:document,_l:window.location,
		_ValByKey:function(str,key,f,r)/*f-field, r-array of record separators*/{
		    var s='',i2,i3,i1=str.indexOf(key);if(i1<0)return'';
		    if(i1<0||(i2=str.indexOf(f,i1+key.length))<0)return'';
		    i1=i2+f.length;i3=str.indexOf(r,i1);
		    return this._T(s=i3<0?str.substring(i1):str.slice(i1,i3))},	
		_T:function(str){return str.replace(/^\s+/g,'').replace(/\s+$/g,'')},
	    _L:function(str){return str.toLowerCase()},	
	    _TL:function(str){return this._L(this._T(str))},
	    _PN:function(str){return this._TL(this.cprefix+str)},
	    _Host:function(){
		    var _t=this,_h=_t._TL(_t._l.hostname),_d=_t._TL(_t.domain),_d2=_t._TL(_t.cookie_domain);
		    if (_h=='localhost')return '';if(_d2.length==0)_d2=_d;if(_d2[0]=='.')_d2=_d2.substring(1);if(_h.indexOf(_d2)>=0)_h=_d2;
		    return _h.replace('www.', '')},		
		//PRIVATE:
		_SerializeArray:function(arr){
			var row,el,res='',col='',rec;
			for(row in arr){col='';
				for(el in arr[row]){rec=arr[row][el];if(typeof rec=='undefined')rec='';col+=escape(rec)+',';}
				if(col.length>0)col=col.slice(0,-1);res+=col+';';}
			return escape(res);},
	    _Tag:function(uri){var _t=this,_n,px=_t.tpixel,tp='text/javascript',d=_t._d,i,_a,id='_mmtag_'+Math.random();		    
		    if(_t._async){_n=d.createElement(px?'img':'script');_n.id=id;_n.src=uri;if(!px){_n.type=tp;_n.charset='utf-8'};
			_a=d.getElementsByTagName(px?'body':'head');if(_a&&_a.length)_a[0].appendChild(_n)
		    }else{_t._d.write(px?'<img id="'+id+'" src="'+uri+'"\/>':'<scr'+'ipt id="'+id+'" type="'+tp+'" charset="utf-8" src="'+uri+'"><\/scr'+'ipt>')}
		    return id },		          	
    	_TagUri:function(){
		    var _t=this,_p=_t._l.protocol,s='',s1='',i,_v,_k;
			for(_k in _t._fv)s1+=_k+'='+_t._fv[_k]+';';s1.slice(0,-1)			
		    s=_t.server+'?'+'fv='+escape(s1);
			s+='&pu='+_t._SerializeArray(_t._purchases)+'&rat='+_t._SerializeArray(_t._ratings)
		       +'&rul='+_t._SerializeArray(_t._filters)+'&rh='+escape(_t.GetCookie('rh'))
		       +'&met='+_t._SerializeArray(_t._methods)+'&ri='+_t._request_id;
		    s+=(_t.tpixel?'&tp=1':'')+'&jsver='+_t._jsver;
		    return s.indexOf('://')>0?s:((_p!=''?_p:'http:')+'//'+s)
		},		
	    _Init:function(){this._Clear();var _t=this,_fv=_t._fv,_u=_t._l.href,_r=_t._d.referrer,_rnd=(''+Math.random()).substring(0,5),_id;
		    _fv.dmn=_t.domain;_t.SetCookie('tst',_rnd,10);_fv.cok=(_t.GetCookie('tst')==_rnd?1:0);
		    if(_r.length>256)_r=_r.substring(0,256);if(_u.length>1024)_u=_u.substring(0,1024);
		    _fv.ref=escape(_r);_fv.url=escape(_u); 
		},
	    _Clear:function(){var _t=this;_t._methods=[];_t._purchases=[];_t._ratings=[];}
    }
    window.mmpa._Init()
}
var _mmCapt="";
		function _mmBuild(arr)
		{
			var res="";
			if (!arr||arr=='undefined') return false;
				res+="<table width='100%'  cellpadding='2' border='0' align='center' style='marin-bottom:10px;' cellspacing='0'><tr><td height='24' colspan='5' background='/img/sec1_fon.gif' style='color: rgb(255, 255, 255); text-align:left;' class='text13bw'>"+_mmCapt+"</td> </tr><tr>";
			for (var i=0; i<5; i++) 
			{ 
			
				res+="<td style='width:20%;'>";
				if (i>=arr.length) {res+="</td>";continue;}
				res+="<table height='100%' cellspacing='1' cellpadding='0' border='0' width='100%' style='font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px;line-height: normal;color: rgb(64, 64, 64); text-decoration: none;'><tbody><tr><td align='center' valign='middle' rowspan='2'><a  target='_blank' style='' href='"+arr[i].pageurl+"'  onmousedown=\"$.cookie('last_action_id', 60, { expires: 0.01, path: '/'}); pageTracker._trackPageview('/priceua_blocks/banners_split_click_by_60');\">";
				if (arr[i].imageurl=="") res+="<img border='0' alt='' src='/img/phone.jpg' />";
				else res+="<img border='0' alt='' src='"+arr[i].imageurl+"' />";
				res+="</a></td>";
				res+="<td style='text-align: center;'><a  target='_blank' href='"+arr[i].pageurl+"' style='font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(21, 78, 115); text-decoration: underline;' onmousedown=\"$.cookie('last_action_id', 60, { expires: 0.01, path: '/'}); pageTracker._trackPageview('/priceua_blocks/banners_split_click_by_60');\"><b>";
				res+=arr[i].name+"</b></a></td></tr>";
				res+="<tr><td style='text-align: center;'><a  target='_blank' href='"+arr[i].pageurl+"' style='font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(21, 78, 115); text-decoration: underline;' onmousedown=\"$.cookie('last_action_id', 60, { expires: 0.01, path: '/'}); pageTracker._trackPageview('/priceua_blocks/banners_split_click_by_60');\">";
				res+=arr[i].description;
				res+="</a></td></tr></tbody></table>";
				res+="</td>";
			}
res+="</tr></table>";
return res;
		}
			function mmRender ()
{
var ToIns="";
if (window.mmpa.response.ib_array&&window.mmpa.response.ib_array!='undefined') 
 {
	_mmCapt="Рекомендуем также посмотреть следующие товары:";
	ToIns=_mmBuild(window.mmpa.response.ib_array);
	if (ToIns&&ToIns!="") 
	{
	var obj=document.getElementById('Item_based');
	if (obj) obj.innerHTML=ToIns;
	window.mmpa.response.ib_array="undefined";
	ToIns="";
	}
 }
 if (window.mmpa.response.bo_array&&window.mmpa.response.bo_array!='undefined') 
 {
    if(window.mmRecType&&window.mmRecType==2) _mmCapt="Пользователи, купившие этот товар, также выбирают :";
	else _mmCapt="Хиты продаж:"
	ToIns=_mmBuild(window.mmpa.response.bo_array);
	if (ToIns&&ToIns!="") 
	{
	var obj=document.getElementById('Best_offer');
	if (obj) obj.innerHTML=ToIns;
	window.mmpa.response.bo_array="undefined";
	ToIns="";
	}
 }
    var oDiv=document.getElementById('Best_offer');
	if (oDiv)
	{
    var aCol=oDiv.getElementsByTagName('a');
	//console.log(aCol.length);
    for (var i in aCol){mmcore.events.Tag(aCol[i],'price_click','1','','return true;');}
	}

    var oDiv=document.getElementById('Item_based');
	if (oDiv)
	{
    var aCol=oDiv.getElementsByTagName('a');
	//console.log(aCol.length);
    for (var i in aCol){mmcore.events.Tag(aCol[i],'price_click','1','','return true;');}
	}
}