﻿// JScript File



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 dragObj = new Object();
dragObj.zIndex = 5000;
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 CreateXmlHttpNewsEq()
{
	try
		{
			XmlHttpNewsEq = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{  
				XmlHttpNewsEq = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpNewsEq = false;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if (!XmlHttpNewsEq && typeof XMLHttpRequest!='undefined') 
		{
	        try 
	        {
		        XmlHttpNewsEq = new XMLHttpRequest();
	        } 
	        catch (e) 
	        {
		        XmlHttpNewsEq=false;
	        }
        }
        if (!XmlHttpNewsEq && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpNewsEq = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpNewsEq=false;
	        }
        }
}





function GetHomNews(SecID,SubSec,Id)
{	
//alert(SecID,SubSec);
    CreateXmlHttpNewsEq();
	document.body.style.cursor = "progress";
   
	var requestUrl = "AjaxHomeNews.aspx?Sec="+ SecID +"&SubSec="+SubSec+"&Id="+Id+"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	//alert(requestUrl);
	if(XmlHttpNewsEq)
	{
	   
	   
	    XmlHttpNewsEq.onreadystatechange = function(){getEqDataResponseHot();};
		XmlHttpNewsEq.open("GET", requestUrl,  true);
		XmlHttpNewsEq.send(null);
	}
	return false;
}

function getEqDataResponseHot()
{
    if(XmlHttpNewsEq.readyState == 4)
	{	
	 // alert(XmlHttpNewsEq.status);
	  
	   var NewTd = document.getElementById("NewTd");
	    if(XmlHttpNewsEq.status == 200)
		{	
			
			
		//alert(XmlHttpNewsEq.responseText);
		
				NewTd.innerHTML =  XmlHttpNewsEq.responseText;
				
		       // NewTd.innerHTML = Second_Table;
		       
		      // populate(Second_Table,Mrq1,Mrq2);
		       
			document.body.style.cursor = "auto";
			
		}
		
		
		else
		{
			NewTd.innerHTML = "There was a problem retrieving data from the server.";
			
			document.body.style.cursor = "auto";
		}
	}
}






 function CreateXmlHttpPop()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpPop= new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpPop = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpPop = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpPop && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpPop = new XMLHttpRequest();
		}
	}
	
    function GetNewsDetail(secId,SubSecId,NewsID,opt)
	{

		var NewsWin = document.getElementById("divNews").style.display='inline';
		var currentDivObj;	
		
			currentDivObj = document.getElementById("TdNews");
			//alert(currentDivObj);
			currentDivObj.innerHTML ="<img src=../App_Themes/Common/images/loading.gif>"; 
		
		CreateXmlHttpPop();
		document.body.style.cursor = "progress";
		var requestUrl = "PopupNewsData.aspx?SecId="+ secId +"&SubSecId="+ SubSecId+"&NewsID="+NewsID+"&timeStamp="+new Date().getTime()+"opt="+opt;
		//alert(requestUrl);
		if(XmlHttpPop)	{
					XmlHttpPop.onreadystatechange = function(){getDetailsResp();};
					XmlHttpPop.open("GET", requestUrl,  true);
					XmlHttpPop.send(null);					
				}
	}
	
	function getDetailsResp()
	{
		// To make sure receiving response data from server is completed
		if(XmlHttpPop.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(XmlHttpPop.status == 200)
			{
        	document.getElementById("TdNews").innerHTML = XmlHttpPop.responseText;
			document.body.style.cursor = "auto";
			}
		
			else
			{
		
					document.getElementById("NewTd").innerHTML = "<img src=../App_Themes/Common/images/ajax-loader.gif>";
					
				
			}
		}
	}
	
	




/*GetQuotes home */




 function Searchempty()
{
    if (document.getElementById("txtSearch").value=="Company Name")
    {
        document.getElementById("txtSearch").value="";
    }
}

function Searchfill()
{
    var getquote=document.getElementById("txtSearch").value;
    if (getquote=="")
    {
        document.getElementById("txtSearch").value="Company Name";
    }
}	

