//var browser		= navigator.appName
//var ver			= navigator.appVersion
//var thestart	= parseFloat(ver.indexOf("MSIE"))+1 //This finds the start of the MS version string.
//var brow_ver	= parseFloat(ver.substring(thestart+4,thestart+7)) //This cuts out the bit of string we need.

//if ((browser=="Microsoft Internet Explorer") && (brow_ver < 7)) //By default the min. IE ver is set to 6. Change as desired.
//	{
//	window.location="browsersupport.aspx"; //URL to redirect to.
//	}

function handleEnter (event, obj) 
{       
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        
    if (keyCode == 13)
    { 
        var element = document.getElementById(obj);
        element.click();

        return false;
    }
    else
        return true;	        
}  

// JavaScript Document
function HideFeatures3 (x)
{
	var CurrentFeature;
	var Features;

	Features           = document.getElementById(x);
	
	var IndivFeatures = Features.getElementsByTagName('div');
	
	//loop through the child "div" tags of the MainFeatures div.
	//          This will hide all of the Features.
	for (var i = 0; i < IndivFeatures.length; i++)
	{           
		CurrentFeature = IndivFeatures[i].id; 
		//if the element isn't "" or Undefined, update the div by calling the change function...
		try
		{
			if (CurrentFeature != "" && CurrentFeature.toLowerCase() != 'undefined')
			{
				NewFeatureStyle = change(CurrentFeature, 'hide')
			}
		}
		catch(ex)
		{;}
	}
}

function navOut(elem, action)

{

    var t=setTimeout("change('" + elem + "', '" + action + "')",2000)

}


function change(elem, action) 
{
    
	if (action == 'hide')
		document.getElementById(elem).style.display = 'none';
	else if (action == 'show')
		{document.getElementById(elem).style.display = 'block';}

}

function clearAcctReq() {
	document.getElementById('acc1on').style.display = 'none';
	document.getElementById('acc1off').style.display = 'none';
	document.getElementById('acc2on').style.display = 'none';
	document.getElementById('acc2off').style.display = 'none';
}

function HideFeatures ()
{
	var CurrentFeature;
	var Features;

	Features           = document.getElementById('mbtMainAdHldr');
	
	var IndivFeatures = Features.getElementsByTagName('div');
	
	//loop through the child "div" tags of the MainFeatures div.
	//          This will hide all of the Features.
	for (var i = 0; i < IndivFeatures.length; i++)
	{           
		CurrentFeature = IndivFeatures[i].id; 
		//if the element isn't "" or Undefined, update the div by calling the change function...
		try
		{
			if (CurrentFeature != "" && CurrentFeature.toLowerCase() != 'undefined')
			{
				NewFeatureStyle = change(CurrentFeature, 'hide')
			}
		}
		catch(ex)
		{;}
	}
}

function HideFeatures2 (xx)
{
	var CurrentFeature;
	var Features;

	Features           = document.getElementById(xx);
	
	var IndivFeatures = Features.getElementsByTagName('div');
	
	//loop through the child "div" tags of the MainFeatures div.
	//          This will hide all of the Features.
	for (var i = 0; i < IndivFeatures.length; i++)
	{           
		CurrentFeature = IndivFeatures[i].id; 
		//if the element isn't "" or Undefined, update the div by calling the change function...
		try
		{
			if (CurrentFeature != "" && CurrentFeature.toLowerCase() != 'undefined')
			{
				NewFeatureStyle = change(CurrentFeature, 'hide')
			}
		}
		catch(ex)
		{;}
	}
}


function change(elem, action) 
{
	if (action == 'hide')
		document.getElementById(elem).style.display = 'none';
	else if (action == 'show')
		{document.getElementById(elem).style.display = 'block';}

}


var saveXX;
function dsp(xx, y) {
	if (saveXX) {
		if (xx != saveXX) {
		    if (y != 1)
			    document.getElementById(saveXX).style.display = "none";	
		    else {
                //nothing	        
		    }
		}
	}
	saveXX = xx;
	var xy = document.getElementById(xx).style.display;
	document.getElementById(xx).style.display = (xy != "block") ? "block" : "none";
}

