$(function() {
   $(".thickbox img").mouseover(function() {
    $(this).css({'border-color': '#00FF00'});
   });
   $(".thickbox img").mouseout(function() {
    $(this).css({'border-color': '#000000'});
   });
   $(".thickbox img").click(function() {
    $(this).css({'border-color': '#000000'});
   });
  });
  
  tb_pathToImage = "/jcarousel/images/loading-thickbox.gif";
  
  var selected = (selected!='') ? parseInt(carousel_sel)+1 : 0;
  //var csize = parseInt(carousel.size());
  var csize = 6;
  var ctotal = (carousel_total!='') ? parseInt(carousel_total) : 6;
  var start = 1;

  if(selected > csize)
  {
     blocks = Math.ceil(ctotal/csize);
     for(i=0;i<blocks;i++)
     {
         lim = parseInt(i*csize+1);
         lim2 = parseInt((i+1)*csize+1);
         if(selected >= lim && selected < lim2)
         {
            start = lim; //alert(i+"=>"+lim+"=>"+selected +"=>"+lim2);
            break;
         }
     }
  }
  //alert(start);

    function mycarousel_itemLoadCallback(carousel, state)
    {
        first_item = carousel.first;
        last_item = carousel.last;

        // Check if the requested items already exist
        if (carousel.has(first_item, last_item)) {
            return;
        }
        
        jQuery.get(
            '/ajax_bottom_section.php',
            {
                first: first_item,
                last: last_item,
                categ: cat
            },
            function(xml) {
                mycarousel_itemAddCallback(carousel, first_item, last_item, xml);
            },
            'xml'
        );
    };

    function mycarousel_itemAddCallback(carousel, first, last, xml)
    {
        // Set the size of the carousel
        carousel.size(parseInt(jQuery('total', xml).text()));

        string = '';
        jQuery('image', xml).each(function(i) {
          var item = jQuery(mycarousel_getItemHTML(jQuery(this).text()));
          //var item = mycarousel_getItemHTML(jQuery(this).text());
          //string +='<li class="jcarousel-item"><div style="width:245px">'+item+'</div></li>';
          carousel.add(first + i, item);
        });

    };

    function mycarousel_getItemHTML(url)
    {
        var url_ = url.split(',');
        var cid = url_[1];
        var title = url_[2];
        var src = url_[0];
        var repl = '/images/cat/'+url_[3];
        var height = url_[4];
        var act = url_[5];
        var realcatname = url_[6];
        var id = "img_"+cid; // alert(src);
        
        if(realcatname!='' && realcatname!='/') catid = realcatname;
        else catid = '/'+cid+'/';
        
        if(act == 1)
        {
          //alert ('<img id="img_'+cid+'" src="/images/cat/'+src+'" height="'+height+'" border="0" />');
          return '<img id="img_'+cid+'" src="/images/cat/'+src+'" height="'+height+'" border="0" />';
        }
        else
        {
          //alert('<a href="/cat/'+cid+'/\' title="'+title+'" onMouseOver="document.getElementById(\''+id+'\').src=\''+repl+'\' " onMouseOut="document.getElementById(\''+id+'\').src=\'/images/cat/'+src+'\' " ><img id="img_'+cid+'" src="/images/cat/'+src+'" height="'+height+'" border="0" /></a>');
          return '<a href="/cat'+catid+'" title="'+title+'" onMouseOver="document.getElementById(\''+id+'\').src=\''+repl+'\' " onMouseOut="document.getElementById(\''+id+'\').src=\'/images/cat/'+src+'\' " ><img id="img_'+cid+'" src="/images/cat/'+src+'" height="'+height+'" border="0" /></a>';
        }
    };

    jQuery(document).ready(function() {
        //alert(start+"=>"+ctotal);
        jQuery('#mycarousel').jcarousel({
            start: start,
            size: ctotal,
            scroll: 6,
            visible: 6,
            itemLoadCallback: mycarousel_itemLoadCallback

            
        });
    });

var ldr=null;
var ldr2=null;

