var ns = (navigator.appName.indexOf("Netscape") != -1);
bName = navigator.appName;
bVer = parseInt(navigator.appVersion); 
if  ((bName=="Netscape" && bVer>=3) || (bName=="Microsoft Internet Explorer" && bVer>=4)) ver="good"; else ver="bad"; 
var speed=20;
var delay=1;
function View_Foto(W,H,ImageName,Tit,id) {
var x;
var y;
var w;
var h;
var Z=0;
var deltax=0;
var deltay=0;
var deltaw=0;
var deltah=0;
var startx;
var starty;
var startw;
var starth;
var W2=W;
var	H2=H;
var height=document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
var width=document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
var scrollY = ns ? pageYOffset : document.body.scrollTop;

if(W2>width) {W2=width;W=W2;}
if(H2>height) {H2=height;H=height;}
var left=Math.ceil((width-W2)/2);
var top=Math.ceil((height-H2)/2)+scrollY;
var top2=Math.ceil((height-H2)/2);
//alert("height="+height+" H2="+H2+" scrollY="+scrollY);
var img = document.getElementById(id);
var imgw = img.offsetWidth;
var imgh = img.offsetHeight;
var cc=getOffset(img);
var imgx=cc.left;
var imgy=cc.top;
    startx=x=imgx;
	starty=y=imgy;
	startw=w=imgw;
	starth=h=imgh;
	deltax=(x-left)/speed;
	deltay=(y-top)/speed;
	deltaw=(W2-w)/speed;
	deltah=(H2-h)/speed;
	W2=w+10;
	H2=h+10;
	document.getElementById("ViewFoto").style.visibility='visible';
	document.getElementById("ViewFoto").style.display='block';
	document.getElementById("ViewFoto").style.position='absolute';
	document.getElementById("ViewFoto").style.backgroundColor='#ffffff';
	document.getElementById("ViewFoto").style.border='1px solid #999999';
	document.getElementById("ViewFoto").style.padding='10';
	document.getElementById("ViewFoto").style.width=W2;
	document.getElementById("ViewFoto").style.height=H2;
	document.getElementById("ViewFoto").style.top=y;
	document.getElementById("ViewFoto").style.left=x;
	document.getElementById("ViewFoto").innerHTML="<center><a href=\"javascript:CloseImg("+w+","+h+","+deltax+","+deltay+","+deltaw+","+deltah+");\"><img id=\"BigImg\" class=\"tphotob\" src=\"" + ImageName + "\"" + " width=\"" + w + "\" height=\"" + h + "\" onclick=\"\" title=\"Закрыть\" alt=\"Закрыть\"></a>";
	document.getElementById("BigImg").style.width=w;
	document.getElementById("BigImg").style.height=h;

	DrawImg(W,H,left,top2,deltax,deltay,deltaw,deltah);
  }

function DrawImg(W,H,L,T,dx,dy,dw,dh)
{

	var y=parseInt(document.getElementById("ViewFoto").style.top);
	var x=parseInt(document.getElementById("ViewFoto").style.left);
	var w=parseInt(document.getElementById("BigImg").style.width);
	var h=parseInt(document.getElementById("BigImg").style.height);
	if(w<W)
		{
		x=Math.ceil(x-dx);
		y=Math.ceil(y-dy);
		w=Math.ceil(w+dw);
		h=Math.ceil(h+dh);
		document.getElementById("ViewFoto").style.width=w;
		document.getElementById("ViewFoto").style.height=h;
		document.getElementById("ViewFoto").style.top=y;
		document.getElementById("ViewFoto").style.left=x;
		document.getElementById("BigImg").style.width=w;
		document.getElementById("BigImg").style.height=h;
		setTimeout('DrawImg('+W+','+H+','+L+','+T+','+dx+','+dy+','+dw+','+dh+')',delay);
		}
	else
		{
		document.getElementById("ViewFoto").style.top=T;
		document.getElementById("ViewFoto").style.left=L;
		JSFX_FloatTopDiv("ViewFoto",L,T,H);
		}
}

