/* Author: 

*/




docWidth = $(document).width();
docHeight = $(document).height();
winWidth = $(window).width();
winHeight = $(window).height();
scrHeight = screen.height;
srcWidth = screen.width - 10;
vMiddle = screen.height / 2;
charMiddle = vMiddle - 180;
charBottom = screen.height - 500;


//$('.chars').show("scale",{percent: 100, direction: 'vertical', origin: ['center','top']},250).animate({opacity: 0.85});


	
$(document).ready(function() { 
		$('html, body').css({width:srcWidth});
		$('.bg_city').css({width:srcWidth});
		var options = { 
		target:        '#alert',
		beforeSubmit:  showRequest,
		success:       showResponse
		}; 
		$('#contactForm').ajaxForm(options); 
		}); 
		function showRequest(formData, jqForm, options) { 
		var queryString = $.param(formData); 
		return true; 
		} 
		function showResponse(responseText, statusText)  {  
		} 
		$.fn.clearForm = function() {
		  return this.each(function() {
			var type = this.type, tag = this.tagName.toLowerCase();
			if (tag == 'form')
			  return $(':input',this).clearForm();
			if (type == 'text' || type == 'password' || tag == 'textarea')
			  this.value = '';
			else if (type == 'checkbox' || type == 'radio')
			  this.checked = false;
			else if (tag == 'select')
			  this.selectedIndex = -1;
	  });
	  
  	
};

function resizeWindow() {
	$('html, body').css({width:srcWidth});
	$('.bg_city').css({width:srcWidth});
}
$(window).bind("resize", resizeWindow);



var disco_canvas = Raphael("disco", 2000, 1000);
var c = disco_canvas.path("M998.948-0.338c-552.285,0-1000,223.857-1000,500c0,251.829,372.351,460.167,856.79,494.903l19.658-377.695  c38.818-4.81,80.361-7.417,123.552-7.417s84.734,2.607,123.552,7.417l19.658,377.695c484.438-34.736,856.79-243.074,856.79-494.903  C1998.948,223.519,1551.232-0.338,998.948-0.338z").attr({
			stroke: "none",
			fill: "90-#000e02:10-#2e4a3e:26-#316052:40-#81c1bc:80"
		});
var c = disco_canvas.path("M876.339,616.753c-154.271,19.115-266.391,73.158-266.391,136.699c0,61.584,104.447,113.975,251.336,134.555  L876.339,616.753z").attr({
			stroke: "none",
			fill: "270-#57FFC2:10-#2e553c:50-#00301b:70"
		});			 
var c = disco_canvas.path("m 876.339,616.749 c -154.271,19.115 -266.391,73.158 -266.391,136.699 0,61.584 104.447,113.975 251.336,134.555 l 1.90101,0.3 14.08,-271.77301 z").attr({
			stroke: "none",
			fill: "175-#95f7e3:5-#2d6762:50",
			"fill-opacity": 0
		});
var c = disco_canvas.path("M1136.629,888.007c146.89-20.58,251.336-72.971,251.336-134.555c0-63.541-112.119-117.584-266.391-136.699  L1136.629,888.007z").attr({
			stroke: "none",
			fill: "270-#57FFC2:10-#2e553c:50-#00301b:70"
		});
var c = disco_canvas.path("m 1120.041,616.57 8.2945,135.7165 7.1502,135.69069 1.1443,0.0258 c 146.89,-20.58 251.336,-72.971 251.336,-134.555 0,-63.541 -112.119,-117.584 -266.391,-136.699 z").attr({
			stroke: "none",
			fill: "5-#95f7e3:5-#2d6762:50",
			"fill-opacity": 0
		});
var c = disco_canvas.path("M999.475,553.161c-244.384,0-442.496,78.154-442.496,174.561c0,27.184,15.754,52.916,43.854,75.854  c-18.961-18.819-29.375-39.309-29.375-60.744c0-91.966,191.63-166.521,428.017-166.521c236.387,0,428.017,74.556,428.017,166.521  c0,21.434-10.413,41.921-29.371,60.74c28.097-22.938,43.849-48.668,43.849-75.851  C1441.969,631.315,1243.857,553.161,999.475,553.161z").attr({
			stroke: "none",
			fill: "270-#6ebead:30-#2e493d:95",
			"fill-opacity": 0
		});
var c = disco_canvas.path("m 1000.4568,580.49625 c -230.82814,0 -417.95095,70.23969 -417.95095,156.88398 0,24.4312 14.88013,47.55745 41.42144,68.17262 -17.90924,-16.91329 -27.74558,-35.32836 -27.74558,-54.59273 0,-82.65302 181.00036,-149.65816 404.27509,-149.65816 223.2747,0 404.2751,67.00604 404.2751,149.65816 0,19.26347 -9.8354,37.67584 -27.7419,54.58913 26.5386,-20.61518 41.4167,-43.7396 41.4167,-68.16991 -9e-4,-86.6434 -187.1237,-156.88309 -417.9499,-156.88309 z").attr({
			stroke: "none",
			fill: "270-#6ebead:30-#2e493d:80",
			"fill-opacity": 0
		});	




