var slog=0;
var nlid=0;
var inpcnt=1;
var scrollTimer=null;
var fadeTimer=null;
var waitTimer=null;
var selimg=1;
var imgfn='';
var lastTime=null;
var preimg=null;
var isDrag=false;
var dragOfsX=0;
var dragOfsY=0;

window.onload=function() {
//alert('onload');
  stdel=getCookie('StartDelay');
  tofs=0;
  if (stdel==1) tofs=2000;
  frs=parent.document.getElementById("frs");
  if (frs!=null && frs.rows!='0,*') {
    for (i=0;i<=2000;i=i+20) {
      window.setTimeout('parent.document.getElementById("frs").rows=\''+(2000-i)+',*\';',tofs+i/2);
    }
    for (i=0;i<=50;i=i+10) {
      window.setTimeout('parent.document.getElementById("frs").rows=\''+(i)+',*\';',tofs+i*3+1000);
    }
    for (i=0;i<=50;i=i+10) {
      window.setTimeout('parent.document.getElementById("frs").rows=\''+(50-i)+',*\';',tofs+i*3+1200);
    }
  }
  di=document.getElementById('IMGSLOG');
  if (di) {
    di.style.backgroundImage='url('+document.getElementById('MIDIMG').src+')';
    di.style.backgroundRepeat='no-repeat';
    window.setTimeout('ch_slog(0);',10);
  }
}

function ch_slog(i) {
  slog=i+1;
  geturl('getpage.php?pg=slogen&sn='+i);
}

function geturl(url) {
  try { xmlHttp=new XMLHttpRequest(); }
  catch(e) {
    try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {
      alert ("Your browser does not support XMLHTTP!"); return; }
  }
  xmlHttp.onreadystatechange=state_Change; xmlHttp.open("GET",url,true); xmlHttp.send(null);
}

function state_Change() {
//alert('state_Change state: '+xmlHttp.readyState+', status: '+xmlHttp.status);
  if (xmlHttp.readyState==4) {// 4 = "loaded"
    if (xmlHttp.status==200) {// 200 = OK
      txt=xmlHttp.responseText;
      di=document.getElementById('IMGSLOG');
      if (di) {
        di.style.backgroundRepeat='no-repeat';
        di.innerHTML=txt;
        im=document.getElementById('MIDIMG');
        im.myOp=0;
        window.setTimeout('ch_slog(slog);',2500);
        fade();
      }
    } /*else {
      alert("Problem retrieving XML data");
    }*/
  }
}

function fade() {
  im=document.getElementById('MIDIMG');
  im.myOp+=0.05;
  if(im.myOp>1) {
    im.myOp = 1;
    di=document.getElementById('IMGSLOG');
    di.style.background='url('+im.src+')';
    di.style.backgroundRepeat='no-repeat';

  }
  setOpacity(im);
  if(im.myOp<1) setTimeout(fade,50);
}

function hidetxt() {
  dd=document.getElementById('divtxt');
  document.body.removeChild(dd);
}

function showtxt(dl,txt,evt) {
  var divTag = document.createElement("div");
  divTag.id = "divtxt";
//  divTag.setAttribute("align","center");
//  divTag.style.margin = "0px auto";
  divTag.className ="difflev";
  divTag.innerHTML = '<b>Comfort level '+dl+'</b><hr>'+txt;
  document.body.appendChild(divTag);
  mx=0; my=0;
  br=browser();
  if (br=='IE') {
    mx=window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    my=window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    wi=document.documentElement.clientWidth;
  }
  if (br=='OP') {
    mx=event.pageX; my=event.pageY; wi=window.innerWidth-14;
  }
  if (br=='SA') {
    mx=event.pageX; my=event.pageY; wi=window.innerWidth-14;
  }
  if (br=='NS') {
    mx=evt.pageX; my=evt.pageY; wi=window.innerWidth-14;
  }
  xx=mx-150;
  divTag.style.left=(mx+10)+'px';
  divTag.style.top=(my+10)+'px';
}

function setOpacity(obj) {
  obj.style.opacity = obj.myOp;
  obj.style.MozOpacity = obj.myOp;
  obj.style.filter = "alpha(opacity=" + (obj.myOp*100) + ")";
}


function refreshbar(id) {
  nlid=id;
  if (id>0) geturl2('getmailsent.php?nlid='+nlid);
}

function browser() {
  br='';
  if (navigator.appName=='Netscape') br='NS';
  if (navigator.appVersion.indexOf('Safari')>0) br='SA';
  if (navigator.appName=='Microsoft Internet Explorer') br='IE';
  if (navigator.appName=='Opera') br='OP';
  if (br=='') if (document.all && !window.opera) br='IE';
  if (br=='') br='IE';
  return br;
}

