/**
 * @author Vlad Yakovlev (red.scorpix@gmail.com)
 * @copyright Art.Lebedev Studio (http://www.artlebedev.ru)
 * @link www.scorpix.ru
 * @requires jQuery
 */

$(function() {

	var
		coords = [0, 0, 300, 300],
		svgEl,
		width = 300,
		height = 300,
		svgNs = 'http://www.w3.org/2000/svg';

	// Ему тут делать нечего…
	if ($.browser.msie) return;

	createSVG();

	function createSVG() {
		var rootEl = $('.svg_container1');

		svgEl = document.createElementNS(svgNs, 'svg');
		svgEl.setAttribute('version', '1.1');
		svgEl.setAttribute('class', 'shape');
		svgEl.setAttribute('viewBox', '0 0 300 300');
		svgEl.setAttribute('width', width);
		svgEl.setAttribute('height', height);
		rootEl.append(svgEl);

		var lineEl = document.createElementNS(svgNs, 'line');
		lineEl.setAttribute('id', 'lineEl');
		lineEl.setAttribute('x1', coords[0]);
		lineEl.setAttribute('y1', coords[1]);
		lineEl.setAttribute('x2', coords[2]);
		lineEl.setAttribute('y2', coords[3]);
		lineEl.setAttribute('stroke', '#ff0000');
		svgEl.appendChild(lineEl);
	}
});

$(function() {

	var
		coords = [0, 0, 300, 300],
		svgEl,
		width = 300,
		height = 300,
		svgNs = 'http://www.w3.org/2000/svg';

	// Ему тут делать нечего…
	if ($.browser.msie) return;

	createSVG();

	webkitSvgFix.bind(function(factor) {
		svgEl.setAttribute('width', width * factor);
		svgEl.setAttribute('height', height * factor);
		svgEl.setAttribute('viewBox', [coords[0], coords[1], coords[2] / factor, coords[3] / factor].join(' '));
	});

	function createSVG() {
		var rootEl = $('.svg_container2');

		svgEl = document.createElementNS(svgNs, 'svg');
		svgEl.setAttribute('version', '1.1');
		svgEl.setAttribute('class', 'shape');
		svgEl.setAttribute('viewBox', '0 0 300 300');
		svgEl.setAttribute('width', width);
		svgEl.setAttribute('height', height);
		rootEl.append(svgEl);

		var lineEl = document.createElementNS(svgNs, 'line');
		lineEl.setAttribute('id', 'lineEl');
		lineEl.setAttribute('x1', coords[0]);
		lineEl.setAttribute('y1', coords[1]);
		lineEl.setAttribute('x2', coords[2]);
		lineEl.setAttribute('y2', coords[3]);
		lineEl.setAttribute('stroke', '#ff0000');
		svgEl.appendChild(lineEl);
	}
});
