function pausecomp(millis){
	var date = new Date();
	var curDate = null;
	do { 
		curDate = new Date(); 
	}while(curDate-date < millis);
} 
function submit_make_oder_form(){
	document.make_order.action = document.make_order.action + '&mo_submit=1';
	document.make_order.submit();
}
function submit_login_form(){
	document.login_form.submit();
}
function disableGroup(formName, groupName, booleanDisabled) {
  for (var i=0; i<formName.elements.length; i++) {
	if (formName.elements[i].name == groupName) {
	  formName.elements[i].disabled = booleanDisabled;
	}
  }
}
function add_to_cart(user_id , product_id, count_str, type){
	var count = parseInt(count_str);
	//if(user_id != 0){
		if(count != "NaN" && count > 0){
			new Ajax.Updater('header_cart_info', 'scripts/add_to_cart.php', {method: 'post', postBody:'user_id='+user_id+'&product_id='+product_id+'&count='+count+'&type='+type+''});
			setTimeout("window.location.href = 'index.php?page=13'",100);
		}else{
			alert("Въведете число за брой на добавените продукти!");
		}
	//}else{
	//	alert("За да ползвате кошница,\n трябва да сте регистриран потребител и да сте направили вход в системата като такъв.");
	//}
}
function update_cart(user_id, product_id, new_value_str , page, type){
	var new_value = parseInt(new_value_str);
	if(new_value != "NaN" && new_value >= 0){
		new Ajax.Updater('cart_list', 'scripts/update_cart.php', {method: 'post', postBody:'user_id='+user_id+'&product_id='+product_id+'&new_value='+new_value+'&type='+type+''});
		setTimeout("window.location.href = 'index.php?page="+page+"'",100);

		//<?php
		//	if (isset($_SESSION['loged_user'])) {
		//		require_once("scripts/cart_functions.php");
		//		$order_id = make_order_id($_SESSION[loged_user][id]);
		//		count_products_in_card($order_id);
		//	}
		//?>
		//pausecomp(50);
		//new Ajax.Updater('header_cart_info', 'scripts/add_to_cart.php', {method: 'post', postBody:'user_id='+user_id+'&product_id='+product_id+'&count=0'});
	}else{
		alert("Въведете число(по-голямо или равно на нула)\n за нов брой на продуктите в кошницата!");
	}
}
function but_over (id) {
	var imagesPath = "pics/";
	var link_hover = document.getElementById(id);
	//link_hover.setAttribute("style","margin-left:-8px");
	var buttonLeft = document.createElement('div');
	buttonLeft.setAttribute("id","buttonLeft");
	//buttonLeft.src = imagesPath + "but-menu-left.jpg";
	//buttonLeft.className = "buttonImg";
	link_hover.parentNode.insertBefore(buttonLeft, link_hover);
	
	var buttonRight = document.createElement('div');
	buttonRight.setAttribute("id","buttonRight");
	link_hover.parentNode.appendChild(buttonRight);

}

function but_out() {
	var d = document.getElementById("buttonLeft");
	d.setAttribute("id","buttonLeft_hidden");
	
	var d1 = document.getElementById("buttonRight");
	d1.setAttribute("id","buttonRight_hidden");
}