function ea() {
	var divs = document.getElementsByTagName('div')
	for( var i = 0; i < divs.length; i++ ) {
		var sid = divs[i].getAttribute('id')
		if( sid && sid.length > 2 ) {
			if( sid.substr(0, 2) == 'dd') {
				document.getElementById(sid).style.display = 'block'
			}
		}
	}
}
function ca() {
	var divs = document.getElementsByTagName('div')
	for( var i = 0; i < divs.length; i++ ) {
		var sid = divs[i].getAttribute('id')
		if( sid && sid.length > 2 ) {
			if( sid.substr(0, 2) == 'dd') {
				document.getElementById(sid).style.display = 'none'
			}
		}
	}
}



bidElems = new Array();
askElems = new Array();
function storeQuotesValue() {
    divElems = new Array();
    divElems = document.getElementsByTagName("div");
    j = 0, k = 0;
    for(i=0; i<divElems.length; i++) {
        if(divElems[i].id.search("bidElem") != -1) {
            bidElems[j] = divElems[i].innerHTML;
            j++;
        }
        else if(divElems[i].id.search("askElem") != -1) {
            askElems[k] = divElems[i].innerHTML;
            k++;
        }
    }
}

function switchColor() {
    divElems = new Array();
    divElems = document.getElementsByTagName("div");
    j = 0, k = 0;
    for(i=0; i<divElems.length; i++) {
        if(divElems[i].id.search("bidElem") != -1) {
            if(bidElems[j] != divElems[i].innerHTML) {
                bidElems[j] = divElems[i].innerHTML;
                divElems[i].style.backgroundColor = "#6699bb";
                if (j % 2 == 0) {
                    setTimeout("quoteRevertColor('bidElem" + j +"', 2)", 800);
                }
                else {
                    setTimeout("quoteRevertColor('bidElem" + j +"', 1)", 800);
                }  
            }
            j++;
        }
        else if(divElems[i].id.search("askElem") != -1) {
            if(askElems[k] != divElems[i].innerHTML) {
                askElems[k] = divElems[i].innerHTML;
                divElems[i].style.backgroundColor = "#6699bb";
                if (k % 2 == 0) {
                    setTimeout("quoteRevertColor('askElem" + k +"', 2)", 800);
                }
                else {
                    setTimeout("quoteRevertColor('askElem" + k +"', 1)", 800);
                }  
            }
            k++;
        }
    }
}

function quoteSwitchColor() {
    switchColor();
    setTimeout("quoteSwitchColor()", 500);
}

function quoteRevertColor(elemId, type) {
    if(type == 1) {
        document.getElementById(elemId).style.backgroundColor = "#003366";
    }
    else if(type == 2) {
        document.getElementById(elemId).style.backgroundColor = "#336699";
    }

}

function tryLogin(loginPath, loginForm, username, password) {
	var ers = 0
	if (username.length < 4) {
		ers = 1
	}
	if (password.length < 4) {
		ers = 1
	}
	if (ers == 1) {
		return false
	}
	/*if ( loginPath.length < 2 ) {
		document.fl.action = 'https://www.mbtrading.com/secure/scripts/x_login.asp'
		} else {
				document.fl.action = loginPath + 'scripts/x_login.asp'
		}*/
	loginForm.submit()
	return true
}

function showBlock() {
	

	function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
	var pair = vars[i].split("=");
	if (pair[0] == variable) {
	return pair[1];
	}
	}
	alert('Query Variable ' + variable + ' not found');
	} 
	
	var dPage = getQueryVariable("page")
	//alert(dPage);
	
	//HideFeatures3('featureList')
	//if (dPage = 2) {
	//	document.getElementById('list2').style.display = 'block';
	//}
	//else (dPage = 4) {
	//	document.getElementById('list5').style.display = 'block';
	//}
}
function popWin(xx) {
var nw = window.open(xx,'disc','resizable,width=650,height=200,scrollbars,menubar')
nw.focus()
}

function popWin2(xx) {
var nw = window.open(xx,'disc','resizable,width=450,height=500,scrollbars,menubar')
nw.focus()
}

function popWin3(xx, w, h) {
var nw = window.open(xx,'disc','resizable,width=' + w + ',height=' + h + ',scrollbars,menubar')
nw.focus()
}

function showSearch(x,layerName) {
	if (x == 'hide')
		document.getElementById(layerName).style.visibility = 'hidden';
	else if (x == 'show')
		{document.getElementById(layerName).style.visibility = 'visible';}
    
}