if(typeof GTBLOCK=="undefined"){
function getblock(blockId){
GTBLOCK(blockId).init()}
Array.prototype.shuffle=function(b){
var i=this.length,j,t
while(i){
j=Math.floor((i--)*Math.random())
t=b&&typeof this[i].shuffle !=='undefined' ? this[i].shuffle()
: this[i]
this[i]=this[j]
this[j]=t}
return this}
var GTBLOCK=(function(){
var GTBLOCK=function(BID){
return GTBLOCK.fn.set(BID)
},w=window,d=window.document,s=screen,BID,GT_BDATA=[],TBS,TBT,URI,HOST='gotarget.su',IMHOST='gotarget.su',UNICAL_REF=10*60*1000
GTBLOCK.fn=GTBLOCK.prototype={
top_X : function(o){
var c=0
if(o.offsetParent)
while(1){
c+=o.offsetLeft
if(!o.offsetParent)
break
o=o.offsetParent}
else if(o.x)
c+=o.x
return c
},
top_Y : function(o){
var c=0
if(o.offsetParent)
while(1){
c+=o.offsetTop
if(!o.offsetParent)
break
o=o.offsetParent}
else if(o.y)
c+=o.y
return c
},
id : function(ID){
return d.getElementById(ID)
},
rem : function(ID){
var i=this.id(ID)
i.parentNode.removeChild(i)
},
c : function(n,a,i){
var e=d.createElement(n)
if(typeof a !=='undefined')
for(var n in a)
this.setAttr(e,n,a[n])
if(typeof i !=='undefined')
e.innerHTML=i
return e
},
setAttr : function(e,a,v){
if(typeof v=="object")
for(var i in v)
e[a][i]=v[i]
else
e[a]=v
return e
},
set : function(i){
BID=i
if(typeof GT_BDATA[i] !='undefined'){
TBS=GT_BDATA[i].s
TBT=GT_BDATA[i].t
URI=GT_BDATA[i].uri}
return this
},
init : function(){
if(typeof GT_BDATA[BID] !='undefined')
return
GT_BDATA[BID]={
uri : this.getUnicalURI()+'&'+this.getSharedURI()}
d.write('<div id="gotarget_su_'+BID+'_unical"></div>')
d.write("<scr"+""+"ipt id=\"GT_BDATA_transfer_"+BID
+"\" src=\""+"http://"+HOST+"/gen/block.php?"
+GT_BDATA[BID].uri
+"\" type=\"text/javascript\"></script>")
},
getSharedURI : function(){
return 'b='
+BID
+'&s='
+((typeof(s)=="undefined")? "" : s.width+"_"
+s.height+"_"
+(s.colorDepth ? s.colorDepth : s.pixelDepth))
+'&cref='+escape(d.referrer)+'&u='+escape(d.URL)
+'&t='+Math.random()
},
getUnicalURI : function(){
var cR=d.cookie.split('z_wn'+BID+'=')[1],rR='',rT=0
cR=(cR !==undefined)? unescape(cR.split(';')[0]): ''
if(cR.split('|')[0]=='gotarget_su_'+BID){
rR=cR
rT=2
}else{
rT=3
rR='gotarget_su_'+BID+'|'+d.referrer
w.name=rR
var da=new Date()
da.setTime(da.getTime()+UNICAL_REF)
d.cookie='z_wn'+BID+'='+escape(rR)+";expires="
+da.toGMTString()+";path=/;"}
return 'r='+escape(rR)+'&rt='+rT
},
setData : function(st,t){
if(t==false)
return
this.rem("GT_BDATA_transfer_"+BID)
var B=GT_BDATA[BID]
TBS=B.s=st
TBT=B.t=t.shuffle(1)
B.b=this.id('gotarget_su_'+BID+'_unical')
return this
},
build : function(){
var TT=this.c("table",{
style :{
margin : "0px",
padding : "0px",
borderCollapse : 'collapse'}
})
this
.setAttr(
GT_BDATA[BID].b,
"style",{
background :(TBS.transparent_bg=='0' ? TBS.bg_color
: ''),
margin : "0px",
padding : "0px",
border : TBS.border+"px solid "
+TBS.border_color
})
if(TBS.show_block_logo==1){
var n=this.c("div",{
style :{
textAlign : "left",
width : "100%",
height : "12px",
lineHeight : "12px",
paddingLeft : "2px"}
})
n.appendChild(this.c("span",{
style :{
fontFamily : "tahoma",
fontSize : "10px",
color : "gray",
margin : "0px",
padding : "0px"}
},"Gotarget.SU"))
GT_BDATA[BID].b.appendChild(n)}
GT_BDATA[BID].b.appendChild(TT)
var i=0
for(var rc=0;rc<TBS.teaser_rows;rc++){
var r=this.row(TT)
for(var cc=0;cc<TBS.teaser_cols;cc++){
var c=this.fillCell(this.cell(r),rc,cc)
if(typeof TBT[i] !='undefined'){
TBT[i].relId=i
this.addTeaser(c,TBT[i])}
i++}}
},
addTeaser : function(e,t){
var TT=this.c("table",{
style :{
width : "100%",
height : "100%"}
}),r=this.row(TT),c=this.cell(r),i=this.c("div",{
style :{
verticalAlign : "middle",
textAlign : "center"}
}),n={
verticalAlign : "middle",
textAlign : "left"
},il=this.tSLink(t,{})
il.appendChild(this.tImg(t))
i.appendChild(il)
c.appendChild(i)
if(TBS.teaser_text_orientation==1){
r=this.row(TT)
n={
verticalAlign : "top",
textAlign : "center"}}
c=this.cell(r)
i=this.c("div",{
style : n
})
i.appendChild(this.tLink(t))
c.appendChild(i)
if(t.is_sell==1){
var st={
style :{
fontSize : TBS.price_font_size+"px",
color : TBS.price_font_color,
marginTop : "5px",
margin : "0px",
padding : "0px"}}
if(TBS.price_font !==null)
st.style.fontFamily=TBS.price_font
var pt=this.c("div",st,parseFloat(t.price)+" р.")
c.appendChild(this.c("br"))
c.appendChild(pt)}
if(TBS.is_newsblock==1){
c.appendChild(this.c("br"))
c.appendChild(this.tLink(t,true))}
e.appendChild(TT)
},
tImg : function(t){
var ts=(TBS.tiz_size==100)? "" : '_'+TBS.tiz_size
var img=this.c("img",{
id : "gotargetsu_t_"+TBS.id+"_"+t.id+"_"
+TBS.tiz_size,
src : "http://"+IMHOST+"/teasers/"+t.id+ts+"."
+t.img+"?b="+TBS.id+"&i="+t.id,
style :{
border : TBS.teaser_border+"px solid "
+TBS.teaser_border_color,
margin : "0px",
padding : "0px"}
})
if(TBS.expandable==1&&TBS.tiz_size<200)
img.onmouseover=new Function("GTBLOCK("+BID
+").tbMakeExpand('"+img.id+"',"+t.relId
+")")
return this.tSLink(t,{}).appendChild(img)
},
tLink : function(t,nl){
var news=typeof nl !='undefined'
var text=news ? "читать далее>>>" : t.text
var font=news ? TBS.news_font : TBS.teaser_font
var font_size=news ? TBS.news_font_size
: TBS.teaser_font_size
var font_color=news ? TBS.news_font_color
: TBS.teaser_font_color
var link_text_style=news ? TBS.news_link_text_style
: TBS.link_text_style
var link_bold=news ? TBS.news_link_bold : TBS.link_bold
var link_text_style_hover_color=news ? TBS.news_link_text_style_hover_color
: TBS.link_text_style_hover_color
var link_text_style_hover=news ? TBS.news_link_text_style_hover
: TBS.link_text_style_hover
var st={
fontFamily : font,
fontSize : font_size+"px",
color : font_color,
textDecoration : link_text_style}
if(link_bold==1)
st.fontWeight="bold"
var l=this.tSLink(t,st)
l.innerHTML=text
l.onmouseover=new Function("GTBLOCK("+BID
+").lHover(this,'"+link_text_style_hover_color
+"','"+link_text_style_hover+"')")
l.onmouseout=new Function("GTBLOCK("+BID
+").lHover(this,'"+font_color+"','"
+link_text_style+"')")
return l
},
lHover : function(o,c,t){
o.style.color=c
o.style.textDecoration=t=='undefined' ? '' : t
},
tSLink : function(t,lst){
var a={
style : lst}
a.style.cursor="pointer"
if(TBS.unclickable==1)
var l="span"
else{
if(!TBS.multiply){
a.href=t.url+'?ref_id='+BID+(TBS.popunder=='0' ? '&nopop' : '')+"&i="+t.id;
}else{
a.href="http://"+HOST+"/multiply/click.php?b="+TBS.id+"&i="+t.id}
var l="a"}
if(TBS.new_window)
a.target="_blank"
return this.c(l,a)
},
row : function(e){
return e.insertRow(-1)
},
cell : function(r){
var c=r.insertCell(-1),a=TBS.teaser_text_orientation==1 ?{
verticalAlign : "top",
textAlign : "center"}
:{
verticalAlign : "middle",
textAlign : "left"}
a.padding=TBS.padding+"px"
this.setAttr(c,"style",a)
return c
},
fillCell : function(c,y,x){
if(TBS.is_newsblock==1){
var st=TBS.news_line_width+"px "+TBS.news_line_style
+" "+TBS.news_line_color
if(x+1<TBS.teaser_cols)
c.style.borderRight=st
if(y+1<TBS.teaser_rows)
c.style.borderBottom=st
if(x>0)
c.style.borderLeft=st
if(y>0)
c.style.borderTop=st}
return c
},
tbMakeExpand : function(el_id,oid){
new_id=el_id+"_expanded",el=this.id(el_id),n=this
.id(new_id),x=this.top_X(el),y=this.top_Y(el)
if(n==null){
var n=this.c("div",{
id : new_id,
style :{
position : "absolute",
top : y+"px",
left : x+"px",
width : TBS.tiz_size+"px",
height : TBS.tiz_size+"px"}
}),l=this.tSLink(TBT[oid],{})
var i=this.tImg(TBT[oid])
l.appendChild(i)
n.appendChild(l)
d.getElementsByTagName("body")[0].appendChild(n)}
n.style.display='block'
this
.tExpand(new_id,TBS.tiz_size,150,oid,TBS.tiz_size,
x,y)
},
tExpand : function(el_id,from_s,to_s,oid,orig_s,left,top){
var div=this.id(el_id),img=div.getElementsByTagName("img")[0]
from_s=parseInt(from_s)
to_s=parseInt(to_s)
top=parseInt(top)
left=parseInt(left)
if(from_s<to_s){
top=top-1
left=left-1
from_s=from_s+2
div.style.width=div.style.height=img.style.width=img.style.height=from_s
+"px"
div.style.top=top+"px"
div.style.left=left+"px"
setTimeout(new Function("GTBLOCK("+BID+").tExpand('"
+el_id+"',"+from_s+","+to_s+","+oid
+","+orig_s+","+left+","+top+")"),10)
}else{
img.src="http://"+IMHOST+"/teasers/"+TBT[oid].id
+"_150."+TBT[oid].img+"?b="+BID}
img.onmouseout=new Function("GTBLOCK("+BID+").tShrink('"
+el_id+"',"+from_s+","+orig_s+","+left
+","+top+")")
},
tShrink : function(el_id,from_s,to_s,left,top){
var div=this.id(el_id),img=div.getElementsByTagName("img")[0]
from_s=parseInt(from_s)
to_s=parseInt(to_s)
top=parseInt(top)
left=parseInt(left)
if(from_s>to_s){
from_s=from_s-2
top=top+1
left=left+1
div.style.top=top+"px"
div.style.left=left+"px"
img.style.width=img.style.height=div.style.width=div.style.height=from_s
+"px"
setTimeout(new Function("GTBLOCK("+BID+").tShrink('"
+el_id+"',"+from_s+","+to_s+","+left
+","+top+")"),10)
}else
div.style.display="none"}}
GTBLOCK.fn.set.prototype=GTBLOCK.fn
window.GTBLOCK=GTBLOCK
return window.GTBLOCK
})()}

