﻿// JScript File
function MatrixRefresh(type)
	{MatrixGridData(type);}
function MatrixGridData(PageNo)
{
	document.body.style.cursor = "progress";
	var requestUrl = "AjaxProfitMatrixGrid.aspx?PageNo="+ PageNo +"&timeStamp="+new Date().getTime();	
	document.getElementById("tdMatrixEq").style.display="" ;
  ajaxpage(1,requestUrl, 'MarketEyeBind')
}

function MarketEyeDetails()
{ document.getElementById("divNews").style.display="" ;	var requestUrl = "AjaxMarketEyeDetails.aspx?timeStamp="+new Date().getTime();	
     ajaxpage(1,requestUrl, 'NewsPop')
}	
  function AddEditProfitMatrix()
    { 
          document.getElementById("MatrixData").style.display="none" ;
          document.getElementById("TdAddComp").style.display='';
          document.getElementById("tdControls").style.display='none';
    } 
    function AddClose()
	{
	 document.getElementById("MatrixData").style.display="" ;
     document.getElementById("TdAddComp").style.display='none';
     document.getElementById("tdControls").style.display='';
   
    }
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""    

function SchResultEye()
 {
 	 var txtSchName = document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_txtSchName");
	 if(txtSchName.value=="Enter Company Name")
	{ 
	alert("Please Enter some text");
	} 
	else
		{
 		var SearchResult = document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchResult");	
 		var page_request = false
        if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
        else if (window.ActiveXObject)
        { // if IE
                try {
                    page_request = new ActiveXObject("Msxml2.XMLHTTP")
                    } 
                catch (e){
                        try{
                            page_request = new ActiveXObject("Microsoft.XMLHTTP")
                        }
                        catch (e){}
                        }
        }
        else
        return false
		document.body.style.cursor = "progress";
		var requestUrl = "GetSchDataAjax.aspx?timeStamp="+ new Date().getTime() +"&txtSchName="+txtSchName.value;
	        page_request.onreadystatechange=function()
        {
            fillSymbolRespEye(page_request,SearchResult)
        }

    if (bustcachevar) //if bust caching of external page
    bustcacheparameter=(requestUrl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', requestUrl+bustcacheparameter, true)
    page_request.send(null)
		
    }
 }
 
  function RemoveC2P()
{
        if(document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_txtSchName").value=="Enter Company Name")
        {
            document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_txtSchName").value="";
        }
}

 
 //Called when response comes back from server Only For Symbol
function fillSymbolRespEye(page_request, ig_)
{

	// To make sure receiving response data from server is completed
	if(page_request.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(page_request.status == 200)
		{		
			
			//var availSchemes   = document.getElementById(ig_);
			var strData = page_request.responseText
			//alert(strData)
			if(strData != "") {	
			    
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) {	
								
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "No Data Found";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}

function StoreSch()
{
    var search=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchResult");
    var SchMine=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchMine");
   
     var len = SchMine.length;
        if(len>=10)
        {
            alert('You already have the maximum limit of Ten');
              return false;
        }
       
       for(i=0; i<len; i++)
        {
		 if (SchMine.options[i].text == search.options[search.selectedIndex].outerText)
		 {
		 alert("You already have this Name in your list");
		 return false;
		 }
		  
	
		}
     
    var Tempstr;
    
        SchMine.options[len] = new Option();
        for(j=len-1; j>-1; j--)
        {
	SchMine.options[j+1].value = SchMine.options[j].value
	SchMine.options[j+1].text = SchMine.options[j].text
	     
	   	}
    
    
   
    SchMine.options[0].value = search.value;
	SchMine.options[0].text = search.options[search.selectedIndex].outerText; 

    
        if(search=="")
        {
            alert('select Company Name');
        }
       
       return false;
       
        }
        
        function MoveUpSch()
	{

    var SchMine=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchMine");
	var TempVal1 ,TempTxt1;
	var TempVal2 ,TempTxt2;
	 
	 if (SchMine.selectedIndex<0)
	 {
	 alert("Please select a name from list");
	 return false;
	 }
	
	 
	 if (SchMine.selectedIndex<=0)
	 {
	 return false;
	 }
	 
	 TempVal1=SchMine.options[SchMine.selectedIndex].value;
	 TempTxt1=SchMine.options[SchMine.selectedIndex].outerText; 
	 
     TempVal2=SchMine.options[SchMine.selectedIndex-1].value;
	 TempTxt2=SchMine.options[SchMine.selectedIndex-1].outerText; 
	 
	
	SchMine.options[SchMine.selectedIndex].value = TempVal2;
	SchMine.options[SchMine.selectedIndex].text = TempTxt2; 
	
	SchMine.options[SchMine.selectedIndex-1].value = TempVal1;
	SchMine.options[SchMine.selectedIndex-1].text = TempTxt1; 
	
	
	SchMine.selectedIndex = SchMine.selectedIndex-1;
	}
	
	
		function MoveDownSch()
	{

	 var SchMine=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchMine");
	var TempVal1 ,TempTxt1;
	var TempVal2 ,TempTxt2;
	 var len = SchMine.length;
	 
	 if (SchMine.selectedIndex<0)
	 {
	 alert("Please select a name from list");
	 return false;
	 }
	
	 
	  if (SchMine.selectedIndex>=len-1)
	 {
	 return false;
	 }
	 
	 TempVal1=SchMine.options[SchMine.selectedIndex].value;
	 TempTxt1=SchMine.options[SchMine.selectedIndex].outerText; 
	 
     TempVal2=SchMine.options[SchMine.selectedIndex+1].value;
	 TempTxt2=SchMine.options[SchMine.selectedIndex+1].outerText; 
	 
	
	SchMine.options[SchMine.selectedIndex].value = TempVal2;
	SchMine.options[SchMine.selectedIndex].text = TempTxt2; 
	
	SchMine.options[SchMine.selectedIndex+1].value = TempVal1;
	SchMine.options[SchMine.selectedIndex+1].text = TempTxt1; 
	SchMine.selectedIndex = SchMine.selectedIndex+1;
	
	}

function DeleteSch()
	{
	
    var SchMine=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchMine");
 
    if (SchMine.selectedIndex<0)
	 {
	 alert("Please select a name from list");
	 return false;
	 }
	 
    if (SchMine.selectedIndex==0)
    {
    if (SchMine.options[1] == null)
    {
    alert('The only remaining Name cannot be deleted');
    return false;
    }
    }
    SchMine.options[SchMine.selectedIndex] = null;
      //alert(SchMine.length)


	
	return false;
	
	}


function SaveSch()
   {   
   
     var SchMine=document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_lbSchMine");
      
      var len = SchMine.length;   
    
   for(var i=0;i<len;i++)
   
    {
         document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_hidSchValue"+i).value=SchMine.options[i].value;
        document.getElementById("MarketEye1_ProfitMatrixGrid1_AddEditProfitMatrix1_hidSchText"+i).value=SchMine.options[i].text;
         //alert( document.getElementById(SchMineCtrl+"_hidSchText"+i).value);
    }
	 document.getElementById("MatrixData").style.display="" ;
     document.getElementById("TdAddComp").style.display='none';
    
}

function MovePrev()
	{
 	MatrixRefresh(1);
   }
    
    function MoveNext()
	{
 	 MatrixRefresh(2);
 	 }
 	 
 	 function Showdetails1(rowid,FinCode,Exchg,Cnt,type)
    {
        var GridId,GridPlusID,GridMinusID,GID,GPID;
          var tdet;
         if(type=='EQ') {GID="Griddetails";GPID="Grid1";tdet="Griddetails"+rowid;}
         else {GID="GridMFdetails";GPID="Grid1MF";tdet="GridMFdetails"+rowid;}
     
        for(i=10; i<=Cnt-1; i++)
			{
			  GridId=GID + i;
			  GridPlusID=GPID+"Plus"+ i;
			  GridMinusID=GPID+"Minus"+ i;
			//  	   DivID="#sdiv"+i;
			
			if (i==rowid)
			{
			
			document.getElementById(GridId).style.display = "";   
			document.getElementById(GridPlusID).style.display = "none";  
           document.getElementById(GridMinusID).style.display = "";  
             //$("#sdiv10").slideDown(500);

			}
			else
			{
		
		   document.getElementById(GridId).style.display = "none";   
		   document.getElementById(GridPlusID).style.display = "";  
           document.getElementById(GridMinusID).style.display = "none";  
			}
		
		}
		
		
 GridDetailsWindow(tdet,FinCode,Exchg,rowid,type);
		
		}
		
function Showdetails2(rowid,FinCode,Exchg,Cnt,type)
    {
        var GridId,GridPlusID,GridMinusID,GID,GPID;
           var tdet;
         if(type=='EQ'){tdet="Griddetails"+rowid;GID="Griddetails";GPID="Grid2"}
		  else{tdet="GridMFdetails"+rowid;GID="GridMFdetails";GPID="Grid2MF"}
        
		for(i=20; i<=Cnt-1; i++)
			{
			  GridId=GID + i;
			  GridPlusID=GPID+"Plus"+ i;
			  GridMinusID=GPID+"Minus"+ i;
			   //DivID="#sdiv"+i;
			  
			if (i==rowid)
			{
			document.getElementById(GridId).style.display = "";   
			document.getElementById(GridPlusID).style.display = "none";  
           document.getElementById(GridMinusID).style.display = "";  
         //  $(DivID).slideDown(1000);

			}
			
			else
			{
		   document.getElementById(GridId).style.display = "none";   
		   document.getElementById(GridPlusID).style.display = "";  
           document.getElementById(GridMinusID).style.display = "none";  
			}
		}
        
        
 
    GridDetailsWindow(tdet,FinCode,Exchg,rowid,type);
    
    
    
    }
    
var XmlHttpGridDetails;

function CreateXmlHttpGridDetails()
{
    try
	{
		XmlHttpGridDetails = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpGridDetails = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpGridDetails = null;
		}
	}
	if(!XmlHttpGridDetails && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpGridDetails = new XMLHttpRequest();
	}
}

function GridDetailsWindow(TdDetails,FinCode,Exchg,rowid,type)
{
  var requestUrl
    CreateXmlHttpGridDetails();
    var currentDivObj = document.getElementById(TdDetails);
    currentDivObj.innerHTML ="<img src=../App_Themes/Common/Images/ajax-loader.gif />";
    document.body.style.cursor = "progress";
requestUrl = "ProfitMatrixGridDetails.aspx?FinCode="+FinCode+"&Exchg="+Exchg+"&rowid="+rowid;
    if(XmlHttpGridDetails!=null)	
	{
	    XmlHttpGridDetails.onreadystatechange = function(){ChangeResponseGridDetails(TdDetails,FinCode,Exchg,type)}
		XmlHttpGridDetails.open('GET', requestUrl,  true);
		XmlHttpGridDetails.send(null);
	}
	

    return false;
}

function ChangeResponseGridDetails(TdDetails,FinCode,Exchg,type)
{

	if(XmlHttpGridDetails.readyState == 4)
	{
	    var td_Id = document.getElementById(TdDetails);
		if(XmlHttpGridDetails.status == 200)//
		{
		td_Id.innerHTML =  XmlHttpGridDetails.responseText;
		
			document.body.style.cursor = "auto";		
			ShowChart_Profit_Inner(FinCode,Exchg);
			
		}
		else
		{
		    td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
	
}	

function ShowChart_Profit_Inner(FinCode,Exchg)
{
document.getElementById("ChartBSEPR"+FinCode).className="TickTabUnSelect";
document.getElementById("ChartNSEPR"+FinCode).className="TickTabUnSelect";
document.getElementById("Chart"+Exchg+"PR"+FinCode).className="TickTabSelect";
 // <![CDATA[		
		var so = new SWFObject("amline/amline.swf", "SnapChart_settings", "264", "170", "1", "#ECECEC");
		so.addVariable("path", "amline/");
		so.addParam("wmode","opaque");
		so.addVariable("settings_file", encodeURIComponent("ProfitExcgChart.xml"));
		so.addVariable("data_file", encodeURIComponent("ProfitExcgChart.aspx?timenow=" + new Date().getTime() + "&FinCode="+FinCode +"&period=1Y&Exchg="+Exchg));
		so.write("flashcontentPro"+FinCode);
		// ]]>
}
 function Hidedetails(Str,type)
{
	var GridId,GridPlusID,GridMinusID,DivID,GID,GPID;
	 if(type=='EQ'){GID="Griddetails";GPID="Grid1";}
		  else{GID="GridMFdetails";GPID="Grid1MF";}
	 GridId=GID+ Str;
	 GridPlusID=GPID+"Plus"+ Str;
	 GridMinusID=GPID+"Minus"+ Str;
	
	 document.getElementById(GridId).style.display="none";
 	 document.getElementById(GridPlusID).style.display="";
     document.getElementById(GridMinusID).style.display="none";
    //$("#sdiv10").slideUp(1000);
  
    }
     function Hidedetails2(Str,type)
{
	var GridId,GridPlusID,GridMinusID,DivID,GID,GPID;
	 if(type=='EQ'){GID="Griddetails";GPID="Grid2";}
		  else{GID="GridMFdetails";GPID="Grid2MF";}
	 GridId=GID+ Str;
	 GridPlusID=GPID+"Plus"+ Str;
	 GridMinusID=GPID+"Minus"+ Str;
	
	 document.getElementById(GridId).style.display="none";
 	 document.getElementById(GridPlusID).style.display="";
     document.getElementById(GridMinusID).style.display="none";
    //$("#sdiv10").slideUp(1000);
  
    }
    
    function GetNewsDetail(secId,SubSecId,NewsID,FinCode,opt)
{	
    var NewsWin = document.getElementById("divNews").style.display='';	
	document.body.style.cursor = "progress";
	var requestUrl = "News/GetNews.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"&opt="+opt+"&FinCode="+FinCode;
	ajaxpage(1,requestUrl,'NewsPop');
}

function sensexvalue(val)
{

if(val=='BSE')
    {
        document.getElementById('sec_1').style.backgroundColor="#e2e2e2";
        document.getElementById('sec_2').style.backgroundColor="#f0f0f0";
        document.getElementById('sec_11').style.display="";
        document.getElementById('sec_22').style.display="none";
        document.getElementById("chart").src="http://content.acesphere.com/charts/nirmanbse.png?time="+new Date().getTime();
        
    }
    else
    {
        document.getElementById('sec_2').style.backgroundColor="#e2e2e2";
        document.getElementById('sec_1').style.backgroundColor="#f0f0f0";
        document.getElementById('sec_11').style.display="none";
        document.getElementById('sec_22').style.display=""; 
        document.getElementById("chart").src="http://content.acesphere.com/charts/nirmannse.png?time="+new Date().getTime();
       
    }
   
    GetData(val);
    return true;   

}	
function sensexvalueAuto()
{

    if(SelectedTab=='BSE')
    {
        ChangeControl("GAIN","BSE");
        document.getElementById('sec_1').style.backgroundColor="#e2e2e2";
        document.getElementById('sec_2').style.backgroundColor="#f0f0f0";
        document.getElementById('sec_11').style.display="";
        document.getElementById('sec_22').style.display="none";
        document.getElementById("chart").src="http://content.acesphere.com/charts/nirmanBse.png?time=" + new Date().getTime() + "";
     }
    else
    {
         ChangeControl('GAIN','NSE');
        document.getElementById('sec_2').style.backgroundColor="#e2e2e2";
        document.getElementById('sec_1').style.backgroundColor="#f0f0f0";
        document.getElementById('sec_11').style.display="none";
        document.getElementById('sec_22').style.display="";
        document.getElementById("chart").src="http://content.acesphere.com/charts/nirmannse.png?time=" + new Date().getTime() + "";
    }
  
}
function GetData(Exch)
{ document.body.style.cursor = "progress";var requestUrl = "AjaxGainLoseVol.aspx?Exch="+ Exch +"&timeStamp="+new Date().getTime();
    ajaxpage(1,requestUrl,'GLVol_Td');
}

function GetIndices(Exch)
{ document.body.style.cursor = "progress";var requestUrl = "AjaxInterNationalIndices.aspx?Contiment="+ Exch +"&timeStamp="+new Date().getTime();
    ajaxpage(1,requestUrl,'InternationalData');
}
function LoadNFOUpdate(Option)
	{document.body.style.cursor = "progress";var requestUrl = "AjaxNFOUpdateData.aspx?&Option="+Option;
	ajaxpage(1,requestUrl,'NFOId');
	}

function OpenTrade()
	{
		var wind;
		wind=window.open("http://www.nowonline.in" ,"Nirman");
		wind.focus();
	}
