var moveX = -868;
var markerOffset = 25;
var markerMoveX = 149;
var entryTw;
var arrowTw;
var entryNowPos = 1;
var arrowNowPos = 1;

function entrySlide(e_id, m_id){
	var m = moveX * (e_id-1);
	//$("inner").style.left= m + "px";
	if(entryTw){entryTw.cancel();}
	entryTw = new Effect.Move($("inner"), 
		Object.extend({ x: m - parseFloat($("inner").getStyle('left')), y: 0 }, {
		from:0.0,
		to:1.0,
		// delay:0,
		transition: Effect.Transitions.easeOutCirc,
		fps:25,
		duration: 0.8
	}));

	if(m_id){
		var m_m = markerMoveX * (m_id-1) + markerOffset;
		//$("gushes").style.left=m_m + "px"; - 
		if(arrowTw){arrowTw.cancel();}
		arrowTw = new Effect.Move($("gushes"), 
		Object.extend({ x: m_m - parseFloat($("gushes").getStyle('left')), y: 0 }, {
			from:0.0,
			to:1.0,
			// delay:0,
			transition: Effect.Transitions.easeOutCirc,
			fps:25,
			duration: 0.8
		}));
	}
}


function twoBlueResize(){
	var w=SystemY.getPageSize();
	var o = w.ww-765;
	if(o > 0){
		$("outer").style.marginLeft=o/2+"px";
	}else{
		$("outer").style.marginLeft="0px";
	}
}

function twoBlueOnload(){
	twoBlueResize();
	$("body").style.overflow="hidden";
	$("html").style.overflow="hidden";
	$("outer").style.position="relative";
	$("inner").style.position="absolute";
	$("inner").style.left="0px";
	if($("mainWraper")){
	$("mainWraper").style.width="765px";
	}
	var ua = navigator.userAgent.toLowerCase();
	var isIE5 = ua.indexOf("msie 5.");
	var isIE6 = ua.indexOf("msie 6.");
	var isIE7 = ua.indexOf("msie 7.");
	if(isIE6 != -1 || isIE5 != -1){
		$("outer").style.height="375px";
	}
	if(isIE7 == -1){
		$("main").style.position="relative";
	}
	
	var list = location.hash ? location.hash.split("_") : [false];
	if(list[0] !== false){
		entrySlide(list[2], list[1]);
		selectChange(list[1]);
	}
		
}


function selectChange(id){
	var target;
	var i = 1;
	while(target = $("sub" + i)){
		if(target.className == "selected"){
			target.className = "";
			if(target.firstChild && target.firstChild.onmouseout){
				target.firstChild.onmouseout();
			}
		}
		i++;
	}
	target = $("sub" +id);
	target.className = "selected";
	target.firstChild.onmouseout();
}

Event.observe(window, "load", twoBlueResize, false);
Event.observe(window, "resize", twoBlueResize, false);
document.observe('dom:loaded', twoBlueOnload);


