<?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" /> 

     </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>


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>
<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>
</Module>