var c = disco_canvas.set();
c.push(
	disco_canvas.path("M814.285,975.074c-0.282,3.082,6.192,5.911,14.463,6.317c8.271,0.407,15.205-1.762,15.488-4.844     c0.283-3.083-6.192-5.911-14.464-6.318C821.501,969.822,814.567,971.991,814.285,975.074z"),
	disco_canvas.path("M766.811,968.946c-0.566,4.029,6.545,7.966,15.883,8.793c9.337,0.827,17.365-1.769,17.932-5.797     c0.565-4.029-6.545-7.965-15.883-8.793C775.404,962.322,767.376,964.917,766.811,968.946z"),
	disco_canvas.path("M712.509,960.501c-0.85,4.976,6.897,10.021,17.302,11.27c10.404,1.247,19.526-1.776,20.375-6.75     c0.848-4.977-6.899-10.021-17.303-11.271C722.479,952.503,713.356,955.526,712.509,960.501z"),
	disco_canvas.path("M651.7,948.59c-1.131,5.923,7.252,12.078,18.722,13.745c11.472,1.669,21.688-1.78,22.82-7.703 c1.131-5.923-7.252-12.077-18.723-13.746C663.047,939.219,652.831,942.667,651.7,948.59z"),
	disco_canvas.path("M584.707,932.064c-1.414,6.87,7.605,14.133,20.143,16.222c12.539,2.089,23.848-1.788,25.263-8.657     c1.413-6.871-7.605-14.133-20.143-16.221C597.432,921.318,586.12,925.194,584.707,932.064z"),
	disco_canvas.path("M511.853,909.773c-1.696,7.816,7.958,16.188,21.562,18.697c13.605,2.51,26.009-1.793,27.707-9.61     c1.695-7.816-7.958-16.187-21.563-18.697C525.954,897.654,513.55,901.957,511.853,909.773z"),
	disco_canvas.path("M433.46,880.568c-1.979,8.763,8.311,18.244,22.981,21.174c14.672,2.929,28.171-1.8,30.15-10.562     c1.979-8.765-8.311-18.244-22.982-21.174C448.938,867.076,435.438,871.805,433.46,880.568z"),
	disco_canvas.path("M349.851,843.301c-2.263,9.71,8.664,20.298,24.4,23.65c15.74,3.351,30.333-1.805,32.596-11.516 c2.261-9.71-8.664-20.298-24.404-23.65C366.705,828.435,352.112,833.59,349.851,843.301z"),
	disco_canvas.path("M261.346,796.822c-2.544,10.657,9.017,22.355,25.821,26.126c16.806,3.771,32.492-1.812,35.039-12.469     c2.543-10.658-9.017-22.354-25.824-26.126C279.578,780.582,263.891,786.164,261.346,796.822z"),
	disco_canvas.path("M168.27,739.983c-2.828,11.604,9.37,24.411,27.241,28.601c17.874,4.192,34.653-1.817,37.482-13.422     c2.826-11.605-9.37-24.41-27.243-28.601C187.878,722.369,171.099,728.378,168.27,739.983z")
);
c.attr({stroke: "none", fill: "0-#57FFC2:20-#95d5b9:30-#8dcdb1:50-#005641:70-#001e16:85"});




