var transitions = Array('bars','zip','blinds','blocks','concentric','warp','slide','bars3d','cube','tiles3d','blinds3d','turn');

var bgImages = ['./images/_background_main_1.jpg',
'./images/_background_main_2.jpg',
'./images/_background_main_3.jpg',
'./images/_background_main_4.jpg',

'./images/_background_main_1.jpg',
'./images/_background_main_2.jpg',
'./images/_background_main_3.jpg',
'./images/_background_main_4.jpg'];

var colors = ['#84c124','#0293d6','#e24e34','#edb00f',

'#84c124','#0293d6','#e24e34','#edb00f'
];

var rotArr = [3,-4,2,-1,
5,-1,3,-2];

var hovered = [];

var animation = true;	// if smth animate
var gallAnim = false;	// if gallery aimate
var showed = false;	// if show page
var splashShow = false;	// if show splash
var MSIE = false;		// if browser -- internet explorer
var FF = false;			// if browser -- mozilla firefox
var CHROME = false;		// if browser -- google chrome
var support3D = true;	// if browser support 3d transitions
var linkPage = undefined; // number of Page
var lastlinkPage= undefined;
var privacy = Boolean(false);
var mustShowGall = Boolean(false);
var posit;
var allowScenario = Boolean(true);

function windowHalfH() {
	return (window.innerHeight/2);
}

function windowHalfW() {
	return (window.innerWidth/2);
}

var startCoords = [ {x : -1, y : 1},
{x : -1, y : -1},
{x : 1, y : -1},
{x : 1, y : 1}];

var overItem = -1;
var firstTime = true;
var curr = 0;
var ROT_ANG = 10;

function showSplash() {
	splashShow = true;

	var i = 0;
	var del = 0;
	var all = $('#main nav ul li');

	for (i=0;i<=all.length-1;i++){
		hovered[i]=false;
	}

	var cnt = 0;
	var j = 0;

	for (i=0;i<=all.length-1;i++){
		all.eq(i).css('left',startCoords[i].x*windowHalfW());
		all.eq(i).css('top',startCoords[i].y*windowHalfH());

		all.eq(i)
		.stop()
		.animate({
			scale : .01,
			rotate : rotArr[i]*20,
		},{
			duration: 2
		});

		setTimeout(function () {
			all.eq(j)
			.stop()
			.animate({
				opacity: 1,
				left : '0px',
				top : '0px',
				rotate : rotArr[j],
				scale : 1
			},{
				duration: 1800,
				easing: 'easeOutElastic',
				complete : function (){
					cnt++;
					if (cnt === all.length){
						animation = false;
					}
				}
			})
			j++;
		},i*250 + 50);
	}
}

function hideSplash() {
	splashShow = false;
	animation = true;

	var i = 0;
	var del = 0;
	var all = $('#main nav ul li');

	var cnt = 0;
	var j = 0;

	var posL = 0;
	var posT = 0;

	for (i=0;i<all.length;i++){
		var _del = Number(i*150 + 30);
		setTimeout(function () {
			posL = startCoords[j].x*windowHalfW();
			posT = startCoords[j].y*windowHalfH();

			//if (!MSIE){
				all.eq(j)
				.stop()
				.animate({
					opacity: 0,
					left : posL,
					top : posT,
					scale : .01
				},{
					duration: 700,
					easing: 'easeInBack'
				})
			j++;
		},_del);
	}
}

function hideSplashQ(){
	var i = 0;
	var all = $('#main nav ul li');
	var cnt = 0;
	var j = 0;
	var posL = 0;
	var posT = 0;

	for (i=0;i<all.length;i++){
		var _del = Number(i*150 + 30);
			posL = startCoords[j].x*windowHalfW();
			posT = startCoords[j].y*windowHalfH();
			all.eq(j).css({
				'opacity': '0',
				'left' : String(posL),
				'top' : String(posT),
				'scale' : '.01'
			});
		j++;
	}
}

function showBack() {
	$('#back').show().animate({
		right: 0
	},{
		duration: 500,
		easing: 'easeOutBack'
	});
}

function hideBack() {
	$('#back').animate({
		right: -250,
		width: '231px'
	},{
		duration: 600,
		easing: 'easeInBack',
		complete: function (){
			$('#back').hide()	
		}
	})
			
			var el = $('#back a');
			el.stop().animate({
				"font-size": 32,
				'margin-left': -25
			},{
				duration : 600,
				easing: 'easeInBack'
			})
			
			$('#back a img').stop().animate({
				rotate: 0
			},{
				duration : 600,
				easing: 'easeInBack'	
			});
}

