﻿var HideOption = "tr";
function browserVersion() {
    var brVerId = navigator.userAgent.search("Firefox/");
    if (brVerId != -1) {
        var brNum = navigator.userAgent.substring(brVerId + 8, brVerId + 9);
        if (parseInt(brNum) < 3) HideOption = "td";
        else HideOption = "tr";
    }
    else HideOption = "tr";
}
browserVersion();
var XmlHttpSch;
function CreateXmlHttpSch() {
    
    try {
        XmlHttpSch = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            XmlHttpSch = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (oc) {
            XmlHttpSch = null;

        }
    }
    if (!XmlHttpSch && typeof XMLHttpRequest != "undefined") {
        XmlHttpSch = new XMLHttpRequest();
    }
    return XmlHttpSch;
}

function TopGLHome(Exchg, option) 
{
    document.getElementById("imgGL").src = "images/Today_Market_Left_Arrow.gif";
   // document.getElementById("IMGHL").src = "images/newHighLow_Off_Arrow.gif";
    document.getElementById("btnhigh").className = 'TabGainLossOff';
    document.getElementById("btnLow").className = 'TabGainLossOff';
    document.getElementById("tblGainLoss").style.display = 'inline';
    document.getElementById("tblHighLow").style.display = 'inline';
    if (Exchg == "BSE") {
        document.getElementById("btnBSEGL").className = 'BtnOn';
        document.getElementById("btnNSEGL").className = 'BtnOff';
    }
    else if (Exchg == "NSE") {
        document.getElementById("btnBSEGL").className = 'BtnOff';
        document.getElementById("btnNSEGL").className = 'BtnOn';
    }
    else if (Exchg == "") {
    if (document.getElementById("btnBSEGL").className == "BtnOn") {
        Exchg = "BSE";
    }
    else {
        Exchg = "NSE";
    }
    }
    if (option == "GAIN") {
        document.getElementById("btnGain").className = 'TabGainLossOn';
        document.getElementById("btnLoss").className = 'TabGainLossOff';
    }
    else if (option == "LOSE") {
        document.getElementById("btnGain").className = 'TabGainLossOff';
        document.getElementById("btnLoss").className = 'TabGainLossOn';
    }
    else if (option == "") {
    if (document.getElementById("btnGain").className == "TabGainLossOn") {
        option = "GAIN";
        }
        else {
            option = "LOSE";
        }
    }
    var HomGLUrl = "pgDataGL.aspx?Exchg=" + Exchg + "&strpage=" + option;
    document.getElementById("TdGLVV").innerHTML = "<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center' valign='top' height='126px'><img src='../images/loading.gif'></td></tr></table>";
    var ajax = new Ajax.Updater('TdGLVV', HomGLUrl);
}

function NewHighLow(Exchg, option) {

    document.getElementById("IMGHL").src = "images/Today_Market_Left_Arrow.gif";
    //document.getElementById("imgGL").src = "images/newHighLow_Off_Arrow.gif";
    document.getElementById("btnGain").className = 'TabGainLossOff';
    document.getElementById("btnLoss").className = 'TabGainLossOff';
    document.getElementById("tblGainLoss").style.display = 'inline';
    document.getElementById("tblHighLow").style.display = 'inline';
    if (Exchg == "BSE") {
        document.getElementById("btnBSEHL").className = 'BtnOn';
        document.getElementById("btnNSEHL").className = 'BtnOff';
    }
    else if (Exchg == "NSE") {
        document.getElementById("btnBSEHL").className = 'BtnOff';
        document.getElementById("btnNSEHL").className = 'BtnOn';
    }
    else if (Exchg == "") {
        if (document.getElementById("btnBSEHL").className == "BtnOn") {
            Exchg = "BSE";
        }
        else {
            Exchg = "NSE";
        }
    }
    if (option == "HIGH") {
        document.getElementById("btnhigh").className = 'TabGainLossOn';
        document.getElementById("btnLow").className = 'TabGainLossOff';
    }
    else if (option == "LOW") {
    document.getElementById("btnhigh").className = 'TabGainLossOff';
    document.getElementById("btnLow").className = 'TabGainLossOn';
    }
    else if (option == "") {
    if (document.getElementById("btnhigh").className == "TabGainLossOn") {
        option = "HIGH";
        }
        else {
            option = "LOW";
        }
    }
    var HomGLUrl = "pgDataHL.aspx?Exchg=" + Exchg + "&option=" + option;
    document.getElementById("tdHL").innerHTML = "<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center' valign='top'><img src='images/loading.gif'></td></tr></table>";
    var ajax = new Ajax.Updater('tdHL', HomGLUrl);
}
function LoadNews(SrNo, Type, cocode) {
    document.getElementById("L_NewsDetails").innerHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'><img src='images/loading.gif'></td></tr></table>";
    CreateXmlHttpSch();
    var Dt = Date();
    var LBUrl = "/News/NewsDetails.aspx?SrNo=" + SrNo + "&Type=" + Type + "&cocode=" + cocode;
    if (XmlHttpSch) {
        XmlHttpSch.onreadystatechange = function() { GetData1(); };
        XmlHttpSch.open("GET", LBUrl, true);
        XmlHttpSch.send(null);
    }
}