function CloseImg(sw,sh,dx,dy,dw,dh)
{
window.stayTopright=function()
	{
	}	
ClosePhoto();
return;
	var w=parseInt(document.getElementById("BigImg").style.width);
	var h=parseInt(document.getElementById("BigImg").style.height);
	var y=parseInt(document.getElementById("ViewFoto").style.top);
	var x=parseInt(document.getElementById("ViewFoto").style.left);
	x=Math.ceil(x+dx);
	y=Math.ceil(y+dy);
	w=Math.ceil(w-parseFloat(dw));
	h=Math.ceil(h-parseFloat(dh));
	if(w>sw && dw>1)
		{		
		document.getElementById("ViewFoto").style.width=w;
		document.getElementById("ViewFoto").style.height=h;
		document.getElementById("ViewFoto").style.top=y;
		document.getElementById("ViewFoto").style.left=x;
		document.getElementById("BigImg").style.width=w;
		document.getElementById("BigImg").style.height=h;
		setTimeout('CloseImg('+sw+','+sh+','+dx+','+dy+','+dw+','+dh+')',delay);
		}
	else
		{
			ClosePhoto();
		}
}


function CloseImg2(sw,sh,dx,dy,dw,dh)
{
CloseImg(parseInt(sw),parseInt(sh),parseFloat(dx),parseFloat(dy),parseFloat(dw),parseFloat(dh));
}

function pause(ms)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < ms);
}

function ClosePhoto()
{
	document.getElementById("ViewFoto").style.display='none';
	document.getElementById("ViewFoto").style.visibility='hidden';
	document.getElementById("BigImg").style.width=0;
	document.getElementById("BigImg").style.height=0;	
	document.getElementById("ViewFoto").style.width=0;
	document.getElementById("ViewFoto").style.height=0;	
	x=0;
	y=0;
	w=0;
	h=0;
	deltax=0;
	deltay=0;
	deltaw=0;
	deltah=0;
	startx=0;
	starty=0;
	startw=0;
	starth=0;	
}


function getOffset(elem) {
    if (elem.getBoundingClientRect) {
        // "правильный" вариант
        return getOffsetRect(elem)
    } else {
        // пусть работает хоть как-то
        return getOffsetSum(elem)
    }
}

function getOffsetSum(elem) {
    var top=0, left=0
    while(elem) {
        top = top + parseInt(elem.offsetTop)
        left = left + parseInt(elem.offsetLeft)
        elem = elem.offsetParent
    }

    return {top: top, left: left}
}

function getOffsetRect(elem) {
    // (1)
    var box = elem.getBoundingClientRect()

    // (2)
    var body = document.body
    var docElem = document.documentElement

    // (3)
    var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
    var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft

    // (4)
    var clientTop = docElem.clientTop || body.clientTop || 0
    var clientLeft = docElem.clientLeft || body.clientLeft || 0

    // (5)
    var top  = box.top +  scrollTop - clientTop
    var left = box.left + scrollLeft - clientLeft

    return { top: Math.round(top), left: Math.round(left) }
}


function View_Foto2(W,H,ImageName,Tit) {
	W2=W+40;
	H2=H+40;
	newWindow=window.open("","","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width="+W2+",height="+H2+"");
       var newContent = "<html><head>\n"
       newContent += "<title>" + Tit + "</title></head>\n";
       newContent += "<link rel=\"stylesheet\" href=\"/style.css\"><body bgcolor=\"#ffffff\" style=\"margin=0;padding:0;padding-top:5\">\n";
       newContent += "<center><img class=\"tphoto\" src=\"" + ImageName + "\"" + " width=\"" + W + "\" height=\"" + H + "\"></a>\n";
	   newContent+="<div style=\"position:absolute;left:0px;top:0px;\"><img src=\"/images/1x1.gif\" width="+W+" height="+H+"  alt=\""+Tit+"\"></div>";
       newWindow.document.writeln(newContent);
       newWindow.document.writeln("</body></html>");
  }



