//// mli added
var v_exposure_info, v_exposure_ticker, v_exposure_name, v_exposure_data
var v_exposure_min, v_exposure_max;
var b_down  = true;
var customarray = new Array();
var codemarray  = new Array();
function getSelID(ticker)
{
  for (var i=0; i< customarray.length; i++)
  {
     if (customarray[i].indexOf(ticker+",")>=0)
       return codemarray[i]; 
  }
  return -1;
}
function getKeyChart(code)
{
    var chart="A";
	switch (code)
	{
		case 97:
			chart = "A";
			break;
		case 98:
			chart = "B";
			break;
		case 99:
			chart = "C";
			break;
		case 100:
			chart = "D";
			break;
		case 101:
			chart = "E";
			break;
		case 102:
			chart = "F";
			break;
		case 103:
			chart = "G";
			break;
		case 104:
			chart = "H";
			break;
		case 105:
			chart = "I";
			break;
		case 106:
			chart = "J";
			break;
		case 107:
			chart = "K";
			break;
		case 108:
			chart = "L";
			break;
		case 109:
			chart = "M";
			break;
		case 110:
			chart = "N";
			break;
		case 111:
			chart = "O";
			break;
		case 112:
			chart = "P";
			break;
		case 113:
			chart = "Q";
			break;
		case 114:
			chart = "R";
			break;
		case 115:
			chart = "S";
			break;
		case 116:
			chart = "T";
			break;
		case 117:
			chart = "U";
			break;
		case 118:
			chart = "V";
			break;
		case 119:
			chart = "W";
			break;
		case 120:
			chart = "X";
			break;
		case 121:
			chart = "Y";
			break;
		case 122:
			chart = "Z";
			break;		
			
		default:
			chart = "";
			break;
	 }
	return chart;

}
function change_drop_Up(v)
{
    if (v.value != "" && v.value.length == 1)
   	  load_name_list(v.value)
}
function setDrop_Down()
{
  	actb(document.getElementById('tb'),customarray);
}
function load_name_list(v)
{
	var  xmlhttp = getXMLHTTP();/// in common.js
	var url ="all_stock_name_list.aspx?text=" + v+ "&r="+Math.random();
	xmlhttp.onreadystatechange = function() { processName_list_Data(xmlhttp); }; 
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}
function processName_list_Data(xmlhttp)
{
    try{
		if(xmlhttp.readyState == 4)
		{
			if(xmlhttp.status == 200)
			{	
				try{
		 			var tmp       = xmlhttp.responseText; 
		 			if (tmp == "#" )
		 			   return;
		 		    var temp      = tmp.split('#');
		 		    customarray   = new Array();
                    codemarray    = new Array();
		 			customarray   = temp[0].split('|');
		 			codemarray    = temp[1].split('|');
		 		    var t=setTimeout("setDrop_Down()",100);  
			 				 		
				}catch(ex)
				{
						alert(ex + "in processCriteria_Data");
				}
			}
		}
	  }
	 catch(ex)
	 {
		alert(ex + " in processCriteria_Data End");
	 }
}

function getETF_Weightings(sticker)
{

    var  xmlhttp = getXMLHTTP();/// in common.js
	var url ="getETF_Weightings.aspx?ticker=" + sticker+ "&r="+Math.random();
	xmlhttp.onreadystatechange = function() { processETF_Weighting(xmlhttp, sticker); }; 
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}
function processETF_Weighting(xmlhttp, sticker)
{
    try{
		if(xmlhttp.readyState == 4)
		{
			if(xmlhttp.status == 200)
			{	
				try{
		 			var tmp       = xmlhttp.responseText; 
	  	 			if (tmp == "")
		 			{	
		 			    $("#exposure1").hide();
		 			   
		 			   //$("#etf_not_found").html("We could not find the security <b>"+v_exposure_ticker+"</b>")
						// message
						$("#exp_msg_title").html('<span class="alert_msg">We could not find the security '+sticker+'</span>')
						$("#exp_msg_title, #exp_msg").fadeIn();
						
						$.timer(2000, function (timer) {
						$("#exp_msg").fadeOut("" );
					 
						timer.stop();
						}); 
					  //message end				 			   
		 			   return;
		 			} 
		 			if ( Change_Exposure(sticker) != "")
		 			  return;
					v_stock_exposure[v_stock_exposure.length] = {name:"% Exposure to "+ sticker, ticker:sticker,  sort:-1};
					resetResults_Data()   
		 		}catch(ex)
				{
						alert(ex + "in processETF_Weighting");
				}
			}
		}
	  }
	 catch(ex)
	 {
		alert(ex + " in processETF_Weighting End");
	 }
}

function get_ETF_Leverage()
{
	var  xmlhttp = getXMLHTTP();/// in common.js
	var url ="etf_data/ETF_Leverage.txt";
	xmlhttp.onreadystatechange = function() { processETF_Leverage_Data(xmlhttp); }; 
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}
function processETF_Leverage_Data(xmlhttp)
{
    try{
		if(xmlhttp.readyState == 4)
		{
			if(xmlhttp.status == 200)
			{	
				try{
		 			v_ETF_Leverage      = xmlhttp.responseText; 
				}catch(ex)
				{
						alert(ex + "in processCriteria_Data");
				}
			}
		}
	  }
	 catch(ex)
	 {
		alert(ex + " in processCriteria_Data End");
	 }
}
function load_ETF_Leverage()
{
	var  xmlhttp = getXMLHTTP();/// in common.js
	var url ="getETF_Leverage.aspx?r="+Math.random();
	xmlhttp.onreadystatechange = function() { processETF_Leverage(xmlhttp); }; 
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}
function processETF_Leverage(xmlhttp)
{
    try{
		if(xmlhttp.readyState == 4)
		{
			if(xmlhttp.status == 200)
			{	
				try{
		 			v_ETF_Leverage      = xmlhttp.responseText; 
		 			//alert(v_ETF_Leverage)
				}catch(ex)
				{
						alert(ex + "in processCriteria_Data");
				}
			}
		}
	  }
	 catch(ex)
	 {
		alert(ex + " in processCriteria_Data End");
	 }
}

function load_Stock_SelID(ticker)
{
	var  xmlhttp = getXMLHTTP();/// in common.js
	var url ="getStock_SelID.aspx?ticker=" + ticker+ "&r="+Math.random();
	xmlhttp.onreadystatechange = function() { processStock_SelID(xmlhttp); }; 
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}
function processStock_SelID(xmlhttp)
{
    try{
		if(xmlhttp.readyState == 4)
		{
			if(xmlhttp.status == 200)
			{	
				try{
		 			var selId       = xmlhttp.responseText; 
		 			if (selId == "" )
		 			{	
		 				$("#exposure1").hide();
		 			     //alert(v_exposure_ticker +" does not have % exposure of ETFs")
		 			   $("#etf_not_found").html("We could not find the security. <b>"+v_exposure_ticker+"</b>")
		 			    return;
		 			}else
		 			    load_ETF_Weighting(selId)
				}catch(ex)
				{
						alert(ex + "in processCriteria_Data");
				}
			}
		}
	  }
	 catch(ex)
	 {
		alert(ex + " in processCriteria_Data End");
	 }
}
 //change backimage
 //var url ="sub_charts.aspx?data="+v_criteria[i].info +"&total=" +v_data.length;
//	    changeBackground_1(url, v_criteria[i].ColumnName) 
