﻿ <!--//--><![CDATA[//><!--
   //var url = "http://custom.marketwatch.com/custom/ziegler-com/html-quickquote.asp?symb="
   var url = "http://test.marketwatch.com/custom/ziegler-com/html-quickquote.asp?symb="
   
    window.onload = function()
    {
        if (window.SymbolComplete != null)
        {
            // Parameters: textBox id, display area id, # results in div (1-20), delay, callback, use iframe hack to cover controls in IE
            window.SymbolComplete.SetupDynamicScript('symb', 'myContainer', 10, .050, formatResult, false);
            window.SymbolComplete.DisableAutoHighlight();  // don't autohightlight first item in list.
            }
    }


    function formatResult(query, selectionValue, symbol, companyName, countryCode)
    {
        if(countryCode.toUpperCase() != 'US')
        {
            symbol = countryCode + ':' + symbol;
        }
    	    
        selectionValue.setValue(symbol);


        //Eliminate Country from query text when only using US symbols.
        if (query.indexOf(':') == 2)
        {
            if (query.length > 3)
            {
            query = query.substring(3);
            }
            else
            {
                query = '';
            }
        }

        var scRegExp = new RegExp('\\b(' + query + ')(.*)\\b', 'i'); //Find part to bold

        if (symbol.match(scRegExp))
        {
            symbol = symbol.replace(scRegExp, '<span style="font-weight:bold">$1</span>$2');
        }
        else
        {
            companyName = companyName.replace(scRegExp, '<span style="font-weight:bold">$1</span>$2');
        }

        var aMarkup = ['<table class="resulttable"><tr><td class="col1">',
               symbol,
               '</td><td class="col2">',   
               companyName,   
               '</td></tr></table>'];   


        return (aMarkup.join(''));
    }

    function GetQuote(){
        var symbol;
        symbol = document.quoteform.symb.value;
    	
        if (symbol.length != 0){
            quoteurl = url;
            quoteurl += symbol;
            quoteurl += '&rand=' + Math.random();
    		
            //window.open(quoteurl);
    		
            var script_object = document.createElement('SCRIPT') ;
            script_object.src = quoteurl;
            script_object.type = 'text/javascript' ;
            //do the insert
            var div=document.getElementById("AJAXScript");
            div.appendChild(script_object);
    		
            document.getElementById('quotearea').style.visibility = 'visible';
    		
        }else{
            alert('Please input a symbol.');
        }
    }


    document.writeln('<link rel="stylesheet" href="http://custom.marketwatch.com/custom/ziegler-com/mwstyle.css">');

    document.writeln('<scr' + 'ipt language="JavaScript" src="http://symbolcomplete.marketwatch.com/SymbolComplete/service.aspx?license=5D6050B88D8194734E3263EEF6378DFAA8A9E900272524293864A2F682C4BEA7A6B9BE70DAA796410839950326D28090AAAF7AABD1CE1D3DA602899F14B81F9B8F5E7D3AA2070C199E7612DCAE68CAC58257B1092362986C51C221EEA4BC0E44EBF74F1E261ECEC6DAA5D504FB9CDD2CC8752D2845A70A52FF8A777884F675EB166CEDD6"></sc' +'ript>');

    document.writeln('<div id="AJAXScript"></div>');
    //document.writeln('<div style="width:204px;height:30px;text-align:center;padding:0;background-color:#ffffff;">');
    //document.writeln('	<img src="images/wm-marketw-header.gif" border="0" alt="Market Watch" title="Market Watch"/>');
    //document.writeln('</div>');
    document.writeln('<div style="width:209px;height:250px;">');
    document.writeln('	<img id="mwIndicesChartImg" src="http://chart.bigcharts.com/custom/ziegler-com/ziegler-wm_djia.gifquote" border="0" alt="" usemap ="#mwIndicesMap" width="209" height="250" />');
    document.writeln('	<map id ="mwIndicesMap" name="mwIndicesMap">');
    document.writeln('		<area shape="polygon" coords ="0,7 7,0 65,0 68,0 68,15 0,15" href="#" alt="" onclick="javascript:document.getElementById(\'mwIndicesChartImg\').src=\'http://chart.bigcharts.com/custom/ziegler-com/ziegler-wm_djia.gifquote\';return false;" />');
    document.writeln('		<area shape="polygon" coords ="70,7 77,0 135,0 138,15 138,15 70,15" href="#" alt="" onclick="javascript:document.getElementById(\'mwIndicesChartImg\').src=\'http://chart.bigcharts.com/custom/ziegler-com/ziegler-wm_spx.gifquote\';return false;" />');
    document.writeln('		<area shape="polygon" coords ="140,7 147,0 205,0 208,15 208,15 140,15" href="#" alt="" onclick="javascript:document.getElementById(\'mwIndicesChartImg\').src=\'http://chart.bigcharts.com/custom/ziegler-com/ziegler-wm_nasdaq.gifquote\';return false;" />');
    document.writeln('	</map>'); 
    document.writeln('</div>');
    document.writeln('<div style="width:204px;height:30px;text-align:center;padding:0;background-color:#ffffff;">');
    document.writeln('	<img src="/res/img/wm-quickq-header.gif" border="0" alt="Quick Quote" title="Quick Quote"/>');
    document.writeln('</div>');
    document.writeln('<form style="margin:0;padding:0;" name="quoteform" onSubmit="GetQuote(); return false;">');
    document.writeln('<input type="text" class="text" width="50" name="symb" id="symb" AUTOCOMPLETE="OFF"/>&nbsp;<input class="image" type="image" border="0" src="/res/img/go.gif" alt="Go" title="Go" >');
    document.writeln('</form>');
    document.writeln('<div id="myContainer"></div>');
    document.writeln('<div id="quotearea" style="{visibility: hidden;}">');
    document.writeln('</div>');
    document.writeln('<br/>');
//--><!]]>                        