function img_over(imgName,src) {
document.images[imgName].src=src;
return true;
}

function menuOpen(id)
	{
	obj=document.getElementById("razdel"+id);
	if( (obj.style.visibility!='visible') )
		{
		obj.style.visibility='visible';
		obj.style.position='static';
		obj.style.display='block';
		}
	else
		{
		obj.style.visibility='hidden';
		obj.style.position='absolute';
		obj.style.display='none';
		}
	}
function HideRazdel()
{
for (i in razdel)
	{
	document.getElementById('razdel'+i).style.visibility='hidden';
	document.getElementById('razdel'+i).style.position='absolute';
	}
}	

function fixPNG(element)
{
  //Если браузер IE версии 5.5-6
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	
    if (element.tagName=='IMG') //Если текущий элемент картинка (тэг IMG)
    {
      if (/\.png$/.test(element.src)) //Если файл картинки имеет расширение PNG
      {
        src = element.src;
        element.src = "/images/blank.gif"; //заменяем изображение прозрачным gif-ом
      }
    }
    else //иначе, если это не картинка а другой элемент
    {
	  //если у элемента задана фоновая картинка, то присваеваем значение свойства background-шmage переменной src
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1]; //берем из значения свойства background-шmage только адрес картинки
        element.runtimeStyle.backgroundImage="none"; //убираем фоновое изображение
      }
    }
    //если, src не пуст, то нужно загрузить изображение с помощью фильтра AlphaImageLoader
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "'";
  }
}

function tdover(o)
{
	o.style.backgroundPosition='0px -120px';
}

function tdout(o)
{
	o.style.backgroundPosition='0px 0px';
}

function pr(p)
{
	window.location="/catalog/?pr="+p;
}


function JSFX_FloatTopDiv(divname,x,y,h)
{
	var placeX = x,	placeY = y;
	var Z=0;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function DeLayer(id)
	{
		var GetElements=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)GetElements.style=GetElements;
		GetElements.sP=function(x,y){this.style.right=x;this.style.top=y;};
		GetElements.x = placeX;
		GetElements.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		GetElements.y -= placeY;
		return GetElements;
	}
	window.stayTopright=function()
	{
		scrh=ns ? innerHeight : document.body.clientHeight;
		var pY = ns ? pageYOffset + innerHeight: (document.body.scrollTop + document.body.clientHeight);
		var scrolly = ns ? pageYOffset : document.body.scrollTop;
		if(Z==0) 
			{
//				alert(pY);
				if(pY==scrh){ pY++;}
			ftlObj.y=pY-scrh+placeY;
			}
		Z=1;
		if(ftlObj.y!=placeY)
		{
			ftlObj.y += (pY- scrh + placeY - ftlObj.y)/15;
		}
		
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopright()", 10);
	}
	ftlObj = DeLayer(divname);
	stayTopright();
}
function MenuUp(n)
{
	speed=3;
	o=document.getElementById("LeftMenu");
	//alert("scrolltop="+o.scrollTop+"scrollHeight="+o.scrollHeight+ " offsetHeight="+o.offsetHeight);
	if(n==-1)
		{
			if(o.scrollTop<o.scrollHeight+20)
			{
			o.scrollTop+=speed;
			}
		TO=setTimeout("MenuUp(-1)",30);
		}
	if(n==1)
		{
			if(o.scrollTop>0)
			{
			o.scrollTop-=speed;
			}
		TO=setTimeout("MenuUp(1)",30);
		}
	if(n==0)
		clearTimeout(TO);
		{
		}
}
function setH()
{
//	alert(document.getElementById("MainTD").offsetHeight);
//	alert(document.getElementById("LeftMenu").style.height);
	h=document.getElementById("MainC").offsetHeight-130;
	if(h>250)
	document.getElementById("LeftMenu").style.height=300;
//	document.getElementById("LeftMenu").style.height=document.getElementById("MainTD")style.height;
}
//addEvent(window,"load",setH);

function Print(id)
{
window.open("/cgi-bin/print.cgi?id="+id,"","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width=800,height=600");
	
}


