/*
Author: per.johnsson@omxgroup.com / per.jonsson@it-huset.se
Version: $Id: StaticMarketDataJavascript.js,v 1.11 2008/05/28 08:44:36 PEJN Exp $
*/
var array = new Array (
        [ "Consumer Discretionary", "25",
          [ "Automobiles & Components", "2510",
           [ "Auto Components", "251010",
           [ "Auto Parts & Equipment", "25101010" ] ,
           [ "Tires & Rubber", "25101020" ] 
           ] ,
           [ "Automobiles", "251020",
           [ "Automobile Manufacturers", "25102010" ] ,
           [ "Motorcycle Manufacturers", "25102020" ] 
           ]  
        ] ,
          [ "Consumer Durables & Apparel", "2520",
           [ "Household Durables", "252010",
           [ "Consumer Electronics", "25201010" ] ,
           [ "Home Furnishings", "25201020" ] ,
           [ "Homebuilding", "25201030" ] ,
           [ "Household Appliances", "25201040" ] ,
           [ "Housewares & Specialties", "25201050" ] 
           ] ,
           [ "Leisure Equipment & Products", "252020",
           [ "Leisure Products", "25202010" ] ,
           [ "Photographic Products", "25202020" ] 
           ] ,
           [ "Textiles, Apparel & Luxury Goods", "252030",
           [ "Apparel, Accessories & Luxury Goods", "25203010" ] ,
           [ "Footwear", "25203020" ] ,
           [ "Textiles", "25203030" ] 
           ]  
        ] ,
          [ "Consumer Services", "2530",
           [ "Diversified Consumer Services", "253020",
           [ "Education Services", "25302010" ] ,
           [ "Specialized Consumer Services", "25302020" ] 
           ] ,
           [ "Hotels Restaurants & Leisure", "253010",
           [ "Casinos & Gaming", "25301010" ] ,
           [ "Hotels, Resorts & Cruise Lines", "25301020" ] ,
           [ "Leisure Facilities", "25301030" ] ,
           [ "Restaurants", "25301040" ] 
           ]  
        ] ,
          [ "Media", "2540",
           [ "Media", "254010",
           [ "Advertising", "25401010" ] ,
           [ "Broadcasting & Cable TV", "25401020" ] ,
           [ "Movies & Entertainment", "25401030" ] ,
           [ "Publishing", "25401040" ] 
           ]  
        ] ,
          [ "Retailing", "2550",
           [ "Distributors", "255010",
           [ "Distributors", "25501010" ] 
           ] ,
           [ "Internet & Catalog Retail", "255020",
           [ "Catalog Retail", "25502010" ] ,
           [ "Internet Retail", "25502020" ] 
           ] ,
           [ "Multiline Retail", "255030",
           [ "Department Stores", "25503010" ] ,
           [ "General Merchandise Stores", "25503020" ] 
           ] ,
           [ "Specialty Retail", "255040",
           [ "Apparel Retail", "25504010" ] ,
           [ "Automotive Retail", "25504050" ] ,
           [ "Computer & Electronics Retail", "25504020" ] ,
           [ "Home Improvement Retail", "25504030" ] ,
           [ "Homefurnishing Retail", "25504060" ] ,
           [ "Specialty Stores", "25504040" ] 
           ]  
        ]  
      ] ,
        [ "Consumer Staples", "30",
          [ "Food & Staples Retailing", "3010",
           [ "Food & Staples Retailing", "301010",
           [ "Drug Retail", "30101010" ] ,
           [ "Food Distributors", "30101020" ] ,
           [ "Food Retail", "30101030" ] ,
           [ "Hypermarkets & Super Centers", "30101040" ] 
           ]  
        ] ,
          [ "Food Beverage & Tobacco", "3020",
           [ "Beverages", "302010",
           [ "Brewers", "30201010" ] ,
           [ "Distillers & Vintners", "30201020" ] ,
           [ "Soft Drinks", "30201030" ] 
           ] ,
           [ "Food Products", "302020",
           [ "Agricultural Products", "30202010" ] ,
           [ "Meat Poultry & Fish - discontinued 02-03", "30202020" ] ,
           [ "Packaged Foods & Meats", "30202030" ] 
           ] ,
           [ "Tobacco", "302030",
           [ "Tobacco", "30203010" ] 
           ]  
        ] ,
          [ "Household & Personal Products", "3030",
           [ "Household Products", "303010",
           [ "Household Products", "30301010" ] 
           ] ,
           [ "Personal Products", "303020",
           [ "Personal Products", "30302010" ] 
           ]  
        ]  
      ] ,
        [ "Energy", "10",
          [ "Energy", "1010",
           [ "Energy Equipment & Services", "101010",
           [ "Oil & Gas Drilling", "10101010" ] ,
           [ "Oil & Gas Equipment & Services", "10101020" ] 
           ] ,
           [ "Oil, Gas & Consumable Fuels", "101020",
           [ "Coal & Consumable Fuels", "10102050" ] ,
           [ "Integrated Oil & Gas", "10102010" ] ,
           [ "Oil & Gas Exploration & Production", "10102020" ] ,
           [ "Oil & Gas Refining & Marketing", "10102030" ] ,
           [ "Oil & Gas Storgae & Transportation", "10102040" ] 
           ]  
        ]  
      ] ,
        [ "Financials", "40",
          [ "Banks", "4010",
           [ "Commercial Banks", "401010",
           [ "Diversified Banks", "40101010" ] ,
           [ "Regional Banks", "40101015" ] 
           ] ,
           [ "Thrifts & Mortgage Finance", "401020",
           [ "Thrifts & Mortgage Finance", "40102010" ] 
           ]  
        ] ,
          [ "Diversified Financials", "4020",
           [ "Capital Markets", "402030",
           [ "Asset Management & Custody Banks", "40203010" ] ,
           [ "Diversified Capital Markets", "40203030" ] ,
           [ "Investment Banking & Brokerage", "40203020" ] 
           ] ,
           [ "Consumer Finance", "402020",
           [ "Consumer Finance", "40202010" ] 
           ] ,
           [ "Diversified Financial Services", "402010",
           [ "Multi-Sector Holdings", "40201030" ] ,
           [ "Other Diversified Financial Services", "40201020" ] ,
           [ "Specialized Finance", "40201040" ] 
           ]  
        ] ,
          [ "Insurance", "4030",
           [ "Insurance", "403010",
           [ "Insurance Brokers", "40301010" ] ,
           [ "Life & Health Insurance", "40301020" ] ,
           [ "Multi-line Insurance", "40301030" ] ,
           [ "Property & Casualty Insurance", "40301040" ] ,
           [ "Reinsurance", "40301050" ] 
           ]  
        ] ,
          [ "Real Estate", "4040",
           [ "Real Estate", "404010",
           [ "Real Estate Investment Trusts", "40401010" ] ,
           [ "Real Estate Management & Development", "40401020" ] 
           ] ,
           [ "Real Estate Investment Trusts (REITs)", "404020",
           [ "Diversified REITs", "40402010" ] ,
           [ "Industrial REITs", "40402020" ] ,
           [ "Mortgage REITs", "40402030" ] ,
           [ "Office REITs", "40402040" ] ,
           [ "Residential REITs", "40402050" ] ,
           [ "Retail REITs", "40402060" ] ,
           [ "Specialized REITs", "40402070" ] 
           ] ,
           [ "Real Estate Management & Development", "404030",
           [ "Real Estate Management & Development", "40403010" ] 
           ]  
        ]  
      ] ,
        [ "Health Care", "35",
          [ "Health Care Equipment & Services", "3510",
           [ "Health Care Equipment & Supplies", "351010",
           [ "Health Care Equipment", "35101010" ] ,
           [ "Health Care Supplies", "35101020" ] 
           ] ,
           [ "Health Care Providers & Services", "351020",
           [ "Health Care Distributors", "35102010" ] ,
           [ "Health Care Facilities", "35102020" ] ,
           [ "Health Care Services", "35102015" ] ,
           [ "Managed Health Care", "35102030" ] 
           ] ,
           [ "Health Care Technology", "351030",
           [ "Health Care Technology", "35103010" ] 
           ]  
        ] ,
          [ "Pharmaceuticals, Biotechnology & Life Sc", "3520",
           [ "Biotechnology", "352010",
           [ "Biotechnology", "35201010" ] 
           ] ,
           [ "Life Science Tools & Services", "352030",
           [ "Life Science Tools & Services", "35203010" ] 
           ] ,
           [ "Pharmaceuticals", "352020",
           [ "Pharmaceuticals", "35202010" ] 
           ]  
        ]  
      ] ,
        [ "Industrials", "20",
          [ "Capital Goods", "2010",
           [ "Aerospace & Defense", "201010",
           [ "Aerospace & Defense", "20101010" ] 
           ] ,
           [ "Building Products", "201020",
           [ "Building Products", "20102010" ] 
           ] ,
           [ "Construction & Engineering", "201030",
           [ "Construction & Engineering", "20103010" ] 
           ] ,
           [ "Electrical Equipment", "201040",
           [ "Electrical Components & Equipment", "20104010" ] ,
           [ "Heavy Electrical Equipment", "20104020" ] 
           ] ,
           [ "Industrial Conglomerates", "201050",
           [ "Industrial Conglomerates", "20105010" ] 
           ] ,
           [ "Machinery", "201060",
           [ "Construction & Farm Machinery&Heavy Truc", "20106010" ] ,
           [ "Industrial Machinery", "20106020" ] 
           ] ,
           [ "Trading Companies & Distributors", "201070",
           [ "Trading Companies & Distributors", "20107010" ] 
           ]  
        ] ,
          [ "Commercial Services & Supplies", "2020",
           [ "Commercial Services & Supplies", "202010",
           [ "Commercial Printing", "20201010" ] ,
           [ "Diversified Commercial & Prof. Services", "20201030" ] ,
           [ "Environmental & Facilities Services", "20201050" ] ,
           [ "Human Resource & Employment Services", "20201040" ] ,
           [ "Office Services & Supplies", "20201060" ] 
           ]  
        ] ,
          [ "Transportation", "2030",
           [ "Air Freight & Logistics", "203010",
           [ "Air Freight & Logistics", "20301010" ] 
           ] ,
           [ "Airlines", "203020",
           [ "Airlines", "20302010" ] 
           ] ,
           [ "Marine", "203030",
           [ "Marine", "20303010" ] 
           ] ,
           [ "Road & Rail", "203040",
           [ "Railroads", "20304010" ] ,
           [ "Trucking", "20304020" ] 
           ] ,
           [ "Transportation Infrastructure", "203050",
           [ "Airport Services", "20305010" ] ,
           [ "Highways & Railtracks", "20305020" ] ,
           [ "Marine Ports & Services", "20305030" ] 
           ]  
        ]  
      ] ,
        [ "Information Technology", "45",
          [ "Semiconductors & Semiconductor Equipment", "4530",
           [ "Semiconductors & Semicond. Equipment", "453010",
           [ "Semiconductor Equipment", "45301010" ] ,
           [ "Semiconductors", "45301020" ] 
           ]  
        ] ,
          [ "Software & Services", "4510",
           [ "IT Services", "451020",
           [ "Data Processing & Outsourced Services", "45102020" ] ,
           [ "IT Consulting &  Other Services", "45102010" ] 
           ] ,
           [ "Internet Software & Services", "451010",
           [ "Internet Software & Services", "45101010" ] 
           ] ,
           [ "Software", "451030",
           [ "Application Software", "45103010" ] ,
           [ "Home Entertainment Software", "45103030" ] ,
           [ "Systems Software", "45103020" ] 
           ]  
        ] ,
          [ "Technology Hardware & Equipment", "4520",
           [ "Communications Equipment", "452010",
           [ "Communications Equipment", "45201020" ] 
           ] ,
           [ "Computers & Peripherals", "452020",
           [ "Computer Hardware", "45202010" ] ,
           [ "Computer Storage & Peripherals", "45202020" ] 
           ] ,
           [ "Electronic Equipment & Instruments", "452030",
           [ "Electronic Equipment Manufacturers", "45203010" ] ,
           [ "Electronic Manufacturing Services", "45203020" ] ,
           [ "Technology Distributors", "45203030" ] 
           ] ,
           [ "Office Electronics", "452040",
           [ "Office Electronics", "45204010" ] 
           ]  
        ]  
      ] ,
        [ "Materials", "15",
          [ "Materials", "1510",
           [ "Chemicals", "151010",
           [ "Commodity Chemicals", "15101010" ] ,
           [ "Diversified Chemicals", "15101020" ] ,
           [ "Fertilizers & Agricultural Chemicals", "15101030" ] ,
           [ "Industrial Gases", "15101040" ] ,
           [ "Specialty Chemicals", "15101050" ] 
           ] ,
           [ "Construction Materials", "151020",
           [ "Construction Materials", "15102010" ] 
           ] ,
           [ "Containers & Packaging", "151030",
           [ "Metal & Glass Containers", "15103010" ] ,
           [ "Paper Packaging", "15103020" ] 
           ] ,
           [ "Metals & Mining", "151040",
           [ "Aluminum", "15104010" ] ,
           [ "Diversified Metals & Mining", "15104020" ] ,
           [ "Gold", "15104030" ] ,
           [ "Precious Metals & Minerals", "15104040" ] ,
           [ "Steel", "15104050" ] 
           ] ,
           [ "Paper & Forest Products", "151050",
           [ "Forest Products", "15105010" ] ,
           [ "Paper Products", "15105020" ] 
           ]  
        ]  
      ] ,
        [ "Telecommunication Services", "50",
          [ "Telecommunication Services", "5010",
           [ "Diversified Telecommunication Services", "501010",
           [ "Alternative Carriers", "50101010" ] ,
           [ "Integrated Telecommunication Services", "50101020" ] 
           ] ,
           [ "Wireless Telecommunication Services", "501020",
           [ "Wireless Telecommunication Services", "50102010" ] 
           ]  
        ]  
      ] ,
        [ "Utilities", "55",
          [ "Utilities", "5510",
           [ "Electric Utilities", "551010",
           [ "Electric Utilities", "55101010" ] 
           ] ,
           [ "Gas Utilities", "551020",
           [ "Gas Utilities", "55102010" ] 
           ] ,
           [ "Independent Power Prod.&Energy Traders", "551050",
           [ "Independent Power Prod.&Energy Traders", "55105010" ] 
           ] ,
           [ "Multi-Utilities", "551030",
           [ "Multi-Utilities", "55103010" ] 
           ] ,
           [ "Water Utilities", "551040",
           [ "Water Utilities", "55104010" ] 
           ]  
        ]  
      ]  );

