﻿// JScript File

//Creating object of XMLHTTP For AJAX Method
function CreateXmlHttpLN()
{
    //Creating object of XMLHTTP in IE
	try
	{
	    XmlHttp_LN = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttp_LN = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp_LN = null;	
		}
	} 
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp_LN && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp_LN = new XMLHttpRequest();
	}
}



function getNews(secid,subsecid,type)
{
       closeallMarket();
       document.getElementById("ML"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabLef1.gif align=absbottom />";
       document.getElementById("MM"+type).className="TabTextSel";
       document.getElementById("MR"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabRig1.gif align=absbottom />";
    


       

    CreateXmlHttpLN();
    
    
    
    document.getElementById("NewsTD").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	document.body.style.cursor = "progress";

    var requestUrl="AjaxHomeNews.aspx?Sec="+secid+"&SubSec="+subsecid+"&timeStamp="+new Date().getTime();
   
	if(XmlHttp_LN)
	{
		
		XmlHttp_LN.onreadystatechange=function(){getNewsData();};
		XmlHttp_LN.open("GET",requestUrl,true);
		XmlHttp_LN.send(null);
	}
}
function closeallMarket()
{
    for(var i=1;i<=4;i++)
    {
        
        document.getElementById("ML"+i).innerHTML ="";
        document.getElementById("MM"+i).className="TabTextUnSel";
        document.getElementById("MR"+i).innerHTML ="";

    

      
    }
}
function getNewsData()
{
    if(XmlHttp_LN.readyState==4)
	{
	    if(XmlHttp_LN.status == 200)
		{
   		    document.getElementById("NewsTD").innerHTML=XmlHttp_LN.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			document.getElementById("NewsTD").innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}

function CreateXmlHttpGN()
{
    //Creating object of XMLHTTP in IE
	try
	{
	    XmlHttp_GN = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttp_GN = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp_GN = null;	
		}
	} 
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp_GN && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp_GN = new XMLHttpRequest();
	}
}

function getGeneralNews(secid,subsecid,type)
{
       closeallGeneral()
       document.getElementById("GL"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabLef1.gif align=absbottom />";
       document.getElementById("GM"+type).className="TabTextSel";
       document.getElementById("GR"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabRig1.gif align=absbottom />";
      
  
    document.getElementById("GeneralNewsTD").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	document.body.style.cursor = "progress";

        CreateXmlHttpGN();
    
    
    
    
    var requestUrl="AjaxHomeNews.aspx?Sec="+secid+"&SubSec="+subsecid+"&timeStamp="+new Date().getTime();
   
	if(XmlHttp_GN)
	{
		
		XmlHttp_GN.onreadystatechange=function(){getGeneralNewsData();};
		XmlHttp_GN.open("GET",requestUrl,true);
		XmlHttp_GN.send(null);
	}
}

function getGeneralNewsData()
{
    if(XmlHttp_GN.readyState==4)
	{
	    if(XmlHttp_GN.status == 200)
		{
   		    document.getElementById("GeneralNewsTD").innerHTML=XmlHttp_GN.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			document.getElementById("GeneralNewsTD").innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}

function closeallGeneral()
{
    for(var i=1;i<=2;i++)
    {
      
        document.getElementById("GL"+i).innerHTML ="";
        document.getElementById("GM"+i).className="TabTextUnSel";
        document.getElementById("GR"+i).innerHTML ="";

    

      
    }
}




function CreateXmlHttpFN()
{
    //Creating object of XMLHTTP in IE
	try
	{
	    XmlHttp_FN = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttp_FN = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp_FN = null;	
		}
	} 
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp_FN && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp_FN = new XMLHttpRequest();
	}
}

function getFundNews(secid,subsecid,type)
{
      

        CreateXmlHttpFN();
    
    
    
    document.getElementById("FundNews").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	document.body.style.cursor = "progress";

    var requestUrl="AjaxHomeNews.aspx?Sec="+secid+"&SubSec="+subsecid+"&timeStamp="+new Date().getTime();

	if(XmlHttp_FN)
	{
		
		XmlHttp_FN.onreadystatechange=function(){getFundNewsData();};
		XmlHttp_FN.open("GET",requestUrl,true);
		XmlHttp_FN.send(null);
	}
}

function getFundNewsData()
{
    if(XmlHttp_FN.readyState==4)
	{
	    if(XmlHttp_FN.status == 200)
		{
   		    document.getElementById("FundNews").innerHTML=XmlHttp_FN.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			document.getElementById("FundNews").innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}


function CreateXmlHttpCN()
{
    //Creating object of XMLHTTP in IE
	try
	{
	    XmlHttp_CN = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
	    try
		{
			XmlHttp_CN = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp_CN = null;	
		}
	} 
	
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp_CN && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp_CN = new XMLHttpRequest();
	}
}



function getCorporateNews(secid,subsecid,type)
{
       closeallCorporate();
       document.getElementById("CL"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabLef1.gif align=absbottom />";
       document.getElementById("CM"+type).className="TabTextSel";
       document.getElementById("CR"+type).innerHTML ="<img src=../App_Themes/HomeCommon/Homeimages/OrTabRig1.gif align=absbottom />";
    




    CreateXmlHttpCN();
    
    
    
    document.getElementById("CorporateNews").innerHTML = "<table align=center><tr><td ><img src =../App_Themes/HomeCommon/Homeimages/loader.gif /></td></tr></table>";
	document.body.style.cursor = "progress";
    var requestUrl="AjaxHomeNews.aspx?Sec="+secid+"&SubSec="+subsecid+"&timeStamp="+new Date().getTime();
   
	if(XmlHttp_LN)
	{
		
		XmlHttp_CN.onreadystatechange=function(){getCorporateData();};
		XmlHttp_CN.open("GET",requestUrl,true);
		XmlHttp_CN.send(null);
	}
}

function getCorporateData()
{
    if(XmlHttp_CN.readyState==4)
	{
	    if(XmlHttp_CN.status == 200)
		{
   		    document.getElementById("CorporateNews").innerHTML=XmlHttp_CN.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
			document.getElementById("CorporateNews").innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}
function closeallCorporate()
{
    for(var i=1;i<=2;i++)
    {
        
        document.getElementById("CL"+i).innerHTML ="";
        document.getElementById("CM"+i).className="TabTextUnSel";
        document.getElementById("CR"+i).innerHTML ="";

    

      
    }
}



var XmlHttpNews;

function CreateXmlHttpNews()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttpNews = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttpNews = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttpNews = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttpNews && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttpNews = new XmlHttpRequest();
		}
		if (!XmlHttpNews && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpNews = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpNews=false;
	        }
        }
	}



function GetNewsDetail(secId,SubSecId,NewsID,opt)
{
 

	 //var MoreGLVV=document.getElementById("MoreGLVV"); 
	CreateXmlHttpNews();

	var requestUrl = "PopupNews.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
	
    //window.location.href = requestUrl;		
	if(XmlHttpNews)	
	{
	    XmlHttpNews.onreadystatechange = function(){getDetailsResp();};
		XmlHttpNews.open("GET", requestUrl,  true);
		XmlHttpNews.send(null);					
	}
}
	
function getDetailsResp()
{
  
    // To make sure receiving response data from server is completed
	if(XmlHttpNews.readyState == 4)
	{
	    // To make sure valid response is received from the server, 200 means response received is OK
	    
	    
	    
		if(XmlHttpNews.status == 200)
		{
		   
		   var News= document.getElementById("divNews").style.display='inline';
		    document.getElementById("TDNews").innerHTML = XmlHttpNews.responseText;
		    
			//var strData = XmlHttpNew.responseText;
			
			//News.innerHTML = "<marquee  onmouseout='this.start();' trueSpeed scrollAmount='1' height=126px scrollDelay='150' direction='up' loop='repeat' width='100%'></marquee>";
			document.body.style.cursor = "auto";
		}
		else
		{
		    document.getElementById("TDNews").innerHTML = "<img src=../App_Themes/Common/images/ajax-loader.gif>";
		}
	}
}