function chooseTypeGalleryBySupport3D(){
	if (support3D){
		$('.folio ul li').hide();
		$('.container').show();
	}else {
		$('.container').hide();
		$('.foio ul li').show();
	}
}

function initFluxSlider(){
	$(function(){
		/*
		if(!flux.browser.supportsTransitions)
		alert("Flux Slider requires a browser that supports CSS3 transitions");
		*/
		window.f = new flux.slider('#slider', {
			autoplay: false,
			pagination: false,
			onTransitionEnd: function(data) {
				setTimeout(function () {
					gallAnim = false;
				},300);
			}
		});

		// If this is a 3D transform and the browser doesn't support 3D then inform the user
		if(!flux.browser.supports3d)
		{
			//alert("Flux Slider requires a browser that supports CSS3 transitions");
			return;
		}
	});
}

function detectBrowser(){
	if($.browser.msie){
		MSIE = true;
		FF = false;
		CHROME = false;
	}
	if ($.browser.mozilla){
		MSIE = false;
		FF = true;
		CHROME = false;
	}

	if (/chrome/.test( navigator.userAgent.toLowerCase()) || $.browser.safari){
		MSIE = false;
		FF = false;
		CHROME = true;
	}
}

function colorizeElements(pos){
			///////////////////////// CHANGE BG FOR BACK BUTT /////////////////////
			posit = pos;
			if (pos !== undefined) {
					$('#back')
					.stop()
					.animate({
						backgroundColor: colors[pos]
					},{
						duration: '1000',
						easing: 'easeOutExpo'
					});
					
					$('#main nav ul li a')
					.stop()
					.animate({
						backgroundColor: colors[pos]
					},{
						duration: '1500',
						easing: 'easeOutCubic'
					});
			
					$('#mainBody')
					.stop()
					.animate({backgroundColor: colors[pos]},{ duration : '1500', easing : 'easeOutCubic'
				});
			}
}

//SLIDER PAGE3

var numLink = Number(-1);	
function verticalMenuActions(){
	var all = $('.page3_vert_menu a');
	all.bind('click',function (e){
		var num = 0;
		for (var i =0;i<all.length;i++){
			if (all[i] == e.target){
				num = i;
			}	
		}
		
		if (numLink != num) {
			numLink = num;
			$('.page3_vert_menu ul li a').trigger('mouseleave');
			
			$('.contentSlider').animate({
				top: -(485*num)
			},{
				duration: '1800',
				easing: 'easeInOutExpo',
				complete: function () {
					changeURL($('.page3_vert_menu ul li a').eq(num).attr('href'));
				}
			});
		}
	})
	
	var allPar = $('.page3_vert_menu ul li');
	allPar.bind('mouseenter',function(e){
		var num = -1;
		for (var i =0;i<allPar.length;i++){
			if (allPar[i] == this){
				num = i;
			}	
		}
		
		if (numLink != num) {
			$(this).removeClass();
			$(this).removeClass('li_out');
			$(this).addClass('li_over');
			
			$(this).children('a').removeClass('a_out');
			$(this).children('a').addClass('a_over');	
		}
	})
	.bind('mouseleave',function(e){
		var num = -1;
		for (var i =0;i<allPar.length;i++){
			if (allPar[i] == this){
				num = i;
			}	
		}
		
		if (numLink != num) {
			$(this).removeClass();
			$(this).removeClass('li_over');
			$(this).addClass('li_out');
			
			$(this).children('a').removeClass('a_over');
			$(this).children('a').addClass('a_out');	
		}
	})	
}

