        function set1()
        {
                var img = document.getElementById("sub");
                img.style.color = "#FF0000";
        }
        function set2()
        {
                var img = document.getElementById("sub");
                img.style.color = "#3879D6";
        }

    function del(id) {
        var req = new Subsys_JsHttpRequest_Js();
        req.caching = false;
        req.onreadystatechange = '';
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.responseJS) {
                                        var img = document.getElementById('item'+id);
                                        img.style.display = "none";
                                        if (req.responseJS.num ==0)
                                        {
                                        document.getElementById('table').style.display = "none";
                                        //document.getElementById('count').innerHTML = 'нет';
                                        document.getElementById('empty').style.display = "block";
                                        document.getElementById('frm').style.display = "none";
                                        }
                }
            }
        }
        req.open('POST', '/delete.php?id='+id, true);
        req.send('id='+id);
    }
    function checksub() {
            _qfMsg='';
                if (document.getElementById('name').value == '') {
                        _qfMsg = _qfMsg + 'Не указано имя\n';
                }
                if (document.getElementById('phone').value == '') {
                        _qfMsg = _qfMsg + 'Не указан телефон\n';
                }
                value = document.getElementById('company').value;
                if (value == '') {
                        _qfMsg = _qfMsg + 'Не указана компания';
                }
                if (_qfMsg!='')
                {
                        alert (_qfMsg);
                        return false;
                }
    }
    function PopUp(PopUpUrl){
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((360)/2);
    placementy=(ScreenHeight/2)-((380)/2);
    WinPop=window.open(PopUpUrl,"","width=360,height=290,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
   }
    function popupBig(PopUpUrl,name){
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((600)/2);
    placementy=(ScreenHeight/2)-((413)/2);
    WinPop=window.open("/show.php?url="+PopUpUrl+"&name="+name,"","width=600,height=413,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
   }
    function popup_(PopUpUrl){
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((600)/2);
    placementy=(ScreenHeight/2)-((600)/2);
    WinPop=window.open(PopUpUrl,"","width=600,height=413,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
   }
    function addcart(id) {
        // Получаем текст запроса из <input>-поля.
        if (isNaN(document.getElementById('num'+id).value))
        {
                alert('Необходимо ввести число.');
                return false;
        }

        var price = document.getElementById('price'+id).value;
        var napol = document.getElementById('napol'+id).value;
        if (napol==0)
        {
                alert('Выберите наполнитель');
                return false;
        }
        var num = document.getElementById('num'+id).value;
        if (num<=0)
        {
                alert('Необходимо ввести число.');
                return false;
        }
            var name = document.getElementById('name'+id).value;
        // Создаем новый объект JSHttpRequest.
        var req = new Subsys_JsHttpRequest_Js();
        req.onreadystatechange = '';
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.responseJS) {
                    alert('Товар '+name+' добавлен в корзину ('+num+' шт.)');
                    //alert(req.responseJS.napol);
                }
            }
        }
        req.caching = false;
        // Подготваливаем объект.
        //alert('/addcart.php?id='+id+'&name='+name+'&price='+price+'&num='+num+'&type='+type);
        req.open('POST', '/addcart.php', true);
        // Посылаем данные запроса (задаются в виде хэша).
        req.send('id='+id+'&name='+name+'&price='+price+'&num='+num+'&napol='+napol);

    }





ToolTip.offsetX=20; //смещения подсказки от курсора
ToolTip.offsetY=10; //
function ToolTip(obj, text) {
  if(!obj||obj.nodeType!=1) throw "Illigal argument exception"; //обьект к кому привязываем подсказку
  //-- Разметка подсказки ---
  var tip=document.createElement("DIV");
  tip.className="tool_tip";
  tip.innerHTML=text;
  document.body.appendChild(tip);
  //-- события --
  obj.onmouseout=function (ev) {
      tip.style.visibility="hidden";
  };
  obj.onmousemove=function(ev) { //если не нужно что бы подскасзка бегала, то onmouseover
      tip.style.visibility="visible";
      if(window.event) ev=window.event;
      tip.style.left=ev.clientX + document.body.scrollLeft + ToolTip.offsetX;
      tip.style.top=ev.clientY + document.body.scrollTop + ToolTip.offsetY;
  };
}
//переберем заданные элементы, дадим подказку тем у кого есть аттрибут tooltip
//В аргументах передаем имена рассматриваемых тегов, * все теги
function initToolTips() {
//   return;
    var tags, tooltext;
    for(var i=0; i<arguments.length; i++) {
       tags=document.body.getElementsByTagName(arguments[i]);
       for(var j=0; j<tags.length; j++)
            if((tooltext=tags[j].getAttribute("tooltip"))) ToolTip(tags[j], tooltext);
   }
}
old='';
done=0;
function resize (obj)
{
    if (old!=='')
    {
        var img = document.getElementById('choose'+old);
        img.style.display = "none";
        check_old();
    }

var img = document.getElementById('choose'+obj);
img.style.display = "block";
    new Rico.Effect.Size( 'choose'+obj,
                        230, // width = 450px

                        150, // don't change the height

                        300, // 500ms (1/2 second)

                        10, // 10 steps

                        {complete:function() {done=1;}}  );
old=obj;
}

function mkch (main,ob)
{
        var img = document.getElementById('link'+main);
        img.innerHTML = document.getElementById('napnam'+ob).value;
        var img = document.getElementById('napol'+main);
        img.value = ob;
        var img = document.getElementById('choose'+main);
        img.style.display = "none";
        img.style.width=50;
        img.style.height=10;
        old='';
        done=0;
}

function check_old()
{
    if (old!='') if (done==1)
    {
        var img = document.getElementById('choose'+old);
        img.style.display = "none";
        img.style.width=50;
        img.style.height=10;
        old='';
        done=0;
        return false;
    }

}

function Start(url,name,wid,hei)
 {
 OpenWin = this.open("/show.php?url="+url+"&amp;name="+name+"&amp;width="+wid,"_blank","toolbar=No,menubar=No,location=No,scrollbars=No,resizable=Yes,status=No,width="+wid+",height="+hei+"");

 }

    function woimg(sname, w, h)
    {
        ww = w + 40; hh = h + 55;
        window.open(sname,'','width=' + ww + ' , height=' + hh + ', tollbar=no, location=no, status=no, menubar=no, directories=no resizable=no, scrollbars=yes');
        return false;
    }
 