var obj,idx;

function setCookie (name, value, expires) {
 document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + "; path=/";
}

function checkCookie (name) {
 var x=document.cookie.indexOf(name+'='+name)+1;
 if (x) return 1;
 else return 0;
}

function startDrag(ev) {
 obj = document.all.txd.style;
 X=event.offsetX;
 Y=event.offsetY;
 clearTimeout(idx);
};

function stopDrag(ev) {
 obj=null;
};

function mousemove(ev) {
 if (obj) {
   document.all.txd.style.left = event.clientX-X + document.body.scrollLeft;
   document.all.txd.style.top = event.clientY-Y + document.body.scrollTop;
   return false;
 }
}

function CheckCookieMode(Pop_cookie_mode,Pop_cookie_name) {
tm = new Date();
switch (Pop_cookie_mode) {
 case 'once_time':
  tm.setTime(tm.getTime()+365*24*60*60*1000);
  setCookie(Pop_cookie_name,Pop_cookie_name,tm.toGMTString());
 break;
 case 'once_session':
  setCookie(Pop_cookie_name,Pop_cookie_name);
 break;
 case 'once_day':
  hs=23-tm.getHours();
  mn=60-tm.getMinutes();
  tm.setTime(tm.getTime()+hs*60*60*1000+mn*60*1000);
  setCookie(Pop_cookie_name,Pop_cookie_name,tm.toGMTString());
 break;
 case 'specify_day':
  x=eval(Pop_cookie_days)+0;
  if (x>0) {
   tm.setTime(tm.getTime()+x*24*60*60*1000);
   setCookie(Pop_cookie_name,Pop_cookie_name,tm.toGMTString());
  };
 break;
 default:
  setCookie(Pop_cookie_name,1);
 break;
};
};
function ClosePopup() {
 document.all.txd.style.left=-5000;
 document.all.txd.style.display='none';
 ;;;;;;;;;;;;;
};document.write("<table id='txd' border=0 cellspacing=0 cellpadding=0  style='cursor: default; position: absolute; left:-283; top: -173; width: 283; height: 173'><tr><td height=170 width=280 colspan=2 rowspan=2><table border=0 width=280 height=170 cellspacing=0 cellpadding=0 style='border: 1 solid Blue'><tr><td width='100%' bgcolor='Blue'><span style='padding-left:2px; color:White;font-size:12px;font-weight:bold;font-family:Tahoma;'>  ЧИСТАЯ ВОДА - ЭТО ПРОСТО !</span></td><td width=10 height=10 bgcolor='Blue'><input style='border: 1 outset; font-weight: bold; font-size: 10px' type=button value='X' onClick='ClosePopup()'></td></tr><tr><td width='100%' colspan=2 height='100%' bgcolor='White' align=center valign=middle><br><b><font color='#0033CC'>Хотите пить кристально<br> чистую воду?</font></b><BR><BR><a href='http://profiltr.ru/water_filter/osmos_filter.html'><img src='http://kupleno.ru/images/osmos_for_popup.gif' width='93' height='75' border='0'></a>  <br> <a href='http://profiltr.ru/water_filter/osmos_filter.html'><b><font color='#0033CC'>узнайте  больше<br> о бытовых фильтрах<br> обратного осмоса >></font></b></a><br><br><br></td></tr></table></td><td height=1 width=3><img border=0 src='http://uvlagniteli.com/popup/images/1.gif' width=3 height=3></td></tr><tr><td bgcolor='Gray'><img border=0 src='http://uvlagniteli.com/popup/images/1.gif' width=3 height=167></td></tr><tr><td><img border=0 src='http://uvlagniteli.com/popup/images/1.gif' width=3 height=3></td><td bgcolor='Gray'><img border=0 src='http://uvlagniteli.com/popup/images/1.gif' width=277 height=3></td><td bgcolor='Gray'><img border=0 src='http://uvlagniteli.com/popup/images/1.gif' width=3 height=3></td></tr></table>");

  var Show_delay=2000;
  var Show_Pos='top_left';
  var Show_Left=0;
  var Show_Top=0;
  var Pop_width=280;
  var Pop_height=170;
  var Pop_slide_dir='left';
  var Pop_slide_speed='14';
  var Pop_cookie_name='popup20060302124705';
  var Pop_cookie_mode='once_time';
  var Pop_cookie_days='';

var xpos,ypos,xstart,ystart,xshift=0,yshift=0;

switch (Show_Pos) {
 case 'as_above':
  xpos=Show_Left;
  ypos=Show_Top;
 break;
 case 'center_left':
  xpos=1;
  ypos=(document.body.clientHeight-Pop_height)/2;
 break;
 case 'center':
  xpos=(document.body.clientWidth-Pop_width)/2;
  ypos=(document.body.clientHeight-Pop_height)/2;
 break;
 case 'center_right':
  xpos=document.body.clientWidth-Pop_width-5;
  ypos=(document.body.clientHeight-Pop_height)/2;
 break;
 case 'top_left':
  xpos=1;
  ypos=1;
 break;
 case 'top_center':
  xpos=(document.body.clientWidth-Pop_width)/2;
  ypos=1;
 break;
 case 'top_right':
  xpos=document.body.clientWidth-Pop_width-5;
  ypos=1;
 break;
 case 'bottom_left':
  xpos=1;
  ypos=document.body.clientHeight-Pop_height-5;
 break;
 case 'bottom_center':
  xpos=(document.body.clientWidth-Pop_width)/2;
  ypos=document.body.clientHeight-Pop_height-5;
 break;
 case 'bottom_right':
  xpos=document.body.clientWidth-Pop_width-5;
  ypos=document.body.clientHeight-Pop_height-5;
 break;
}
switch(Pop_slide_dir) {
 case 'left':
  xstart=-1*(Pop_width+5); xshift=eval(Pop_slide_speed);
  ystart=ypos; yshift=0;
 break;
 case 'right':
  xstart=document.body.clientWidth+1; xshift=-1*eval(Pop_slide_speed);
  ystart=ypos; yshift=0;
 break;
 case 'top':
  xstart=xpos; xshift=0;
  ystart=-1*(Pop_height+5); yshift=eval(Pop_slide_speed);
 break;
 case 'bottom':
  xstart=xpos; xshift=0;
  ystart=document.body.clientHeight+1; yshift=-1*eval(Pop_slide_speed);
 break;
 default:
  xstart=xpos; xshift=0;
  ystart=ypos; xshift=0;
 break;
};

function ShowPopup() {
 if (xshift > 0) {
  if (xstart < xpos) xstart += xshift;
 }
 else if (xshift < 0) {
  if (xstart > xpos) xstart += xshift;
 };
 if (yshift > 0) {
  if (ystart < ypos) ystart += yshift;
 }
 else if (yshift < 0) {
  if (ystart > ypos) ystart += yshift;
 };
 document.all.txd.style.top=ystart;
 document.all.txd.style.left=xstart;
 idx=setTimeout('ShowPopup()',20);
};

document.onmousemove = mousemove;

if (!checkCookie(Pop_cookie_name)) idx=setTimeout('ShowPopup()',Show_delay); CheckCookieMode(Pop_cookie_mode,Pop_cookie_name);

