function verProductos(id, _all, _tipe, _categoria, _pagina, _key){

		if(_tipe == 'C')
			showHide(id, _all);
		else{
			if(_tipe == 'S')
				showHideSub(id);
		}
	jQuery.get("x-productos.php", { categoria: _categoria, p: _pagina, key: _key}, 
		function(data){ 
			document.getElementById("center").innerHTML = data;
		});
	return false;
}

function showHide(id, _all)
{
	for(var x =1; x<=_all; x++){
		if(x!=id)
			document.getElementById('listado_' + x).style.display = 'none';
	}
	var obj = document.getElementById('listado_' + id);
	if (obj.style.display == 'none')
		obj.style.display = 'block';
	else
		obj.style.display = 'none';
}

function showHideSub(id)
{
var obj = document.getElementById('sublistado_' + id);
if (obj.style.display == 'none')
    obj.style.display = 'block';
else
    obj.style.display = 'none';
}

function actionsProductos(_idProducto, _actions, _cantidad, _valida){
	
	jQuery.get("x-carro-compras.php", { id: _idProducto, actions: _actions, cantidad: _cantidad, valida: _valida}, 
		function(data){ 
			document.getElementById("cont-carro").innerHTML = data;
		});
		if(_actions == 'add')
			var _res = 	'Se agrego producto correctamente.'
		if(_actions == 'edit')
			var _res = 	'Se actualizo el producto correctamente.'
		if(_actions == 'del')
			var _res = 	'Se elimino el producto correctamente.'

		$.pnotify({
					pnotify_title: 'San Marco Virtual',
					pnotify_text: _res,
					pnotify_opacity: .8,
					pnotify_delay: 3000,
					pnotify_width: 2,
					pnotify_animation: 'show'
				});
	
	return false;
}

function verCarro(){

	jQuery.get("x-carro-compras.php", 
		function(data){ 
			document.getElementById("cont-carro").innerHTML = data;
		});
	return false;
}

function actualizar(_obj){
	var _max = document.forms['form-carro'].maximo.value;
	
	for(var _x=1; _x<=_max; _x++){
			_idU = document.getElementById('carro'+_x).value;
			_value = document.getElementById('value'+_x).value;
			_valida = document.getElementById('valida'+_x).value;
			actionsProductos(_idU, 'edit', _value, _valida);
	}
	return false;
		
}
// ACTUALIZAR CARRO DE COMPRA GRANDE.
function actualizarGrande(_obj){
	var _max = document.forms['form-carro'].maximo.value;

	for(var _x=1; _x<=_max; _x++){
		_idU = document.getElementById('carro'+_x).value;
		_value = document.getElementById('value'+_x).value;
		_valida = document.getElementById('valida'+_x).value;
		actionsProductosGrandes(_idU, 'edit', _value, _valida);
	}
	return false;

}


function verCarroGrande(){
	jQuery.get("x-carro-compras-grande.php", 
		function(data){ 
			document.getElementById("cont-mi-carro").innerHTML = data;
		});
	return false;
}

function actionsProductosGrandes(_idProducto, _actions, _cantidad){
	jQuery.get("x-carro-compras-grande.php", { id: _idProducto, actions: _actions, cantidad: _cantidad}, 
		function(data){ 
			document.getElementById("cont-mi-carro").innerHTML = data;
		});
		if(_actions == 'add')
			var _res = 	'Se agrego producto correctamente.'
		if(_actions == 'edit')
			var _res = 	'Se actualizo el producto correctamente.'
		if(_actions == 'del')
			var _res = 	'Se elimino el producto correctamente.'

		$.pnotify({
					pnotify_title: 'San Marco Virtual',
					pnotify_text: _res,
					pnotify_opacity: .8,
					pnotify_delay: 3000,
					pnotify_width: 2,
					pnotify_animation: 'show'
				});
	
	
	return false;
}

function validaCarro(_obj){

	if(submitForm(_obj))
		actualizar(_obj);

	return false;
}
function validaCarroGrande(_obj){
	if(submitForm(_obj))
		actualizarGrande(_obj);
	return false;
}

