<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs 
title="BSE India Stocks update" 
height="210" 
description="Indian stock price update from BSE (sensex). No need to add any scrip codes."  

author ="Karthik"  
author_email ="manikarthik84@yahoo.com"   
author_location ="Chennai, India"   


title_url="http://bsebull.com"  

thumbnail="http://goooglegadgets.googlepages.com/mystocks.png"
screenshot ="http://goooglegadgets.googlepages.com/mystocks_.png"


author_affiliation=""   
render_inline="never"   
category="Finance" 
>

<Require feature="dynamic-height" /> 
<Require feature="analytics" /> 
 <Require feature="setprefs" /> 
 <Require feature="views" /> 


     </ModulePrefs>


<UserPref name="k1" display_name="BSE Scrip 1" default_value="500390" /> 
<UserPref name="k2" display_name="BSE Scrip 2" default_value="" /> 
<UserPref name="k3" display_name="BSE Scrip 3" default_value="" /> 
<UserPref name="k4" display_name="BSE Scrip 4" default_value="" /> 
<UserPref name="k5" display_name="BSE Scrip 5" default_value="" /> 

<UserPref name="k6" display_name="BSE Scrip 6" default_value="" /> 
<UserPref name="k7" display_name="BSE Scrip 7" default_value="" /> 
<UserPref name="k8" display_name="BSE Scrip 8" default_value="" /> 
<UserPref name="k9" display_name="BSE Scrip 9" default_value="" /> 
<UserPref name="k10" display_name="BSE Scrip 10" default_value="" /> 

<UserPref name="interval" display_name="Refresh time" default_value="60" datatype="enum">


<EnumValue value="5" display_value="5 sec" />
<EnumValue value="30" display_value="30 sec" />
<EnumValue value="60" display_value="1 min" />
<EnumValue value="900" display_value="15 min" />
</UserPref>

<UserPref name="t1"  datatype="hidden" /> 
<UserPref name="t2"  datatype="hidden" /> 