function QuoteEnterScript(e)
{
    if(e.keyCode==13)	
    {
        var Scripid = document.getElementById("ddlQuote");
       
        var strUrl ="../CompanyProfile/CompanyList.aspx?SrchQuote="+document.getElementById('txtSearch').value+"&id="+ Scripid.value;
       // alert(strUrl)
        var newWindow = window.open(strUrl, '_parent'); 			
        newWindow.focus(); 
        return false; 
        
    }
}



 function SearchCompany()
    {
                    	
    var SearchTxt = document.getElementById("txtSearch").value;
    var Id = document.getElementById("ddlQuote").value;	
	
    if(SearchTxt =="" || SearchTxt=="Company Name")
    {
        alert("Please enter company name ..!!!");
        return false;
    }
	
    else
    {
	//var StrUrl = ""	
		
   var StrUrl = "../CompanyProfile/CompanyList.aspx?SrchQuote="+SearchTxt+"&id="+Id;

         document.location=StrUrl;
         return false   ;
     
    }
}

 
 

var XmlHttpIndCtrl;
function CreateXmlHttpIndCtrl()
	{
		try
		{
			XmlHttpIndCtrl = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpIndCtrl = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpIndCtrl = null;
					
			}
		}
		if(!XmlHttpIndCtrl && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpIndCtrl = new XMLHttpRequest();
		}
	}
	
function ChangeIndForex(type)
{
    
	    CreateXmlHttpIndCtrl();
	    
	    if(type == "I")
	    {
	 //  document.getElementById("tdworld").innerHTML = "<table border='0' cellpdding='0'><tr><td style='background-image:url(App_Themes/Common/images/WIOn.gif);background-repeat:no-repeat'>&nbsp;</td></tr></table>";
	   
	   document.getElementById("tdworld").innerHTML = "<img src='App_Themes/Common/images/WIOn.gif'/>";
	   document.getElementById("tdComm").innerHTML = "<img src='App_Themes/Common/images/CMOff.gif'/>";
	   document.getElementById("tdforex").innerHTML = "<img src='App_Themes/Common/images/ForexOff.gif'/>"
	   document.getElementById("tdComm").style.cursor = "pointer";
	   document.getElementById("tdforex").style.cursor = "pointer";
	   document.getElementById("tdworld").style.cursor = "default";
	    }
	    if(type == "Forex")
	    {
	    document.getElementById("tdworld").innerHTML = "<img src='App_Themes/Common/images/WIOff.gif'/>";
	     document.getElementById("tdComm").innerHTML = "<img src='App_Themes/Common/images/CMOff.gif'/>";
	     document.getElementById("tdforex").innerHTML = "<img src='App_Themes/Common/images/ForexOn.gif'/>"
	      document.getElementById("tdComm").style.cursor = "pointer";
	       document.getElementById("tdworld").style.cursor = "pointer";
	       document.getElementById("tdforex").style.cursor = "default";
	       
	       
	    }
	    if(type=="Comm")
	    {
	    
	    document.getElementById("tdworld").innerHTML = "<img src='App_Themes/Common/images/WIOff.gif'/>";
	     document.getElementById("tdComm").innerHTML = "<img src='App_Themes/Common/images/CMOn.gif'/>";
	     document.getElementById("tdforex").innerHTML = "<img src='App_Themes/Common/images/ForexOff.gif'/>"
	     document.getElementById("tdworld").style.cursor = "pointer";
	     document.getElementById("tdforex").style.cursor = "pointer";
	     document.getElementById("tdComm").style.cursor = "default";
	    }
	   
	    
	    
		document.body.style.cursor = "progress";
		//document.getElementById("MarqueeId").innerHTML = " <img src='../App_Themes/Common/images/ajax-loader.gif'>";
	    var requestUrl = "Ajaxindcom.aspx?Type="+type;	
		if(XmlHttpIndCtrl){
			XmlHttpIndCtrl.onreadystatechange = function(){getDataResponseIndForex();};
			XmlHttpIndCtrl.open("GET", requestUrl,  true);
			XmlHttpIndCtrl.send(null);
		}
		return false;
    
    
 
    
}


	
	function getDataResponseIndForex()
    {
	if(XmlHttpIndCtrl.readyState == 4)
	{	
	
		if(XmlHttpIndCtrl.status == 200)
		{				
			var NewTd = document.getElementById("tdIForexData");
			var NewData = XmlHttpIndCtrl.responseText;
		
			if(NewData != "")
		    {
				NewTd.innerHTML = NewData;				
			}
				document.body.style.cursor = "auto";
				
		}
		
	}
}

   