function GetData1() {
   
    if (XmlHttpSch.readyState == 4) {
        if (XmlHttpSch.status == 200) {
            var response = XmlHttpSch.responseText;
            document.getElementById("L_NewsDetails").innerHTML = response;
        }
        else {
            alert("Internal Server Error.Please Try after some time");
        }
    }
}
function ShowMe(ID) {
    document.getElementById("tblPopNewsWin").style.display = "inline";
}


function DisplayComp() 
{
   document.getElementById("popup").style.display = "inline";
}

function show_popup1(cocode,Exchg,m_im_id, m_im_shortdesc, m_im_desc, m_ff_desc, m_ff_id, m_fundclass) {
    f_im_id = m_im_id;
    f_im_shortdesc = m_im_shortdesc;
    f_im_desc = m_im_desc;
    f_ff_desc = m_ff_desc;
    f_ff_id = m_ff_id;
    f_fundclass = m_fundclass;

    if (tempX > 700) {
        tempX = tempX - 200;
    }
    if (m_im_id == "100") {
        tempY = tempY - 200;
    }
    document.getElementById("popup").style.left = tempX + "px";
    document.getElementById("popup").style.top = tempY + "px";
    document.getElementById("popup").style.display = "inline";
    m_show = 1;
    document.getElementById("tdCompData").innerHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'><img src='/images/loading.gif'></td></tr></table>";
    var LBUrl = "/GetCompPopData.aspx?Exchg=" + Exchg + "&cocode=" + cocode;
    var ajax = new Ajax.Updater('tdCompData', LBUrl);
    
}
var tempX = 0;
var tempY = 0;
var m_show = 0;
var f_sc_id = "";
var f_sc_dispid = "";
var f_sc_comp = "";
var f_topic_id = 0;
var f_buy_id = 0;

var IE = document.all ? true : false

if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

function getMouseXY(e) {
    if (IE) {

        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else {
        tempX = e.pageX;
        tempY = e.pageY;
    }
    return true;
}

function hide_popup1() 
{
   document.getElementById("popup").style.display = "none";
}

function show_CompanyDetails(Exchg,cocode) 
{
    document.getElementById("CompanyDetail").innerHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'><img src='/images/loading.gif'></td></tr></table>";
    var LBUrl = "/GetCompDetails.aspx?Exchg=" + Exchg + "&cocode=" + cocode;
    var ajax = new Ajax.Updater('CompanyDetail', LBUrl);
    document.getElementById("CompanyDetail").style.display = "inline";
}

//For Commodity/Currenncy Tabs in Home page
function GetCommCurrData(option)
{
	if(option == "COM")
	{
	    document.getElementById("ImgCommodity").className = 'TabGainLossOn';
        document.getElementById("ImgCurrncy").className = 'TabGainLossOff';
	  	HomCommCurrUrl = "../HomeCommData.aspx";	
    }
	else
	{
		document.getElementById("ImgCommodity").className = 'TabGainLossOff';
        document.getElementById("ImgCurrncy").className = 'TabGainLossOn';
		HomCommCurrUrl = "../HomeCurrencyData.aspx";
	}
		
	document.getElementById("TdComCurrency").innerHTML="<table cellpadding='0' cellspacing='0' width='100%'><tr><td align='center' height='100px'><img src='../images/Loading.gif'></td></tr></table>";
	var ajax = new Ajax.Updater('TdComCurrency',HomCommCurrUrl);  
}





