$(document).ready(function(){
  init();
});
function init() { document.onkeydown = doOnKeyDown; }
function doOnKeyDown (e) {
  e = e || window.event;
  if (e.keyCode == 27){
    hideRe();
  }
}

function hideRe() {
    $('#sa').hide();
    $('#divadd').hide();
};



function getAngleNav(obj, basis) {
  var cnt = $(obj).length;
  for (i=0; i<cnt; i++) {
    offset = basis - (i*10);
    $(obj+':eq('+i+') a').css('margin-left', offset+'px')
    $(obj+':eq('+i+') span').css('margin-left', offset+'px')
  }
}

function getAngle(obj, basis) {
  var cnt = $(obj).length;
  for (i=0; i<cnt; i++) {
    offset = basis - (i*8.5);
    $(obj+':eq('+i+')').css('margin-left', offset+'px')
    $(obj+':eq('+i+')').css('margin-left', offset+'px')
  }
}

function getMargin(obj, h) {
  var w = parseInt((h-1003)/-2.51579); 
  $(obj).css('margin-left', w + 'px');
};


function getMain(mfile, mode, frm) {
    $('#sa').show();
    $("#divadd").show();
    putLayer('divadd', 85);
    var options = {
    url:      '/'+mfile+'.php',
    type:     'POST',
    data:     {mode:mode},
    success:  function(answer) { 
                $('#divadd .wcontent').html(answer).animate({"opacity": "show"}, "slow");
              } 
    }
    $("#"+frm).ajaxSubmit(options);
}
function putLayer(mydiv, top) {
    var Width = document.documentElement.scrollTop;

if (document.body.scrollTop == 0) {
    var Y = document.documentElement.scrollTop;
} else {
    var Y = document.body.scrollTop;
}
    heightBrowser = top + Y;
    document.getElementById(mydiv).style.top = heightBrowser + "px";
}