$(window).load(function(){	
	if (checkInputHash() != ''){
		allowScenario = false;
	}
	change_page();
	
	$('#back').hide();
	detectBrowser();

	support3D = flux.browser.supportsTransitions;
	chooseTypeGalleryBySupport3D();
	$('.container').hide();
	
	if (!MSIE){
		initFluxSlider();
	}
	
	$('.scroll-pane').jScrollPane({
		showArrows:false,
		scrollbarWidth:28,
		dragMaxHeight:95,
		reinitialiseOnImageLoad: true
	});

	var all = $('#main nav ul li');
	var i = 0;
	for (i=0;i<all.length;i++){
		hovered.push(false);
	}

	verticalMenuActions();
	
	$('#content').sprites()
	$('#form1 .name .bg,#form1 .email .bg').sprites({method:'gStretch'})
	$('#form1 .msg .bg').sprites({method:'vStretch'})

	$('.folio').each(function(){
		var th=$(this)
		th.gSlider()
		th.siblings('a')
		.bind('click',function(){
			changeURL();
			
			if($(this).is('.next'))
			th.gSlider('next')
			if($(this).is('.prev'))
			th.gSlider('prev')
			return false
		})
	})

	// gallery actions
	$('.container .prev').bind('click',function(){
		var num = Number(4);
		if (support3D){
			if (!gallAnim){
				if (CHROME)
					num = 7;
				window.f.prev(transitions[num]);
				gallAnim = true;
			}
		}
	})

	$('.container .next').bind('click',function(){
		
		var num = Number(4);
		if (support3D){
			if (!gallAnim){
				if (CHROME)
					num = 7;
				window.f.next(transitions[num]);
				gallAnim = true;
			}
		}
	})
	
	// buttons actions
	$('.link1').bind('mouseenter',function(){
			$(this).stop().animate({
				color: '#302c2b',
				"font-size": 28
			},{
				duration : 400,
				easing: 'easeOutExpo'
			})
	})
	.bind('mouseleave',function(){
			var el = $(this);
			$(this).stop().animate({
				color: "#fff",
				"font-size": 8
			},{
				duration : 300,
				easing: 'easeInExpo',
				complete: function () {
					el.animate({
						"font-size": 22
					},{	
						duration : 800,
						easing: 'easeOutElastic',
					});
				}
			})
	});
	
	$('.butt').bind('mouseenter',function(){
			$(this).stop().animate({
				color: '#302c2b',
				"font-size": 28
			},{
				duration : 400,
				easing: 'easeOutExpo'
			})
	})
	.bind('mouseleave',function(){
			var el = $(this);
			$(this).stop().animate({
				color: "#fff",
				"font-size": 8
			},{
				duration : 300,
				easing: 'easeInExpo',
				complete: function () {
					el.animate({
						"font-size": 22
					},{	
						duration : 800,
						easing: 'easeOutElastic',
					});
				}
			})	
	});
	
	// back button	
	$('#back').bind('mouseenter',function(){
		if (!animation) {
			$(this).stop().animate({
				width: '300px'
			},{
				duration : 400,
				easing: 'easeOutBack'
			})
			
			$('#back a').stop().animate({
				"font-size": 40,
				'margin-left': 6
			},{
				duration : 400,
				easing: 'easeOutExpo'
			})
			
			$('#back a img').stop().animate({
				rotate: 180
			},{
				duration : 400,
				easing: 'easeOutBack'
			})
		}
	})
	.bind('mouseleave',function(){
		if (!animation) {
			$(this).stop().animate({
				width: '231px'
			},{
				duration : 600,
				easing: 'easeInOutExpo'	
			});
			
			var el = $('#back a');
			el.stop().animate({
				"font-size": 12,
				'margin-left': -25
			},{
				duration : 300,
				easing: 'easeInExpo',
				complete: function () {
					el.animate({
						"font-size": 32
					},{	
						duration : 800,
						easing: 'easeOutElastic',
					});
				}
			})
			
			$('#back a img').stop().animate({
				rotate: 0
			},{
				duration : 600,
				easing: 'easeInOutExpo'	
			});
		}
	});
	
	// folio actions
	$('.folio a').fancybox({
		// disableNavButtons : false
	});

	$('.folio ul li a')
	.bind('mouseenter', function (){
		$(this)
		.stop()
		.animate({
			rotate: getRandomFromRangeInt(-15,15)
		},{
			duration: 300,
			easing: 'easeOutQuad'
		})
	})
	.bind('mouseleave', function (){
		$(this)
		.stop()
		.animate({
			rotate: 0
		},{
			duration: 1500,
			easing: 'easeOutBounce'
		})
	})
	.bind('click', function (){
		$(this)
		.stop()
		.animate({
			rotate: 0
		},{
			duration: 1500,
			easing: 'easeOutBounce'
		})
	})
	
	// nav buttons action 
	
	var content=$('#content'),
	nav=$('nav');

	// splash navigation menu
	nav.navs({
		hover:true,
		hoverIn:function(el,pos){

			if ((!animation) && (!hovered[pos])){
				hovered[pos] = true;

				var img=$('img',el),
				duration=300,
				easing='easeInQuart'
				el.css({zIndex:999})

				if (pos !== undefined) {
					$(el).css('z-index',999);

					$(el)
					.stop()
					.animate({
						rotate : 0,
						scale : 1.2
					},{
						duration : 1000,
						easing: 'easeOutElastic'
					});

					colorizeElements(pos);
				}
			}
		},
		hoverOut:function(el,pos){
		if (firstTime){
			change_page();
			
			firstTime = false;
		} else {

			if (!animation){
				hovered[pos] = false;

				var img=$('img',el);

				duration=300;
				easing='easeOutElastic';

				$(el).css('z-index',1);

				var hoverTime = 2000;
				if (FF) {
					hoverTime = 600;
					easing = 'easeInOutQuad';
				}

				$(el)
				.stop()
				.animate({
					rotate : getRandomFromRangeInt(-ROT_ANG,ROT_ANG),
					scale : 1
				},{
					duration : hoverTime,
					easing: easing
				});
			}
		}
	}
})

nav.navs(function(n){
	$('li',this).eq(n).css({zIndex:1});
	content.tabs(n);
})

content
.tabs({
	showFu:function(){		
		animation = true;

		setTimeout(function (){ if (!splashShow)  showBack();},1700);

		hideSplash();

		var _time = 900;
		var _delay = 900;

		var _elem = $('#content');

		_elem.css('z-Index','99999');
		
		$(_elem).show();
		// if support3D
		if (support3D && (
		((linkPage == 1) && (lastlinkPage == -1)) ||
		((linkPage == 1) && (lastlinkPage == 1))
		)){

			var gall = $('.container');

			setTimeout(function () {
				gall.stop().css({'top': String(-windowHalfH()*1.3)+'px','opacity':'0'});

				var _t = 175;
				var _h = 485;
				var _w = 912;

				gall.show().animate({
					opacity: 1,
					top: '0px'
				},{
					duration: _time,
					easing: 'easeOutElastic',
					complete : function (){
						animation = false;
						showed= true;
					}
				});
			},_delay);
		}else{
			// if browser doesn't support transform 3D
			setTimeout(function () {
				_elem.stop().animate({
					top: -windowHalfH()*2,
					height: 100
				},{duration: 1});

				var _t = 175;
				var _h = 485;
				var _w = 912;

				setTimeout(function () {
					_elem.animate({
						top: _t,
						height: _h
					},{
						duration: _time,
						easing: 'easeOutElastic',
						complete : function (){
							animation = false;
							showed= true;
						}
					});
				},10);
			},_delay);

			var elem = this;
			setTimeout(function () {
				elem.next.css({
					width: 912,
					height: 485
				})

				setTimeout(function () {
					elem.next.show().stop()
				},10);
			},_delay);
		}
	},
	hideFu:function(){
		if (showed){
			var _time = 700;
			var ease = 'easeInBack';

			if (support3D && (((linkPage == 1) && (lastlinkPage != -1)) ||
			((linkPage == undefined) && (lastlinkPage == 1))) && (!privacy)){
				privacy = false;

				animation = true;

				$('.container').stop().
				animate({
					opacity: 0,
					top: -windowHalfH()*1.3
				},{
					duration: (_time),
					easing: ease,
					complete: function(){
						showed= false;
						$('.container').hide();
					}
				});
			} else {

				animation = true;
				var _elem = $('#content');

				privacy = false;

				_elem.
				stop().
				animate({
					top: -windowHalfH()/1.5,
					height: 250
				},{
					duration: (_time),
					easing: ease,
					complete: function(){
						showed= false;
						elem.itms.not(':hidden').hide();
					}
				});

				var elem = this;
				elem.itms.not(':hidden')
				.stop()
			}
		}
	}
})

var bgImg=$('img.bg-img').css({position:'absolute',left:0,top:0,zIndex:-1,height:'100%',width:'auto'}),
main=$('#main'),
onResize=function(){
	if(!(document.body.offsetHeight > 700))
	bgImg.height(700)
	else
	bgImg.height('100%')
}

$(window).bind('resize',onResize)
onResize()

$('#gspinner').fadeOut()
$(window).trigger('resize')
})

