﻿// JScript File

/* Forex Ctrl */

var browser = new Browser();

function Browser() {
  var ua, s, i;
  this.isIE    = false;
  this.isNS    = false;
  this.version = null;
  ua = navigator.userAgent;
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}











var url;

    var containerid="contentarea";
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=""

var XmlHttpForex;

function CreateXmlHttpForex()
{
    try
	{
		XmlHttpForex = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpForex = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpForex = null;
		}
	}
	if(!XmlHttpForex && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpForex = new XMLHttpRequest();
	}
}
function GetDataForex()
{
    CreateXmlHttpForex();
    var currentDivObj = document.getElementById("Forexdata");
	currentDivObj.innerHTML ="<img src=App_Themes/Seeta/Images/loading.gif>";
	document.body.style.cursor = "progress";
	var requestUrl = "AjaxForex.aspx?Exchange="+ Math.random();
	if(XmlHttpForex!=null)	
	{
	    XmlHttpForex.onreadystatechange = function(){ChangeResponseForex()}
		XmlHttpForex.open('GET', requestUrl,  true);
		XmlHttpForex.send(null);
	}
	return false; 
}	
	
function ChangeResponseForex()
{
	if(XmlHttpForex.readyState == 4)
	{
	    var td_Id = document.getElementById("Forexdata");
		if(XmlHttpForex.status == 200)//
		{
			td_Id.innerHTML =  XmlHttpForex.responseText;
			document.body.style.cursor = "auto";		
		}
		else
		{
		    td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			document.body.style.cursor = "auto";
		}
	}
}	






function ChangeBseNSeVal(val)
{

        if(val=='BSE')
        {
           // alert(val);
           document.getElementById('tdBSE').className="ValVolVctlunsel";
           document.getElementById('tdNSE').className="ValVolVctlsel";
           document.getElementById("chart").src="http://content.acesphere.com/Charts/BNKCapitalBse.png?time=" + new Date().getTime();
            document.getElementById('Sensex').style.display="inline";
            document.getElementById('Nifty').style.display="none";
             ChangeControl("GAIN","BSE");
        //   GetADVDEC('BSE');
            
        }
        else
        { 
         //  alert(val);
           document.getElementById('tdBSE').className="ValVolVctlsel";
           document.getElementById('tdNSE').className="ValVolVctlunsel";
           document.getElementById("chart").src="http://content.acesphere.com/Charts/BNKCapitalNse.png?time=" + new Date().getTime();
           document.getElementById('Sensex').style.display="none";
           document.getElementById('Nifty').style.display="inline";
           ChangeControl('GAIN','NSE');
             //GetADVDEC('NSE');
    }
}



var XmlHttp

function CreateXmlHttp()
{
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttp = null;				
		}
	}
	if(!XmlHttp && typeof XMLHttpRequest != "undefined")
	{
		XmlHttp = new XMLHttpRequest();
	}
}






function ChangeControl(Opt,Exch)
{
	CreateXmlHttp();
       var currentDivObj = document.getElementById("Td_Data");
        
		//currentDivObj.innerHTML ="<img src=App_Themes/CommonTheme/Images/ajax-loader.gif>";
	document.body.style.cursor = "progress";
	
	
	var requestUrl = "AjaxDataGLVV.aspx?Option="+ Opt +"&Exchange="+ Exch;
    //alert(requestUrl) 
	if(XmlHttp!=null)	
	        {
				XmlHttp.onreadystatechange = function(){ChangeControlResponse(Opt,Exch)}
				XmlHttp.open('GET', requestUrl,  true);
				XmlHttp.send(null);
			}
			 return false; 
}	
	
function ChangeControlResponse(Opt,Exch)
{
    var Head_td =document.getElementById("Heading");
    var More=document.getElementById("More");
    var BSE_td =document.getElementById("Td_BSE");
    var NSE_td =document.getElementById("Td_NSE");
	switch (Opt)
	{
	case "GAIN":
		Head_td.innerHTML="Gainers";
	    if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../Equity/TopGainersAndLosers.aspx?Option=GAIN&EXCHG=BSE&id=1&index=0'>More</a>";
		}
		else
		{
		More.innerHTML="<a class='HomeMore' href='../Equity/TopGainersAndLosers.aspx?Option=GAIN&EXCHG=NSE&id=1&index=0'>More</a>";
		}
		
		break;
		
	case "LOSE":
		Head_td.innerHTML="Losers";
		 if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../Equity/TopGainersAndLosers.aspx?Option=LOSE&EXCHG=BSE&id=1&index=0'>More</a>";
		}
		else
		{
		More.innerHTML="<a class='HomeMore' href='../Equity/TopGainersAndLosers.aspx?Option=LOSE&EXCHG=NSE&id=1&index=0'>More</a>";
		}
	break;
	
	case "Vol":
		Head_td.innerHTML="Volume";
		 if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../Equity/MostActive.aspx?id=2&Option=Volume&EXCHG=BSE&index=0'>More</a>";
		}
		else
		{
		    More.innerHTML="<a class='HomeMore' href='../Equity/MostActive.aspx?id=2&Option=Volume&EXCHG=NSE&index=0'>More</a>";
		}
	break;
	
	case "Val":
	    Head_td.innerHTML="Value";
	     if(Exch=='BSE')
	    {
		More.innerHTML="<a class='HomeMore' href='../Equity/MostActive.aspx?id=2&Option=Value&EXCHG=BSE&index=0'>More</a>";
		}
		else
		{
		    More.innerHTML="<a class='HomeMore' href='../Equity/MostActive.aspx?id=2&Option=Value&EXCHG=NSE&index=0'>More</a>";
		}
	break;
	
	}

	// To make sure receiving response data from server is completed
	
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var td_Id = document.getElementById("Td_Data");
	    //alert(XmlHttp.status)
		if(XmlHttp.status == 200)//
		{
			td_Id.innerHTML =  XmlHttp.responseText;
				
			document.body.style.cursor = "auto";		
		}
		else
		{
			td_Id.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}	