function geturl2(url) {
  try { xmlHttp=new XMLHttpRequest(); }
  catch(e) {
    try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {
      alert ("Your browser does not support XMLHTTP!"); return; }
  }
  xmlHttp.onreadystatechange=state_Change2; xmlHttp.open("GET",url,true); xmlHttp.send(null);
}

function state_Change2() {
//alert('state_Change state: '+xmlHttp.readyState+', status: '+xmlHttp.status);
  if (xmlHttp.readyState==4) {// 4 = "loaded"
    if (xmlHttp.status==200) {// 200 = OK
      txt=xmlHttp.responseText;
      if (document.getElementById('sendmailbar')) {
        document.getElementById('sendmailbar').innerHTML=txt;
        window.setTimeout('refreshbar(nlid);',5000);
      }
    } else {
      alert("Problem retrieving XML data");
    }
  }
}

function sho( pFileName, pWidth, pHeight ,pTitle ) {
  filename=pFileName.split("/").pop();
  ofsx=(screen.width-pWidth)/2; ofsy=(screen.height-pHeight)/4;
  Win=window.open( "", "_blank", "width="+ pWidth+ ",height="+pHeight+",status=no,scrollbars=no,menubar=no,resizable=no,screenX="+ofsx+",screenY="+ofsy+",left="+ofsx+",top="+ofsy);
  Win.document.write('<html><head><title>'+pTitle+'</title></head>');
  Win.document.title=pTitle;
  Win.document.write('<body topmargin="0" leftmargin="0" text="#FFFFFF" background="'+'pic/'+filename + '" style="background-repeat: no-repeat" onclick="self.close()" onblur="self.close()">');
  Win.document.write('<table border="0" width="100%" height="100%" cellspacing="5" cellpadding="0">');
  Win.document.write('<tr><td width="100%" valign="bottom" align="center"><b><i>');
  if (document.title.substring(0,6)=="Gambia") Win.document.write('(C) Pelican, 2001');
  else if (document.title.substring(0,5)=="Costa") Win.document.write('(C) Pelican, 2003');
  else if (filename.substring(0,4)=="RTWB") Win.document.write('(C) Len Bolle, 2003');
  else if (filename.substring(0,4)=="RTWJ") Win.document.write('(C) Jutka Bartalis, 2003');
  else if (filename.substring(0,4)=="HIV_") Win.document.write('(C) Hivekovics Ákos');
  else if (filename.substring(0,4)=="IMO_") Win.document.write('(C) Olasz Csaba');
  else if (document.title!="Film" && document.title!="Top secret") Win.document.write('(C) Pelican');
  Win.document.write('</b></i></td></tr></table>');
  Win.document.write('</body></html>');
  Win.document.show;
  Win.document.close();
  if (navigator.appName.substring(0,8) == "Netscape") Win.focus();
}

function show( pFileName, pWidth, pHeight ,pTitle ) {
  ofsx=(screen.width-pWidth)/2; ofsy=(screen.height-pHeight)/4;
  Win = window.open( "", "_blank", "width="+ pWidth+ ",height="+pHeight+",status=no,scrollbars=no,menubar=no,resizable=no,screenX="+ofsx+",screenY="+ofsy+",left="+ofsx+",top="+ofsy);
  Win.document.write('<html><head><title>'+pTitle+'</title></head>');
  Win.document.title=pTitle;
  Win.document.write('<body topmargin="0" leftmargin="0" text="#FFFFFF" background="'+ pFileName + '" style="background-repeat: no-repeat">');
  Win.document.write('<table border="0" width="100%" height="100%" cellspacing="5" cellpadding="0">');
  Win.document.write('<tr><td width="100%" valign="bottom" align="center"><b><i>');
  if (document.title.substring(0,6)=="Gambia") Win.document.write('(C) Pelican, 2001');
  else if (document.title.substring(0,5)=="Costa") Win.document.write('(C) Pelican, 2003');
  else if (document.title!="Film") Win.document.write('(C) Pelican, 1999-2003');
  Win.document.write('</b></i></td></tr></table>');
  Win.document.write('</body></html>');
  Win.document.show;
  Win.document.close();
  if (navigator.appName.substring(0,8) == "Netscape") Win.focus();
}
function init() {
//  if (parent.location==self.location) self.location='http://'+self.location.hostname;
//  if (self.location=='localhost') self.location='localhost/hideph01/public_html/';
//  alert(self.location);
  if (self.document.title!='') self.parent.document.title='WANT expeditions - '+self.document.title;
}
function over(pTitle) {
  self.status=pTitle;
}
function out() {
  self.status='';
}
function hirdet0() {
  window.open("hirdet.htm","Hirdet","width=320,height=130,left=86,top=90,screenx=86,screeny=90");
}
function hirdet() {
  window.open("ftn.htm","FTN","width=120,height=240,left=86,top=90,screenx=86,screeny=90");
}
function info() {
  window.open("getpage.php?pg=info","Info","width=320,height=130,left=86,top=90,screenx=86,screeny=90");
}