var c = disco_canvas.set();
c.push(
	disco_canvas.path("M1181.65,975.074c0.282,3.082-6.192,5.911-14.463,6.317c-8.271,0.407-15.205-1.762-15.488-4.844     c-0.283-3.083,6.192-5.911,14.464-6.318C1174.433,969.822,1181.368,971.991,1181.65,975.074z"),
	disco_canvas.path("M1229.124,968.946c0.565,4.029-6.545,7.966-15.883,8.793c-9.337,0.827-17.365-1.769-17.932-5.797     c-0.565-4.029,6.546-7.965,15.884-8.793C1220.531,962.322,1228.558,964.917,1229.124,968.946z"),
	disco_canvas.path("M1283.425,960.501c0.851,4.976-6.896,10.021-17.302,11.27c-10.404,1.247-19.526-1.776-20.376-6.75     c-0.848-4.977,6.899-10.021,17.303-11.271C1273.457,952.503,1282.579,955.526,1283.425,960.501z"),
	disco_canvas.path("M1344.235,948.59c1.132,5.923-7.252,12.078-18.722,13.745c-11.473,1.669-21.688-1.78-22.82-7.703     c-1.131-5.923,7.252-12.077,18.723-13.746C1332.887,939.219,1343.104,942.667,1344.235,948.59z"),
	disco_canvas.path("M1411.228,932.064c1.414,6.87-7.605,14.133-20.143,16.222c-12.539,2.089-23.848-1.788-25.264-8.657     c-1.412-6.871,7.605-14.133,20.144-16.221C1398.503,921.318,1409.815,925.194,1411.228,932.064z"),
	disco_canvas.path("M1484.082,909.773c1.696,7.816-7.957,16.188-21.562,18.697c-13.605,2.51-26.009-1.793-27.707-9.61     c-1.695-7.816,7.959-16.187,21.564-18.697C1469.98,897.654,1482.384,901.957,1484.082,909.773z"),
	disco_canvas.path("M1562.474,880.568c1.98,8.763-8.311,18.244-22.98,21.174c-14.672,2.929-28.171-1.8-30.15-10.562     c-1.979-8.765,8.311-18.244,22.982-21.174S1560.496,871.805,1562.474,880.568z"),
	disco_canvas.path("M1646.083,843.301c2.264,9.71-8.663,20.298-24.4,23.65c-15.74,3.351-30.332-1.805-32.596-11.516     c-2.26-9.71,8.664-20.298,24.404-23.65C1629.23,828.435,1643.822,833.59,1646.083,843.301z"),
	disco_canvas.path("M1734.588,796.822c2.544,10.657-9.017,22.355-25.821,26.126c-16.805,3.771-32.491-1.812-35.039-12.469     c-2.543-10.658,9.018-22.354,25.824-26.126C1716.357,780.582,1732.043,786.164,1734.588,796.822z"),
	disco_canvas.path("M1827.665,739.983c2.828,11.604-9.37,24.411-27.241,28.601c-17.873,4.192-34.653-1.817-37.482-13.422     c-2.826-11.605,9.369-24.41,27.243-28.601C1808.056,722.369,1824.835,728.378,1827.665,739.983z")
);
c.attr({stroke: "none", fill: "180-#57FFC2:20-#95d5b9:30-#8dcdb1:50-#005641:70-#001e16:85"});
/*
var logo_canvas = Raphael("logo", 1680, 800);
var c = logo_canvas.path("M 347.143,0 V 12.225 28.204 C 330.161,12.123 307.71,1.754 282.858,0.22 v 25.55 6.678 11.141 59.269 H 315 V 43.616 c 19.346,12.613 32.143,34.423 32.143,59.241 h 32.144 V 39.878 c 22.891,11.705 38.571,35.504 38.571,62.979 H 450 C 450,46.051 403.949,0 347.143,0 z").attr({
	stroke: "none",
	fill: "#000"
});
var c = logo_canvas.path("m 347.036,106.716 c -2.004,37.26 -32.848,66.856 -70.607,66.856 -39.055,0 -70.713,-31.66 -70.713,-70.716 0,-39.055 31.659,-70.713 70.713,-70.713 0.863,0 1.716,0.033 2.571,0.063 V 0.065 C 278.143,0.043 277.292,0 276.429,0 239.934,0 207.903,19.023 189.646,47.676 172.139,20.21 141.966,1.6 107.342,0.113 v 32.186 c 36.962,2.316 66.231,33.011 66.231,70.558 0,39.056 -31.663,70.716 -70.715,70.716 -37.668,0 -68.445,-29.453 -70.584,-66.587 H 0.104 c 2.171,54.891 47.331,98.729 102.753,98.729 36.496,0 68.528,-19.025 86.785,-47.68 18.257,28.654 50.29,47.68 86.786,47.68 55.514,0 100.728,-43.983 102.758,-98.999 h -32.15 z").attr({
	stroke: "none",
	fill: "#000"
});
var c = logo_canvas.path("M 0,0 V 32.144 H 28.203 C 10.735,50.578 0,75.456 0,102.857 c 0,0.09 0.008,0.183 0.008,0.272 h 22.088 10.056 71.334 V 70.986 H 39.738 c 11.657,-23.039 35.536,-38.842 63.12,-38.842 0.211,0 0.419,0.015 0.628,0.015 V 32.144 0.016 0 H 0 z").attr({
	stroke: "none",
	fill: "#000"
});
var c = logo_canvas.path("M450,182.924h-32.143h-0.84h-5.857v6.697v0.021c0,5.18-4.197,9.375-9.375,9.375     c-5.177,0-9.376-4.195-9.376-9.375c0-8.876-7.195-16.071-16.07-16.071s-16.072,7.195-16.072,16.071     c0,8.875,7.197,16.072,16.072,16.072c5.185,0,9.784-2.468,12.724-6.281c2.938,3.813,7.538,6.281,12.723,6.281     c8.875,0,16.072-7.197,16.072-16.072v-0.021h12.304v9.661h6.694v-9.661H450V182.924z M376.339,199.017     c-5.178,0-9.375-4.195-9.375-9.375s4.197-9.375,9.375-9.375c5.176,0,9.375,4.195,9.375,9.375S381.515,199.017,376.339,199.017z").attr({
	stroke: "none",
	fill: "#000"
});

var logo_canvas_2 = Raphael("logo2", 1680, 800);
var c = logo_canvas_2.path("M 347.143,0 V 12.225 28.204 C 330.161,12.123 307.71,1.754 282.858,0.22 v 25.55 6.678 11.141 59.269 H 315 V 43.616 c 19.346,12.613 32.143,34.423 32.143,59.241 h 32.144 V 39.878 c 22.891,11.705 38.571,35.504 38.571,62.979 H 450 C 450,46.051 403.949,0 347.143,0 z").attr({
	stroke: "none",
	fill: "#3AFF17"
});
var c = logo_canvas_2.path("m 347.036,106.716 c -2.004,37.26 -32.848,66.856 -70.607,66.856 -39.055,0 -70.713,-31.66 -70.713,-70.716 0,-39.055 31.659,-70.713 70.713,-70.713 0.863,0 1.716,0.033 2.571,0.063 V 0.065 C 278.143,0.043 277.292,0 276.429,0 239.934,0 207.903,19.023 189.646,47.676 172.139,20.21 141.966,1.6 107.342,0.113 v 32.186 c 36.962,2.316 66.231,33.011 66.231,70.558 0,39.056 -31.663,70.716 -70.715,70.716 -37.668,0 -68.445,-29.453 -70.584,-66.587 H 0.104 c 2.171,54.891 47.331,98.729 102.753,98.729 36.496,0 68.528,-19.025 86.785,-47.68 18.257,28.654 50.29,47.68 86.786,47.68 55.514,0 100.728,-43.983 102.758,-98.999 h -32.15 z").attr({
	stroke: "none",
	fill: "#2d2d2d"
});
var c = logo_canvas_2.path("M 0,0 V 32.144 H 28.203 C 10.735,50.578 0,75.456 0,102.857 c 0,0.09 0.008,0.183 0.008,0.272 h 22.088 10.056 71.334 V 70.986 H 39.738 c 11.657,-23.039 35.536,-38.842 63.12,-38.842 0.211,0 0.419,0.015 0.628,0.015 V 32.144 0.016 0 H 0 z").attr({
	stroke: "none",
	fill: "#3AFF17"
});
var c = logo_canvas_2.path("M450,182.924h-32.143h-0.84h-5.857v6.697v0.021c0,5.18-4.197,9.375-9.375,9.375     c-5.177,0-9.376-4.195-9.376-9.375c0-8.876-7.195-16.071-16.07-16.071s-16.072,7.195-16.072,16.071     c0,8.875,7.197,16.072,16.072,16.072c5.185,0,9.784-2.468,12.724-6.281c2.938,3.813,7.538,6.281,12.723,6.281     c8.875,0,16.072-7.197,16.072-16.072v-0.021h12.304v9.661h6.694v-9.661H450V182.924z M376.339,199.017     c-5.178,0-9.375-4.195-9.375-9.375s4.197-9.375,9.375-9.375c5.176,0,9.375,4.195,9.375,9.375S381.515,199.017,376.339,199.017z").attr({
	stroke: "none",
	fill: "#2d2d2d"
});
*/
var bar_canvas_0 = Raphael("bar_0", 250, 30);
var c = bar_canvas_0.path("M0 20L10 10 20 20 30 0 40 20 50 10 210 10 220 0 230 20 240 10 250 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_1 = Raphael("bar_1", 460, 30);
var c = bar_canvas_1.path("M0 20L10 10 20 20 30 0 40 20 50 10 420 10 430 0 440 20 450 10 460 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_2 = Raphael("bar_2", 500, 30);
var c = bar_canvas_2.path("M0 20L10 10 20 20 30 0 40 20 50 10 460 10 470 0 480 20 490 10 500 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_3 = Raphael("bar_3", 500, 30);
var c = bar_canvas_3.path("M0 20L10 10 20 20 30 0 40 20 50 10 460 10 470 0 480 20 490 10 500 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_4 = Raphael("bar_4", 500, 30);
var c = bar_canvas_4.path("M0 20L10 10 20 20 30 0 40 20 50 10 460 10 470 0 480 20 490 10 500 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_5 = Raphael("bar_5", 291, 30);
var c = bar_canvas_5.path("M0 20L10 10 20 20 30 0 40 20 50 10 251 10 261 0 271 20 281 10 291 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_6 = Raphael("bar_6", 428, 30);
var c = bar_canvas_6.path("M0 20L10 10 20 20 30 0 40 20 50 10 378 10 398 0 408 20 418 10 428 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});

var bar_canvas_7 = Raphael("bar_7", 372, 30);
var c = bar_canvas_7.path("M0 20L10 10 20 20 30 0 40 20 50 10 332 10 342 0 352 20 362 10 372 10").attr({
	stroke: "#efefef",
	"srtoke-width": 1,
	fill: "none"
});


/*var footer_lightBase = Raphael("footer_lightBase", 460, 70);
var c = footer_lightBase.ellipse(230, 35, 220, 30)
		.attr({
			stroke: "none",
			fill: "#3AFF17",
});*/

var mask_canvas = Raphael("mask", 3320, 8500);
var c = mask_canvas.path("M 3320,8500 3320,0 1770,0 1890,2544.493 c 1.0407,22.0675 -17.908,40 -40,40 l -145,0 c -22.092,0 -40,17.907 -40,40 l 0,1450 c 0,22.092 17.908,40 40,40 l 0,7.508 c 199.729,22.36 355,191.792 355,397.492 0,205.7 -155.271,375.131 -355,397.492 l 0,7.508 c -22.092,0 -40,17.908 -40,40 l 0,1470 c 0,22.091 17.908,40 40,40 l 415,0 c 22.092,0 40,17.907 40,40 l 0,30 c 0,22.09 -17.909,40 -40,39.998 l -415,0 c -22.092,0 -40,17.908 -40,40 l 0,0 c 0,22.091 17.908,40 40,40 l 315,0 c 22.092,0 40,17.907 40,40 l 0,30 c 0,22.09 -17.909,40 -40,39.998 l -315,0 c -22.092,0 -40,17.908 -40,40 l 0,0 c 0,22.091 17.908,40 40,40 l 240,0 c 22.092,0 40,17.907 40,40 l 0,30 c 10e-4,22.09 -17.909,40 -40,39.998 l -15,0 c -22.092,0 -40,17.908 -40,40 l 0,1350.121 c 0,19.33 -102.975,35 -230,35 -127.025,0 -230,-15.67 -230,-35 l 0,-1350.121 c -10e-4,-22.091 -17.909,-39.998 -40,-40 l -15,0 c -22.091,0 -40,-17.908 -40,-40 l 0,-29.998 c 0,-22.093 17.908,-40 40,-40 l 240,0 c 22.092,0 40,-17.909 40,-40 l 0,-0 c -10e-4,-22.091 -17.909,-39.998 -40,-40 l -315,0 c -22.091,0 -40,-17.908 -40,-40 l 0,-29.998 c 0,-22.093 17.908,-40 40,-40 l 315,0 c 22.092,0 40,-17.909 40,-40 l 0,-0 c -10e-4,-22.091 -17.909,-39.998 -40,-40 l -415,0 c -22.091,0 -40,-17.908 -40,-40 l 0,-29.998 c 0,-22.093 17.908,-40 40,-40 l 415,0 c 22.092,0 40,-17.909 40,-40 l 0,-1470 c 0,-22.092 -17.908,-40 -40,-40 l 0,-7.508 c -199.729,-22.36 -355,-191.792 -355,-397.492 0,-205.7 155.271,-375.131 355,-397.492 l 0,-7.508 c 22.092,0 40,-17.908 40,-40 l 0,-1450 c 0,-22.092 -17.908,-40 -40,-40 l -145,0 c -22.092,0 -40,-17.908 -40,-40 L 1550,0 0,0 0,8500").attr({
	stroke: "none",
	fill: "90-#0F8341-#30333B:20-#374D32:70-#131d17-#000000"
});

var planet_canvas_1 = Raphael("planet_1", 240, 240);
var c = planet_canvas_1.ellipse(120, 120, 110, 110)
		.attr({
			stroke: "none",
			fill: "r(.5,.1)#000-#354C3F"
		});
var c = planet_canvas_1.ellipse(120, 120, 110, 110)
		.attr({
			stroke: "none",
			fill: "r(.5,.2)#688761-#ccc", 
			opacity: 0, 
		});
var c = planet_canvas_1.ellipse(120, 120, 120, 120)
		.attr({
			stroke: "none",
			fill: "r(.5,.9)#333-#fff", 
			opacity: 0, 
		});
		
/*
$('#logo').zlayer({mass:150,canvas:'#topo',force:'push'
});
$('#logo2').zlayer({mass:150,canvas:'#topo',force:'pull'
});
*/

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
	$('.chars').css({position: 'absolute', top: 4350, 'z-index': '5'});
	$('.gallery').width(1200)
	$('.gallery').css({'margin-left': -(600)})
	$('.project_box').width(600)
	var wrapWidth = 0;
	$('.wrap').find('.project_box').each(function() {
	   wrapWidth += $(this).outerWidth(true);
	});
	$('.fb-like').css({left: '1140px'});
	$('.css_award').css({left: '1131px'});
	$('.wrap').width(wrapWidth)
	$('.nav a').click(function(){
		var integer = $(this).attr('rel');
		$('.gallery .wrap').animate({left:-(1200)*(parseInt(integer)-1)}, 1000, 'easeInOutBack')  /*----- Width of div mystuff (here 160) ------ */
		return false
	});	
} else {
	
	$('.gallery').width(srcWidth)
	$('.gallery').css({'margin-left': -(srcWidth / 2)})
	$('.project_box').width(srcWidth / 2)
	var wrapWidth = 0;
	$('.wrap').find('.project_box').each(function() {
	   wrapWidth += $(this).outerWidth(true);
	});
	$('.wrap').width(wrapWidth)
	$('.nav a').click(function(){
		$('.nav a').removeClass('active');
		$(this).addClass('active');
		var integer = $(this).attr('rel');
		$('.gallery .wrap').animate({left:-(srcWidth)*(parseInt(integer)-1)}, 1000, 'easeInOutBack')  /*----- Width of div mystuff (here 160) ------ */
		
	
		 
		return false
	});	

	//$('#menu').css({left: srcWidth - 60});

	(function parallaxObj($) {
		$.fn.parallax = function(options) {
			var $$ = $(this);
			offset = $$.offset();
			var defaults = {
				"start": 0,
				"stop": offset.top + $$.height(),
				"coeff": 0.95
			};
			var opts = $.extend(defaults, options);
			return this.each(function() {
				$(window).bind('scroll', function() {
					windowTop = $(window).scrollTop();
									if ((windowTop >= opts.start) && (windowTop <= opts.stop)) {
										newCoord = windowTop * opts.coeff;
										$$.css({
											"top": newCoord + "px",
					
											//"opacity": parseInt(newCoord) / 300
										});
											//$$.fadeTo(0, parseInt(newCoord) / 300);
									}
								});
							});
		};
		
	})(jQuery);
	
/*
	$('#planet_1').parallax({
		"coeff": -0.3
	});
	$('#planet_2').parallax({
		"coeff": -0.6
	});
	
	

*/	
	
	$(window).scroll(function() {

		
		documentTop = $(document).scrollTop();
		
		if(documentTop < 2000) {
			var parallax_1 =  $(window).scrollTop()/0.80;  
			$('#planet_1').css('top', 1200 - parallax_1);
			var parallax_2 =  $(window).scrollTop()/1.5;
			$('#planet_2').css('top', 900 - parallax_2);
			var parallax_3 =  $(window).scrollTop()/0.90;
			$('#planet_3').css('top', 400 - parallax_3);
		
		}
		

		
		
		
	
		if(documentTop >= 7200 && documentTop <= 10000){
			$('.chars').filter(":not(:animated)").animate({top: charBottom}, 200)
		} else if(documentTop >= 0 && documentTop <= 6800){
			$('.chars').filter(":not(:animated)").animate({top: charMiddle}, 200)	
		}
			
		if(documentTop >= 7200 && documentTop <= 10000) {
			$('#char_1').destroy();
			$(".character").css({backgroundPosition: '0px 0px'});
		} else {
			$(".character").css({backgroundPosition: '0px -760px'})
			$('#char_1').sprite({fps: 1, no_of_frames: 1}).spRandom({top: -20,left: -15,right: 15,bottom: 20,speed: 1500,pause: 100});
		}
		
		if(documentTop >= 5000 ) {
			$('.balloon').css({left: 6000});	
		} else {
			$('.balloon').css({left: 130});	
		}
		
		if(documentTop >= 3880 && documentTop <= 4150 ){
			$('.chars').css({'z-index': '5'});
		} else if(documentTop >= 6200 && documentTop < 6700){
			$('.chars').css({'z-index': '1'});
		} else if(documentTop >= 6800) {
			$('.chars').css({'z-index': '5'});
		} else {
			$('.chars').css({'z-index': '1'});
		}
		
		if(documentTop >= 2200 && documentTop <= 3300){
			$('.chars').fadeOut(250);
		} else if(documentTop >= 3500 && documentTop <= 4400){
			$('.chars').fadeIn(250);
		} else if(documentTop >= 6200 && documentTop <= 6700){
			$('.chars').fadeOut(250);
		} else if(documentTop >= 6800 && documentTop <= 7200){
			$('.chars').fadeIn(250);
		} else {
			$('.chars').fadeIn(250);
		}
		
		if(documentTop > 1000){
			$('.legend').fadeOut();
		} else {
			$('.legend').fadeIn();
		}
		
			
			
		 if (documentTop >= 0 && documentTop <= 500){
  			$("a#link1").addClass("active");
			$("a#link2").removeClass("active");
			$("a#link3").removeClass("active");
			$("a#link4").removeClass("active");
			$("a#link5").removeClass("active");
		  } else if (documentTop >= 501 && documentTop <= 3500){
			$("a#link1").removeClass("active");
			$("a#link2").addClass("active");
			$("a#link3").removeClass("active");
			$("a#link4").removeClass("active");
			$("a#link5").removeClass("active");
		 } else if (documentTop >= 3501 && documentTop <= 4500){
			$("a#link1").removeClass("active");
			$("a#link2").removeClass("active");
			$("a#link3").addClass("active");
			$("a#link4").removeClass("active");
			$("a#link5").removeClass("active");
		 } else if (documentTop >= 5001 && documentTop <= 6000){
			$("a#link1").removeClass("active");
			$("a#link2").removeClass("active");
			$("a#link3").removeClass("active");
			$("a#link4").addClass("active");
			$("a#link5").removeClass("active");
		  } else if (documentTop >= 6001){
			$("a#link1").removeClass("active");
			$("a#link2").removeClass("active");
			$("a#link3").removeClass("active");
			$("a#link4").removeClass("active");
			$("a#link5").addClass("active");
		  }
	})
	$('#char_1')
		.sprite({fps: 1, no_of_frames: 1})
		.spRandom({
			top: -20,
			left: -15,
			right: 15,
			bottom: 20,
			speed: 1500,
			pause: 100
	});
	/*$('#char_2')
		 .sprite({fps: 15, no_of_frames: 1})
		 .spRandom({
			top: -20,
			left: 380,
			right: 350,
			bottom: 20,
			speed: 1500,
			pause: 100
	});
	$('#char_3')
		 .sprite({fps: 15, no_of_frames: 1})
		 .spRandom({
			top: -20,
			left: 100,
			right: 70,
			bottom: 20,
			speed: 1500,
			pause: 100
	});*/
		$('#cloud_1').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_2').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_3').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_4').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_5').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_6').sprite({fps: 1, no_of_frames: 5})
		$('#cloud_7').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_8').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_9').sprite({fps: 1, no_of_frames: 5});
		$('#cloud_10').sprite({fps: 1, no_of_frames: 5});
	/*
	
		$('#cloud_1').animate ({left:'100%'}, 40000 ).animate ({left:'0px'}, 0 )
		$('#cloud_2').animate ({left:'100%'}, 48000 ).animate ({left:'0'}, 0 )
		$('#cloud_3').animate ({left:'100%'}, 43000 ).animate ({left:'0'}, 0 )
		$('#cloud_4').animate ({left:'100%'}, 45000 ).animate ({left:'0'}, 0 )
		$('#cloud_5').animate ({left:'100%'}, 47000 ).animate ({left:'0'}, 0 )
		$('#cloud_6').animate ({left:'100%'}, 46000 ).animate ({left:'0'}, 0 )
		$('#cloud_7').animate ({left:'100%'}, 36000 ).animate ({left:'0px'}, 0 )
		$('#cloud_8').animate ({left:'100%'}, 37000 ).animate ({left:'0'}, 0 )
		$('#cloud_9').animate ({left:'100%'}, 38000 ).animate ({left:'0'}, 0 )
		$('#cloud_10').animate ({left:'100%'}, 39000 ).animate ({left:'0'}, 0 )
		


$.doTimeout( 49000, function(){
		$('#cloud_1').animate ({left:'100%'}, 40000 ).animate ({left:'0px'}, 0 )
		$('#cloud_2').animate ({left:'100%'}, 48000 ).animate ({left:'0'}, 0 )
		$('#cloud_3').animate ({left:'100%'}, 43000 ).animate ({left:'0'}, 0 )
		$('#cloud_4').animate ({left:'100%'}, 45000 ).animate ({left:'0'}, 0 )
		$('#cloud_5').animate ({left:'100%'}, 47000 ).animate ({left:'0'}, 0 )
		$('#cloud_6').animate ({left:'100%'}, 46000 ).animate ({left:'0'}, 0 )
		$('#cloud_7').animate ({left:'100%'}, 36000 ).animate ({left:'0px'}, 0 )
		$('#cloud_8').animate ({left:'100%'}, 37000 ).animate ({left:'0'}, 0 )
		$('#cloud_9').animate ({left:'100%'}, 38000 ).animate ({left:'0'}, 0 )
		$('#cloud_10').animate ({left:'100%'}, 39000 ).animate ({left:'0'}, 0 )
		
});
	
*/	
}

var planet_canvas_2 = Raphael("planet_2", 480, 480);
var c = planet_canvas_2.ellipse(240, 240, 200, 200)
		.attr({
			stroke: "none",
			fill: "r(.5,.1)#354C3F-#000"
		});
			
var c = planet_canvas_2.ellipse(240, 240, 240, 240)
		.attr({
			stroke: "none",
			fill: "r(.5,.2)#688761-#ccc", 
			opacity: 0, 
		});
var c = planet_canvas_2.ellipse(240, 240, 240, 240)
		.attr({
			stroke: "none",
			fill: "r(.5,.9)#354C3F-#333", 
			opacity: 0, 
		});






$('#container').pan({fps: 1, speed: 5, dir: 'down'});




var IDs = [];
$('#main').find('.project').each(function(){ IDs.push(this.id); });

$.each(IDs, function(index, projectId) {
	
	var o =  { 
		init: function(){
			this.diagram();
		},
		random: function(l, u){
			return Math.floor((Math.random()*(u-l+1))+l);
		},
		diagram: function(){
			
			var r = Raphael(projectId, 400, 400),
				rad = 100,
				defaultText = $('#'+projectId).attr('title'),
				speed = 100;
		
			var circleMask = r.circle(200, 200, 102).attr({ stroke: 'none', fill: '#1b1b1b', opacity: 0 });

			var title = r.text(200, 200, defaultText).attr({'font-family': 'Helvetica', 'font-size': '14px', fill:'#efefef'});
	
			
			r.customAttributes.arc = function(value, color, rad){
				var v = 3.6*value,
					alpha = v == 360 ? 359.99 : v,
					random = o.random(91, 240),
					a = (random-alpha) * Math.PI/180,
					b = random * Math.PI/180,
					sx = 200 + rad * Math.cos(b),
					sy = 200 - rad * Math.sin(b),
					x = 200 + rad * Math.cos(a),
					y = 200 - rad * Math.sin(a),
					path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]];
				return { path: path, stroke: color }
			}
			
			$('#'+projectId).find('.arc').each(function(i){
				var t = $(this), 
					color = t.find('.color').val(),
					value = t.find('.percent').val(),
					text = t.find('.text').text();
				
				rad += 20;	
				var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': 15, opacity: 0.9});
				
				z.mouseover(function(){
				 this.animate({ 'stroke-width': 30, opacity: 1, stroke: '#16FE67' }, 50, 'linear');
				 $("#"+projectId).parent().find('.visualizar').hide();
				 if(Raphael.type != 'VML') //solves IE problem
					this.toFront();
					title.stop().animate({ opacity: 0 }, speed, '>', function(){
						this.attr({ text: text + '\n' + value + '%'}).animate({ opacity: 1 }, speed, 'linear');
						circleMask.stop().animate({ opacity: 1}, 50)
						
					});
					
			  }).mouseout(function(){
					this.stop().animate({ 'stroke-width': 15, opacity: 0.8, stroke: '#efefef'  }, speed*4, 'linear');
					$("#"+projectId).parent().find('.visualizar').show();
					title.stop().animate({ opacity: 0 }, speed, '>', function(){
						title.attr({ text: defaultText }).animate({ opacity: 1 }, speed, 'linear');
						circleMask.stop().animate({ opacity: 0}, 100)
					});	
					
			  });
			});
			
		}
	}
	
	$(function(){ o.init(); });
	
});




$(document).ready(function(){

	documentTop = $(document).scrollTop();
	
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').filter(":not(:animated)").animate({scrollTop:target_top}, 3000, 'easeInOutQuint');
	});
	$(".legend").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').filter(":not(:animated)").animate({scrollTop:target_top}, 2000, 'easeInOutQuint');
	});
	
	$('#flickr').jflickrfeed({
		limit: 40,
		qstrings: {
		id: '29699554@N08'
	},
	itemTemplate: 
		
			'<a href="{{image_b}}" rel="lightbox-portfolio" class="gallery_flickr"><img src="{{image_m}}" alt="{{title}}"/><span class="bg_img"></span></a>'
		
	}, function(data) {
		$('#flickr .gallery_flickr').slimbox();
		$('#flickr a').find('img').css({opacity: 0.9});
		$('.bg_img').css({opacity: 0.1});
		$('#flickr a').hover( function(){
				$(this).find('img').animate({opacity: 1}, 250);
				$(this).find('.bg_img').animate({opacity: 0.8}, 250);
			}, function() {
				$(this).find('img').animate({opacity: 0.9}, 250);
				$(this).find('.bg_img').animate({opacity: 0.1}, 250);
		});	
		
	});/**/
	
	$('#flickr').find('a').each(function() {
			var imgHeight = $(this).find('img').height();
			
		  	$(this).height(imgHeight)
		});

	
	
});