function clone(obj){
	if(!obj||typeof obj!=typeof {})
	return obj
	if(obj instanceof Array)
	return [].concat(obj)
	var tmp=new obj.constructor(),
	i
	for(i in obj)
	if(obj.hasOwnProperty(i))
	tmp[i]=clone(obj[i])
	return tmp
}

;(function($){var c=['DOMMouseScroll','mousewheel'];$.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var i=c.length;i;)this.addEventListener(c[--i],handler,false);else this.onmousewheel=handler},teardown:function(){if(this.removeEventListener)for(var i=c.length;i;)this.removeEventListener(c[--i],handler,false);else this.onmousewheel=null}};$.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}});function handler(a){var b=[].slice.call(arguments,1),delta=0,returnValue=true;a=$.event.fix(a||window.event);a.type="mousewheel";if(a.wheelDelta)delta=a.wheelDelta/120;if(a.detail)delta=-a.detail/3;b.unshift(a,delta);return $.event.handle.apply(this,b)}})(jQuery);

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'V\']=h.i[\'y\'];h.M(h.i,{B:\'C\',y:9(x,t,b,c,d){6 h.i[h.i.B](x,t,b,c,d)},14:9(x,t,b,c,d){6 c*(t/=d)*t+b},C:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},12:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},Q:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},O:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},P:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},L:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},S:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},F:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},K:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},N:9(x,t,b,c,d){6-c*8.A(t/d*(8.g/2))+c+b},R:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},X:9(x,t,b,c,d){6-c/2*(8.A(8.g*t/d)-1)+b},11:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},15:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},16:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},E:9(x,t,b,c,d){6-c*(8.q(1-(t/=d)*t)-1)+b},G:9(x,t,b,c,d){6 c*8.q(1-(t=t/d-1)*t)+b},H:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.q(1-t*t)-1)+b;6 c/2*(8.q(1-(t-=2)*t)+1)+b},I:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.u(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.v(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.u(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.v(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},U:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.u(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.v(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},W:9(x,t,b,c,d,s){e(s==w)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},Y:9(x,t,b,c,d,s){e(s==w)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},Z:9(x,t,b,c,d,s){e(s==w)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.D))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.D))+1)*t+s)+2)+b},z:9(x,t,b,c,d){6 c-h.i.r(x,d-t,0,c,d)+b},r:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.o*t*t)+b}m e(t<(2/2.k)){6 c*(7.o*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.o*(t-=(2.17/2.k))*t+.18)+b}m{6 c*(7.o*(t-=(2.19/2.k))*t+.1a)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.z(x,t*2,0,c,d)*.5+b;6 h.i.r(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|5625||sqrt|easeOutBounce|||abs|asin|undefined||swing|easeInBounce|cos|def|easeOutQuad|525|easeInCirc|easeInQuint|easeOutCirc|easeInOutCirc|easeInElastic|easeOutQuint|easeInOutQuint|easeOutQuart|extend|easeInSine|easeInOutCubic|easeInQuart|easeOutCubic|easeOutSine|easeInOutQuart|easeOutElastic|easeInOutElastic|jswing|easeInBack|easeInOutSine|easeOutBack|easeInOutBack||easeInExpo|easeInCubic|easeInOutQuad|easeInQuad|easeOutExpo|easeInOutExpo|25|9375|625|984375|easeInOutBounce'.split('|'),0,{}))

