$(document).ready(function() {
	// when mouseover the 6 big icons
	$('#ddmt dl').hover(function(){
		//if (g_params['browser']=='ie6')
		//$('select', '.s-main-2-art').css('display', 'none');
		$('dd', this).css('display', 'block');
	},function(){
		$('dd', this).css('display', 'none')
		//if (g_params['browser']=='ie6')
		//$('select', '.s-main-2-art').css('display', 'block');
	});

	// hover & click on the dd
	$('#ddmt dd').hover(function(){
		$(this).css('background', '#FCF3EA');
	},function(){
		$(this).css('background', '#EFE7D3');
	});

	// when click on on of the 6 main images
	var cur_id, my_menu;
	$('#ddmt dt').mouseover(function(){
		$('#ddmt > dd').css('display', 'none')
		$('dd', $(this).parent()).css('display', 'block');
	});

	// side menu
	$('.s-men-side > div[@class^=s-men-side-lev], .s-men-album > div[@class^=s-men-album-lev]').each(function(){
		if ($(this).attr('status')=='ac'){
			$(this).css('background', '#EBAD65');
			$(this).css('border-bottom', '1px solid #fff');
			$(this).prev().css('border-bottom', '1px solid #fff');
			$('a', this).css('color', '#fff');
		}
		if ($(this).attr('status')=='dy')
		$(this).css('background', '');
	});
	$('.s-men-side > div[@class^=s-men-side-lev], .s-men-album > div[@class^=s-men-album-lev]').hover(function(){
		if ($(this).attr('status')!='ac')
		$(this).css('background', '#EBF3F6');
	}, function(){
		if ($(this).attr('status')!='ac')
		$(this).css('background', '');
	});

	// hover & click on the dd
	$('#shipment').click(function(){
		var number = $.trim($('#shipment_number').val());
		var error = $('.s-ship-box-error', $(this).parent().parent());
		error.hide();
		if(number)
		window.open('http://www.fedex.com/Tracking?ascend_header=1&clienttype=dotcomreg&cntry_code=au&language=english&tracknumbers='+number, 'fedex', '');
		else{
			error.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow', function() {error.hide();});
		}
	});

	// hover & click on the dd
	$('#join_newsletter').click(function(){
		var email = $.trim($('#newsletter_email').val());
		var error = $('.s-ship-box-error', $(this).parent().parent());
		error.hide();
		if(email && validEmail(email)){
			$('#newsletter_form').submit();
			var data =$("input[@type=text], input[@type=hidden]", '#newsletter_form').serialize();
			$.post('/newsletter/Members/', data, function(msg){
				error.html(msg);
				error.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow', function() {error.hide();});
			});
		}
		else{
			error.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow', function() {error.hide();});
		}
	});
	
	// hover & click on the dd
	$('#login_submit, #forgot_submit').click(function(){
		var type = ($(this).attr('id')=="login_submit" ? 1 : 0);
		if(type){
			var email = $.trim($('#msUser').val());
			var pwd = $.trim($('#msPwd').val());
		}
		else{
			var email = $.trim($('#msPwd').val());
			var pwd = 1;
		}
		
		var error = $('.s-member-box-error');
		error.html('');
		error.hide();
		if(email && pwd){
			if(validEmail(email)){
				$('#member_act').val((type ? 'login' : 'forgot')+'_send');
				var data =$("input[@type=text], input[@type=password], input[@type=hidden]", '#member_form').serialize();
				$.post($('#member_form').attr('action'), data, function(msg){
					if(msg){
						error.html(msg);
						error.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow', function() {error.hide();});
					}
					else{
						window.location = $('#member_form').attr('action');
						return;
					}
						
				});
			}
			else{
				error.html(members_error["invalid_email"]);
			}
		}
		else{
			error.html(members_error["miss_input"]);
		}
		// show mwssage for 5 seconds and hide it
		if(error.html())
			error.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow', function() {error.hide();});

		return false;
	});
	
	
	$('.s-member-box-title').click(function(){
		if($('.s-member-box-form').css('display')=='none')
			$('.s-member-box-form').show('slow');
		else
			$('.s-member-box-form').hide('slow');
	});
});