// JavaScript Document
$(document).ready(function() {
	
	/* banner */
	$('#banner .banners .tabhead').click(
		function(e) {
			$('#banner .banners .tabbody:visible').fadeOut('slow');
			$(this).next('.tabbody').fadeIn('slow');
			e.preventDefault();
		}
	);
	$('#banner > .tabhead').click(
		function(e) {
			$('#banner .banners .tabbody:visible').fadeOut('slow');
			$('#banner .banners .tabbody.default').fadeIn('slow');
			e.preventDefault();
		}
	);
	
	/* quotes */
	$('#quotes .subtabhead').hover(
		function() {
			$('#quotes .subtabhead.tabactive').removeClass('tabactive');
			$(this).addClass('tabactive');
		},
		function() {
			$(this).removeClass('tabactive');
		}
	);
	$('#quotes .subtabhead').click(
		function(e) {
			$('#quotes .subtabhead.default').removeClass('default');
			$('#quotes .tabbody.active').removeClass('active');
			if (this.id == "headlivequotes") {
				$('#headlivequotes').addClass('default');
				$('#tablivequotes').addClass('active');
			} else {
				$('#headchart').addClass('default');
				$('#tabchart').addClass('active');
			}
			e.preventDefault();
		}
	);
	$('#headlivequotes').click(
		function(e) {
			getQuotes();
			e.preventDefault();
		}
	);
	if ($('#quotes').length > 0) {
		getQuotes();
		setInterval("getQuotes()", 500000); 
	}

	/* dailynewsletter */
	var email_text = "Enter email address...";
	$('#client_email').focus(
		function() {
			if ($(this).val() == email_text) $(this).val("");
			$(this).css('color', "#000000");
		}
	).blur(
		function() {
			if ($(this).val() == "") $(this).val(email_text);
			$(this).css('color', "#999999");
		}
	);
});

function getQuotes() {
	$.getScript('http://www.mifx.com/quotes.php');
}

function setval(type, arrayval) {
	$('#quotes_' + type + '_img').attr('src', baseurl + 'images/' + arrayval[0] + '.gif');
	$('#quotes_' + type + '_bid').text(arrayval[2]);
	$('#quotes_' + type + '_ask').text(arrayval[3]);
}

function setdate(val) {
	$('#quotes_date').text("record date " + val + " GMT+2");
}