var XmlHttpFO;

function CreateXmlHttpNew()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpFO = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpFO = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpFO = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpFO && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpFO = new XMLHttpRequest();
		}
	}
	
	

  function ChangeNews(SecId,SubSecId)
    {
   //alert(val,SecId,SubSecId);
    //alert("asd");
       
        CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "TalkingStockAjax.aspx?timeStamp="+ new Date().getTime() +"&Sec="+SecId+"&SubSec="+SubSecId;
		// alert(requestUrl)
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getNewsResp()};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
  
}
//window.onload=initTicker;

    
    function getNewsResp()
{

	if(XmlHttpFO.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
			var	Td_Marquee = document.getElementById("TalkingStocknews");
	   
		if(XmlHttpFO.status == 200)//
		{
		
		var strData=XmlHttpFO.responseText;
	
			Td_Marquee.innerHTML = strData;
		
			document.body.style.cursor = "auto";		
		}
		else
		{
			Td_Marquee.innerHTML =  "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}

 function GetNewsDetail_News(secId,SubSecId,NewsID,opt)
	{
	     document.getElementById("divNews").style.display='inline';
		 var requestUrl = "PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
		 ajaxpage('1',requestUrl,'TdNews','');
	}
	
function ajaxpage(id,url, containerid,fincode)
{

//document.getElementById(containerid).innerHTML = "<table cellspacing=0 cellpadding=0 width=100%><tr><td height=60></td></tr><tr><td align=center><img src='../App_Themes/Common/images/loading.gif'></td></tr></table>";
    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
    page_request.onreadystatechange=function()
    {
        loadpage(page_request, containerid)
    }

    if (bustcachevar) //if bust caching of external page
    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', url+bustcacheparameter, true)
    page_request.send(null)
}

function loadpage(page_request, containerid)
{
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  //alert(page_request.responseText)
    {
      document.getElementById(containerid).innerHTML=page_request.responseText
      
      }
}

 var dragObj = new Object();
dragObj.zIndex = 0;
function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}


	
	
	
		
	function SearchemptyOut()
{
    if (document.getElementById("txtCompany").value=="Company Name")
    {
        document.getElementById("txtCompany").value="";
    }
}

function SearchfillOut()
{
    var getquote=document.getElementById("txtCompany").value;
    if (getquote=="")
    {
        document.getElementById("txtCompany").value="Company Name";
    }
}	

function QuoteEnterScriptOut(e)
{
    if(e.keyCode==13)	
    {
        var Scripid = document.getElementById("ddlQuote");
      // var StrUrl = "Underconstruction.aspx";
        var strUrl ="CompanyProfile/CompanyList.aspx?SrchQuote="+document.getElementById('txtCompany').value+"&id="+ Scripid.value;
       // alert(strUrl)
        var newWindow = window.open(strUrl, '_parent'); 			
        newWindow.focus(); 
        return false; 
        
    }
}


function isCharKey(evt)
	{
	    var charCode =(evt.which) ? evt.which : event.keyCode
		
		if((charCode > 90 || charCode < 65) && (charCode > 122 || charCode < 97) && (charCode > 31))
		{
		    if (charCode!=32)
		    {
			    alert("Use Charcters Only");
			    return false;
			}
		}
		else
		{	
		    return true;
	    }
    }

 function SearchCompanyOut()
    {
                    	
    var SearchTxt = document.getElementById("txtCompany").value;
    var Id = document.getElementById("ddlQuote").value;	
	
    if(SearchTxt =="" || SearchTxt=="Company Name")
    {
        alert("Please enter Company Name");
        document.getElementById("txtCompany").focus();
        
        return false;
    }
	
    else
    {
		//var StrUrl = "Underconstruction.aspx";
   var StrUrl = "CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;

         document.location=StrUrl;
         return false   ;
     
    }
}

myMsg = "  BNK Capital Group – Opportunities Unlimited   "

i=0

function scrollMsg() {
    frontPart = myMsg.substring(i,myMsg.length)
    backPart = myMsg.substring(0,i)
    window.status = frontPart + backPart

    if (i < myMsg.length) {
        i++
    }
    else {
        i = 0
    }

    setTimeout("scrollMsg()",80)

}

window.onload=scrollMsg


