var paper;
var i = 0;
var obj_arr = [];

var shapes = {
		"shape2": {
			path: "M856.042,111.666c-66.313,148.146-126.96,290.497-182.31,428.599c149.057,77.223,305.044,160.782,462.729,247.779C1027.646,511.565,931.507,286.315,856.042,111.666z"
		},
		"shape3": {
			path: "M1406.36,939.377c-89.873-51.201-180.16-101.824-269.897-151.333c32.564,82.739,66.268,170.081,100.885,262.008C1293.991,1012.429,1350.332,975.534,1406.36,939.377z"
		},
		"shape5": {
			path: "M2048.13,0h-244.179c51.808,68.24,123.574,163.605,206.079,275.542C2025.336,164.571,2038.489,69.597,2048.13,0z"
		},
		"shape4": {
			path: "M1136.462,788.044c89.737,49.509,180.024,100.132,269.897,151.333c190.234-122.768,376.855-237.004,559.459-342.116c15.781-115.3,30.82-224.631,44.212-321.719C1927.527,163.605,1855.759,68.24,1803.951,0H906.594c-17.204,37.595-34.056,74.812-50.552,111.667C931.507,286.315,1027.646,511.565,1136.462,788.044z"
		}
}

var static_shapes = {
		"shape1": {
			path: "M2048.13,0c-9.642,69.597-22.794,164.571-38.1,275.542c-13.392,97.087-28.431,206.418-44.212,321.719c-182.604,105.112-369.225,219.35-559.459,342.116c-56.027,36.158-112.368,73.053-169.013,110.676c-34.618-91.928-68.32-179.27-100.885-262.008c-157.686-86.997-313.673-170.557-462.729-247.779c55.349-138.102,115.995-280.452,182.309-428.599C872.539,74.812,889.391,37.594,906.594,0H0v1600h2500V0H2048.13z"
			}
	}

var gridlines = {
		"line1": {
			path: "M2481.572,1599.999C1795.812,1134.258,635.807,488.472,0.003,215.896"
		},
		"line2": {
			path: "M1434.969,1600C1176.701,845.961,943.784,314.391,807.702-0.003"
		},
		"line3": {
			path: "M1159.745,1600.003C661.486,1045.02,257.899,658.359-0.001,413.646"
		},
		"line4": {
			path: "M906.591-0.001C632.818,598.277,449.224,1099.772,333.335,1600"
		},
		"line5": {
			path: "M455.995,1600.001C1182.393,1061.797,1870.121,622.598,2500,310.468"			
		},
		"line6": {
			path: "M1803.953,0.002c143.919,189.566,441.865,588.451,696.048,970.355"
		},
		"line7": {
			path: "M1831.671,1600c62.718-489.471,173.854-1292.466,216.458-1600"
		}
}
function initialise_raphael(width, height) {
	paper = new Raphael(document.getElementById("canvas_container"), width, height);
}

function create_paths(arr, fill_colour, stroke_colour, opacity) {
	var temp_arr = [];
	for(var index in arr){
		window[index] = paper.path(arr[index].path);
		window[index].attr( 
	        {
	            fill: fill_colour,
	            opacity: opacity,
	            stroke: stroke_colour
	        }
	    );
	    temp_arr.push(window[index]);
	}
	obj_arr.push(temp_arr);
}

function animate_paths(arr, i, opacity_min, opacity_max, anim_speed, delay, callback){
	if(i < arr.length){			
    	 arr[i].animate({opacity: opacity_max}, anim_speed);
         i++;
         setTimeout(function(){animate_paths(arr, i, opacity_min, opacity_max, anim_speed, delay, callback);}, delay);
    }
    else {
    	if(callback !== undefined){ 
    		callback();
    	}
    }
}
