$(document).ready(function()
{	
	$('#header .nav .menu .has_sub').hover(function()
	{
		var bgcolor=$(this).attr('bgcolor');
		
		$(this).attr('style','background-color: '+bgcolor);
		$(this).addClass('show_sub');
		$(this).children('img[@name=split]').attr('src','/images/web/nav_split_2.png');
		$(this).children('.sub_menu').css('display','block');
		$(this).children('a[@name=nav_link]').attr('style','background:'+bgcolor+'; color: #FFFFFF; text-decoration:none');
	},
	function()
	{
		$(this).attr('style','background-color: #FFFFFF');
		$(this).removeClass('show_sub');
		$(this).children('img[@name=split]').attr('src','/images/web/nav_split_1.png');
		$(this).children('.sub_menu').css('display','none');
		$(this).children('a[@name=nav_link]').attr('style','');
	});
	
	$('#body .icon_menu a[@name=n_expand_menu]').click(function()
	{
		$('#body .icon_menu').hide();
		$('#body .expand_menu').show();
		
		$('#body .extend').each(function(i)
		{
			var width=$(this).width();
			$(this).css('width',width-120);
		});
		
		$.cookie('7looks_cookie_menu_style',null);
	});
	
	$('#body .expand_menu a[@name=n_shrink_menu]').click(function()
	{
		$('#body .expand_menu').hide();
		$('#body .icon_menu').show();
		
		$('#body .extend').each(function(i)
		{
			var width=$(this).width();
			$(this).css('width',width+120);
		});
		
		$.cookie('7looks_cookie_menu_style','icon');
	});
	
});

var disable=function(id)
{
	$(id).attr('disabled','disabled');
}

var enable=function(id)
{
	$(id).attr('disabled','');
}

var formSubmit=function(form_id,url,timeout)
{
	var options={

			type: "POST",
				
			url: _web_path+"passport/postLogin",
				
			dataType: 'json',
				
			timeout: 0,

			beforeSend: function()
			{
				disable('#s_submit');
				
				$('#s_submit_msg').empty();
				$('#body .passport_login').block(_ajaxWaiting,_ajaxWaitingStyle);
			},

			error: function(request, settings)
			{
				$('#s_submit_msg').attr('class','failed');
				$('#s_submit_msg').html(_ajaxError);
				
				$('#body .passport_login').unblock();
			},
				
			success: function(msg)
			{
				if(msg.status!=1)
				{
					$('#'+msg.component+'_msg').attr('class','failed');
					$('#'+msg.component+'_msg').html(msg.message);

					$('#'+msg.component).focus();

					$('#random_image').attr('src',_web_path+'passport/getLoginRandomImage/?t='+Math.random());
					
					$('#body .passport_login').unblock();
					
					enable('#s_submit');
				}
				else
				{
					if(msg.f!='')
					{
						self.location.href=msg.f;
					}
					else
					{
						self.location.href=_web_path;
					}
				}
			}
		};

		$(this).ajaxSubmit(options);
		
		return false;
}