// Функции для поля ввода даты
var Mdays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Month=new Array('январь','февраль','март','апрель','май','июнь','июль','август','сентябрь','октябрь','ноябрь','декабрь');
var Day=new Array('пн','вт','ср','чт','пт','сб','вс');

function DateDivClose(divid)
{
document.getElementById("selyear_"+divid).style.visibility='hidden';
document.getElementById("selmonth_"+divid).style.visibility='hidden';
document.getElementById(divid).style.visibility='hidden';
curdatediv='';
}

function InsertDate(d,divid,inputid)
{
document.getElementById(inputid).value=d;
document.getElementById(divid).style.visibility='hidden';
if(document.getElementById("Period"))
	{
	ChangePeriod2();
	}
}

function SelectYear(d,divid,inputid)
{
date=new Date();
document.getElementById("selmonth_"+divid).style.visibility='hidden';
document.getElementById("selyear_"+divid).style.visibility='visible';
var cc='<center>';
gyear=date.getYear();
if(bName=="Netscape") gyear+=1900;
ddd=d.substring(0,6);
for(gy=gyear;gy>gyear-100;gy--)
	{
		dddd=ddd+gy;
		if(gy==gyear)
			{
			cc=cc+'<a href="javascript:ChangeYear('+"'"+gy+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+gy+'</b></a><br>';
			}
		else
			{
			cc=cc+'<a href="javascript:ChangeYear('+"'"+gy+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+gy+'</a><br>';
			}
	}
document.getElementById("selyear_"+divid).innerHTML=cc;
}
function ChangeYear(y,inputid)
{
var v=document.getElementById(inputid).value;
document.getElementById(inputid).value=v.substring(0,6)+y;
}
function ChangeMonth(m,inputid)
{
var v=document.getElementById(inputid).value;
var month=''+m;
document.getElementById(inputid).value=v.substring(0,2)+"/"+month+"/"+v.substring(6,10);
}
function SelectMonth(d,divid,inputid)
{
date=new Date();
document.getElementById("selyear_"+divid).style.visibility='hidden';
document.getElementById("selmonth_"+divid).style.visibility='visible';
var cc='<center>';
gyear=date.getMonth();
ddd1=d.substring(0,2)+'/';
ddd2='/'+d.substring(6,11);
for(gy=0;gy<12;gy++)
	{
		m=gy+1;
		m=(m>9?m:'0'+m);
		dddd=ddd1+m+ddd2;
		if(gy==gyear)
			{
			cc=cc+'<a href="javascript:ChangeMonth('+"'"+m+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+Month[gy]+'</b></a><br>';
			}
		else
			{
			cc=cc+'<a href="javascript:ChangeMonth('+"'"+m+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+Month[gy]+'</a><br>';
			}
	}
document.getElementById("selmonth_"+divid).innerHTML=cc;
}
var curdatediv='';
function MouseClick(e)
{
	if(curdatediv!='')
		{
			DateDivClose(curdatediv);
			curdatediv='';
		}
}

