function is_numeric(mixed_var)
{ 
 return !isNaN (mixed_var);
}

function CheckFields(value)
{
 if (!is_numeric(value) || value == "")
 {
  alert('Количество должно быть числом!');
  return false;
 }
 return true;
}

nn4 = (document.layers)? true : false;
ie4 = (document.all)? true : false;
nn6 = (document.getElementById && !ie4)? true : false;
function popupWin(cardName, winW, winH, winTitle) {
//if (nn4 || ie4 || nn6) {
posX = Math.round((screen.width - winW) / 2);
posY = Math.round((screen.height - winH) / 2);
posCode = /*(nn4 || nn6)? 'screenX='+posX+',screenY='+posY :*/ 'left='+posX+',top='+posY;
//} else { posCode = ''; }
//alert(posCode);
cardWindow = window.open('','_blank','menubar=no,toolbar=no,scrollbars=no,status=no,width='+winW+',height='+winH+','+posCode);
cardWindow.document.open();
cardWindow.document.write('<html><head><title>'+winTitle+'<\/title><\/head>');
cardWindow.document.write('<body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>');
cardWindow.document.write('<center><img src="'+cardName+'" width="'+winW+'" height="'+winH+'" align="center" /></center><\/body><\/html>');
cardWindow.document.close();
cardWindow.focus();
}

function CheckGood(good_id)
{
 var req = new JsHttpRequest();
 req.onreadystatechange = function() {
  if (req.readyState == 4) {
    if (req.responseJS.res != 'error')
	{
 	 document.getElementById('go_type').value='good';
	 document.getElementById('go_id').value=good_id;
	}
  }
 }
 req.open('POST','/index_ajax.php',true);
 req.send({ 'act': 'good_check', 'good_id': good_id}); 
}

// при выборе каталога грузим товары и подкатегории
function LoadCatalogue(catalogue_id)
{
 document.getElementById('search_info').innerHTML = '';
 document.getElementById('search_result').innerHTML = '';
 
 document.getElementById('go_button').disabled = true;
 
 if(catalogue_id != 0)
 {
  document.getElementById('search_info').innerHTML = '<strong>'+loading+'</strong>';
  var req = new JsHttpRequest();
  req.onreadystatechange = function() {
   if (req.readyState == 4) {
    if (req.responseJS.res == 'error')
	 document.getElementById('search_info').innerHTML = '<strong>'+error_loading+'</strong>';
	else
	{
	 document.getElementById('search_info').innerHTML = '';
     document.getElementById('search_result').innerHTML = req.responseJS.res;
    }
   }
  }
  req.open('POST','/index_ajax.php',true);
  req.send({ 'act': 'catalogue_list', 'catalogue_id': catalogue_id}); 
 }
}

// при выборе подкатегории грузим товары и из подкатегории
function LoadSubcatalogue(catalogue_id)
{
 document.getElementById('search_info').innerHTML = '';
 document.getElementById('search_goods').innerHTML = '';
 
 document.getElementById('go_button').disabled = true;
 
 if(catalogue_id != 0)
 {
  document.getElementById('search_info').innerHTML = '<strong>'+loading+'</strong>';
  var req = new JsHttpRequest();
  req.onreadystatechange = function() {
   if (req.readyState == 4) {
    if (req.responseJS.res == 'error')
	 document.getElementById('search_info').innerHTML = '<strong>'+error_loading+'</strong>';
	else
	{
	 document.getElementById('search_info').innerHTML = '';
     document.getElementById('search_goods').innerHTML = req.responseJS.res;
    }
   }
  }
  req.open('POST','/index_ajax.php',true);
  req.send({ 'act': 'subcatalogue_list', 'catalogue_id': catalogue_id}); 
 }
}


// при выборе товара делаем активную кнопку перехода
function LoadGood(good_id)
{
 if (good_id != 0)
 {
  document.getElementById('good_id').value = good_id;
  document.getElementById('go_button').disabled = false;
 }
 else
 {
  document.getElementById('go_button').disabled = true;
 }
}

function Go()
{
 location.href=document.getElementById('lang_path').value + "good_show/" + document.getElementById('good_id').value + ".html";
}