function hideshow(hid) {
  if (document.getElementById('speclist'+hid).className=='hiddenpart') {
    document.getElementById('speclist'+hid).className='nothidden';
  } else {
    document.getElementById('speclist'+hid).className='hiddenpart';
  }
  return false;
}

function nameDefined(ckie,nme) {
   var splitValues
   var i
   for (i=0;i<ckie.length;++i)
   {
      splitValues=ckie[i].split("=")
      if (splitValues[0]==nme) return true;
   }
   return false;
}
function delBlanks(strng) {
   var result=""
   var i
   var chrn
   for (i=0;i<strng.length;++i) {
      chrn=strng.charAt(i)
      if (chrn!=" ") result += chrn
   }
   return result
}

function SetCookieAfter(cn,cv,nHours) {
  try { xmlHttp=new XMLHttpRequest(); }
  catch(e) {
    try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {
     alert(err); return; }
  }
  xmlHttp.open('GET','setcookie.php?cn='+cn+'&amp;cv='+cv,true); xmlHttp.send(null);
}


function SetCookie(cookieName,cookieValue,nHours) {
 var today = new Date();
 var expire = new Date();
 if (nHours==null || nHours==0) nHours=1;
 expire.setTime(today.getTime() + 3600000*nHours);
 document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString()+";path=/";
}

