window.onmousemove = move;
function AgressItem(type,id)
{
	document.getElementById('pict').style.display = 'block';
	$.ajax({
	   url: '/ajax/actions.php?type='+type+'&item='+id,
	    success: function (data, textStatus) {
            document.getElementById('pict').style.display = 'none';
                     if(data.length > 0) jAlert(data, 'Востановление пароля');	   }
	});
}

function CheckCode(text)
{
	document.getElementById('pict').style.display = 'block';
	$.ajax({
	   url: '/ajax/actions.php?type=code&item='+text,
	    success: function (data, textStatus) {
            document.getElementById('pict').style.display = 'none';
            		if (data=='error')
                     document.getElementById('code_status').src = '/i/status-error.gif';
                     else  document.getElementById('code_status').src = '/i/status-ok.gif';
	   }
	});
}
function getNews(id)
{
	document.getElementById('pict').style.display = 'block';
	$.ajax({
	   url: '/ajax/actions.php?type=news&id='+id,
	    success: function (data, textStatus) {
            document.getElementById('pict').style.display = 'none';
              	document.getElementById('news_id').innerHTML = data;
                if (id == 'stocks') var title = 'Все акции';
                if (id == 'articles') var title = 'Все статьи';
                if (id == 'exhibitions') var title = 'Все выставки';
              	document.getElementById('head_url').innerHTML = '<a class="all" href="/page/'+id+'.html">'+title+'</a>';
	   }
	});
}
function updateUserAcount(obj)
{
   	$.ajax({
	   url: '/ajax/actions.php?type=update_user&user_id='+obj.user_id+'&pass='+obj.pass+'&fio='+obj.fio+'&tel='+obj.tel+'&email='+obj.email+'&icq='+obj.icq+'&paket='+obj.paket,
	    success: function (data, textStatus) {
                     if(data.length > 0) jAlert(data, 'Сравнение');

	   }
	});
}
function sendZhaloba(obj)
{
   	$.ajax({
	   url: '/ajax/actions.php?type=zhaloba&email='+document.getElementById('email').value+'&fio='+document.getElementById('fios').value,
	    success: function (data, textStatus) {
                     if(data.length > 0) jAlert(data, 'Сравнение');

	   }
	});
}
function CheckLogin(login)
{
	document.getElementById('pict').style.display = 'block';
	$.ajax({
	   url: '/ajax/checlogin.php?login='+login,
	    success: function (data, textStatus) {
            if (data == 'error'){ document.getElementById('login_status').src='/i/status-error.gif';
           	    document.getElementById('submit_but').onclick = function (){jAlert('Все поля обязательны к заполнению', 'Введите корректный логин');}}
            else{ document.getElementById('login_status').src='/i/status-ok.gif';   document.getElementById('submit_but').onclick = function (){calidateForm();}}
	    document.getElementById('pict').style.display = 'none';
	   }
	});
}
 function getScrollY() {
          var scrOfY = 0;
          if( typeof( window.pageYOffset ) == 'number' ) {
            scrOfY = window.pageYOffset;
          } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            scrOfY = document.body.scrollTop;
          } else if( document.documentElement &&
              (document.documentElement.scrollTop ) ) {
            scrOfY = document.documentElement.scrollTop;
          }
          return scrOfY;
        }

function move(e) {
    var o=document.getElementById('pict');
    var bodyHeight = parseInt(document.body.offsetHeight);
    var bodyWidth = parseInt(document.body.offsetWidth);
    x = e.clientX>0 ? e.clientX:e.pageX;
            y = e.clientY>0 ? e.clientY:e.pageY;
            y = getScrollY()+y;
            o.style.left = x + 8+"px";
            o.style.top = y + (-10)+"px";
            o.style.position = 'absolute';
}
HotKeyHandler.keys = {};
HotKeyHandler.convertIEKey={"1":65,"2":66,"4":68,"12":76,"16":80,"19":83,"20":84,"21":85,"26":90};
HotKeyHandler.windowInit=function() {
   if(document.addEventListener && (getOperaVersion()>6||getOperaVersion()==0)) {
     document.addEventListener("keypress", HotKeyHandler, false);
   } else {
     document.attachEvent("onkeydown", HotKeyHandler);
   }
}
function getOperaVersion() {
  var opver=navigator.userAgent.match(/Opera\s*([0-9.]+)/i);
  return (opver&&opver.length>1)? parseFloat(opver[1]): 0;
}
HotKeyHandler.keys = {
 "\x1B":function(){$.modal.close();}
};
HotKeyHandler.windowInit();
function HotKeyHandler(ev) {
    var evt, key;
    if(!(evt=window.event? window.event: ev)) return;
    key = evt.keyCode? evt.keyCode: evt.charCode;
    key=HotKeyHandler.convertIEKey[String(key)]? HotKeyHandler.convertIEKey[String(key)]: key;
    if (evt.ctrlKey||key==27) {
     key=evt.shiftKey? String.fromCharCode(key).toUpperCase(): String.fromCharCode(key).toLowerCase();
     if(typeof(HotKeyHandler.keys[key]) == "function"){
        HotKeyHandler.keys[key](evt);
     evt.cancelBubble = true;
     evt.returnValue = false;
     if(evt.preventDefault) evt.preventDefault();
     if(evt.stopPropagation) evt.stopPropagation();
                   return false;
  }
    }
    return true;
}


function GetSubcats(id, suffix)
{
    if (!suffix) suffix = '';
    
	document.getElementById('pict').style.display = 'block';
	$.ajax({
	   url: '/ajax/actions.php?type=get_subcats&parent='+id,
	    success: function (data, textStatus) {
            document.getElementById('pict').style.display = 'none';
              	document.getElementById('subcats'+suffix).innerHTML = data;

	   }
	});
}


function calculate(){
    
    var data = $('#form_calc').serialize();
    
    $.ajax({
	   url: '/ajax/actions.php?type=calculate',
       type: 'POST',
       data: data,
       success: function (data, textStatus) {
            alert(data);
	   }
	});
    
    
    
}
