function jspop(url) {
	winpopup1 = window.open('mods/mod.'+url+'.php',"popup","height=200,width=350,menubar=no,scrollbars=yes,status=no,toolbar=no,screenX=100,screenY=0,left=100,top=0");
}
function pop(url) {
	winpopup1 = window.open(url,"popup","height=500,width=750,menubar=no,scrollbars=yes,status=no,toolbar=no,screenX=100,screenY=0,left=100,top=0");
}
function jspix(url) {
	winpopup1 = window.open('mods/mod.editpix.php?id='+url,"popup1","height=500,width=500,menubar=no,scrollbars=yes,status=no,toolbar=no,screenX=100,screenY=0,left=100,top=0");
}
function delfromform(url) {
	var frm = document.forms['addimot'][url].value
	top.location.replace('?m=imoti&t='+url+'&del='+frm);
}
function deltemplate(url) {
	var frm = document.forms['templates'][url].value
	top.location.replace('?m=settings&y=email_templates&r=del&t='+url+'&id='+frm);
}
function edittemplate() {
	var frm = document.forms['templates']['templates'].value
	top.location.replace('?m=settings&y=email_templates&r=edit&id='+frm);
}
function delstatic(url) {
	var frm = document.forms['static'][url].value
	top.location.replace('?m=static&r=del&t='+url+'&id='+frm);
}
function editstatic() {
	var frm = document.forms['static']['static'].value
	top.location.replace('?m=static&r=edit&id='+frm);
}
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset 
  offY: 6,   // vertical offset 
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);
  },
  
  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById) 
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
  },
  
  position: function(mnu, e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    
    if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - mnu.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = y + this.offY;
    
    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
  },
  
  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },
  
  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode ) 
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }
  
}
var http_request;

function requestc(){
  if (http_request.readyState == 4){
    if (http_request.responseText==1){
      t=document.getElementById('reft');
      t.innerHTML='&nbsp; този номер е зает!';
    }
    else{
      t=document.getElementById('reft');
      t.innerHTML='&nbsp; OK';
    }
  }
}

function makeRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
        http_request.overrideMimeType('text/xml');
      }
  } else if (window.ActiveXObject) { // IE
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
  }
  if (!http_request) {
      return false;
  }
  http_request.onreadystatechange = requestc;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function checkref(fn){
  v=document.forms.addimot[fn].value;
  makeRequest('mods/mod.checkref.php?ref=', v);
}