function getCookie(cookieName) {
  if (document.cookie.length>0) {
    c_start=document.cookie.indexOf(cookieName + "=");
    if (c_start!=-1) {
      c_start=c_start + cookieName.length+1 ;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return '';
}

function testCookie(cname, cvalue) {
   var cookie=document.cookie
   var chkdCookie=delBlanks(cookie)
   var nvpair=chkdCookie.split(";")
   if(nameDefined(nvpair,cname))
   {
      tvalue=getCookie(nvpair,cname)
      if (tvalue == cvalue) return true
   else return false
   }
   else return false
}
function log(pTitle) { if (!testCookie("MyComputerName","Pelican"))
  ;//top.frames["Header"].document.location="http://www.pel.hu/header.php?ref="+pTitle;
}
function makeArray(arraySize) {
  this.length = arraySize; return this
}
function getlastmod() {
  monthNames=new makeArray(12)
  monthNames[0]="január"; monthNames[1]="február"; monthNames[2]="március"; monthNames[3]="április";
  monthNames[4]="május"; monthNames[5]="június"; monthNames[6]="július"; monthNames[7]="augusztus";
  monthNames[8]="szeptember"; monthNames[9]="október"; monthNames[10]="november"; monthNames[11]="december"
  updated=new Date(document.lastModified);
  theMonth=monthNames[updated.getMonth()];
  theYear=updated.getYear(); if (theYear<2000) theYear+=1900;
  zero='';
  if (updated.getMinutes()<10) zero='0';
  return theYear+". "+theMonth+" "+updated.getDate()+". "+updated.getHours()+":"+zero+updated.getMinutes();
}
function getstat() {
  t=new Date();
  y=t.getYear() % 100; if (y<10) y="0"+y;
  m=t.getMonth()+1; if (m<10) m="0"+m;
  return "stats.php?ho="+y+m;
}
function getdays() {
  start=new Date(2003,09,27,0,0,0);  /* a hónapnál 1-el kevesebbet kell írni, mert 0-tól indul */
  curr=new Date();
  days=(Date.UTC(curr.getFullYear(),curr.getMonth(),curr.getDate(),0,0,0)
      - Date.UTC(start.getFullYear(),start.getMonth(),start.getDate(),0,0,0))/86400000;
  return days;
}

function popImage(imageURL,imageTitle) {
  var isNN,isIE;
  if (parseInt(navigator.appVersion.charAt(0))>=4) {
    isNN=(navigator.appName=="Netscape")?1:0;
    isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
  }
  var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
  var optIE='scrollbars=no,width=747,height=547,left='+PositionX+',top='+PositionY;
  if (isNN){imgWin=window.open('about:blank','',optNN);}
  if (isIE){imgWin=window.open('about:blank','',optIE);}
  with (imgWin.document){
    writeln('<html><head><title>Loading ...</title><style>body  {margin:0px;} </style>');writeln('<sc'+'ript>');
    writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
    writeln('width=100-(document.body.clientWidth-document.images[0].width);');
    writeln('height=100-(document.body.clientHeight-document.images[0].height);');
    writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
    writeln('window.innerWidth=document.images["IMG"].width;');writeln('window.innerHeight=document.images["IMG"].height;}}');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
    if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()"  onClick="self.close()" >')
    else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()" onClick="self.close()" >');
    writeln('<img name="IMG" src='+imageURL+' style="display:black"></body></html>');
    close();
  }
}

function Resize(pTitle) {
  var isNN,isIE,im;
  if (parseInt(navigator.appVersion.charAt(0))>=4) {
    isNN=(navigator.appName=="Netscape")?1:0;
    isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
    isOP=(navigator.appName.indexOf("Opera")!=-1)?1:0;
    isFF=(navigator.appName.indexOf("Firefox")!=-1)?1:0;
  }
  if (isIE) {
    window.resizeTo(150,50);
    width=100-(document.body.clientWidth-document.images[0].width);
    height=100-(document.body.clientHeight-document.images[0].height);
    document.images[0].width=1;
    document.images[0].height=1;
    window.resizeTo(width,height);
  }
  if (isOP) {
//    window.resizeTo(150,50);
//    im=document.getElementById('IMG');
//    document.body.clientWidth=im.width;
//    document.body.clientHeight=im.height;
//    im.width=1; im.height=1;
//    window.resizeTo(im.width+2,im.height+2);
//  document.documentelement.clientheight=im.height;
//  document.documentelement.clientwidth=im.width;
    im=document.body.background;
    window.clientX=im.width;
    window.clientY=im.height;
    window.resizeTo(600+8,412+27);
  }
  if (isNN) {
    window.innerWidth=document.images["IMG"].width;
    window.innerHeight=document.images["IMG"].height;
    document.images["IMG"].width=1;
    document.images["IMG"].height=1;
  }
  if (isFF) {
    window.innerWidth=document.images["IMG"].width;
    window.innerHeight=document.images["IMG"].height;
    document.images["IMG"].width=1;
    document.images["IMG"].height=1;
  }
  document.title=pTitle;
}

function sh(pFileName,pWidth,pHeight,pTitle) {
  filename=pFileName.split("/").pop();
  pWidth=150; pHeight=50;
  ofsx=(screen.width-pWidth)/2; ofsy=(screen.height-pHeight)/4;
  Win=window.open( "", "_blank", "width="+ pWidth+ ",height="+pHeight+",status=no,scrollbars=no,menubar=no,resizable=no,screenX="+ofsx+",screenY="+ofsy+",left="+ofsx+",top="+ofsy);
  Win.document.write('<html><head><title>Loading...</title>'); Win.document.title="Loading...";
  Win.document.write('<script type="text/javascript" src="/show.js"></script></head>');
//  Win.document.write('<body topmargin="0" leftmargin="0" text="#FF0000">');
  Win.document.write('<body topmargin="0" leftmargin="0" text="#FFFFFF" background="'+'/pic/'+filename+'" style="background-repeat: no-repeat" onclick="self.close()" onblur="self.close()">');
//  Win.document.write('<img id="IMG" name="IMG" src="/pic/'+filename+'">');
  Win.document.write('<script>Resize("'+pTitle+'");</script>');
  Win.document.write('<table border="0" width="100%" height="100%" cellspacing="5" cellpadding="0">');
  Win.document.write('<tr><td width="100%" valign="bottom" align="center"><b><i>');
  if (document.title.substring(0,6)=="Gambia") Win.document.write('(C) Pelican, 2001');
  else if (document.title.substring(0,5)=="Costa") Win.document.write('(C) Pelican, 2003');
  else if (document.title!="Film" && document.title!="Top secret") Win.document.write('(C) Pelican, 1999-2004');
  Win.document.write('</b></i></td></tr></table>');
  Win.document.write('</body></html>');
  Win.document.show;
//  Win.document.title=pTitle;
  Win.document.close();
  if (navigator.appName=="Netscape") Win.focus();
}

function pwdmin(e,id) {
  if(e.value.length>4) document.getElementById(id).src='pic/WantExpeditions.com.OK.small.png'; else document.getElementById(id).src='pic/spacer.png';
}

function pwdchk(e1,e2,id) {
//alert(e1.value.length);
  if(e1.value==e2.value && e1.value.length>4) document.getElementById(id).className=''; else document.getElementById(id).className='nodisp';
}

function flag(e,id) {
  document.getElementById(id).src='pic/flag/Flag.'+(e.value)+'.png';
}

function showhide(id) {
  el=document.getElementById(id);
  if (el.className=='disp') el.className='nodisp'; else el.className='disp';
//  setCookieAfter('disp'+id,el.className,999999);
  try { xmlHttp=new XMLHttpRequest(); }
  catch(e) {
    try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {alert(e); }
  }
  try {
    url='setcookie.php?cn=disp'+id+'&cv='+el.className;
    xmlHttp.open('GET',url,true);
    xmlHttp.send(null);
  } catch(e) {alert(e); }
}

function createNewInput() {
  inpcnt++;
  tbl=document.getElementById('inpfields');
  row=tbl.insertRow(tbl.rows.length);
  var cell1=row.insertCell(0);
  var textNode = document.createTextNode('pic:');
  cell1.appendChild(textNode);
  cell2=row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'file';
  el.name = 'pic[]';
  el.size = 55;
  cell2.appendChild(el);
  row=tbl.insertRow(tbl.rows.length);
  var cell1=row.insertCell(0);
  var textNode = document.createTextNode('thumb:');
  cell1.appendChild(textNode);
  cell2=row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'file';
  el.name = 'thumb[]';
  el.size = 55;
  cell2.appendChild(el);
  row=tbl.insertRow(tbl.rows.length);
  var cell1=row.insertCell(0);
  var textNode = document.createTextNode('title:');
  cell1.appendChild(textNode);
  cell2=row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'title[]';
  el.size = 70;
  cell2.appendChild(el);
}

function addnc(id) {
  tbl=document.getElementById(id);
  row=tbl.insertRow(tbl.rows.length);
  cell1=row.insertCell(0);
  txin=document.createElement('input');
  txin.name=id+'nam[]';
  txin.type='text';
  stop=document.getElementById('style');
  txin.className='nlettercat'+stop.options[stop.selectedIndex].value;
  txin.size=60;
  txin.maxlength=100;
  cell1.appendChild(txin);
  txin.focus();

  row=tbl.insertRow(tbl.rows.length);
  cell2=row.insertCell(0);
  txin=document.createElement('input');
  txin.name=id+'tit[]';
  txin.type='text';
  stop=document.getElementById('style');
  txin.className='nletterlnk'+stop.options[stop.selectedIndex].value;
  txin.size=60;
  txin.maxlength=100;
  cell2.appendChild(txin);


  row=tbl.insertRow(tbl.rows.length);
  cell1=row.insertCell(0);
  txar=document.createElement('textarea');
  txar.name=id+'txt[]';
  txar.rows=4;
  cell1.appendChild(txar);

  row=tbl.insertRow(tbl.rows.length);
  cell1=row.insertCell(0);
  txin=document.createElement('input');
  txin.name=id+'url[]';
  txin.type='text';
  txin.size=50;
  txin.maxlength=100;
  txin.value='http://wantexpeditions.com/getpage.php?pg=trip&amp;trip_id=';
  cell1.appendChild(txin);
}

function addnl(id) {
  tbl=document.getElementById(id);
  row=tbl.insertRow(tbl.rows.length);
  cell1=row.insertCell(0);
  txin=document.createElement('input');
  txin.name=id+'txt[]';
  txin.type='text';
  txin.value=document.getElementById('hdl').value;
  stop=document.getElementById('style');
  txin.className='nletterlnk'+stop.options[stop.selectedIndex].value;
//  txin.size=60;
//  txin.maxlength=100;
  cell1.appendChild(txin);
//  txin.focus();

/*  row=tbl.insertRow(tbl.rows.length);
  var cell1=row.insertCell(0);
  var txin=document.createElement('input');
  txin.name=id+'url[]';
  txin.type='text';
  txin.size=50;
  txin.maxlength=100;
  txin.value='http://wantexpeditions.com/getpage.php?pg=trip&amp;trip_id='+document.getElementById('tripsel').value;
  cell1.appendChild(txin);
  txar.focus();*/
}

function chtripimg(num,id) {
//alert(id);
  img=document.getElementById('img'+id);
  id=id.substr(0,id.indexOf('_'));
  if (img) img.src='tn/t17_Akos.Hivekovics.Wildlife.And.Nature.Travel.com.Trip.'+id+'.'+num+'.jpg';
  else alert('image not found');
}

function addimg(id) {
  td=document.getElementById('sel'+id);
  if (td) {
    sp=document.createElement('span'); sp.innerHTML='&nbsp;'; td.appendChild(sp);
    op=''; isr=0;
    sel=document.createElement('select'); sel.name='trip'+id+'img[]';
    for (i=0;i<30;i++) {
      op=op+'<option value="'+(i+1)+'">Image '+(i+1)+'</option>';
      if (isr==0 && !document.getElementById('img'+id+'_'+(i+1))) isr=i+1;
      sel.options[sel.options.length]=new Option('Image '+(i+1),(i+1));
    }
    if (isr==0) isr=1;
    sel.onchange=function(){chtripimg(this.options[this.selectedIndex].value,this.id);}
    sel.id=id+'_'+isr;
//alert(id+'_'+isr)    ;
    td.appendChild(sel);
//alert(td.innerHTML);
    td=document.getElementById('img'+id);
    img=document.createElement('img');
    div=document.createElement('div');
    div.style="padding: 0px 0px 10px 10px;";
    img.id='img'+id+'_'+isr;
    img.src='tn/t17_Akos.Hivekovics.Wildlife.And.Nature.Travel.com.Trip.'+id+'.1.jpg';
    stop=document.getElementById('style');
    img.className='nlettertrip'+stop.options[stop.selectedIndex].value;
    div.appendChild(img);
    td.appendChild(div);
//alert(td.innerHTML);
  }
}

function flag(e,id) {
  document.getElementById(id).src='pic/flag/Flag.'+(e.value)+'.png';
}

function scrollLeft(step) {
//alert('scrollLeft('+step+')');
  var sb=document.getElementById ("scrollbox");
  /*if (sb.doScroll)   // Internet Explorer
    sb.doScroll("scrollbarRight"); else */
  sb.scrollLeft += step;
}

function scrollRight(step) {
//alert('scrollRight('+step+')');
  var sb=document.getElementById ("scrollbox");
  //if (sb.doScroll)   // Internet Explorer  sb.doScroll("scrollbarLeft"); else
  sb.scrollLeft -= step;
}

function stopScroll() {
  if (scrollTimer!==null) { clearTimeout (scrollTimer); scrollTimer=null; }
}

function stopWait() {
  if (waitTimer!==null) { clearTimeout (waitTimer); waitTimer=null; }
}

function startScroll(e) {
  stopScroll();
  var posx=0;
  if (!e) var e=window.event;
  if (e.pageX) posx=e.pageX;
  else if (e.clientX) posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
  if (window.innerWidth == undefined) // Internet Explorer
    scrx=document.body.clientWidth; else scrx=window.innerWidth;
  if (posx>scrx/2+100) scrollTimer=setInterval('scrollLeft('+((posx-scrx/2-100)/10)+')', 50);
  if (posx<scrx/2-100) scrollTimer=setInterval ('scrollRight('+((scrx/2-posx-100)/10)+')', 50);
}

function chimg(fn,sn) {
//alert('chimg('+fn+','+sn+')');
  stopWait();
  document.getElementById('tripimg').src=fn;
  document.getElementById('thumb'+(selimg)).style.borderColor='#888';
  img=document.getElementById('thumb'+(sn)); img.style.borderColor='#ff0';
  document.getElementById('imgtitle').innerHTML=sn+'. '+img.alt;
  selimg=sn;
  lastTime=new Date();
  // load next image to next thumb
  thunex=document.getElementById('thumb'+(sn+1));
  if (thunex!=null)

  { prim=new Image();
    prim.src=thunex.src.replace('/tn/','/');
//    alert(tim.src);
  }
}

function slshow() {
//alert('show');
  nn=selimg+1;
  th=document.getElementById('thumb'+(nn));
  if (th==null) {th=document.getElementById('thumb1'); nn=1;}
  imgfn=th.src.replace('/tn/','/');
  if (1==1) {preimg=new Image(); preimg.src=imgfn; preimg.onLoad=imgloaded(nn);
  } else imgloaded(nn);
}

function imgloaded(sn) {
  ///th=document.getElementById('thumb'+(sn));
  if (preimg.complete==false) {stopWait(); waitTimer=setInterval('imgloaded('+sn+');',250); return false; }
//  while (!th.complete) waitms(100);
  tim=new Date();
  chimg(imgfn,sn);
  stopScroll();
  if ((tim-lastTime)>3000) scrollTimer=setInterval(slshow,1); else scrollTimer=setInterval(slshow,3000-(tim-lastTime));
}

function nextpic() {
  nn=selimg+1;
  th=document.getElementById('thumb'+(nn));
  if (th==null) {th=document.getElementById('thumb1'); nn=1;}
  src=th.src.replace('/tn/','/');
  th=document.createElement('img');
  if (th.src!=src) th.src=src;
  if (th.complete==false) {stopWait(); waitTimer=setTimeout(nextpic,250); return false;}
//  while (th.complete==false) waitms(100);
  chimg(src,nn);
}

function prevpic() {
  if (selimg>1) nn=selimg-1;
  th=document.getElementById('thumb'+(nn));
  if (th==null) {th=document.getElementById('thumb1'); nn=1;}
  src=th.src.replace('/tn/','/');
  if (th.src!=src) th.src=src;
  if (th.complete==false) {stopWait(); waitTimer=setTimeout(prevpic,250); return false;}
//  while (th.complete==false) waitms(100);
  chimg(src,nn);
}

function showbutt() {
  stopfade(); fadebutt(0.9);
}

/*function hidebutt() { stopfade(); fadebutt(0);}*/

function fadebutt(lev) {
  if(navigator.userAgent.indexOf('Firefox')>-1) {
    bt=document.getElementById('buttons');
    bt.style.top='720px'; if (window.innerWidth>1000) bt.style.left=(window.innerWidth/2-500+346)+'px';
  }
  bt=document.getElementById('buttons');
  if (!bt.myOp) bt.myOp=0;
  if (bt.myOp<lev) {
    bt.myOp+=0.05;
    if(bt.myOp>lev) {
      bt.myOp=lev;
    }
    setOpacity(bt);
    if(bt.myOp<lev) fadeTimer=setTimeout('fadebutt('+lev+');',15);
  } else {
    bt.myOp-=0.05;
    if(bt.myOp<lev) {
      bt.myOp=lev;
    }
    setOpacity(bt);
    if(bt.myOp>lev) fadeTimer=setTimeout('fadebutt('+lev+');',15);
  }
}

function stopfade() {
  if (fadeTimer!==null) {
    clearTimeout(fadeTimer);
    fadeTimer=null;
  }
}

function hidemap() {
  div=document.getElementById('bigmap');
  div.style.display='none';
  hidezoom();
  return false;
}

function showmap() {
  div=document.getElementById('bigmap');
  if(navigator.userAgent.indexOf('Firefox')>-1) {
    div.style.top='150px'; if (window.innerWidth>1000) div.style.left=(window.innerWidth/2-500+50)+'px';
  }
  div.style.display='block';
}

function movemap(e) {
  zoom=document.getElementById('zoommap');
  if (zoom.style.display=='block') {
    if (!e) var e=window.event;
    if (e.pageX) posx=e.pageX;
    else if (e.clientX) posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    if (e.pageY) posy=e.pageY;
    else if (e.clientY) posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
    ofsx=131; ofsy=137;
//    document.getElementById('th').innerHTML=posx+', '+posy;
    scr=document.getElementById('zoomscr');
    scr.scrollLeft=(posx-137)*2.422-200;
    scr.scrollTop=(posy-175)*2.422-200;
    if (scr.scrollLeft>0 && scr.scrollLeft<1998) zoom.style.left=posx-ofsx-203;
    if (scr.scrollTop>0 && scr.scrollTop<789) zoom.style.top=posy-ofsy-203;
  }
}

function showzoom(e) {
  if (!e) var e=window.event;
  zoom=document.getElementById('zoommap');
  zoom.style.display='block';
  movemap(e);
}

function hidezoom() {
  zoom=document.getElementById('zoommap');
  zoom.style.display='none';
}

function showgal(e) {
//alert('showgal');
  tr=document.getElementById('trsld');
  if (tr!=null) {
    tr.style.display='inline';
    document.getElementById('loading').style.display='none';
  }
}

function addOnloadHandler(func) {
  if (window.onload) {
    var windowOnload = window.onload;
    window.onload = function(evt) {
      windowOnload(evt);
      func(evt);
    }
  } else {
    window.onload = function(evt) {
      func(evt);
    }
  }
}

function waitms(millis)
{
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); }
  while(curDate-date < millis);
}

