var hctmo=0;
var maininfolink;

function openad(){

}

function openfriendswin(l) {
  window.open(l,'_blank','width=1000, height=700, scrollbars=1, resizable=1');
}

function showhidename(field,val) { 
  if (typeof val=='undefined') val=field.defaultValue;
  if (val==field.value) {
    field.value = '';
  } else if (field.value == '') {
    field.value = val;
  } 
}

function setmenugender(g){
  if (g==0) g=1;
  document.getElementById('friendsmenu').className='friendsmenudiv'+g;
  document.getElementById('friendsmenuinside').className='friendsmenudivinside'+g;
  document.getElementById('friendstxt').className='friendsmenutxt'+g;
  document.getElementById('friendslink1').className='friendsmenulink'+g;
  document.getElementById('friendslink2').className='friendsmenulink'+g;
  document.getElementById('friendslink3').className='friendsmenulink'+g;
  document.getElementById('friendslink4').className='friendsmenulink'+g;
}

function hltopl(a){
  a.style.backgroundColor='#ffffff';
  a.style.color='#68a18a';
}
function dhltopl(a){
  a.style.color='#ffffff';
  a.style.backgroundColor='#68a18a';
}
function sethctmo() {
  if (hctmo!=0) clearhctmo();
  hctmo=setTimeout('hidecats()',1);
  //document.getElementById('tracewin').value+='Timeout: '+hctmo+'\r\n';
}
function clearhctmo(){
  if (hctmo!=0) clearTimeout(hctmo);
  //document.getElementById('tracewin').value+='Cleared: '+hctmo+'\r\n';
}

