function createForm(url) {
	var form = document.createElement("form");
	form.setAttribute("method", "POST");
	form.setAttribute("action", url);
	return form;
}

function createElement(name, value) {
	var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", name);
    hiddenField.setAttribute("value", value);
	return hiddenField;
}

function goToAddProduct(url, pcfield, pcvalue, cfield, cvalue, rfield, rvalue) {
 	var form = createForm(url);
 	document.body.appendChild(form);
 	var pcfield = createElement(pcfield, pcvalue)
 	var cfield = createElement(cfield, cvalue)
 	var rfield = createElement(rfield, rvalue)
	form.appendChild(pcfield);
	form.appendChild(cfield);
	form.appendChild(rfield);
    form.submit();
}

function goToAddRanking(url, pcfield, pcvalue, cfield, cvalue) {
 	var form = createForm(url);
 	document.body.appendChild(form);
 	var pcfield = createElement(pcfield, pcvalue)
 	var cfield = createElement(cfield, cvalue)
	form.appendChild(pcfield);
	form.appendChild(cfield);
    form.submit();
}

function goToAddCategory(url, pcfield, pcvalue) {
 	var form = createForm(url);
 	document.body.appendChild(form);
 	var pcfield = createElement(pcfield, pcvalue)
	form.appendChild(pcfield);
    form.submit();
}

function myPopup(windowName, URL, width, height, scrolling) {

	width = width || 500;
	height = height || 460;
	scrolling = scrolling || 0;

	var topX = (window.screen.width / 2) - ( width / 2);
	var topY = (window.screen.height / 2) - ( height / 2);

	window.open(URL, windowName, 'width=' + width + ',height=' + height + ',location=no,resizable=yes,scrollbars=' + scrolling + ',screenX=' + topX + ',screenY=' + topY);

}