function showpre(name,e,py) {
//alert('showpre');
  el=document.getElementById(name);
  el.style.display='inline';
  if (!e) var e=window.event;
  if (e.pageX) {posx=e.pageX; posy=e.pageY;}
  else if (e.clientX) {posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    posy=e.clientY+document.body.scrollRight+document.documentElement.scrollRight; }
  if (!posy) posy=py;
  if(!posx) posx=400;
  page=hs.getPageSize(); maxx=page.width; maxy=page.height;
  br=browser();
  if (page) {
    posx=posx+20-(maxx-1000)/2; posy=posy-20;
    if (br=='NS') {posx=posx+(maxx-1000)/2; posy=posy+50;}
  }
  if (e.clientY) if (e.clientY>maxy/2) posy=posy-400;
  if (py>0) {
    el.style.top=(posy+'px'); el.style.left=posx+'px';
  }
}

function showpre2(name,e,py) {
//alert('showpre2');
  el=document.getElementById(name);
  el.style.display='inline';
  if (!e) var e=window.event;
  if (e.pageX) {posx=e.pageX; posy=e.pageY;}
  else if (e.clientX) {posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    posy=e.clientY+document.body.scrollRight+document.documentElement.scrollRight; }
  //if (!posy)
  posy=py;
  if(!posx) posx=400;
  page=hs.getPageSize();
  if (page) {
    maxx=page.width;
    if(posx<maxx/2) {
      posx=posx-100-(maxx-1000)/2;
    } else {
      posx=posx-790;
    }
    br=browser();
    posy=posy+80;
    if (br=='NS') {posx=posx+(maxx-1000)/2; posy=posy+50;}
  }
  if (py>0) {
    el.style.top=(posy+'px'); el.style.left=posx+'px';
  }
}