function checkval(e,l) {
  if (e.value.length>l) e.value=e.value.slice(0,l);
}
function showmenu1(n){
  clearhctmo();
 // hidecats();
  posmenu('menu'+n,'menu'+n+'items',15,0);
}
function showcats(c,obj) {
  clearhctmo();
  document.getElementById('menu1items').style.display='none';
  document.getElementById('menu2items').style.display='none';
  document.getElementById('menu3items').style.display='none';
  ns=0;
  if (document.getElementById('selcateg'+c).style.display!='none') ns=1;
  for (var i=1;i<=7;i++) {
    document.getElementById('selcateg'+i).style.display='none';
  }
  if (ns==0) posmenu(obj,'selcateg'+c,20,0);
}
function showcats3(c,obj) {
  clearhctmo();
  document.getElementById('menu1items').style.display='none';
  document.getElementById('menu2items').style.display='none';
  document.getElementById('menu3items').style.display='none';
  ns=0;
  if (document.getElementById('selcateg'+c).style.display!='none') ns=1;
  for (var i=1;i<=7;i++) {
    document.getElementById('selcateg'+i).style.display='none';
  }
  if (ns==0) posmenu(obj,'selcateg'+c,22,0);
}
function hidecats() {
  document.getElementById('menu1items').style.display='none';
  document.getElementById('menu2items').style.display='none';
  document.getElementById('menu3items').style.display='none';
  for (var i=1;i<=7;i++) {
    document.getElementById('selcateg'+i).style.display='none';
    dhltopl(document.getElementById('categslink'+i));
    document.getElementById('popupstart'+i).style.backgroundColor='#68a18a';
    document.getElementById('droplnk'+i).style.color='#ffffff';
  }
}
function showcats2(c,obj) {
  ns=0;
  if (document.getElementById('selcateg'+c).style.display!='none') ns=1;
  for (var i=1;i<=7;i++) {
    document.getElementById('selcateg'+i).style.display='none';
  }
  if (ns==0) posmenu(obj,'selcateg'+c,0,0);
}
function showpopup(url, w, h){
  document.getElementById('popupframe').style.width=w+'px';
  document.getElementById('popupframe').style.height=h+'px';
  parent.frames.popup.document.location.href=url;
  document.getElementById('popuptable').style.display='';
  document.getElementById('popuptable').style.left=Math.round((screen.width-w-40)/2);
  document.getElementById('popuptable').style.top=Math.round((screen.height-h-100)/2)-100;
}
function hidepopup(){
  document.getElementById('popuptable').style.display='none';
}
var menutmo=0;
function cleartmo(){
  if (menutmo!=0) clearTimeout(menutmo);
}
function settmo(){
  cleartmo();
  menutmo=setTimeout('hidefriendsmenu()',100);
}
function showusermenu(){
  document.getElementById('userlinksdropdown').style.display='block';
}
function hideusermenu(){
  document.getElementById('userlinksdropdown').style.display='none';
}
function posfriendsmenu(u,c){
  cleartmo();
  obj=document.getElementById('friendtbl'+u);
  var curleft = 0;
  var curtop = 0;
  if (obj.offsetParent) {
  curleft = obj.offsetLeft
  curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  document.getElementById('friendscountry').innerHTML=c;
  document.getElementById('friendsmenu').style.top=parseInt(curtop);
  document.getElementById('friendsmenu').style.left=parseInt(curleft);
  document.getElementById('friendsmenu').style.display='block';
  return false;
}
function hidefriendsmenu() {
  document.getElementById('friendsmenu').style.display='none';
}
maploaded=0;
winsready=0;
function showwin(w) {
  if (winsready==1) openwin(w);
  else setTimeout('showwin('+w+');',500);
}
function showviewads() {
  document.getElementById('topa2').style.fontWeight='';
  document.getElementById('topa1').style.fontWeight='bold';
  document.getElementById('topa2').style.color='#071965';
  return showwin('1');
}
function showaddad() {
  document.getElementById('topa1').style.fontWeight='';
  document.getElementById('topa2').style.fontWeight='bold';
  document.getElementById('topa1').style.color='#071965';
  return showwin('2');
}
function posmenu(obj1,menu,ot,ol){
  obj=document.getElementById(obj1);
  if (document.getElementById(menu).style.display!='none') {
    document.getElementById(menu).style.display='none';
    return false;
  }
  var curleft = 0;
  var curtop = 0;
  if (obj.offsetParent) {
  curleft = obj.offsetLeft
  curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  document.getElementById(menu).style.top=parseInt(curtop)+parseInt(ot);
  document.getElementById(menu).style.left=parseInt(curleft)+parseInt(ol);
  document.getElementById(menu).style.display='';
  //window.scrollTo(0,parseInt(curtop)-20);
  return false;
}
function checkint(v,hd){
  var ret='';
  if (hd==1) hasdot=1;
  else hasdot=0;
  afterdot=0;
  for (var i=0;i<v.length;i++) {
    nm=v.slice(i,i+1);
    if (nm==0 || nm==1 || nm==2 || nm==3 || nm==4 || nm==5 || nm==6 || nm==7 || nm==8 || nm==9 || nm=="." || nm==",") {
      if (nm=="." || nm==",") {
        if (hasdot==0) {
          ret=ret+nm;
          afterdot=1;
        }
        hasdot=1;
      } else {
        if (afterdot<=2) ret=ret+nm;
        if (afterdot>0) afterdot++;
      }
    }
  }
  return ret.replace(' ','');
}

function checkint2(v,hd){
  ret='';
  if (hd==1) hasdot=1;
  else hasdot=0;
  afterdot=0;
  for (var i=0;i<v.length;i++) {
    nm=v.slice(i,i+1);
    if (nm==='0' || nm==1 || nm==2 || nm==3 || nm==4 || nm==5 || nm==6 || nm==7 || nm==8 || nm==9) ret=ret+nm;
  }
  return ret;
}


function opened(id,table,extra,wd,ht,sb){
  lt=(Math.round((screen.width-wd)/2));
  tp=(Math.round((screen.height-ht)/2));
  tp-=50;
  if (tp<1) tp=1;
  window.open("edit.php?table="+table+"&id="+id+"&"+extra,"_blank","toolbar=0, scrollbars="+sb+", resizable=1, width="+wd+", height="+ht+",top="+tp+",left="+lt);
}
function switchit(i){
  if (document.getElementById(i).style.display=='none') {
    document.getElementById(i).style.display='block';
  } else {
    document.getElementById(i).style.display='none';
  }
  return false;
}

function hlrow(n){   
  document.getElementById('c1_'+n).className='paramcellh';
  document.getElementById('c2_'+n).className='paramcellh';
  document.getElementById('c3_'+n).className='paramcellh';
  document.getElementById('c4_'+n).className='paramcellh';
}
function dhlrow(n){
  document.getElementById('c1_'+n).className='paramcell';
  document.getElementById('c2_'+n).className='paramcell';
  document.getElementById('c3_'+n).className='paramcell';
  document.getElementById('c4_'+n).className='paramcell';
}        
function changelang(l) {
  document.form2.data.value=l;
  document.form2.todo.value='changelang';
  document.form2.submit();
}
function setdesign(c) {
  document.form2.data.value=c;
  document.form2.todo.value='setdesign';
  document.form2.submit();
}
function addzeros(n) {
  var f=parseFloat(n);
  return f.toFixed(2);
}

function addelement(div,html) {
  var ni = document.getElementById(div);
  var newdiv = document.createElement('div');
  newdiv.innerHTML = html;
  ni.appendChild(newdiv);
}