<Content type="html">
<![CDATA[
<HEAD>


<script type="text/javascript">
        function goToView(dest) {
      var supported_views = gadgets.views.getSupportedViews();
      gadgets.views.requestNavigateTo(supported_views[dest]);
    };
</script>

<SCRIPT>


var timer;

function getSensex()
{
_IG_FetchContent('http://www.bseindia.com/dataref.asp'+'?time=' + new Date().getTime(), function (responseText) {

            var records = responseText.split('|') ;

var columns = records[1].split('@');
var sensex = columns[2];
var change =  columns[3];
var percentage = columns[4];
var k = change.toString();
var imag,colr;
if (k.charAt(0) == '-')
{
imag="down";
colr="#aa0000";
}
else
{
imag="up";
colr="#00aa00";
}

m="<center><table border=0 align=center style=\"width:100%\"><tr>";
m = m + "<td valign=bottom><font  color=\"" + colr + "\"><b>"+sensex+"</b></font>&nbsp;</td>";
m = m + "<td valign=bottom ><img src = \"http://goooglegadgets.googlepages.com/" + imag +".jpg\" border=0>";
m = m + "<font  color=\"" + colr + "\"><b>&nbsp;&nbsp;&nbsp;" + change + "&nbsp;</td>";
m = m + "<td valign=bottom><font  color=\"" + colr + "\"><b>(" + percentage + "%)&nbsp;</td></tr></table></center>";
//document.getElementById("mainform").innerHTML = m;
  _IG_AdjustIFrameHeight();
timer = setTimeout( 'getSensex()',120000 ) ;

  });
}
</SCRIPT>


<style type="text/css"> 

caption {
  padding: 0 0 5px 0;
  width: 700px;   
  font: italic 11px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  text-align: right;
}

th {
  font: bold 10px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  color: #000030;
  text-transform: uppercase;
  text-align: left;
  padding: 1px 1px 1px 1px;
  background: #ffffff;
}

th.nobg {

}

td {

  background: #ffffff;
  padding: 1px 1px 1px 1px;
  color: #000088;
  word-wrap: break-word;
}

tr.alt {
  background: #Ffffff;
  color: #00429C;
}
td.alt {
  background: #ffffff;
  color: #00429C;
  font: bold 10px  Verdana, Arial, Helvetica, sans-serif;
}
td.alt1 {
  background: #ffffff;
  color: green;
  font: bold 10px Verdana, Arial, Helvetica, sans-serif;
}
td.negalt {
  background: #ffffff;
  color: #8B0000;
  font: bold 10px  Verdana, Arial, Helvetica, sans-serif;
}


th.spec {
  background: #fff;
  font: bold 10px  Verdana, Arial, Helvetica, sans-serif;
}

th.specalt {
  background: #ffffff;
  font: bold 10px  Verdana, Arial, Helvetica, sans-serif;
  color: #000081;
}
-->
</style>


    
      <SCRIPT type="text/javascript" language="javascript">
var timer;
//var newDiv = null;
var prefs = new _IG_Prefs(__MODULE_ID__);
var _numStocks = 20;



 document.getElementById('s1').value =  prefs.getString("t1");
 document.getElementById('s2').value =  prefs.getString("t2");




function roundNumber(numberField) {
if(isNaN(numberField)) { return '-'; }
var rnum = numberField;
var rlength = 2; // The number of decimal places to round to
if (rnum > 8191 && rnum < 10485) {
rnum = rnum-5000;
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
newnumber = newnumber+5000;
} else {
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}
return newnumber;
}
//http://quote.yahoo.com/d/quotes.csv?s=%5ebsesn+%5ensei+532418.BO+ASHOKLEY.NS+GPIL.NS+530005.BO+MLL.NS+NTPC.NS+TTML.NS&f=nvl1'
function init(newDiv)
{
//Create a div in which we will be rendering table
//newDiv = document.createElement("div");
//document.body.appendChild(newDiv);
getSensex();
get_stockdetails();
}

function CommaFormatted(volume)
{
var delimiter = ","; // replace comma if desired
var a = volume;//.split('.',2)
if(isNaN(volume)) { return '-'; }
var i = parseFloat(volume);
i = Math.abs(i);
var n = new String(i);
var a = [];
while(n.length > 3)
{
var nn = n.substr(n.length-3);
a.unshift(nn);
n = n.substr(0,n.length-3);
}
if(n.length > 0) { a.unshift(n); }
volume = a.join(delimiter);
return volume;
}


function get_stockdetails()
{
var mudStock = new Array(_numStocks-1);
var arrStock = new Array(_numStocks-1);
var arrShares = new Array(_numStocks-1);
var arrPrice = new Array(_numStocks-1);
var arrCurrPrice = new Array(_numStocks-1);
var arrCurrchange = new Array(_numStocks-1);
var isConfigured = false;
var surl = "http://finance.yahoo.com/d?s=";
var confStocks = 0;
var quotes = "";
var temp="";


if(document.getElementById('500410').selected == true)         temp = "500410";
else if(document.getElementById('500425').selected == true)         temp = "500425";
else if(document.getElementById('500490').selected == true)         temp = "500490";
else if(document.getElementById('500547').selected == true)         temp = "500547";
else if(document.getElementById('532454').selected == true)         temp = "532454";
else if(document.getElementById('500103').selected == true)         temp = "500103";
else if(document.getElementById('500087').selected == true)         temp = "500087";
else if(document.getElementById('517326').selected == true)         temp = "517326";
else if(document.getElementById('532902').selected == true)         temp = "532902";
else if(document.getElementById('532868').selected == true)         temp = "532868";
else if(document.getElementById('500124').selected == true)         temp = "500124";
else if(document.getElementById('532155').selected == true)         temp = "532155";
else if(document.getElementById('500300').selected == true)         temp = "500300";
else if(document.getElementById('532281').selected == true)         temp = "532281";
else if(document.getElementById('500010').selected == true)         temp = "500010";
else if(document.getElementById('500180').selected == true)         temp = "500180";
else if(document.getElementById('500182').selected == true)         temp = "500182";
else if(document.getElementById('500440').selected == true)         temp = "500440";
else if(document.getElementById('500696').selected == true)         temp = "500696";
else if(document.getElementById('532174').selected == true)         temp = "532174";
else if(document.getElementById('500209').selected == true)         temp = "500209";
else if(document.getElementById('500875').selected == true)         temp = "500875";
else if(document.getElementById('500228').selected == true)         temp = "500228";
else if(document.getElementById('532901').selected == true)         temp = "532901";
else if(document.getElementById('500510').selected == true)         temp = "500510";
else if(document.getElementById('500520').selected == true)         temp = "500520";
else if(document.getElementById('532500').selected == true)         temp = "532500";
else if(document.getElementById('500108').selected == true)         temp = "500108";
else if(document.getElementById('532234').selected == true)         temp = "532234";
else if(document.getElementById('532555').selected == true)         temp = "532555";
else if(document.getElementById('500312').selected == true)         temp = "500312";
else if(document.getElementById('532898').selected == true)         temp = "532898";
else if(document.getElementById('500359').selected == true)         temp = "500359";
else if(document.getElementById('500325').selected == true)         temp = "500325";
else if(document.getElementById('532712').selected == true)         temp = "532712";
else if(document.getElementById('500390').selected == true)         temp = "500390";
else if(document.getElementById('532709').selected == true)         temp = "532709";
else if(document.getElementById('532743').selected == true)         temp = "532743";
else if(document.getElementById('500113').selected == true)         temp = "500113";
else if(document.getElementById('500376').selected == true)         temp = "500376";
else if(document.getElementById('500112').selected == true)         temp = "500112";
else if(document.getElementById('500900').selected == true)         temp = "500900";
else if(document.getElementById('532667').selected == true)         temp = "532667";
else if(document.getElementById('513434').selected == true)         temp = "513434";
else if(document.getElementById('500570').selected == true)         temp = "500570";
else if(document.getElementById('500400').selected == true)         temp = "500400";
else if(document.getElementById('500470').selected == true)         temp = "500470";
else if(document.getElementById('500800').selected == true)         temp = "500800";
else if(document.getElementById('532371').selected == true)         temp = "532371";
else if(document.getElementById('532540').selected == true)         temp = "532540";
else if(document.getElementById('500483').selected == true)         temp = "500483";
else if(document.getElementById('507685').selected == true)         temp = "507685";
else if(document.getElementById('532939').selected == true)         temp = "532939";

else  temp = "";

if (temp!= document.getElementById('s1').value)
{

document.getElementById('s2').value = document.getElementById('s1').value;
document.getElementById('s1').value = temp;


prefs.set("t1", document.getElementById('s1').value);
prefs.set("t2", document.getElementById('s2').value);

}

 mudStock[2] =  prefs.getString("k1");
 mudStock[3] =  prefs.getString("k2");
 mudStock[4] =  prefs.getString("k3");
 mudStock[5] =  prefs.getString("k4");
 mudStock[6] =  prefs.getString("k5");

 mudStock[7] =  prefs.getString("k6");
 mudStock[8] =  prefs.getString("k7");
 mudStock[9] =  prefs.getString("k8");
 mudStock[10] =  prefs.getString("k9");
 mudStock[11] =  prefs.getString("k10");


mudStock[1]=document.getElementById('s2').value;
mudStock[0]=document.getElementById('s1').value;


//get user settings
for (i=0; i<12; i++){
//mudStock[i] = prefs.getString("s" + i);

//For sensex and nifty
confStocks++;confStocks++;
 


arrStock[i] = mudStock[i]+".BO";
arrCurrPrice[i] = 0;
arrCurrchange[i] = 0;
if (mudStock[i] !='' && mudStock[i]!=null ) {
quotes += _esc(arrStock[i]);
isConfigured = true;
quotes += '+';
confStocks++;


}


}

if (confStocks > 0) {
surl += "%5EBSESN+%5ENSEI+" +_esc(quotes)+"&f=nl1c2vgh&random="+ Math.random();
_IG_FetchContent(surl, _IG_Callback(processResult));
}

function processResult(str) {
var responseText = str;
var shtml = "<div>";
if (responseText == null || responseText == "") {
shtml += "<i><font size='3'>Service is temporarily unavailable. </font></i></div>";
newDiv.innerHTML = shtml;
timer = setTimeout( 'get_stockdetails()', 5000 ) ;
return;
}


//Lets create table & headers for the same.

shtml += "<table style=\"width:100%\" >";
shtml += "<tr><th >Script </th>";
shtml += "<th  >BSE Price</th></tr>"



// Lets replace \n by commas because we will be getting multiple records
var tmp1 = responseText.replace(new RegExp( "\\n", "g" ), ",");

//Replace any double quotes; that looks ugly
var tmp2 = tmp1.replace(new RegExp( "\"", "g" ),"");

// Use the split function to extract substrings separated by comma
// delimiters.
var contacts = tmp2.split(",");

//Process array of extracted substrings.
var rec = 0;
var total_profit = 0;
var pct_prof = 0;
var invest = 0;
var mktvalue = 0;
var col = 0;
for (var i = 0; i < (contacts.length-5) ; i++) {
switch(col)
{
case 0 : //Script name, Qty, Buy Price

shtml += "<tr><th scope='row' class='spec'>";

shtml +=  contacts[i] + "</th>";


col++;
break;
case 1 : //Mkt Price and change
arrCurrPrice[rec] = roundNumber(parseFloat(contacts[i]));

i++;
arrCurrchange[rec] = contacts[i].replace(/ - /,"  (");;

if(roundNumber(parseFloat(contacts[i]))<0){
shtml += "<td class='negalt'><big><big>" + arrCurrPrice[rec] + "</big></big>&nbsp;"+ arrCurrchange[rec]+ ")</td>";
  }else{
    shtml += "<td class='alt1'><big><big>" + arrCurrPrice[rec] + "</big></big>&nbsp;"+ arrCurrchange[rec]+ ")</td>";
      }
col++;
break;
case 2 : //Volume
//shtml += "<td class='alt'>" + CommaFormatted(contacts[i]) + "</td>";
col++;
break;
case 3 : //Day Low
//shtml += "<td class='alt'>" + roundNumber(parseFloat(contacts[i])) + "</td>";
col++;
break;
case 4 : //Day High & Profit
//shtml += "<td class='alt'>" + roundNumber(parseFloat(contacts[i])) + "</td>";
col=0;
rec++
break;
}


if (rec >= confStocks)
break;

} //end of for

shtml += "</table><table>";
shtml += "</div>";
// Output html in div.
newDiv.innerHTML = shtml;

var interval = prefs.getInt('interval');

timer = setTimeout( 'get_stockdetails()', parseFloat(interval * 1000) ) ;
  _IG_AdjustIFrameHeight();
}
}

</SCRIPT>
</HEAD>

<BODY  onload="init(newDiv);">


<div id=mainform></div>

<div style="height:1px;">


<input type="hidden" id="s1" value="">
<input type="hidden" id="s2" value="">

</div>

<select size=4 onchange="init(newDiv)" style="background-color:White;color:#0000AF; font-family:Verdana; font-size:13px; font-weight:bold; padding:1px; margin:0px; ">
<option id="500410">ACC Limited</option>

<option id="500425">Ambuja Cements </option>

<option id="500490">Bajaj Auto </option>

<option id="500547">Bharat Petroleum </option>

<option id="532454">Bharti Airtel </option>

<option id="500103">BHEL</option>

<option id="500087">Cipla </option>

<option id="517326">CMC</option>

<option id="532902">Consolidated Construction </option>

<option id="532868">DLF</option>

<option id="500124">Dr Reddy</option>

<option id="532155">GAIL</option>

<option id="500300">Grasim Industries </option>

<option id="532281">HCL Technologies </option>

<option id="500010">HDFC</option>

<option id="500180">HDFC Bank </option>

<option id="500182">Hero Honda Motors</option>

<option id="500440">Hindalco </option>

<option id="500696">Hindustan Unilever </option>

<option id="532174">ICICI Bank </option>

<option id="500209">Infosys </option>

<option id="500875">ITC</option>

<option id="500228">JSW Steel </option>

<option id="532901">Koutons </option>

<option id="500510">Larsen and Toubro </option>

<option id="500520">Mahindra and Mahindra </option>

<option id="532500">Maruti Suzuki </option>

<option id="500108">MTNL</option>

<option id="532234">National Aluminium Company</option>

<option id="532555">NTPC </option>

<option id="500312">ONGC</option>

<option id="532898">Power Grid Corporation </option>

<option id="500359">Ranbaxy</option>

<option id="500325">Reliance </option>

<option id="532712">Reliance Comm</option>

<option id="500390">Reliance Energy</option>

<option id="532709">Reliance Naturals</option>
<option id="532939">Reliance Power</option>
<option id="532743">Reliance Petroleum</option>

<option id="500113">SAIL</option>

<option id="500376">Satyam </option>

<option id="500112">SBI</option>

<option id="500900">Sterlite Industries </option>

<option id="532667">Suzlon </option>

<option id="513434">Tata Metaliks</option>

<option id="500570">Tata Motors</option>

<option id="500400">Tata Power </option>

<option id="500470">Tata Steel </option>

<option id="500800">Tata Tea</option>

<option id="532371">Tata Teleservices </option>

<option id="532540">TCS</option>

<option id="500483">VSNL</option>

<option id="507685">Wipro </option>



</select>

<div id="newDiv"></div><center>

<input type="button" onclick="goToView('canvas')" value="Top Gainers!"/><br>
</center>

<font color=#880000 style="font-size:14px;"><a href="http://yourbse.com" target="_blank">YourBSE.com</a></font>
<br>
<font color=#000099 style="font-size:12px;">Edit settings to add scrips</font>
<br>
<font  style="font-size:10px;">
Customised from </font>
<a href="http://www.google.co.in/ig/directory?&hl=en&root=%2Fig&dpos=top&url=http://www.mudraa.com/modified1.xml" target="_blank">
<font color=#8B0000 style="font-size:9px;">Portfolio Tracker
</font>
</a>

</BODY>
]]>
</Content>
<Content type="html" view='canvas'>