function showtitledit(id) {
  tit=document.getElementById('title'+id);
  tit.style.display='none';
  div=document.getElementById('titledit'+id);
  div.style.display='inline';
  inp=document.getElementById('tited'+id);
  sp=document.getElementById('sptit'+id);
  inp.value=sp.innerHTML;
  inp.focus();
}

function savetitle(id,txt) {
  div=document.getElementById('titledit'+id);
  div.style.display='none';
  div=document.getElementById('title'+id);
  div.style.display='inline';
  sp=document.getElementById('sptit'+id);
//  inp=document.getElementById('tited'+id);
  sp.innerHTML='<img src="pic/loading.gif" alt="">';
  url='getpage.php?pg=tripimg&Cmd=savetitle&img='+id+'&tid='+document.getElementById('tid').value+'&newtit='+txt;
//  alert(url);
  geturl3(url);
}

function geturl3(url) {
  try { xmlHttp=new XMLHttpRequest(); }
  catch(e) {
    try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {
      alert ("Your browser does not support XMLHTTP!"); return; }
  }
  xmlHttp.onreadystatechange=state_Change3; xmlHttp.open("GET",url,true); xmlHttp.send(null);
}

function state_Change3() {
//alert('state_Change state: '+xmlHttp.readyState+', status: '+xmlHttp.status);
  if (xmlHttp.readyState==4) {// 4 = "loaded"
    if (xmlHttp.status==200) {// 200 = OK
      txt=xmlHttp.responseText;
  sp=document.getElementById('sptit'+txt);
  inp=document.getElementById('tited'+txt);
  sp.innerHTML=inp.value;

    } else {
      alert("Problem retrieving XML data");
    }
  }
}

