var block = new Array();

﻿$(document).ready(function(){
	$(".feedback-link").click(function (){
		$(".feedback").slideToggle("normal");
		return false;
	});

	$(".login-link").click(function (){
		$(".login").slideToggle("normal");
		return false;
	});

//	$(".menu li").fadeTo("fast", 1);

	var num = 0;
	$(".menu .subtop").each(function(i,html) {
		if($(this).html() == $(".menu .subtop:last").html())
			num = i;
	});
	for(i=0;i<=num;i++)
		block[i] = 0;

	$(".menu .subtop").hover(
		function (){
			var pos = 0;
			var htm = $(this).html();
			$(".menu .subtop").each(function(i,html) {
				if($(this).html() == htm)
					pos = i;
			});
			if(!block[pos])	{
				block[pos] = 1;
				$(this).find("ul").show("normal");
			}
			return false;
		},
		function (){
			var pos = 0;
			var htm = $(this).html();
			$(".menu .subtop").each(function(i,html) {
				if($(this).html() == htm)
					pos = i;
			});

			if(block[pos])	{
				$(this).find("ul").hide("normal",function(){block[pos] = 0});
			}
			return false;
		}
	);
	$(".menu .subtop ul").css("display","none");

	$(".menu td.active ul").hide("fast").show("fast");

	$(".flash-wrapper .fade").each(function(i) {
		if($(this).html() == $(".flash-wrapper .fade:last").html())
			num = i;
	});

	toggleMainEvent(0,num, 1500, 5000);
	return false
});

function toggleMainEvent(cur, num, delay1, delay2)	{
	$(".fade:eq("+cur+")").fadeOut(
		delay1,
		function() {
			if(cur+1 <= num)	{
				next = cur+1;
			} else {
				next = 0
			}
			$(".fade:eq("+ next +")").fadeIn(
				delay1,
				function() {
					setTimeout(
						"toggleMainEvent("+next+", "+num+", "+delay1+", "+delay2+")", delay2
					); return false;
				}
			); return false;
		}
	); return false;
}