$("a.scroll").hover( 
		function() {
			//if(documentTop < section_1_top || documentTop == section_2_top){
			
				$(this).find('.legend').fadeIn(250, 'easeInOutQuint');
				//$(this).css({backgroundPosition: '0px -380px'});
			//}
		}, function() {
			//if(documentTop < section_1_top || documentTop == section_2_top){
	
				$(this).find('.legend').fadeOut(250, 'easeInOutQuint');
				//$(this).css({backgroundPosition: '0px 0px'});
			//}
		}
);


$("#charList").find('li').hover(
		function() {
			char = $(this).attr('class');
			$('#'+char).find('.balloon').show("scale",{percent: 100, direction: 'vertical', origin: ['bottom','left']},250);
			$('#'+char).find('.balloon_2').show("scale",{percent: 100, direction: 'horizontal', origin: ['top','left']},250);
		}, function(){
			char = $(this).attr('class');
			$('#'+char).find('.balloon_2').hide("scale", {origin: ['top','left']}, 250);
			$('#'+char).find('.balloon').delay(200).hide("scale", {origin: ['bottom','center']}, 250);
		}
);	


$(".hoverChar").hover( 
		function() {
			//if(documentTop < section_1_top || documentTop == section_2_top){
				$(this).parent().find('.balloon').show("scale",{percent: 100, direction: 'vertical', origin: ['bottom','left']},250);
				$('.balloon_2').delay(200).show("scale",{percent: 100, direction: 'horizontal', origin: ['top','left']},250);
				//$(this).css({backgroundPosition: '0px -380px'});
			//}
		}, function(){
			//if(documentTop < section_1_top || documentTop == section_2_top){
				$('.balloon_2').hide("scale", {origin: ['top','left']}, 250);
				$(this).parent().find('.balloon').delay(200).hide("scale", {origin: ['bottom','center']}, 250);
				//$(this).css({backgroundPosition: '0px 0px'});
			//}
		}
	);


 $(".twitter").tweet({
            username: "guimbento",
            join_text: "auto",
            count: 4,
});