function upimg(id) {
//alert('upimg: '+id);
  fi=document.getElementById('fileinp'+id);
  fi.style.display='none';
  fl=document.getElementById('fileload'+id);
  fl.style.display='block';
  ff=document.getElementById('imgform');
  inp=document.getElementById('iid');
//alert(inp);
  inp.value=id;
  if (ff) {
//    ff.target='upload_target'+id;
//alert(ff.target);
    ff.submit();
  }
  for(i=1;i<=30;i++) {
    inp=document.getElementById('inppic'+i);
    if (inp) inp.disabled=true;
  }
}

function uploadDone(id,img,size) {
  fi=document.getElementById('fileinp'+id);
  fi.style.display='none';
  fi=document.getElementById('fileload'+id);
  fi.style.display='none';
  fi=document.getElementById('title'+id);
  fi.style.display='block';
  sp=document.getElementById('sptit'+id);
  sp.innerHTML='title';
  fi=document.getElementById('thpasim'+id);
  if (id<10) nn='0'+id; else nn=id;
  fi.src=img;
  is=document.getElementById('imgsize'+id);
  is.innerHTML=size;
  db=document.getElementById('delbutt'+id);
  db.style.display='block';
  db=document.getElementById('delbuttdis'+id);
  db.style.display='none';
  for(i=1;i<=30;i++) {
    inp=document.getElementById('inppic'+i);
    if (inp) inp.disabled=false;
  }
}

