timer = null;
w_timer = null;

function logout()
{
	$.fn.colorbox({
		href: 'templates/default/content/logout.html',
		onClosed: function(){
			window.clearInterval(w_timer);
			timer = setTimeout('logout();', logout_seconds*1000);
		},
		onComplete: function(){
			$.fn.colorbox.resize();
		}
	});
}

function cleartime()
{
	if (timer != null)
	{
		for (var i = 0; i <= timer; i++)
			clearTimeout(i);
	}
}

$(document).ready(function(){
	if ($("#menu_h").size() > 0)
	{
		ddsmoothmenu.init({
			mainmenuid : 'menu_h',
			orientation : 'h',
			classname : 'ddsmoothmenu',
			contentsource: "markup"
		});
	}

	if ($("#menu_v").size() > 0)
	{
		ddsmoothmenu.init({
			mainmenuid : 'menu_v',
			orientation : 'v',
			classname : 'ddsmoothmenu-v',
			contentsource: "markup"
		});
	}

	$("a.video").flowplayer('flowplayer/flowplayer-3.2.5.swf', {clip: {autoPlay: false}});

	//$("input, textarea, select, button").uniform();
	$("input, textarea").focus(function(){
		$(this).parent().addClass("curFocus")
	});
	$("input, textarea").blur(function(){
		$(this).parent().removeClass("curFocus")
	});

	//Logout functional
	$.fn.colorbox.settings.onClosed = function(){
		cleartime();
		timer = setTimeout('logout();', logout_seconds*1000);
	};

	$(document).ajaxStart(function(){
		cleartime();
	})

	$(document).ajaxSend(function(event, request, settings){
		if (!settings.url.match(/members_logout.(html|php)$/i))
			timer = setTimeout('logout();', logout_seconds*1000);
	})

	if (!is_cookie && is_logged) //Start time
	{
		timer = setTimeout('logout();', logout_seconds*1000);
	}
});