function SelectDate(d,divid,inputid)
{
curdatediv='';
Event.add(document.body,"click",MouseClick);
var cod='';
var div=document.getElementById(divid);
var bgcolor='#ffffff';
var textcolor='#0000ff';
var curbgcolor='#0066cc';
var curtextcolor='#ffffff';
var tdhovercolor='#dddddd';
var day,month,year;
var dat=new String();
var dd=1;
var m1;
var m2;
var mday;
var f=0;
dat=""+d;
//alert(document.getElementById(inputid).value);
var cur=""+document.getElementById(inputid).value;
if(dat=="" || dat=="//") f=1;
if(dat.substr(0,2)=="00") f=1;
if(dat.substr(3,2)=="00") f=1;
if(dat.substr(6,4)=="0000") f=1;
bName = navigator.appName;
if(f==1) 
	{
	date=new Date();
	year=date.getYear();
	if(bName=="Netscape") year+=1900;
	month=date.getMonth();
	day=date.getDate();
	date1=new Date(year,month,1,0,0,0);
	}
else
	{
	day=dat.substr(0,2);
//	month=parseInt(""+dat.substr(3,2))-1;
	month=dat.substr(3,2)-1;
	year=dat.substr(6,4);
	date=new Date(year,month,day,0,0,0);
	date1=new Date(year,month,1,0,0,0);
	}
if(cur=="") 
	{
	curdat=new Date();
	curyear=curdat.getYear();
	if(bName=="Netscape") curyear+=1900;
	
	curmonth=curdat.getMonth();
	curday=curdat.getDate();
	}
else
	{
	curday=parseInt(cur.substr(0,2));
	curmonth=Math.ceil(parseFloat(cur.substr(3,2)))-1;
	curyear=parseInt(cur.substr(6,4));
	curdat=new Date(curyear,curmonth,curday,0,0,0);
	}
	if(bName=="Netscape") 
		{
			document.getElementById(divid).style.height="260";
		}
	
//	if(bName=="Netscape") 
//		{
		cd=''+curday;
		curday=(curday<10 && cd.substring(0,1)!='0')?'0'+curday:curday;
//		}

document.getElementById(inputid).value=""+curday+"/"+((curmonth+1)>9?(curmonth+1):'0'+(curmonth+1))+"/"+curyear;
if(year%4>0){Mdays[1]=29;}
//curdate=(curday<10?"0"+curday:curday)+'/'+((curmonth+1)<10?"0"+(curmonth+1):(curmonth+1))+'/'+curyear;
curdate=''+curday+'/'+((curmonth+1)<10?"0"+(curmonth+1):(curmonth+1))+'/'+curyear;
day1=date1.getDay();
if(day1==0) {day1=6;} else {day1--;}
MonthName=Month[month];
nyear=parseInt(""+year);
pyear=parseInt(""+year);
pmonth=parseInt(""+month)+1;
nmonth=parseInt(""+month)+1;
prevyear=parseInt(""+year)-1;
nextyear=parseInt(""+year)+1;
prevmonth=parseInt(""+month);
nextmonth=parseInt(""+month)+2;
if(prevmonth==0) {prevmonth=12;pyear--;}
if(nextmonth==13) {nextmonth=1;nyear++;}
pday=parseInt(""+day);
nday=parseInt(""+day);
if(day==29 && (pyear%4)>0) {pday=28;}
if(day==29 && (nyear%4)>0) {nday=28;}
y1=(pday<10?"0"+pday:pday)+'/'+(pmonth<10?"0"+pmonth:pmonth)+'/'+prevyear;
y2=(nday<10?"0"+nday:nday)+'/'+(nmonth<10?"0"+nmonth:nmonth)+'/'+nextyear;
m1=(pday<10?"0"+pday:pday)+'/'+(prevmonth<10?"0"+prevmonth:prevmonth)+'/'+pyear;
m2=(nday<10?"0"+nday:nday)+'/'+(nextmonth<10?"0"+nextmonth:nextmonth)+'/'+nyear;
cod+='<table width=100% border=0 ><tr><td width=100% align=right><a href="javascript:DateDivClose('+"'"+divid+"'"+');"><img src="/images/close.jpg" border=0 alt="закрыть"></a></td></tr></table><table><tr><td><a href="javascript:SelectDate('+"'"+y1+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><<</a></td><td width=100%><center><a title="Выбрать год" href="javascript:SelectYear('+"'"+curdate+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+')"><b>'+year+'</b></a><div id="selyear_'+divid+'" style="position:absolute;display:inline-block;visibility:hidden;width:110;height:300;overflow:scroll;z-index:100;background-color:#ffffff;border:1px dotted #000000;padding:7;"></div></td><td><a href="javascript:SelectDate('+"'"+y2+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">>></a></td></tr></table><table><tr><td><a href="javascript:SelectDate('+"'"+m1+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><<</a></td><td width=100%><center><a title="Выбрать месяц" href="javascript:SelectMonth('+"'"+curdate+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+MonthName+'</b></a><div id="selmonth_'+divid+'" style="position:absolute;display:inline-block;visibility:hidden;width:110;height:300;overflow:scroll;z-index:100;background-color:#ffffff;border:1px dotted #000000;padding:7;"></div></center></td><td><a href="javascript:SelectDate('+"'"+m2+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">>></a></td></table><br>';
cod+='<table cellpadding=5 width=100%><tr>';
mday=Mdays[month];
for(i=0;i<7;i++)
	{
	cod+='<td><b><center>'+Day[i]+'</b></center></td>';
	}