function showalltr() {
  if (browser()=='IE') {
    for(i=1;i<=30;i++) {
      tr=document.getElementById('imgtr'+i);
      if (tr) tr.style.display='inline';
    }
  } else {
    for(i=1;i<=30;i++) {
      tr=document.getElementById('imgtr'+i);
      if (tr) tr.style.display='table-row';
    }
  }
  hr=document.getElementById('shalla');
  if (hr) hr.style.display='none';
}

function dragstar(e,mode) {
  if (!e) var e=window.event;
  if (e.pageX) {posx=e.pageX; posy=e.pageY;}
  else if (e.clientX) {
    posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    posy=e.clientY+document.body.scrollRight+document.documentElement.scrollRight; alert(posy);}
  im=document.getElementById('star');
  if (mode==1) {
    isDrag=true;
    if (im) {
      dragOfsX=posx-parseInt(im.style.left);
      dragOfsY=posy-parseInt(im.style.top);
    }
  }
  if (mode==2) {
    if (isDrag) {
      im=document.getElementById('star'); if (im) {im.style.left=(posx-dragOfsX)+'px'; im.style.top=(posy-dragOfsY)+'px';}
    }
  }
  if (mode==0) {
    isDrag=false;
    mx=document.getElementById('mapx'); if (mx) {mx.value=((posx-dragOfsX)+1006);}
    my=document.getElementById('mapy'); if (my) {my.value=((posy-dragOfsY)+488);}
  }
}

function shidelem(el,sh) {
  ob=document.getElementById(el);
  if (ob) ob.style.display=sh;
}

function shpass(num) {

 if (num>1) {document.getElementById('tab2').className='disp';} else {document.getElementById('tab2').className='nodisp';}
 if (num>2) {document.getElementById('tab3').className='disp';} else {document.getElementById('tab3').className='nodisp';}
 if (num>3) {document.getElementById('tab4').className='disp';} else {document.getElementById('tab4').className='nodisp';}
 if (num>4) {document.getElementById('tab5').className='disp';} else {document.getElementById('tab5').className='nodisp';}
 if (num>5) {document.getElementById('tab6').className='disp';} else {document.getElementById('tab6').className='nodisp';}

}
