function MakeOrder()
{
   $.ajax({
    type: 'POST',
    url: '/json/check_basket.php',
    dataType: 'json',
    success: function(data){
      if (data['success'] == 1)
      {
         if (data['ok'] == 1)
         {
           window.location='/order.php';           
         }
         else 
         {
           DisplayWarning(data['message']);
         }
      }
      else
      {
           DisplayError(data['message']);
      }
    }
   });
   return false;   
// 
}

function DisplayError(msg)
{
alert(msg);
           $.modaldialog.error(msg);         
}
function DisplayWarning(msg)
{
           $.modaldialog.warning(msg);         
}

function setCurrency()
{
    var radios = document.getElementsByName('currency');
    for(var i=0; i<radios.length; i++)
    {
      if(radios[i].checked) 
      {
        parent.location = "/change_currency.php?id="+radios[i].value+"";
      }
    }
}

// 
function RemoveGood(id, source)
{
  if (confirm("Вы хотите удалить товар из корзины?"))
  {
    window.location= "/basket.php?ACTION=removeItem&good_id=" + id + "&source=" + source ; 
  }
  return false;
}



function setUFilter(id)
{
  document.getElementById('filter_id').value = id;
  document.getElementById('setFilter').submit();
}

function makeSubmit(id)
{
    document.getElementById('brend_id').value = id;
    document.getElementById('setBrend').submit();
}

function RowsMakeSubmit(id)
{
    document.getElementById('brend_id').value = id;
    document.getElementById('setItemsCount').submit();
}


// 
function compCost()
{
   var myPayment = $("#paymenttype").val();
   var myDelivery = $("#delivery").val();

   $.ajax({
    type: 'POST',
    url: '/json/calc_order.php',
    dataType: 'json',
    data: { payment: myPayment, delivery: myDelivery},
    success: function(data){
      if (data['success'] == 1)
      {
         $("#delivery_sign").attr("innerHTML", data['delivery_sign']);
         $("#discount_sign").attr("innerHTML", data['discount_sign']);
         $("#clear_sign").attr("innerHTML", data['clear_sign']);
         $("#common_sign").attr("innerHTML", data['common_sign']);
         
         $("#common_cost").attr("innerHTML", data['common_cost']);
         $("#discount_cost").attr("innerHTML", data['discount_cost']);
         $("#delivery_cost").attr("innerHTML", data['delivery_cost']);
         $("#clear_cost").attr("innerHTML", data['clear_cost']);
         
      }
      else
      {
	// $.modaldialog.error(data['message']);
      }
    }
   });
   return false;   
}





// ------------------------------------------
// Resize window
// ------------------------------------------

function ResizeWindow(w,h) 
    {

    var height=0; var width=0;
    if (self.screen) 
    {
        width = screen.width
        height = screen.height
    }
    else if (self.java) 
    {
        var jkit = java.awt.Toolkit.getDefaultToolkit();
        var scrsize = jkit.getScreenSize();
        width = scrsize.width;
        height = scrsize.height;
    }
    height -= 180;
           
    if (parseInt(navigator.appVersion)>3) 
        {
        if (navigator.appName=='Netscape') 
            {
            if(height)
                {
                if(height > h+51) 
                    {
                    top.outerHeight= h+51;
                    top.outerWidth = w;
                    }
                else 
                    {
                    top.outerHeight= height;
                    top.outerWidth = w+14;
                    }
                }
            }
            else 
            {
//          top.resizeTo(400,300);
//            wd = 400-document.body.clientWidth;
//            hd = 340-document.body.clientHeight;
            //top.resizeTo(w+0,h+51);
            if(height > h+51) top.resizeTo(w+18,h+51);
            else top.resizeTo(w+18,height);
            }
        }
    }

//
function SetMainPhoto(myurl)
{
   $("#mainimage").attr("src", myurl);
}

                                    function switch_product_img(divName, totalImgs) {
                                        for (var i=0; i<totalImgs; i++) {
                                            var showDivName = 'photo_' + i;
                                            var showObj = document.getElementById(showDivName);
                                            if (showDivName == divName)
                                                showObj.style.display = 'block';
                                            else
                                                showObj.style.display = 'none';
                                            }
                                        }


