var shop = {
	
	addFileInput : function(el){
		var n = document.createElement('input');
		n.type = 'file';
		n.name = 'files[]';
		el.appendChild(n);
	},
	
	addOption : function(el){
		n = el.getElementsByTagName('div')[1].cloneNode(true);
		inputs = n.getElementsByTagName('input');
		for (i = 0; i < inputs.length; i++) inputs[i].value = '';
		el.appendChild(n);
	},
		
	switchImage : function(id){
		if (this.imageList && this.imageList[id]){
			img = document.getElementById('mainProductImage');
			img.src = String(img.src).replace(/=[^=]*$/,'=') + this.imageList[id]['filename'];
			
			return false;
		}
		return true;
	},

	admin : function(a,id){
		switch (a){
			case 'delete-category':
				if (confirm('Are you sure you want to delete that category?')) window.location = '?action=delete-category&cId=' + id;
			break;
			case 'delete-product':
				if (confirm('Are you sure you want to delete that product?')) window.location = '?action=delete-product&pId=' + id;
			break;
			case 'edit-category':
			case 'edit-product':
				window.location = '?form=' + a + '&id=' + id;
			break;
			default:
				window.location = '?action=' + a + '&id=' + id;
			break;
		}
	},
	
	hideAddButton : function(btn_id,max,current_number){
		if(current_number >= max){
			document.getElementById(btn_id).style.display = 'none';
		}
	}
	
};