//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com [v1.0]

String.prototype.repeat = function(l){
	return new Array(l+1).join(this);
};

//firebugx
if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}


$(function () {

	$('#svg-box').svg({onLoad:draw});
	
});

function draw (svg) {
	
	//going for a spiral thing here.
	window.svg = svg;
	
	window.ww = $(window).width();
	window.wh = $(window).height();
	
	$('#svg-box').css({width:ww,height:wh});
	

	
	window.len = 1;
	window.len_increment = .2;
	window.angle_increment = 30;
	window.g = svg.group({stroke:'black',strokeWidth:'1'});
	spirals(ww/2, wh/2);
	
	
	
	
}

function spirals (x, y) {

	if (window.angle == undefined) {
		window.angle = 0;
	}
	else {
		window.angle += angle_increment*Math.PI/180;
		window.len+=len_increment;
	}

	var y1 = y+(Math.sin(angle)*len);
	var x1 = x+(Math.cos(angle)*len);

	console.log(x, y, x1, y1);
	svg.line(g, x, y, x1, y1);
	
	setTimeout(function () {spirals(x1, y1);}, 100);

}

