/* This taken from Javascript: The Definitive Guide, pgs. 551-552 */


/* Create a namespace */
var SVG = {};

// SVG related namespace URLs 
SVG.ns = "http://www.w3.org/2000/svg";
SVG.xlinkns = "http://www.w3.org/1999/xlink";

//Create and return an empty <svg> element.
//The element is not added to the document.
//Note that we can specify the pixel size of the image as well as its internal coordinate system.

SVG.makeCanvas = function(id, pixelWidth, pixelHeight, userWidth, userHeight) {

	var svg = document.createElementNS(SVG.ns, "svg:svg");
	svg.setAttribute("id", id);
	//How big is the canvas in pixels
	svg.setAttribute("width", pixelWidth);
	svg.setAttribute("height", pixelHeight);
	//Set the coordinates used by drawings in the canvas
	svg.setAttribute("viewBox", "0 0 " + userWidth + " " + userHeight);
	//Define the XLink namespace that SVG uses
	svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", SVG.xlinkns);
	return svg;
};

SVG.report = function() {

	 var log = document.getElementById("log");
	 var p = document.createElement("p");
	 p.innerHTML = "SVG loaded";
	 log.appendChild(p);
};
