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:-103; top: -103; width: 103; height: 103'><tr><td height=100 width=100 colspan=2 rowspan=2><table border=0 width=100 height=100 cellspacing=0 cellpadding=0 style='border: 0 ridge '><tr><td width='100%' bgcolor=''><span style='padding-left:2px; color:;font-size:6px;font-family:Arial;'></span></td><td width=10 height=10 bgcolor=''><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='' align=center valign=middle><div id='popup_slide_content'></div></td></tr></table></td><td height=1 width=3><img border=0 src='http://tourism-school.ru/pop/images/1.gif' width=3 height=3></td></tr><tr><td bgcolor=''><img border=0 src='http://tourism-school.ru/pop/images/1.gif' width=3 height=97></td></tr><tr><td><img border=0 src='http://tourism-school.ru/pop/images/1.gif' width=3 height=3></td><td bgcolor=''><img border=0 src='http://tourism-school.ru/pop/images/1.gif' width=97 height=3></td><td bgcolor=''><img border=0 src='http://tourism-school.ru/pop/images/1.gif' width=3 height=3></td></tr></table>");

  var Show_delay=0;
  var Show_Pos='as_above';
  var Show_Left=0;
  var Show_Top=205;
  var Pop_width=100;
  var Pop_height=100;
  var Pop_slide_dir='top';
  var Pop_slide_speed='3';
  var Pop_cookie_name='popup20060823104520';
  var Pop_cookie_mode='every_time';
  var Pop_scrolling=0;
  var Pop_cookie_days='';
  var Pop_scrolling='0';
  var Pop_Slide_Time=1000;
  var Pop_Slide_Timer=0;
  var Pop_Slide_Index=1;
  var Pop_Slide_Array=Array('','<a href="http://tourism-school.ru/light.htm"><img border=0 src="http://tourism-school.ru/pop/images/pop1.gif"></a>  ');

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=5;
  ypos=5;
 break;
 case 'top_center':
  xpos=(document.body.clientWidth-Pop_width)/2;
  ypos=5;
 break;
 case 'top_right':
  xpos=document.body.clientWidth-Pop_width-5;
  ypos=5;
 break;
 case 'bottom_left':
  xpos=5;
  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 (!Pop_Slide_Timer) {
  if (Pop_Slide_Array[Pop_Slide_Index]) document.all.popup_slide_content.innerHTML = Pop_Slide_Array[Pop_Slide_Index];
 }
 Pop_Slide_Timer += 20;
 if (Pop_Slide_Timer >= Pop_Slide_Time) {
  Pop_Slide_Timer=0;
  Pop_Slide_Index++;
  if (Pop_Slide_Array[Pop_Slide_Index]); else Pop_Slide_Index=1;
 };
 if (xshift > 0) {
  if (xstart < xpos) xstart += xshift;
 }
 else if (xshift < 0) {
  if (xstart > xpos) xstart += xshift;
 };
 if (Pop_scrolling==1) {
  yshift=Math.abs(yshift);
  yspos = ypos + document.body.scrollTop;
  if (yshift == 0) yshift=10;
  dy=Math.abs(yspos-ystart);
  if (dy > (yshift/2)) {
   if (yspos > ystart) ystart += yshift;
   else if (yspos < ystart) ystart -= yshift;
  };
 }
 else {
  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);
