$(document).ready(function() {

	//nav	
	var $enter = 0;

	$("ul#navigation li.mainnav").mouseenter(function() { 
	
	if ($enter == 0){
//		$(this).find("div").slideDown(250);
		$(this).find("div").show();
		$enter += 1;
		
	} else {
		$("ul#navigation li div").hide();
		$(this).find("div").show();
		}
	});
	
	$("ul#navigation").mouseleave(function() {
//		$("ul#navigation li div").slideUp(150);
		$("ul#navigation li div").hide();
		$enter = 0;
	});

	//change Region
	$("#changeregion").hover(function() { 
		$(this).find("ul").slideDown(150); 
	} , function() {
		$(this).find('ul').slideUp(200);
	});  
	
	$("#changelanguage").hover(function() { 
		$(this).find("ul").slideDown(150); 
	} , function() { 
		$(this).find("ul").slideUp(200); 
	});  
	
	//trading account
	var $hidetable = $(".hidedetails");
	$hidetable.hide();

   	$("#productexpand").toggle(function (){
		$hidetable.slideToggle(100)
		$("#productexpand").html("<i></i>Hide account details")
		$("#productexpand i").css("background-position", "0px -7px")
		.stop();
	}, function(){
		$hidetable.slideToggle(100)
		$("#productexpand i").css("background-position", "0px 6px")
		$("#productexpand").html("<i></i>Expand for more account details")
		.stop();
	});
	
	//FAQ
	jQuery('.answer').hide();
	jQuery('.hide').hide();

	jQuery('.show').click(function() {
	  jQuery('#faq > li').each(function() {
			jQuery(this).children('.answer').slideUp('slow');
			jQuery(this).children('.hide').fadeOut('slow');
			jQuery(this).children('.show').fadeIn('slow');
		});
		if (jQuery(this).css('display') != "none") {
			jQuery(this).parent().children('.answer').slideDown('slow');
			jQuery(this).parent().children('.show').fadeOut('slow');
			jQuery(this).parent().children('.hide').fadeIn('slow');
		} else {
			jQuery(this).parent().children('.answer').slideUp('slow');
			jQuery(this).parent().children('.hide').fadeOut('slow');
			jQuery(this).parent().children('.show').fadeIn('slow');
		}

		return false;
	});

	jQuery('.hide').click(function() {
		jQuery(this).parent().children('.answer').slideUp('slow');
		jQuery(this).parent().children('.hide').fadeOut('slow');
		jQuery(this).parent().children('.show').fadeIn('slow');
		return false;
	});


	// Showing different tabs and their content on click.  ACCOUNT TABS
	$('.depositfundstab h2').click(function() {
		var tabNo = 0;
		var thisHdr = this;
		$('.depositfundstab h2').each(function() {
			$('#tab' + tabNo).css('display', 'none');
			$(this).parent().attr('class', $(this).parent().attr('class').replace(/On/, 'Off'));
			if ($(thisHdr).hasClass('hdrTab' + tabNo)) {
				$('#tab' + tabNo).css('display', 'block');
				$(thisHdr).parent().attr('class', $(this).parent().attr('class').replace(/Off/, 'On'));
			}
			tabNo++;
		});
	});

});  