function selector()
{
   var A=null;
   try
   {
      A=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch(e)
   {
      try
      {
         A=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(oc)
      {
         A=null;
      }
   }
   if(!A&&typeof XMLHttpRequest!="undefined")
   {
      A=new XMLHttpRequest();
   }
   return A;
}

function selector2()
{
   var A=null;
   try
   {
      A=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch(e)
   {
      try
      {
         A=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(oc)
      {
         A=null;
      }
   }
   if(!A&&typeof XMLHttpRequest!="undefined")
   {
      A=new XMLHttpRequest();
   }
   return A;
}

function add(sel,v,n)
{
   var newOpt=sel.appendChild(document.createElement('option'));
   newOpt.text=n;
   newOpt.value=v;
}


function chan(lng, f,name,qw,parm)
{
  if(ldr && ldr.readyState!=0) { ldr.abort() }
  ldr=selector();

  if(ldr)
  {
    name.length = 0;
    ff = document.getElementById('attrvalue'); //alert(qw);
    //alert("/actions.php?action=getAttribs&q="+parm+"&sel="+qw+"&lng="+lng);
    
    ldr.open("GET","/actions.php?action=getAttribs&q="+parm+"&sel="+qw+"&lng="+lng,true);
    ldr.onreadystatechange=function()
    {
      if(ldr.readyState>=0 && ldr.readyState<4)
      {
         add(ff, '', 'Идёт загрузка значений...');
      }
      else if(ldr.readyState==4 && ldr.responseText)
      {
         ff.innerHTML = '';
         eval(ldr.responseText);
         //alert(ldr.responseText);
      }
    }
    ldr.send(null)
  }
}


function setCurrency(id)
{
  if(ldr&&ldr.readyState!=0) { ldr.abort() }
  ldr=selector();
  if(ldr)
  {
     bl = "curr_div";
     ldr.open("GET","/actions.php?action=setCurrency&curr="+id,true);
     ldr.onreadystatechange=function()
     {
        if(ldr.readyState==4 && ldr.responseText)
        {
           window.location.reload();
           //document.getElementById(bl).innerHTML = ldr.responseText;
        }
        else
        {
           if(document.getElementById(bl)) document.getElementById(bl).innerHTML = '<img src="/i/working.gif"/>';
        }
     }
     ldr.send(null);
  }
}

function setCookie (name, value, path, expires, domain, secure)
{
   document.cookie = name + "=" + escape(value) +
   ((expires) ? "; expires=" + expires : "") +
   ((path) ? "; path=" + path : "") +
   ((domain) ? "; domain=" + domain : "") +
   ((secure) ? "; secure" : "");
}

function cookieVal(cookieName)
{
  thisCookie = document.cookie.split("; ")
  for(i = 0; i < thisCookie.length; i++)
  {
      if(cookieName == thisCookie[i].split("=")[0])
      {
         return thisCookie[i].split("=")[1];
      }
  }
  return 0;
}

function getCartCount()
{
   if(ldr && ldr.readyState!=0) { ldr.abort() }
   ldr=selector();
   if(ldr)
   {
      ldr.open("GET","/actions.php?action=cartCount",true);
      
      ldr.onreadystatechange=function()
      {
         if(ldr.readyState==4 && ldr.responseText)
         {
            return ldr.responseText;
         }
      }
      ldr.send(null);
   }
}

function add2Cart(id, image,image2,lng)
{
  if(cookieVal('diskoff_add2Cart') == 1) return false;  //Другой товар уже добавляется в корзину,блокируем добавление другого до получения ответа
  else
  {
     //Все ОК, блокируем корзину
     setCookie ('diskoff_add2Cart', 1, '/'); //На добавление
     setCookie ('diskoff_delCart', 1, '/');  //На удаление
     var cartCount = parseInt(cookieVal('diskoff_cartCount'));
     cartCount++;
     setCookie ('diskoff_cartCount', cartCount, '/'); //alert(cartCount);
     
     if(ldr && ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        bl = "suma";
        bl2 = "itm_"+id;
        bl3 = "cart_img";

        ldr.open("GET","/actions.php?action=add2Cart&item_id="+id,true);
        ldr.onreadystatechange=function()
        {
           if(ldr.readyState==4 && ldr.responseText)
           {
              if(image) document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url('+image+') no-repeat;" href="javascript://" title="'+ldr.responseText+'" onClick="delFromCart(\''+id+'\',\''+image2+'\',\''+image+'\',\''+lng+'\')"><img src="'+image+'" border="0"/></a>';
              else document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url('+image+') no-repeat;" href="javascript://" title="'+ldr.responseText+'" onClick="delFromCart(\''+id+'\',\''+image2+'\',\'\',\''+lng+'\')"><img src="'+image+'" border="0"/></a>';

              if(cartInfo(lng))
              {
                 document.getElementById(bl).innerHTML = cartInfo(lng);
              }
              document.getElementById(bl3).style.display = 'inline';
              
              //Разблокируем корзину
              setCookie ('diskoff_add2Cart', 0, '/');
              setCookie ('diskoff_delCart', 0, '/');
           }
           else
           {
              document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url(/i/working.gif) no-repeat;"><img src="/i/working.gif"/></a>';
              //document.getElementById(bl).innerHTML = '<img src="/i/working.gif"/>';
           }
        }
     ldr.send(null);
     }
  }
}

function delFromCart(id, image,image2,lng)
{
  if(cookieVal('diskoff_delCart') == 1) return false;  //Другой товар удаляется из  корзины,блокируем удалениее другого до получения ответа
  else
  {
     //Все ОК, блокируем корзину
     setCookie ('diskoff_delCart', 1, '/'); //На удаление
     setCookie ('diskoff_add2Cart', 1, '/'); //На добавление
     var cartCount = parseInt(cookieVal('diskoff_cartCount'));
     cartCount--;
     setCookie ('diskoff_cartCount', cartCount, '/'); //alert(cartCount);

     if(ldr&&ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        bl = "suma";
        bl2 = "itm_"+id;
        bl3 = "cart_img";

        ldr.open("GET","/actions.php?action=delFromCart&item_id="+id,true);
        ldr.onreadystatechange=function()
        {
           if(ldr.readyState==4 && ldr.responseText)
           {
              if(image) document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url('+image+') no-repeat;" title="'+ldr.responseText+'" href="javascript://" onClick="add2Cart(\''+id+'\',\''+image2+'\',\''+image+'\',\''+lng+'\')"><img src="'+image+'" border="0"/></a>';
              else document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url('+image+') no-repeat;" title="'+ldr.responseText+'" href="javascript://" onClick="add2Cart(\''+id+'\',\'\',\'\',\''+lng+'\')"><img src="'+image+'" border="0"/></a>';

              if(cartInfo(lng))
              {
                 document.getElementById(bl).innerHTML = cartInfo(lng);
              }

              if(cartCount <= 0)
              {
                 document.getElementById(bl3).style.display = 'none';
                 
              }
              
              //Разблокируем корзину
              setCookie ('diskoff_delCart', 0, '/');
              setCookie ('diskoff_add2Cart', 0, '/');
           }
           else
           {
              document.getElementById(bl2).innerHTML = '<a class="trash-link" style="background: url(/i/working.gif) no-repeat;"><img src="/i/working.gif"/></a>';
              //document.getElementById(bl).innerHTML = '<img src="/i/working.gif"/>';
           }
        }
        ldr.send(null);
     }
  }
}

function add2Cart2(id, image,image2,lng)
{
  if(cookieVal('diskoff_add2Cart') == 1) return false;  //Другой товар уже добавляется в корзину,блокируем добавление другого до получения ответа
  else
  {
     //Все ОК, блокируем корзину
     setCookie ('diskoff_add2Cart', 1, '/'); //На добавление
     setCookie ('diskoff_delCart', 1, '/');  //На удаление
     var cartCount = parseInt(cookieVal('diskoff_cartCount'));
     cartCount++;
     setCookie ('diskoff_cartCount', cartCount, '/');
     
     if(ldr&&ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        bl = "suma";
        bl2 = "litm_"+id;
        bl3 = "cart_img";

        ldr.open("GET","/actions.php?action=add2Cart&item_id="+id,true);
        ldr.onreadystatechange=function()
        {
           if(ldr.readyState==4 && ldr.responseText)
           {
              //alert('<a href="javascript://" title="'+ldr.responseText+'" onClick="delFromCart(\''+id+'\',\''+image2+'\',\''+image+'\')"><img src="/i/'+image+'" border="0"/></a>');
              if(image) document.getElementById(bl2).innerHTML = '<a href="javascript://" title="'+ldr.responseText+'" onClick="delFromCart2(\''+id+'\',\''+image2+'\',\''+image+'\',\''+lng+'\')"><img src="/i/'+image+'" border="0"/></a>';
              else document.getElementById(bl2).innerHTML = '<a href="javascript://" title="'+ldr.responseText+'" onClick="delFromCart2(\''+id+'\',\'\',\'\',\''+lng+'\')"><img src="/i/'+image+'" border="0"/></a>';
              if(cartInfo(lng)) document.getElementById(bl).innerHTML = cartInfo(lng);
              document.getElementById(bl3).style.display = 'inline';
              
              //Разблокируем корзину
              setCookie ('diskoff_add2Cart', 0, '/');
              setCookie ('diskoff_delCart', 0, '/');
           }
           else
           {
              document.getElementById(bl2).innerHTML = '<img src="/i/working.gif"/>';
           }
        }
        ldr.send(null);
     }
  }
}

function delFromCart2(id, image,image2,lng)
{
  if(cookieVal('diskoff_delCart') == 1) return false;  //Другой товар удаляется из  корзины,блокируем удалениее другого до получения ответа
  else
  {
     //Все ОК, блокируем корзину
     setCookie ('diskoff_delCart', 1, '/'); //На удаление
     setCookie ('diskoff_add2Cart', 1, '/'); //На добавление
     var cartCount = parseInt(cookieVal('diskoff_cartCount'));
     cartCount--;
     setCookie ('diskoff_cartCount', cartCount, '/');
     
     if(ldr&&ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        bl = "suma";
        bl2 = "litm_"+id;
        bl3 = "cart_img";

        ldr.open("GET","/actions.php?action=delFromCart&item_id="+id,true);
        ldr.onreadystatechange=function()
        {
           if(ldr.readyState==4 && ldr.responseText)
           {
              //alert('<a title="'+ldr.responseText+'" href="javascript://" onClick="add2Cart(\''+id+'\',\''+image2+'\',\''+image+'\')"><img src="/i/'+image+'" border="0"/></a>');
              if(image) document.getElementById(bl2).innerHTML = '<a title="'+ldr.responseText+'" href="javascript://" onClick="add2Cart2(\''+id+'\',\''+image2+'\',\''+image+'\',\''+lng+'\')"><img src="/i/'+image+'" border="0"/></a>';
              else document.getElementById(bl2).innerHTML = '<a title="'+ldr.responseText+'" href="javascript://" onClick="add2Cart2(\''+id+'\',\'\',\'\',\''+lng+'\')"><img src="/i/by_ic_green.gif" border="0"/></a>';
              if(cartInfo(lng))
              {
                 document.getElementById(bl).innerHTML = cartInfo(lng);
                 
              }
              if(cartCount <= 0) document.getElementById(bl3).style.display = 'none';
              
              //Разблокируем корзину
              setCookie ('diskoff_delCart', 0, '/');
              setCookie ('diskoff_add2Cart', 0, '/');
           }
           else
           {
              document.getElementById(bl2).innerHTML = '<img src="/i/working.gif"/>';
           }
        }
     ldr.send(null);
     }
  }
}

function cartInfo(lng)
{
  if(ldr&&ldr.readyState!=0) { ldr.abort() }
  ldr=selector();
  if(ldr)
  {
     bl = "suma";
     ldr.open("GET","/actions.php?action=cartInfo&ln="+lng,true);
     ldr.onreadystatechange=function()
     {
        if(ldr.readyState==4 && ldr.responseText)
        {
           if(document.getElementById(bl) && ldr.responseText!='') document.getElementById(bl).innerHTML = ldr.responseText;
           else document.getElementById(bl).innerHTML = '';
        }
        else
        {
           document.getElementById(bl).innerHTML = '&#160;';
        }
     }
     ldr.send(null);
  }
}

function compare(id,del,lng,image,image2,s)
{
  if(cookieVal('diskoff_compare') == 1) return false;  //Другой товар добавляется в сравнение
  else
  {
     if(s != 1) s = 0;
     setCookie ('diskoff_compare', 1, '/');    //alert(s);
     
     if(ldr&&ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        bl = "cmp_"+id;
        ldr.open("GET","/actions.php?action=compare&item_id="+id+"&del="+del,true);
        ldr.onreadystatechange=function()
        {
           if(ldr.readyState==4 && ldr.responseText)
           {
              if(document.getElementById(bl))
              {
                 if(del == 0)
                 {
                    if(image) document.getElementById(bl).innerHTML = '<a class="scale-link" style="background: url('+image+') no-repeat;" href="javascript://" title="'+ldr.responseText+'" onClick="return compare(\''+id+'\',\'1\',\''+lng+'\',\''+image+'\',\''+image2+'\',\'1\');"><img src="'+image+'" border="0"/></a>';
                    else document.getElementById(bl).innerHTML = '<a class="scale-link" href="javascript://" title="'+ldr.responseText+'" onClick="return compare(\''+id+'\',\'1\',\''+lng+'\');"><img src="'+image+'" border="0"/></a>';
                 }
                 else
                 {
                    if(image) document.getElementById(bl).innerHTML = '<a class="scale-link" href="javascript://" title="'+ldr.responseText+'" onClick="return compare(\''+id+'\',\'0\',\''+lng+'\',\''+image+'\',\''+image2+'\',\'1\');"><img src="'+image+'" border="0"/></a>';
                    else document.getElementById(bl).innerHTML = '<a class="scale-link" href="javascript://" title="'+ldr.responseText+'" onClick="return compare(\''+id+'\',\'0\',\''+lng+'\');"><img src="'+image+'" border="0"/></a>';
                 }
              }
              getCompItems(lng,s);
              setCookie ('diskoff_compare', 0, '/');
           }
           else
           {
            if(document.getElementById(bl)) document.getElementById(bl).innerHTML = '<a class="scale-link" style="background: url(/i/working.gif) no-repeat;"><img src="/i/working.gif"/></a>';
           }
        }
        ldr.send(null)
     }
   }
}

function compare2(id,del,lng)
{
  if(cookieVal('diskoff_compare') == 1) return false;  //Другой товар добавляется в сравнение
  else
  {
     if(ldr&&ldr.readyState!=0) { ldr.abort() }
     ldr=selector();
     if(ldr)
     {
        setCookie ('diskoff_compare', 1, '/');
        bl = "cmp_"+id;

        ldr.open("GET","/actions.php?action=compare&item_id="+id+"&del="+del,true);
        ldr.onreadystatechange=function()
        {
         if(ldr.readyState==4 && ldr.responseText)
         {
            setCookie ('diskoff_compare', 0, '/');
            window.location.reload();
         }
         else
         {
            if(document.getElementById(bl)) document.getElementById(bl).innerHTML = '<img src="/i/working.gif"/>';
         }

        }
        ldr.send(null)
     }
  }
}

function getCompItems(lng,s)
{

   if(ldr2&&ldr2.readyState!=0) { ldr2.abort() }
   ldr2=selector();

   if(ldr2)
   {
        blc = "comp_items_list";

        ldr2.open("GET","/actions.php?action=getCompItems&ln="+lng+"&search="+s,true);
        ldr2.onreadystatechange=function()
        {
          if(ldr2.readyState==4 && ldr2.responseText)
          {
             //eval(ldr.responseText);
             if(ldr2.responseText == '&#160;') document.getElementById(blc).innerHTML = '';
             else document.getElementById(blc).innerHTML = ldr2.responseText;
          }
          else
          {
             //document.getElementById(bl).innerHTML = '';
          }
        };
        ldr2.send(null)
    }

}

function setRating(id,dir,lng)
{
   if(ldr&&ldr.readyState!=0) { ldr.abort() }
   ldr=selector();
   if(ldr)
   {
      bl = "rating";

      ldr.open("GET","/actions.php?action=setRating&item_id="+id+"&dir="+dir,true);
      ldr.onreadystatechange=function()
      {
         if(ldr.readyState==4 && ldr.responseText)
         {
            getRating(id,lng);
         }
      }
      ldr.send(null)
   }
}

function getRating(id,lng)
{
   if(ldr&&ldr.readyState!=0) { ldr.abort() }
   ldr=selector();
   if(ldr)
   {
      bl = "rating";

      ldr.open("GET","/actions.php?action=getRating&item_id="+id+"&ln="+lng,true);
      ldr.onreadystatechange=function()
      {
         if(ldr.readyState==4 && ldr.responseText)
         {

            if(document.getElementById(bl))
            {
               document.getElementById(bl).innerHTML = ldr.responseText;
            }

         }
         else
         {
            //if(document.getElementById(bl)) document.getElementById(bl).innerHTML = '<img src="/i/working.gif"/>';
         }

      }
      ldr.send(null)
   }
}

function showOrderForm()
{
   if(document.getElementById('order_div').style.display == 'none') document.getElementById('order_div').style.display = 'block';
   else document.getElementById('order_div').style.display = 'none';
}

function checkOrderForm(errSurName,errEmail,errEmailIncorrect,errName,errPhone)
{
   if(document.orderForm.surname.value == '')
   {
      alert(errSurName);
      document.orderForm.surname.focus();
      return false;
   }

   if(document.orderForm.email.value == '')
   {
      alert(errEmail);
      document.orderForm.email.focus();
      return false;
   }
   else
   {
      if(document.orderForm.email.value.indexOf('@') == '-1')
      {
         alert(errEmailIncorrect);
         document.orderForm.email.focus();
         return false;
      }
   }

   if(document.orderForm.name.value == '')
   {
      alert(errName);
      document.orderForm.name.focus();
      return false;
   }

   if(document.orderForm.phone.value == '')
   {
      alert(errPhone);
      document.orderForm.phone.focus();
      return false;
   }
   
   document.orderForm.submit();
   return false;
}

function showRespForm(obj)
{
   if(document.getElementById(obj).style.display == 'none') document.getElementById(obj).style.display = 'block';
   else document.getElementById(obj).style.display = 'none';
}

function showLoginBlock()
{
   if(document.getElementById('popup').style.display == 'none')
   {
      document.getElementById('popup').style.display = 'block';
   }
   else document.getElementById('popup').style.display = 'none';
}

function showSubscribeBlock()
{
   if(document.getElementById('subscr_div').style.display == 'none')
   {
      document.getElementById('subscr_div').style.display = 'block';
   }

   else document.getElementById('subscr_div').style.display = 'none';
}

function removeCartItem(text,url)
{
   if(confirm(text))
   {
       var cartCount = parseInt(cookieVal('diskoff_cartCount'));
       cartCount--;
       setCookie ('diskoff_cartCount', cartCount, '/');
       location.href = url;
       //window.location = url;
       //window.location.reload();
       //window.location = url;
       //window.location.reload();
   } else return false;
}

function emptyCart(text,url)
{
   if(confirm(text))
   {
     var cartCount = parseInt(cookieVal('diskoff_cartCount'));
     cartCount = 0;
     setCookie ('diskoff_cartCount', cartCount, '/'); //alert(cartCount);
     location.href = url;
     //window.location = url;
     //window.location.reload();
     //window.location = url;
     //window.location.reload();
   } else return false;
}

function checkRespForm()
{
   if(document.respForm.txt.value == '')
   {
      alert('Введите текст сообщения');
      document.respForm.txt.focus();
      return false;
   }

   if(document.respForm.name.value == '')
   {
      alert('Введите Ваше имя');
      document.respForm.name.focus();
      return false;
   }
   
   if(document.respForm.captcha.value == '')
   {
      alert('Введите проверочный код');
      document.respForm.captcha.focus();
      return false;
   }
   return true;
}

function showAlert(val,na,text)
{
   if(val == 1 || val == 2)
   {
      if(na > 0)
      {
         alert(text);
      }
   }
}




