<!--
//alert("Hello");
 var http = createRequestObject();
 function createRequestObject() 
     {
           var xmlhttp;
	 try 
                 { 
                    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
                 }
	  catch(e) 
                 {
	    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	    catch(f) { xmlhttp=null; }
	    }
	        if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
                        {
	  	   xmlhttp=new XMLHttpRequest();
	           }
		   return  xmlhttp;
 }
function getCurrentIndex(iCompany_CD,strStockExchange)
  {
	//var dvelement = document.getElementById('dv'+iCompany_CD);
	//dvelement.innerHTML = "<img src='../images/starimages/progressimgred.gif'>";

	//alert (iCompany_CD +'&'+ strStockExchange);
    try
	{

		http.open('GET', 'StockAjaxAction.asp?a='+iCompany_CD+'&se='+strStockExchange);
//		alert(iCompany_CD);
//		alert(strStockExchange);
//        alert(handleResponseText);
		http.onreadystatechange = handleResponseText;
	    http.send(null);
		//dvelement.innerHTML = "";
	 }
	    catch(e){}
	    finally{}
 }
function handleResponseText() 
{
try
 {
	//alert(http.readyState+' status '+http.status);
  if((http.readyState == 4)&& (http.status == 200))
  {

	var response = http.responseText;
	//--This alert will display of output of .asp page
	//alert(response);

    var update = new Array();
    if(response.indexOf(',') != -1) 
    {
      update = response.split(',');
	  var GraphURL = document.getElementById('GraphURL'+update[0]);
	  var GraphURLW = document.getElementById('GraphURLW'+update[0]);
	  var GraphURLTM = document.getElementById('GraphURLTM'+update[0]);
	  var GraphURLSM = document.getElementById('GraphURLSM'+update[0]);
	  var GraphURLOY = document.getElementById('GraphURLOY'+update[0]);

  	  var GraphURL1 = document.getElementById('GraphURL1'+update[0]);
	  var GraphURLD1 = document.getElementById('GraphURLD1'+update[0]);
	  var GraphURLW1 = document.getElementById('GraphURLW1'+update[0])
	  var GraphURLW2 = document.getElementById('GraphURLW2'+update[0]);
  	  var GraphURLM1 = document.getElementById('GraphURLM1'+update[0]);
   	  var GraphURLM6 = document.getElementById('GraphURLM6'+update[0]);
   	  var GraphURLY1 = document.getElementById('GraphURLY1'+update[0]);
   	  var GraphURLY2 = document.getElementById('GraphURLY2'+update[0]);


  	  var BSETab = document.getElementById('BSETab'+update[0]);
      var NSETab = document.getElementById('NSETab'+update[0]);

	  var BSENSECode = document.getElementById('BSENSECode'+update[0]);

	  //Var to get the color for script + or -
	  var v_Change_Col_Red="Red";		
	  var v_Change_Col_Green="Green";		

	  var v_Curr_Price=""
	  var v_datetime=""


	  var Currentindex = document.getElementById('Currentindex'+update[0]);
	  var sDate = document.getElementById('sDate'+update[0]);
	  var sTime = document.getElementById('sTime'+update[0]);
	  var Change = document.getElementById('Change'+update[0]);
	  var DayOpen = document.getElementById('DayOpen'+update[0]);
	  var DayHigh = document.getElementById('DayHigh'+update[0]);
	  var sDayLow = document.getElementById('sDayLow'+update[0]);
	  var Volumn = document.getElementById('Volumn'+update[0]);
	  var PreviousDayClose = document.getElementById('PreviousDayClose'+update[0]);
	  var ChangeInPercentage = document.getElementById('ChangeInPercentage'+update[0]);
      var FiftyTwoWeekRange = document.getElementById('FiftyTwoWeekRange'+update[0]);



	var CurrPriceHidden = document.getElementById('CurrPriceHidden'+update[0]);
	if (update[1].indexOf(".BO") > 0){
		v_Curr_Price= "<input type='Hidden' name='curr_price' value='"+ "@BSE - Rs " + js_RemoveChar(update[2]) + "'>";
	}
    if (update[1].indexOf(".NS") > 0){
		v_Curr_Price= "<input type='Hidden' name='curr_price' value='"+ "@NSE - Rs " + js_RemoveChar(update[2]) + "'>";
	}
	CurrPriceHidden.innerHTML = v_Curr_Price;


	  
	  if (Currentindex != null){Currentindex.innerHTML = update[2];}


	v_datetime = calTimeZoneTime(js_RemoveChar(update[3]) +" "+ js_RemoveChar(update[4]),4.5);
	//alert(calcTime(v_datetime,4.5));


	  if (sDate != null){sDate.innerHTML = v_datetime;}
//	   if (sDate != null){sDate.innerHTML = js_RemoveChar(update[3]);}
	  if (sTime != null){sTime.innerHTML = js_RemoveChar(update[4]);}


	//--color change 
	  v_Change_Col_Red= "<font color='#FF0000'>" + js_RemoveChar(update[5]) + "<BR>(" + js_RemoveChar(update[12]) + ")" + "<font>";
  	  v_Change_Col_Green= "<font color='#006600'>" + js_RemoveChar(update[5]) + "<BR>(" + js_RemoveChar(update[12]) + ")" + "<font>";

	  if (js_RemoveChar(update[5]) >= 0)
		  {Change.innerHTML = v_Change_Col_Green;}
	  else{Change.innerHTML = v_Change_Col_Red;}
	//--color change end 

	  if (DayOpen != null){DayOpen.innerHTML = update[6];}	  
	  if (DayHigh != null){DayHigh.innerHTML = update[7];}
	  if (sDayLow != null){sDayLow.innerHTML = update[8];}
	  if (Volumn != null){ Volumn.innerHTML = update[9];}
	  
	  if (PreviousDayClose != null){PreviousDayClose.innerHTML = update[11];}
	  if (ChangeInPercentage != null){ChangeInPercentage.innerHTML = js_RemoveChar(update[12]);}
	  if (FiftyTwoWeekRange != null){FiftyTwoWeekRange.innerHTML = js_RemoveChar(update[13]);}

	   if (GraphURL != null){
//			GraphURL.innerHTML = "<img src='http://ichart.finance.yahoo.com/t?s="+js_RemoveChar(update[1])+"'>";
			
	   }

//	   alert(js_RemoveChar(update[17]));
//		alert(js_RemoveChar(update[1]));

	  if (update[1].indexOf(".BO") > 0){
			BSENSECode.innerHTML = js_RemoveChar(update[1]).replace('.BO',"");
			BSETab.innerHTML = "<a class='active' href=javascript:getCurrentIndex("+update[0]+",'BSE');>BSE</a>";
			NSETab.innerHTML = "<a href=javascript:getCurrentIndex("+update[0]+",'NSE')>NSE</a>";
//			GraphURLW.innerHTML = "<a href=# onClick=window.open('http://ichart.finance.yahoo.com/w?s="+js_RemoveChar(update[1])+"','pa','width=540,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes')>5D</a>";
			
//			GraphURL1.innerHTML = "<img id=stockChart"+js_RemoveChar(update[1]).replace('.BO',"")+" src='http://www.icharts.in/ChartServe.php?symbol='"+js_RemoveChar(update[1]).replace('.BO',"")+"&chart_size=300' border='0'></img>";
//			GraphURL1.innerHTML = "<img id=stockChart"+js_RemoveChar(update[1]).replace('.BO',"")+" src='http://ichart.finance.yahoo.com/t?s="+js_RemoveChar(update[1])+"'></img>";
			GraphURL1.innerHTML = "<img id=stockChart"+js_RemoveChar(update[17]).replace('.BO',"")+" src='http://chartfeed.icharts.in/ShowChart.php?symbol="+js_RemoveChar(update[17]).replace('.BO',"")+"&period=Daily&chart_type=LINE&period_type=P&pr_period=1M&chart_size=300' border='0'></img>";
			GraphURLD1.innerHTML = "<div id=\"0D"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"Period\"><a title='Current Day' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"0\",\"0D\");'>Current</a></div>";
			GraphURLW1.innerHTML = "<div id=\"7D"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"Period\"><a title='Last 7 Days' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"7\",\"7D\");'>7D</a></div>";
			GraphURLW2.innerHTML = "<div id=\"15D"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"period\"><a title='Last 15 Days' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"15\",\"15D\");'>15D</a></div>";
			GraphURLM1.innerHTML = "<div id=\"1M"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"PeriodSelected\"><a title='Last 1 Month' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"1M\",\"1M\");'>1M</a></div>";
			GraphURLM6.innerHTML = "<div id=\"6M"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"period\"><a title='Last 6 Month' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"6M\",\"6M\");'>6M</a></div>";
			GraphURLY1.innerHTML = "<div id=\"1Y"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"period\"><a title='Last 1 Year' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"1Y\",\"1Y\");'>1Y</a></div>";
			GraphURLY2.innerHTML = "<div id=\"2Y"+js_RemoveChar(update[17]).replace('.BO',"")+"\" class=\"period\"><a title='Last 2 Year' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.BO',"")+"\",\"2Y\",\"2Y\");'>2Y</a></div>";
	  }
 	  if (update[1].indexOf(".NS") > 0){
			BSENSECode.innerHTML = js_RemoveChar(update[1]).replace('.NS',"");
			BSETab.innerHTML = "<a href=javascript:getCurrentIndex("+update[0]+",'BSE');>BSE</a>";
			NSETab.innerHTML = "<a class='active' href=javascript:getCurrentIndex("+update[0]+",'NSE')>NSE</a>";
//			GraphURLW.innerHTML = "<a href=# onClick=window.open('http://ichart.finance.yahoo.com/w?s="+js_RemoveChar(update[1]).toLowerCase()+"','pa','width=540,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes')>5D</a>";
//			GraphURLTM.innerHTML = "<a href=# onClick=window.open('http://chart.finance.yahoo.com/c/3m/w/"+js_RemoveChar(update[1]).toLowerCase()+"','pa','width=540,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes')>3M</a>";
//			GraphURLSM.innerHTML = "<a href=# onClick=window.open('http://chart.finance.yahoo.com/c/6m/w/"+js_RemoveChar(update[1]).toLowerCase()+"','pa','width=540,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes')>6M</a>";
//			GraphURLOY.innerHTML = "<a href=# onClick=window.open('http://chart.finance.yahoo.com/c/1y/w/"+js_RemoveChar(update[1]).toLowerCase()+"','pa','width=540,height=350,toolbar=no,location=no,directories=no,status=no,menbar=no,scrollbars=yes,resizable=yes')>1Y</a>";

//			GraphURL1.innerHTML = "<img id=stockChart"+js_RemoveChar(update[1]).replace('.NS',"")+" src='http://www.icharts.in/ChartServe.php?symbol="+js_RemoveChar(update[1]).replace('.NS',"")+"&chart_size=300' border='0'></img>";
			GraphURL1.innerHTML = "<img id=stockChart"+js_RemoveChar(update[17]).replace('.NS',"")+" src='http://chartfeed.icharts.in/ShowChart.php?symbol="+js_RemoveChar(update[17]).replace('.NS',"")+"&period=Daily&chart_type=LINE&period_type=P&pr_period=1M&chart_size=300' border='0'></img>";
			GraphURLD1.innerHTML = "<div id=\"0D"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"Period\"><a title='Current Day' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"0\",\"0D\");'>Current</a></div>";
			GraphURLW1.innerHTML = "<div id=\"7D"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"Period\"><a title='Last 7 Days' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"7\",\"7D\");'>7D</a></div>";
			GraphURLW2.innerHTML = "<div id=\"15D"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"period\"><a title='Last 15 Days' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"15\",\"15D\");'>15D</a></div>";
			GraphURLM1.innerHTML = "<div id=\"1M"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"PeriodSelected\"><a title='Last 1 Month' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"1M\",\"1M\");'>1M</a></div>";
			GraphURLM6.innerHTML = "<div id=\"6M"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"period\"><a title='Last 6 Month' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"6M\",\"6M\");'>6M</a></div>";
			GraphURLY1.innerHTML = "<div id=\"1Y"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"period\"><a title='Last 1 Year' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"1Y\",\"1Y\");'>1Y</a></div>";
			GraphURLY2.innerHTML = "<div id=\"2Y"+js_RemoveChar(update[17]).replace('.NS',"")+"\" class=\"period\"><a title='Last 2 Year' href='javascript:funModifyStockChart(\""+js_RemoveChar(update[17]).replace('.NS',"")+"\",\"2Y\",\"2Y\");'>2Y</a></div>";

	  } 


//	alert(js_RemoveChar(update[1]).replace('.BO',""));

	
	}
	}
  }
	catch(e){alert("an error occured");}
	finally{}
}