cod+='</tr><tr>';
for(j=0;j<day1;j++){cod+='<td></td>';}
while(dd<=mday)
	{
	if(j==0) {cod+='<tr>';}
	dt=""+(dd>9?dd:'0'+dd)+'/'+((month+1)>9?(month+1):'0'+(month+1))+'/'+year;
	lstyle='';
	style='cursor:hand;';
	if(dt==cur)
		{
		style='style="background-color:'+curbgcolor+';cursor:hand;"';
		lstyle='style="color:'+curtextcolor+';font-weight:bold;"';
		cod+='<td style="cursor:hand;" bgcolor='+curbgcolor+' onmouseover="this.setAttribute('+"'bgcolor','"+tdhovercolor+"',0"+');" onmouseout="this.setAttribute('+"'bgcolor','"+curbgcolor+"',0"+');" '+style+' onclick="InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><center><a '+lstyle+' href="javascript:InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+dd+'</a></td>';
		}
	else
		{
		cod+='<td style="cursor:hand;" bgcolor='+bgcolor+' onmouseover="this.setAttribute('+"'bgcolor','"+tdhovercolor+"',0"+');" onmouseout="this.setAttribute('+"'bgcolor','"+bgcolor+"',0"+');" '+style+' onclick="InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><center><a '+lstyle+' href="javascript:InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+dd+'</a></td>';
		}
	dd++;
	j++;
	if(j>6) {cod+='</tr>';j=0;}
	}
cod+='</table>';	
div.innerHTML=cod;
div.style.visibility='visible';
}

Event=(function(){var a=0;function c(f){f=f||window.event;if(f.isFixed){return f}f.isFixed=true;f.preventDefault=f.preventDefault||function(){this.returnValue=false};f.stopPropagation=f.stopPropagaton||function(){this.cancelBubble=true};if(!f.target){f.target=f.srcElement}if(!f.relatedTarget&&f.fromElement){f.relatedTarget=f.fromElement==f.target?f.toElement:f.fromElement}if(f.pageX==null&&f.clientX!=null){var e=document.documentElement,d=document.body;f.pageX=f.clientX+(e&&e.scrollLeft||d&&d.scrollLeft||0)-(e.clientLeft||0);f.pageY=f.clientY+(e&&e.scrollTop||d&&d.scrollTop||0)-(e.clientTop||0)}if(!f.which&&f.button){f.which=(f.button&1?1:(f.button&2?3:(f.button&4?2:0)))}return f}function b(i){i=c(i);var d=this.events[i.type];for(var h in d){var f=d[h];var e=f.call(this,i);if(e===false){i.preventDefault();i.stopPropagation()}}}return{add:function(f,e,d){if(f.setInterval&&(f!=window&&!f.frameElement)){f=window}if(!d.guid){d.guid=++a}if(!f.events){f.events={};f.handle=function(g){if(typeof Event!=="undefined"){return b.call(f,g)}}}if(!f.events[e]){f.events[e]={};if(f.addEventListener){f.addEventListener(e,f.handle,false)}else{if(f.attachEvent){f.attachEvent("on"+e,f.handle)}}}f.events[e][d.guid]=d},remove:function(g,f,e){var d=g.events&&g.events[f];if(!d){return}delete d[e.guid];for(var h in d){return}if(g.removeEventListener){g.removeEventListener(f,g.handle,false)}else{if(g.detachEvent){g.detachEvent("on"+f,g.handle)}}delete g.events[f];for(var h in g.events){return}delete g.handle;delete g.events}}}());
