$(window).load(function(){
	midRate=0.88;
	smallRate=0.75;
	bigHeight=$("#i10roller").height();
	midHeight=Math.floor($("#i10roller").height()*midRate);
	smallHeight=Math.floor($("#i10roller").height()*smallRate);
	smallTop=$("#i10roller").height()-smallHeight;
	midTop=$("#i10roller").height()-midHeight;
	$("#i10roller a").each(function(){
		$(this).attr("id",$("#i10roller a").index($(this)))
	})
	$("#i10roller img:eq(0)").css({"height":smallHeight, "width":"auto", "top":smallTop, "left":0}).addClass("shown");
	$("#i10roller img:eq(1)").each(function(){
		$(this).css({"height":midHeight, "top":midTop,"left":"28%","margin-left":0-Math.floor($(this).width()/2*midRate),"width":"auto"});
	}).addClass("shown");
	$("#i10roller img:eq(2)").each(function(){
		$(this).css({"top":0,"left":"50%","margin-left":0-Math.floor($(this).width()/2),"width":"auto"});
	}).addClass("shown");
	$("#i10roller img:eq(3)").each(function(){
		$(this).css({"height":midHeight, "top":midTop,"left":"72%","margin-left":0-Math.floor($(this).width()/2*midRate),"width":"auto"});
	}).addClass("shown");
	$("#i10roller img:eq(4)").each(function(){
		$(this).css({"height":smallHeight,"width":"auto","top":smallTop,"left":"100%"}).css("margin-left",0-$(this).width());
	}).addClass("shown");
	$("#i10roller img:gt(4)").each(function(){
		$(this).css({"height":smallHeight,"top":smallTop,"left":"100%","width":"auto"});
	})
	$("#arrow_right").click(function(event){
		$(".shown:eq(0)").parent().prevAll("a").find("img").each(function(){
			$(this).stop().animate({
				left: "-50%",
				height: smallHeight,
				top:smallTop,
				marginLeft: 0
			},1000,function(){
				if($(this).css("left")=="-50%") $(this).parent().remove();
			})
		})
		$(".shown:eq(0)").each(function(){
			$(this).stop().animate({
				left: "0%",
				height: smallHeight,
				top:smallTop,
				marginLeft:0-Math.floor($(this).width())
			},1000,function(){
				if(parseInt($(this).css("margin-left"))<=(0-$(this).width())) $(this).parent().remove();
			}).parent().clone().appendTo("#i10roller").find("img").css({"height":smallHeight,"top":smallTop,"left":"100%","margin-left":0});
		})
		if ($.browser.safari){
		   	$(".shown:eq(1)").each(function(){
				$(this).stop().animate({
					left: "0%",
					top: smallTop,
					height: smallHeight,
					marginLeft:0
				},1000);
			})
		}
		else{
			$(".shown:eq(1)").each(function(){
				$(this).stop().animate({
					left: "0",
					top: smallTop,
					height: smallHeight,
					marginLeft:0
				},1000);
			})
		}
		$(".shown:eq(2)").each(function(){
			$(this).stop().animate({
				left: "28%",
				top: midTop,
				height: midHeight,
				marginLeft:0-Math.floor($(this).width()*midHeight/$(this).height()/2)
			},1000);
		})
		$(".shown:eq(3)").each(function(){
			$(this).stop().animate({
				left: "50%",
				marginLeft: 0-Math.floor($(this).width()*bigHeight/$(this).height()/2),
				height: bigHeight,
				top:0
			},1000)
		})
		$(".shown:eq(4)").each(function(){
			$(this).stop().animate({
				left: "72%",
				top: midTop,
				height: midHeight,
				marginLeft:0-Math.floor($(this).width()*midHeight/$(this).height()/2)
			},1000);
		})
		.parent().next().find("img").addClass("shown").each(function(){
			$(this).stop().animate({
				left: "100%",
				height: smallHeight,
				top:smallTop,
				marginLeft: 0-Math.floor($(this).width())
			},1000)
		})
		$(".shown:eq(0)").removeClass("shown");
		event.preventDefault();
	})
	
	$("#arrow_left").click(function(event){
		$(".shown:eq(0)").each(function(){
			$(this).stop().animate({
				left: "28%",
				top: midTop,
				height: midHeight,
				marginLeft:0-Math.floor($(this).width()*midHeight/$(this).height()/2)
			},1000);
		})
		$(".shown:eq(1)").each(function(){
			$(this).stop().animate({
				left: "50%",
				marginLeft: 0-Math.floor($(this).width()*bigHeight/$(this).height()/2),
				height: bigHeight,
				top:0
			},1000);
		})
		$(".shown:eq(2)").each(function(){
			$(this).stop().animate({
				left: "72%",
				top: midTop,
				height: midHeight,
				marginLeft:0-Math.floor($(this).width()*midHeight/$(this).height()/2)
			},1000);
		})
		$(".shown:eq(3)").each(function(){
			$(this).stop().animate({
				left: "100%",
				top: smallTop,
				height: smallHeight,
				marginLeft: 0-Math.floor($(this).width()*smallHeight/$(this).height())
			},1000);
		})
		$(".shown:eq(4)").each(function(){
			$(this).stop().animate({
				left: "100%",
				top: smallTop,
				height: smallHeight,
				marginLeft:0
			},1000,function(){
				if($(this).css("left")=="100%") $(this).parent().remove();
			})
		}).removeClass("shown");
		$("#i10roller img:not(.del):last").parent().clone().prependTo("#i10roller").find("img").css("left","0").addClass("shown").each(function(){
			$(this).css("margin-left",0-$(this).width());
			$(this).stop().animate({
				left: "0",
				top: smallTop,
				height: smallHeight,
				marginLeft: 0
			},1000)
		})
		$("#i10roller img:not(.del):last").addClass("del");
		$("img.del:not(:first)").each(function(){
			$(this).stop().animate({
				left: "150%",
				height: smallHeight,
				top:smallTop,
				marginLeft: 0-Math.floor($(this).width()*smallHeight/$(this).height())
			},1000,function(){
				if($(this).css("left")=="150%") $(this).parent().remove();
			})
		})
		event.preventDefault();
	})
})

$(document).ready(function(){
	$("div.js_menu li").hover(function(){
		if($(this).find(".submenu").length){
			//$(this).find(".submenu").fadeIn("fast");
			//$("<div />").addClass("arrow").css("display","none").appendTo($(this)).fadeIn("fast");
			$(this).find(".submenu").toggle();
		}
	},
	function(){
		//$(this).find(".submenu").fadeOut("fast");
		//$(this).find(".arrow").fadeOut("fast",function(){
		//	$(this).remove();
		//})
		$(this).find(".submenu").toggle();
	})
});

function mailTo(login, image) {
    var domain = "@twistcasino.com";
    document.write('<a href="mailto:' + login + domain + '" title=""><img src="' + image + '" alt="" align="absmiddle" border=0 /></a>');
};