function login() {
   $('form_login').addEvent('submit', function(e) {
      new event(e).stop();
      var log = $('logindiv').empty().addClass('ajax-loading');
      
      this.send({
         update: log,
         method: 'post',
         onComplete: function(){
            log.removeClass('ajax-loading');
         }
      });
   });
}

function remove_item(product_id, size_id) {
   var url = 'index.php?page=cart&action=remove_item&product_id=' + product_id + '&size_id=' + size_id;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = '/cart';
         }
      }
   ).request();
}

function remove_img(img, category_id) {
   var url = '/administration/index.php?page=edit_category&action=remove_img&category_id=' + category_id + '&img=' + img;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = '/administration/index.php?page=edit_category&category_id=' + category_id;
         }
      }
   ).request();
}

function remove_product(category_id, id){
   var url = '/administration/index.php?page=edit_products&action=remove_product&category_id=' + category_id + '&product_id=' + id;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = '/administration/index.php?page=edit_products&category_id=' + category_id;
         }
      }
   ).request();
}

function edit_product(id){
   var url = '/administration/index.php?page=edit_product&product_id=' + id;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = '/administration/index.php?page=edit_product&product_id=' + id;
         }
      }
   ).request();
}

function save_product(id){
   var url = '/administration/index.php?page=edit_product&action=edit_product&product_id=' + id;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = 'administration/index.php?page=edit_product&product_id=' + id;
         }
      }
   ).request();
}

function addproduct(page,id,size){
   var url = 'index.php?page=' + page + '&product_id=' + id + '&size_id=' + size + '&action=add_item';
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = '/cart';
         }
      }
   ).request();
}

function orderNow(){
   var url = 'index.php?page=cart&action=order';
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            
         }
      }
   ).request();
}

function removeLink(id){
   var url = 'administration/index.php?action=remove_link&id=' + id;
   new Ajax(
      url,
      {
         method: 'post',
         onComplete: function(){
            window.location = 'administration/index.php';
         }
      }
   ).request();
}

function sendMail(e){
		var url = '/index.php?page=payment&mail=send&type='+ e;
		new Ajax(
			url,
			{
				method: 'post',
				onComplete: function(){
					if(e == 'ideal'){
						 window.location = "https://internetkassa.abnamro.nl/ncol/prod/orderstandard.asp";
						}
				}
			}
		).request();
}