;(function(d){d.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,b){d.fx.step[b]=function(a){if(a.state==0){a.start=getColor(a.elem,b);a.end=getRGB(a.end)}a.elem.style[b]="rgb("+[Math.max(Math.min(parseInt((a.pos*(a.end[0]-a.start[0]))+a.start[0]),255),0),Math.max(Math.min(parseInt((a.pos*(a.end[1]-a.start[1]))+a.start[1]),255),0),Math.max(Math.min(parseInt((a.pos*(a.end[2]-a.start[2]))+a.start[2]),255),0)].join(",")+")"}});function getRGB(a){var b;if(a&&a.constructor==Array&&a.length==3)return a;if(b=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])];if(b=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(a))return[parseFloat(b[1])*2.55,parseFloat(b[2])*2.55,parseFloat(b[3])*2.55];if(b=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)];if(b=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(a))return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)];if(b=/rgba\(0, 0, 0, 0\)/.exec(a))return e['transparent'];return e[d.trim(a).toLowerCase()]}function getColor(a,b){var c;do{c=d.curCSS(a,b);if(c!=''&&c!='transparent'||d.nodeName(a,"body"))break;b="backgroundColor"}while(a=a.parentNode);return getRGB(c)};var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);

//prototype extends
Array.prototype.lastIndexOf=Array.prototype.lastIndexOf||function(val,i){
	i=this.length-i||this.length
	while(--i^-1)
	if(this[i]==val)
	return i
	return -1
}

Array.prototype.indexOf=Array.prototype.indexOf||function(val,i){
	i=i-1||-1
	while(++i^this.length)
	if(this[i]==val)
	return i
	return -1
}
