	// Initial error counter required for proper e-mail validation
	var currentErrorCount = 0;
	
	//Function getFormName returns the name of the current form being validated. Tracked as eVar23 
	function getFormName(currentForm){
		return currentForm.name || currentForm.id || currentForm.parentNode.name || currentForm.parentNode.id || currentForm.parentNode.className || "Form Not Named";
	}
	
	//Checks for any fields related to the requested field name and returns the value, e.g. searching for "name" would get the values for both First Name and Last Name
	function getFieldValue(currentForm, reqField){
		var fieldValue = "";
		var elem = $(currentForm).serializeArray();
		for (var i = 0; i < elem.length; i++){
			if ((elem[i].name.toLowerCase().indexOf(reqField) >= 0) && (elem[i].value != "")){
				fieldValue += elem[i].value + " ";
			}
		}
		if (fieldValue != ""){ return fieldValue; }
	}
	
	// Custom E-Mail Validation
	jQuery.validator.emailValidate = function(value, element) {
		if (this.optional(element)) {
			return this.optional(element);
		}
		if (/^[^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*@(\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([a-z\-0-9]+\.)+[a-z]{2,})$/i.test(value)) {
			if (typeof s !== 'undefined' && s.prop5 !== value){
				// prop5/eVar5 = E-mail Address
				s.prop5 = value;
				s.eVar5 = value;
				s.eVar23 = getFormName(this.currentForm);
				s.TrackingFunctions.SetTrackingTimeout(1000);	// Use a timeout to avoid sending multiple requests as the user types
			}
			return true;
		} else { 
			return false;
		}
	}
	
	jQuery.validator.addMethod("emailcustom", jQuery.validator.emailValidate, "Please enter a valid email address.");
		
	$(document).ready(function(){
        $(".MegaMenuLink").megamenu(".MegaMenuContent");
        $(".MegaMenuLinkR").megamenuR(".MegaMenuContentR", {
            justify: "right"
        });
	});	

// OAS SETUP begin
OAS_url = 'http://oasc17.247realmedia.com/RealMedia/ads/';
OAS_sitepage = 'DailyFX.com/';
OAS_listpos = 'x09,x10,x40,x41,x42,x70';
OAS_query = '';
OAS_target = '_top';
//end of configuration
OAS_version = 10;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String (Math.random()); OAS_rns = OAS_rn.substring (2, 11);
function OAS_NORMAL(pos) {
	document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" TARGET=' + OAS_target + '>');
	document.write('<IMG SRC="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" BORDER=0></A>');
}

OAS_version = 11;
if ((navigator.userAgent.indexOf('Mozilla/3') != -1) || (navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1))
	OAS_version = 10;
if (OAS_version >= 11)
	document.write('<SCR' + 'IPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/SCRIPT>');

document.write('');
function OAS_AD(pos) {
	//alert( pos );
	if (OAS_version >= 11)
		OAS_RICH(pos);
	else
		OAS_NORMAL(pos);
}
//OAS SETUP end

$(document).ready(function(){
	// Table Alternate Rows
	$("table.striped tbody tr:nth-child(odd)").addClass("odd");
	$("table.striped tbody tr:nth-child(even)").addClass("even");
	
	// Tabs
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
	
		var activeTab = $(this).find("a").attr("id"); //Find the href attribute value to identify the active tab + content
		if ($.browser.msie)
		{$(activeTab).show();}
		else
		{$(activeTab).fadeIn();}
		return false;
	});
	
	// Forex Stream
	$.fn.extend({
		linkUrl: function() {
			var returning = [];
			var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
			this.each(function() {
				returning.push(this.replace(regexp,'<a class=\"textlink\" target=\"_blank\" href=\"$1\">$1</a>'));
			});
			return $(returning);
		},
		linkUser: function() {
			var returning = [];
			var regexp = /^[\@]+([A-Za-z0-9-_]+)/gi;
			this.each(function() {
				returning.push(this.replace(regexp,'<a class=\"textlink" target=\"_blank\" href=\"http://twitter.com/$1/">@$1</a>'));
			});
			return $(returning);
		}
	});
	
	var url = 'http://www.dailyfx/f/not_found';
	var count = 6;
	var author = 'DailyFXTeam';
	var options2 = {
		newsList: "ul#news",
		tickerRate: 20,
		startDelay: 10,
		loopDelay: 4999,
		controls: false,
		ownControls: false,
		stopOnHover: true
	}
	$().newsTicker(options2);
	/*
	$.getJSON(url+'?count='+count+'&author='+author+'&callback=?', function(data) {
		$.each(data, function(i,item) {
			var text = $([item.text]).linkUrl().linkUser()[0];
			//var  = $([item.text]).linkUrl().linkUser()[0];
			$('<li>'+text+'</li>').appendTo('ul#news');
		});
		
		$().newsTicker(options2);
		
	});
	*/
});

function doClear(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = ""
	}
}

//lpUnit should be defined on all pages before the JS include. This variable defines the Line of Businsess
if (typeof(lpUnit)=='undefined')
var lpUnit='dailyfx';