if (Effect.Transitions) {
    Object.extend(
        Effect.Transitions,
        {
            easeNone: function(pos) {
                return pos;
            },    
            easeInQuad: function(pos) {
                return pos*pos;
            },    
            easeOutQuad: function(pos) {
                return -(pos)*(pos-2);
            },    
            easeInOutQuad: function(pos) {
                if((t=2*pos) < 1) return 0.5*t*t;
                return -0.5 *((--t)*(t-2) - 1);
            },    
            easeInCubic: function(pos) {
                return pos*pos*pos;
            },    
            easeOutCubic: function(pos) {
                return (t=pos-1)*t*t + 1;
            },    
            easeInOutCubic: function(pos) {
                if((t=2*pos) < 1) return 0.5*t*t*t;
                return 0.5*((t-=2)*t*t + 2);
            },    
            easeOutInCubic: function(pos) {
                if(pos < 0.5) return 0.5*Effect.Transitions.easeOutCubic(pos*2);
                return 0.5+0.5*Effect.Transitions.easeInCubic((pos*2)-1);
            },    
            easeInQuart: function(pos) {
                return pos*pos*pos*pos;
            },    
            easeOutQuart: function(pos) {
                return -((t=pos-1)*t*t*t - 1);
            },    
            easeInOutQuart: function(pos) {
                if((t=2*pos) < 1) return 0.5*t*t*t*t;
                return -0.5 *((t-=2)*t*t*t - 2);
            },    
            easeOutInQuart: function(pos) {
                if(pos < 0.5) return 0.5*Effect.Transitions.easeOutQuart(pos*2);
                return 0.5+0.5*Effect.Transitions.easeInQuart((pos*2)-1);
            },    
            easeInQuint: function(pos) {
                return pos*pos*pos*pos*pos;
            },    
            easeOutQuint: function(pos) {
                return (t=pos-1)*t*t*t*t + 1;
            },    
/*
            easeInOutQuint: function(t, b, c, d) {
                if((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
                return c/2*((t-=2)*t*t*t*t + 2) + b;
            },    
            easeOutInQuint: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeOutQuint(t*2, b, c/2, d);
                return Effect.Transitions.easeInQuint((t*2)-d, b+c/2, c/2, d);
            },    
            easeInSine: function(t, b, c, d) {
                return -c * Math.cos(t/d *(Math.PI/2)) + c + b;
            },    
*/
            easeOutSine: function(pos) {
                return Math.sin(pos *(Math.PI/2));
            },    
            easeInOutSine: function(pos) {
                return -1/2 *(Math.cos(Math.PI*pos) - 1);
            },    
/*
            easeOutInSine: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeOutSine(t*2, b, c/2, d);
                return Effect.Transitions.easeInSine((t*2)-d, b+c/2, c/2, d);
            },    
*/
            easeInExpo: function(pos) {
                return(pos==0) ? 0 : Math.pow(2, 10 *(pos - 1)) - 0.001;
            },    
            easeOutExpo: function(pos) {
                return(pos==1) ? 1 : 1.001 *(-Math.pow(2, -10 * pos) + 1);
            },    
/*
            easeInOutExpo: function(t, b, c, d) {
                if(t==0) return b;
                if(t==d) return b+c;
                if((t/=d/2) < 1) return c/2 * Math.pow(2, 10 *(t - 1)) + b - c * 0.0005;
                return c/2 * 1.0005 *(-Math.pow(2, -10 * --t) + 2) + b;
            },    
            easeOutInExpo: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeOutExpo(t*2, b, c/2, d);
                return Effect.Transitions.easeInExpo((t*2)-d, b+c/2, c/2, d);
            },    
*/
            easeInCirc: function(pos) {
                return -(Math.sqrt(1 -pos*pos) - 1);
            },    
            easeOutCirc: function(pos) {
                return Math.sqrt(1 -(t=pos-1)*t);
            },    
/*
            easeInOutCirc: function(t, b, c, d) {
                if((t/=d/2) < 1) return -c/2 *(Math.sqrt(1 - t*t) - 1) + b;
                return c/2 *(Math.sqrt(1 -(t-=2)*t) + 1) + b;
            },    
            easeOutInCirc: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeOutCirc(t*2, b, c/2, d);
                return Effect.Transitions.easeInCirc((t*2)-d, b+c/2, c/2, d);
            },    
            easeInElastic: function(t, b, c, d, a, p) {
                var s;
                if(t==0) return b;  if((t/=d)==1) return b+c;  if(!p) p=d*.3;
                if(!a || a < Math.abs(c)) { a=c; s=p/4; } else s = p/(2*Math.PI) * Math.asin(c/a);
                return -(a*Math.pow(2,10*(t-=1)) * Math.sin((t*d-s)*(2*Math.PI)/p )) + b;
            },    
            easeOutElastic: function(t, b, c, d, a, p) {
                var s;
                if(t==0) return b;  if((t/=d)==1) return b+c;  if(!p) p=d*.3;
                if(!a || a < Math.abs(c)) { a=c; s=p/4; } else s = p/(2*Math.PI) * Math.asin(c/a);
                return(a*Math.pow(2,-10*t) * Math.sin((t*d-s)*(2*Math.PI)/p ) + c + b);
            },    
            easeInOutElastic: function(t, b, c, d, a, p) {
                var s;
                if(t==0) return b;  if((t/=d/2)==2) return b+c;  if(!p) p=d*(.3*1.5);
                if(!a || a < Math.abs(c)) { a=c; s=p/4; }       else s = p/(2*Math.PI) * Math.asin(c/a);
                if(t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin((t*d-s)*(2*Math.PI)/p )) + b;
                return a*Math.pow(2,-10*(t-=1)) * Math.sin((t*d-s)*(2*Math.PI)/p )*.5 + c + b;
            },    
            easeOutInElastic: function(t, b, c, d, a, p) {
                if(t < d/2) return Effect.Transitions.easeOutElastic(t*2, b, c/2, d, a, p);
                return Effect.Transitions.easeInElastic((t*2)-d, b+c/2, c/2, d, a, p);
            },    
*/
            easeInBack: function(pos, s) {
                if(s == undefined) s = 1.70158;
                return pos*pos*((s+1)*pos - s);
            },    
            easeOutBack: function(pos, s) {
                if(s == undefined) s = 1.70158;
                return (t=pos-1)*t*((s+1)*t + s) + 1;
            },    
/*
            easeInOutBack: function(t, b, c, d, s) {
                if(s == undefined) s = 1.70158;
                if((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
                return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
            },    
            easeOutInBack: function(t, b, c, d, s) {
                if(t < d/2) return Effect.Transitions.easeOutBack(t*2, b, c/2, d, s);
                return Effect.Transitions.easeInBack((t*2)-d, b+c/2, c/2, d, s);
            },    
            easeInBounce: function(t, b, c, d) {
                return c - Effect.Transitions.easeOutBounce(d-t, 0, c, d) + b;
            },    
*/
            easeOutBounce: function(pos) {
                if((pos) <(1/2.75)) {
                    return 7.5625*pos*pos;
                } else if(pos <(2/2.75)) {
                    return 7.5625*(pos-=(1.5/2.75))*pos + .75;
                } else if(pos <(2.5/2.75)) {
                    return 7.5625*(pos-=(2.25/2.75))*pos + .9375;
                } else {
                    return 7.5625*(pos-=(2.625/2.75))*pos + .984375;
                }
            }
/*,    
            easeInOutBounce: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeInBounce(t*2, 0, c, d) * .5 + b;
                else return Effect.Transitions.easeOutBounce(t*2-d, 0, c, d) * .5 + c*.5 + b;
            },    
            easeOutInBounce: function(t, b, c, d) {
                if(t < d/2) return Effect.Transitions.easeOutBounce(t*2, b, c/2, d);
                return Effect.Transitions.easeInBounce((t*2)-d, b+c/2, c/2, d);
            }
*/
            
        }); 
}