<![CDATA[ 
<HEAD>


<style type="text/css">

.senconstyle{
font: bold 10px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  text-align: left;
  background-color:lavender;
  color:darkslateblue;

}
.cborder1{
font: bold 12px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  text-align: left;
  background-color:aliceblue;
  color:green;
  
}
.cborder2{
font: bold 12px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  text-align: left;
  background-color:aliceblue;
  
 color:red;
 }



  .sensexstyle{
  border:1px ridge black;
  width:750px;
}




.chart{
 width:750px;
   border:1px ridge black;
 background-color: lavender;

}
.chart1{
   border:2px solid grey;


}
.txt{

color:blue;
width:180px;
height:22px;
}


.menu{
  font: bold 12px "Tahoma", Verdana, Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  width:120px;
  text-align: center;
  background-color:darkgrey;
  color:darkslateblue;

  }
td.alt1 {
  background: gainsboro;
  color: green;
  font: bold 10px Verdana, Arial, Helvetica, sans-serif;
}
td.negalt {
  background-color: gainsboro;
  color: #8B0000;
  font: bold 10px  Verdana, Arial, Helvetica, sans-serif;
}

</style>

<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>
<SCRIPT type="text/javascript" language="javascript">

//Customized from http://www.google.co.in/ig/directory?hl=en&root=/ig&dpos=top&url=www.mudraa.com/modified1.xml
var timer;
//var newDiv = null;
var prefs = new _IG_Prefs(__MODULE_ID__);
var _numStocks = 50;
var gainers = new Array();
var a=new Array();
//var b=new Array();
var len;
var losers=new Array();
var shtml1;
function ConvertToProperCase(stockName)
{
tempStockName = stockName;
tempStockName = tempStockName.toLowerCase()

var test=""
var isFirstCharOfWord = 1

for (var intCount = 0; intCount < tempStockName.length; intCount++)
{

var temp = tempStockName.charAt(intCount)
if (isFirstCharOfWord == 1)
{
temp = temp.toUpperCase()
}

test = test + temp
if (temp == " ")
{
isFirstCharOfWord = 1
}
else isFirstCharOfWord = 0
}
return test;
}

function roundNum(num) {
var temp = new Number(num);
var fmtNum = temp.toFixed(2);
if (fmtNum > 0){
fmtNum = "+" + fmtNum;
}
return fmtNum;
}


function mySortingRev(c,d) {
a = parseFloat(c[3]);
b = parseFloat(d[3]);
return a == b ? 0 : (a < b ? 1 : -1)
}

function mySorting(c,d) {
a = parseFloat(c[3]);
b = parseFloat(d[3]);

return a == b ? 0 : (a < b ? -1 : 1)
//return b-a;

}


function changecolor()
{
 this.style.backgroundColor="red";
}

function roundNumber(numberField) {
if(isNaN(numberField)) { return '-'; }
var rlength = 2; // The number of decimal places to round to
var rnum = numberField;

if (rnum > 8191 && rnum < 10485) {
rnum = rnum-5000;
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
newnumber = newnumber+5000;
} else {
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}
return newnumber;
}
//http://quote.yahoo.com/d/quotes.csv?s=%5ebsesn+%5ensei+532418.BO+ASHOKLEY.NS+GPIL.NS+530005.BO+MLL.NS+NTPC.NS+TTML.NS&f=nvl1'

function init(newDiv)
{
//Create a div in which we will be rendering table
get_stockdetails();
var timer;
timer = setTimeout( 'init()',30000 ) ;

}

function CommaFormatted(volume)
{
var delimiter = ","; // replace comma if desired
var a = volume;//.split('.',2)

if(isNaN(volume)) { return '-'; }
var i = parseFloat(volume);
i = Math.abs(i);
var n = new String(i);
var a = [];
while(n.length > 3)
{
var nn = n.substr(n.length-3);
a.unshift(nn);
n = n.substr(0,n.length-3);
}
if(n.length > 0) { a.unshift(n); }
volume = a.join(delimiter);
return volume;
}
function get_stockdetails()
{
var b=new Array();

var mudStock = new Array(_numStocks-1);
var arrStock = new Array(_numStocks-1);
var arrShares = new Array(_numStocks-1);
var arrPrice = new Array(_numStocks-1);
var arrCurrPrice = new Array(_numStocks-1);
var arrCurrchange = new Array(_numStocks-1);
var arrPercchange = new Array(_numStocks-1);


var isConfigured = false;
var surl = "http://finance.yahoo.com/d?s=";
var confStocks = 0;
var quotes = "";

 mudStock[0] =  500410;
 mudStock[1] =  500425;
 mudStock[2] =  532215;
 mudStock[3] =  532977;
 mudStock[4] =  500103;
 mudStock[5] =  500547;
 mudStock[6] =  532792;
 mudStock[7] =  500103;
 mudStock[8] =  500087;
 mudStock[9] =  500470;
 mudStock[10] =  532868;
 mudStock[11] =  532155;
 mudStock[12] =  500300;
 mudStock[13] =  532281;
 mudStock[14] =  500180;
 mudStock[15] =  500182;
 mudStock[16] =  507685;
 mudStock[17] =  500440;
 mudStock[18] =  500696;
 mudStock[19] =  500010;
 mudStock[20] =  500875;
 mudStock[21] =  532174;
 mudStock[22] =  500209;
 mudStock[23] =  532659;
 mudStock[24] =  532532;
 mudStock[25] =  500247;
 mudStock[26] =  500510;
 mudStock[27] =  500520;
 mudStock[28] =  532500;
 mudStock[29] =  532555;
 mudStock[30] =  500312;
 mudStock[31] =  532898;
 mudStock[32] =  532461;
 mudStock[33] =  500359;
 mudStock[34] =  532712;
 mudStock[35] =  500325;
 mudStock[36] =  500390;
 mudStock[37] =  532939;
 mudStock[38] =  500295;
 mudStock[39] =  500550;
 mudStock[40] =  500112;
 mudStock[41] =  500113;
 mudStock[42] =  524715;
 mudStock[43] =  532540;
 mudStock[44] =  500400;

//get user settings
for (i=0; i<50; i++){
//mudStock[i] = prefs.getString("s" + i);

// For BSE and NSE
confStocks++;
confStocks++;

arrStock[i] = mudStock[i]+".BO";
arrCurrPrice[i] = 0;
arrCurrchange[i] = 0;
if (mudStock[i] !='' && mudStock[i]!=null ) {
  quotes += _esc(arrStock[i]);
  isConfigured = true;
  quotes += '+';
  confStocks++;
}
}

if (confStocks > 0) {
surl += "%5EBSESN+%5ENSEI+%2BBSE-BANK.BO%2B+%2BBSE-METAL.BO%2B+%2BBSE-TECK.BO%2B+%2BBSE-AUTO.BO%2B+BHARTIART.NS+DRREDDY.NS+JINDALSTE.NS+RELCAPITA.NS+STER.NS+TATAMOTOR.NS+" + _esc(quotes)+"&f=nl1c2vgh&random="+ Math.random();
//document.write(surl);;
_IG_FetchContent(surl, _IG_Callback(processResult));
}

function processResult(str) {
var responseText = str;
//alert(responseText);
// Lets replace \n by commas because we will be getting multiple records
var tmp1 = responseText.replace(new RegExp( "\\n", "g" ), ",");

//Replace any double quotes; that looks ugly
var tmp2 = tmp1.replace(new RegExp( "\"", "g" ),"");

// Use the split function to extract substrings separated by comma
// delimiters.
var contacts = tmp2.split(",");

//display NSE and BSE values
//var shtml = "<tr><th scope='row' class='spec'>";
//shtml +=  contacts[0] + "</th>" + "</tr>";
//alert('hi');
var shtml = "";
if (responseText == null || responseText == "") {
shtml += "<i><font size='3'>Service is temporarily unavailable. </font></i>";
newDiv.innerHTML = shtml;
timer = setTimeout( 'get_stockdetails()', 50 ) ;
return;
}

//Lets create table & headers for the same.


var k = 0;

//alert(contacts);
for (var i = 0; i < (contacts.length) ; i++) {

var remainder = (i + 1) % 6;
switch(remainder)
{
case 1:
var j=0;
var stockName = contacts[i];
a[j] = contacts[i];
j++;
break;

case 2:
var currPrice = contacts[i];
a[j] = contacts[i];
j++;
break;

case 3:
var change = contacts[i];
var parsedChange = change.split(" ");
var absChnage = parsedChange[0];
var percChange = parsedChange[2];
a[j] = absChnage;
j++;
a[j] = percChange;
j++;
break;

case 4:
break;

case 5:
a[j] = contacts[i];
j++;
break;

case 0:
a[j] = contacts[i];
//alert(a[j]);
//alert(a);

j++;
// alert(k); 
b[k] = a.slice(0,6); 
//var temp = a.slice(0,6); 
// alert(temp);
//  alert(b[k]);

k++;
break;
}
}
//alert(k);
//alert('b[k]');
//alert(b[k-1]);
len = b.length;
//alert(len);
//alert(b);
var index = b.slice(0,6);
//alert(index);
//alert('bi');

var x=0;
var y=0;
for (var i = 6; i < b.length ; i++) {
temp = b[i];
if (parseFloat(temp[3]) < 0)
{
losers[x] = temp.slice(0,6);
x++;
}
else {
gainers[y] = temp.slice(0,6);
y++;
}
}
losers.sort(mySorting);
gainers.sort(mySortingRev);


//shtml+="<table class='chart'>";
//shtml+="<tr><td align='right'><input type='text' name='search' class='txt'/></td>";
//shtml+="<td align='left'><input type='text' name='search1' class='txt'/></td></tr>";
//shtml+= "<form action=\"http://www.google.com/cse\" id=\"cse-search-box\" target=\"_blank\">";
//shtml += "<div>";
//shtml += "<input type=\"hidden\" name=\"cx\" value=\"partner-pub-5417499529652032:u5q32eft8qp\" />";
//shtml += "<input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\" />";
//shtml += "<input type=\"text\" name=\"q\" size=\"40\" />";
//shtml += "<input type=\"submit\" name=\"sa\" value=\"Search Company\" />";
//shtml += "</div>";
//shtml+="</table>";

//display BSE indexes
shtml += "<table class='sensexstyle'>";
for (var i =0; i < index.length; i++) {
a = index[i];
if (i% 3 ==  0) {shtml += "<tr>";}

shtml += "<td class='senconstyle'>";
switch(i)
{
case 0:
a[0] = "BSE";
break;

case 1:
a[0] = "NSE";
break;

case 2:
a[0] = "BANKEX";
break;

case 3:
a[0] = "METAL";
break;

case 4:
a[0] = "TECH";
break;

case 5:
a[0] = "AUTO";
break;

}
shtml +=  a[0] + "</td>";
if (parseFloat(a[2]) < 0) {

shtml += "<td class='negalt'><big><big>" + a[1] + "</big></big>&nbsp;"+ a[2] + "(" + a[3] + ")</td>";}
else {
shtml += "<td class='alt1'><big><big>" + a[1] + "</big></big>&nbsp;"+ a[2] + "(" + a[3] + ")</td>";}
}
//alert(shtml);
//Process array of extracted substrings.

shtml += "</table>";
shtml += "<table class='sensexstyle'>";


shtml+= "<tr><th class='menu'>Nifty gainers</th><th class='menu' colspan='5'></th></tr>";
shtml += "<tr><th class='menu'>Script </th>";
shtml += "<th class='menu'>Price</th>";
shtml += "<th class='menu'>Change </th>";
shtml += "<th class='menu'>%Change </th>";
shtml += "<th class='menu'>Low </th>";
shtml += "<th class='menu'>High </th></tr>";


var len = gainers.length;
if (len > 10) {
len = 10 }
for (var i = 0; i < len; i++) {
a = gainers[i];
//shtml += "<tr><th scope='row' class='spec'>";

shtml += "<tr>";
shtml += "<td class='senconstyle'>";
shtml +=  ConvertToProperCase(a[0]) + "</td>";

shtml += "<td class='cborder1'>"
var currentFmted1 = roundNum(a[1]);
shtml +=  currentFmted1 + "</td>";

shtml += "<td class='cborder1'>"
var changeFmted1 = roundNum(a[2]);
shtml +=  changeFmted1+ "</td>";

shtml += "<td class='cborder1'>";
shtml +=  a[3] + "</td>";

shtml += "<td class='cborder1'>"
var lowFmted1 = roundNum(a[4]);
shtml +=  lowFmted1 + "</td>" ;

shtml += "<td class='cborder1'>";
var highFmted1 = roundNum(a[5]);
shtml +=  highFmted1 + "</td>" + "</tr>";

} //end of for


shtml += "<tr><th class='menu'>Nifty Losers</th><th class='menu' colspan=5'></th></tr>";

//Process array of extracted substrings.
var len = losers.length;
if (len > 10) {
len = 10; }

for (var i = 0; i < len; i++) {
a = losers[i];
//shtml += "<tr><th scope='row' class='spec'>";
//shtml +=  a[0] + a[1] + a[2] + a [3] + "</th>";

shtml += "<tr>";
shtml += "<td class='senconstyle'>";
shtml +=  ConvertToProperCase(a[0]) + "</td>";

shtml += "<td class='cborder2'>";
var currentFmted1 = roundNum(a[1]);
shtml +=  currentFmted1 + "</td>";

shtml += "<td class='cborder2'>"
var changeFmted1 = roundNum(a[2]);
shtml +=  changeFmted1;


shtml += "<td class='cborder2'>"+ a[3] + "</td>";

shtml += "<td class='cborder2'>"
var lowFmted1 = roundNum(a[4]);
shtml +=  lowFmted1 + "</td>" ;

shtml += "<td class='cborder2'>";
var highFmted1 = roundNum(a[5]);
shtml +=  highFmted1 + "</td>" + "</tr>";

} //end of for

//shtml += "<TR><TD COLSPAN=2> </TD></TR>";
shtml += "</table>";
shtml+="<table class='chart'>";
shtml+="<tr><td align='right'><img src='http://ichart.yahoo.com/z?s=^NSEI&t=1d&z=s' class='chart1' alt='NSE' height='200'/></td>";
shtml+="<td><img src='http://ichart.yahoo.com/z?s=^BSESN&t=1d&z=s' alt='BSE' class='chart1' height='200'/></td>";
shtml+="</tr></table>";

//alert(shtml);
// Output html in div.
newDiv.innerHTML = shtml;

var interval = prefs.getInt('interval');

//timer = setTimeout( 'get_stockdetails()', parseFloat(interval * 1000) ) ;
  _IG_AdjustIFrameHeight();
}
}

</SCRIPT>
</HEAD>

<BODY  onload="init(newDiv);">
<div>
<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
  <div>
    <input type="hidden" name="cx" value="partner-pub-5417499529652032:u5q32eft8qp" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
    <input type="text" name="q" size="40" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>
<script>
</script>
</div>

<div><font style="font-size:0px;">Feed</font>
<script type="text/javascript">
<!--
if (Math.random() < 0.5)
{
google_ad_client = "pub-5417499529652032";
/* 468x60, created 5/15/11 */
google_ad_slot = "0095576005";
google_ad_width = 468;
google_ad_height = 60;
} else
{
google_ad_client = "pub-5417499529652032";
/* 728x90, created 6/15/11 */
google_ad_slot = "3921539962";
google_ad_width = 728;
google_ad_height = 90;

}
//comment
//-->  
</script>

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

<div id="newDiv"></div>


</BODY>


  ]]> 
</Content>
</Module>

