/* ------------------------------------------------
-- ADD LOAD EVENT
------------------------------------------------ */

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


/* ------------------------------------------------
-- PRINT PAGE
------------------------------------------------ */

function printPage() {
	if (!document.getElementById) return false;
	if (!document.getElementById("page-tools")) return false;

	var list = document.getElementById("page-tools");
	var print_p = document.createElement("p");
	var print_class = print_p.className = "print";
	var print_link = document.createElement("a");
	var print_href = print_link.setAttribute("href","javascript:window.print();");
	var print_title = print_link.setAttribute("title","Print this page");
	var print_text = document.createTextNode("Print page");
	print_link.appendChild(print_text);
	print_p.appendChild(print_link);
	list.appendChild(print_p);
}

addLoadEvent(printPage);


/* ------------------------------------------------
-- Remove uploaded image
------------------------------------------------ */
function removeUpload(fieldName) {
  document.getElementById(fieldName).value = "";
  document.getElementById(fieldName+"_showupload").style.display = "none";
}