// END GICS

// Debug start
var debug = false;
var debugWindow = null;

function printDebug( string )
{
  if ( debug == true && debugWindow == null) {
    debugWindow = window.open( "about:blank","Debug",'height=300,width=600,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
  }
  if ( debugWindow != null ) {
       debugWindow.document.write( "\<pre\>" + new Date() + "\n" + string + "\<\/pre\>" );
       debugWindow.focus();
  }
}
// Debug end

var language = 'en';  // maybe not needed

var ARRAY_NAME = 0; // name of link parameter
var ARRAY_DEFAULT = 1;  // default in the selectbox
var ARRAY_LIST = 2;   // position in the array
var POS_NAME = 0;   // name of the item in the list
var POS_ID = 1;   // id in the name of the list
var POS_ARRAY = 2;

// Adds options from an array (ie marketShareArray) to a select object
function addOptionsFromArray( array, targetElement ) {
  if ( array != null && targetElement != null ) {
    targetElement.options.length = 0;
    //targetElement.options[ 0 ] = new Option( "" , "-" );
	targetElement.options[ 0 ] = new Option( choose , "-" );
    for ( var i = 0; i < array.length; i++ ) {
      targetElement.options[ i + 1] = new Option( array[ i ][ POS_NAME ] , array[ i ][ POS_ID ] );
    }
  }
}

var sector = 0;
var group  = 0;
var industry = 0;
var subindustry = 0;
var sectorDone = false;
function populateGics( selectElement, index ) {
     index -= 1; // -1 --> compensate for the ---select--- option
     if ( isNaN( index ) ) {
         index = 0;
     }
     // init sector first time
     if ( sectorDone == false ) {
         var targetElement = document.getElementById( "sectorSelectId" );
         //targetElement.options[ 0 ] = new Option( "" , "-" );
		 targetElement.options[ 0 ] = new Option( choose , "-" );
         for ( var i = 0; i < array.length; i++ ) {
             targetElement.options[ i +1 ] = new Option( array[i][ POS_NAME ] , array[i][ POS_ID ] );
         }
         sectorDone = true;
     }
     
     if ( selectElement != null && selectElement.getAttribute("id") == "sectorSelectId" ) {
         sector = index;
         fillSelect( document.getElementById( "groupSelectId" ), array[ sector ] );
         if ( index < 0 ) {
            document.getElementById( "groupSelectId" ).disabled = true;
            document.getElementById( "groupSelectId" ).options.length = 0;
         } else {
            document.getElementById( "groupSelectId" ).disabled = false;
         }
         document.getElementById( "industrySelectId" ).options.length = 0;
         document.getElementById( "industrySelectId" ).disabled = true;
         document.getElementById( "subindustrySelectId" ).options.length = 0;
         document.getElementById( "subindustrySelectId" ).disabled = true;
     }
     else if ( selectElement != null && selectElement.getAttribute("id") == "groupSelectId" ) {
         group = index;
         fillSelect( document.getElementById( "industrySelectId" ), array[sector][POS_ARRAY + group] );
         if ( index < 0 ) {
           document.getElementById( "industrySelectId" ).disabled = true;
           document.getElementById( "industrySelectId" ).options.length = 0;
         } else {
           document.getElementById( "industrySelectId" ).disabled = false;
         }
         document.getElementById( "subindustrySelectId" ).options.length = 0;
         document.getElementById( "subindustrySelectId" ).disabled = true;
     } else if ( selectElement != null && selectElement.getAttribute("id") == "industrySelectId" ) {
         industry = index;
         fillSelect( document.getElementById( "subindustrySelectId" ), array[sector][POS_ARRAY + group][POS_ARRAY + industry] );
         if ( index < 0 ) {
           document.getElementById( "subindustrySelectId" ).disabled = true;
           document.getElementById( "subindustrySelectId" ).options.length = 0;
         } else {
           document.getElementById( "subindustrySelectId" ).disabled = false;
         }
     }
}

function fillSelect( targetElement, array ) {
     if ( targetElement != null && array != null ) {
         targetElement.options.length = 0;
		 targetElement.options[ 0 ] = new Option( choose , "-" );
         for ( var i = POS_ARRAY; i < array.length; i++ ) {
             targetElement.options[ i - POS_ARRAY + 1] = new Option( array[i][ POS_NAME ] , array[i][ POS_ID ], false, false );
         }
     }
}

// Enables and disables selectboxes from the value in the options.
// must contains at least one valuepair with one enable or disable.
// Args: ( selectElement - the selected element to parse the value of and make the enable/disable)
// Usage:  
// <select onchange="selectEnableDisable( this );" ... >
// <option value="idOfAnotherElement=true,idOfAthirdElement=false" ... >
function selectEnableDisable( selectElement ) {
  if ( selectElement != null ) {
    var value = selectElement[ selectElement.selectedIndex ].value;
    enableDisable( value );
  }
}

// valuestring should be selectid=true,selectid2=false etc..
function enableDisable( values ) {
  if ( values != null ) {
    var valueArray = values.split(",");
    for ( var i = 0; i < valueArray.length; i++ ) {
      if ( valueArray[i] != null && valueArray[i].indexOf("=") != -1 ) {
        var keyValuePair = valueArray[i].split("=");  // elementId = [0], true/false = [1]
        document.getElementById( keyValuePair[0] ).disabled = eval( keyValuePair[1] );
      }
    }
  }
}


function getSelectedOptionValue( selectElement ) {
  var result = null;
  if ( selectElement != null && selectElement.disabled == false && selectElement.selectedIndex >= 0 ) {
    result = selectElement[ selectElement.selectedIndex ].value;
    if ( result == "-" ) {
      result = null;
    }
  }
  return result;
}

// Sets the select to a specified option with an index and runs the onchange event if exists.
function setSelectedOption( selectElementId, index ) {
  if ( selectElementId != null ) {
    var selectElement = document.getElementById( selectElementId );
    if ( selectElement != null ) {
      selectElement.selectedIndex = index;
      if ( selectElement.onchange ) {
        selectElement.onchange();
      }
    }
  }
}

//Sets the selected values from a key/value pair.
// the string should look like: selectId=2,anotherSelectId=4
function setSelectedString( value ) {
	var valueArray = value.split(",");
	for ( var i = 0; i < valueArray.length; i++ ) {
    	var keyValuePair = valueArray[i].split("=");  // elementId = [0], selectedIndex = [1]
        if ( keyValuePair.length > 1 ) {
          setSelectedOption( keyValuePair[0], keyValuePair[1] );
        }
    }
}

// Checks if a form is enabled or disabled.
function isEnabled( formObjectId ) {
  var result = false;
  var formObject = document.getElementById( formObjectId );
  if ( formObject != null ) {
    result != formObject.disabled;
  }
  return result;
}

// A function to get all selected selectboxes and their selectedindex and store in a string.
function getSelectedString( formObject ) {
  var result = "";
  if ( formObject != null ) {
    for ( var i = 0; i < formObject.length; i++ ) {
      if( formObject[ i ].type == "select-one" && formObject[ i ].selectedIndex > 0 ) {
        result += formObject[ i ].id + '=' + formObject[ i ].selectedIndex + ',';
      }
    }
  }
  if ( result.length > 0 ) {
    result = result.substring( 0, result.length -1 );
  }
  return result;
}

// prevent a form to be submited by the enter key, se this like this:
//<input type="text" id="xpsearch" onkeypress="return noEnter( event );" />
function noEnter( event ) {
  return !( event.keyCode == 13);
} 

var lastname = "";	
function displayLongName(fnm,nm) {
	if (fnm != lastname) {
		document.write("<tr><td colspan=9 bgcolor=#ccccc><h3>"+ fnm +"</h3></td></tr>");
		lastname = fnm;
	}
}

// Graph popup javascript, pejn 2007-06-21
// If use the following tag on the page to handle the popup layer
// <div id="showGraphDivId" style="display:none;background:white;width:200px; height:140px; position:absolute;border: 1px; border-style:solid; border-color: black;"><img style="margin-top:62px;margin-left:92px;" id="showGraphImgId" src="" /></div>
var waitingImage = new Image();
waitingImage.src='/static/img/loading.gif';

var graphStartTimer = null;
function startDisplayGraphTimer() {
  clearInterval(graphStartTimer);
  graphStartTimer = setInterval("displayGraph()",500);
}

var graphLinkUrl = null;

function showGraph( event, element, instrument, name, types ) {
  var div = document.getElementById( 'showGraphDivId' );
  var img = document.getElementById( 'showGraphImgId' );

    graphLinkUrl = "http://omxlinkweb.omxgroup.com/OMXLinkProxy/Charting/Graph.aspx?graphwidth=200&graphheight=140&graphbgcolor=FFFFFF&p_plotxgridcolor=E4E4E4&p_plotygridcolor=E4E4E4";
    if ( types.indexOf(",vol,") != -1 ) {
    	graphLinkUrl += "&volumeshow=true";
   	}
   	if ( types.indexOf(",hilo,") != -1 ) {
    	graphLinkUrl += "&highlowshow=true";
   	}
   	if ( types.indexOf(",hilocl,") != -1 ) {
    	graphLinkUrl += "&highlowshowclose=true";
   	}
	if ( types.indexOf(",nopr,") != -1 ) {
    	graphLinkUrl += "&priceshow=false";
   	}
   	
   	// fix to get fixed income to show longer periods
	var icefi = "IS0000010031,IS0000010007,IS0000010015,IS0000011864,IS0000010023";
	if ( instrument.substring( 0,3 ) == 'OMF' || icefi.indexOf( instrument ) != -1 ) { 
      graphLinkUrl += "&period=6month";
      graphLinkUrl += "&timeformat=MMM";
   	} else if ( types.indexOf(",1day,") != -1 ) {
   		graphLinkUrl += "&period=1day";
   	} else if ( types.indexOf(",1week,") != -1 ) {
   		graphLinkUrl += "&period=1week";
   	} else if ( types.indexOf(",1month,") != -1 ) {
   		graphLinkUrl += "&period=1month";
   		graphLinkUrl += "&timeformat=MMdd";
   	} else if ( types.indexOf(",6month,") != -1 ) {
   		graphLinkUrl += "&period=6month";
   		graphLinkUrl += "&timeformat=MMM";
   	} else {
   		graphLinkUrl += "&period=1day";
   	}
   	
    graphLinkUrl += "&headingfont=Trebuchet%20MS";
    graphLinkUrl += "&headingsize=11";
    graphLinkUrl += "&pricefont=Trebuchet%20MS";
    graphLinkUrl += "&pricesize=9";
    graphLinkUrl += "&pricecolor=606060";
    graphLinkUrl += "&timefont=Trebuchet%20MS";
    graphLinkUrl += "&timeesize=9";
    graphLinkUrl += "&timecolor=606060";
    graphLinkUrl += "&instrument=" + instrument;
    graphLinkUrl += "&headingcolor=370067";
    graphLinkUrl += "&headingtitle=" + name;

    img.style.marginTop='62px';
    img.style.marginLeft='92px';
    img.src = waitingImage.src;
    div.style.display = "none";
    startDisplayGraphTimer();
   

  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {  //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {  //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {  //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  var e = window.event ? window.event : event;
  var x = e.clientX;
  var y = e.clientY;
  div.style.left = (scrOfX + x + 20) + "px";
  div.style.top = (scrOfY + y )  + "px";
}

function displayGraph() {
  var div = document.getElementById( 'showGraphDivId' );
  var img = document.getElementById( 'showGraphImgId' );
  div.style.position = "absolute";
  div.style.display = "block";
  var graphImage = new Image();
  graphImage.src = graphLinkUrl;
  graphImage.onload = function() {
	  img.style.marginLeft='0px';
	  img.style.marginTop='0px';
	  img.src = graphImage.src;
  };
  clearInterval(graphStartTimer);
}

function hideGraph() {
  clearInterval(graphStartTimer);
  graphStartTimer = null;
  var div = document.getElementById( 'showGraphDivId' );
  var img = document.getElementById( 'showGraphImgId' );
  div.style.display = "none";
}