function js_RemoveChar(str)
{
	charToRemove = '"';
	regExp = new RegExp("["+charToRemove+"]","g");
	return str.replace(regExp,"");

}


//This function will chnage the date for given timezone.
//Get the current timezone details and get the GMT time from there.
//Then it will add given offset time
function calTimeZoneTime(dDate, offset) {

    // create Date object for current location
    d = new Date();
    in_date = new Date(dDate)
    // convert to msec
    // add local time zone offset 
    // get GMT/UTC time in msec
	utc = in_date.getTime() + (d.getTimezoneOffset() * 60000);
    // create new Date object for different city
    // using supplied offset
    nd = new Date(utc + (3600000*offset));

	var y=nd.getYear()+"";
	var M=nd.getMonth()+1;
	var d=nd.getDate();
	var H=nd.getHours();
	var m=nd.getMinutes();
	var s=nd.getSeconds();
	var result="";

	if (H==0){ h=12;}
	else if (H>12){h=H-12;}
	else {h=H;}
	
	if (H > 11) { a = "PM"; }
	else { a = "AM"; }

	if (isNaN(M))
	{
		result="";
	}else
		{
		result = M + "/" + d + "/" + y + " " + h + ":" + m + " " + a;	
		}
//	 document.write(M + "/" + d + "/" + y + " " + H + ":" + m + " " + a);
//	document.write("The local time zone is: GMT " + gmtHours + " and " + nd.toLocaleString());
//	result = M + "/" + d + "/" + y + " " + h + ":" + m + " " + a;
	return result;
	}


-->
