var reWhitespace = /^\s+$/
function KeyingCom(event,id)
{
	var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;	

  	if(Key == 13)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo(id);
		if(boolval)
		return true;
		else
		return false;				
	}
	if(Key ==33 || Key == 43 || Key >= 35 && Key <= 38 || Key >= 40 && Key <=42 || Key == 64 || Key == 94 || Key == 95 || Key == 126)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo1(id);
		if(boolval)
		return true;
		else
		return false;		
	}
}
function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}
function isWhitespace(s)
{   
	return (isEmpty(s) || reWhitespace.test(s));
}
function GetquotesInfo(Obj)
{	
	var Getquotestxt = document.getElementById(Obj)
	if(Getquotestxt.value == "" || isWhitespace ( Getquotestxt.value) || Getquotestxt.value =="Get Quotes")
	{
		alert("Enter the Few Characters of a Company Name");
		Getquotestxt.focus();
	}
	else
	{
	    alert("Please select any of the company from Search Result");
	}	
}

function GetquotesInfo1(Obj)
{
	var Getquotestxt = document.getElementById(Obj)
	alert("Special Characters are not allowed");
	Getquotestxt.focus();
}

function txtempty()
{
	document.getElementById("Getquotes").value="";
}
function fill()
{
	if(document.getElementById("Getquotes").value == "")	{
		document.getElementById("Getquotes").value="Get Quotes"
	}
}	
//Original GetQuotes functionalitied Starts here
function KeyingCom2(event,id)
{
    var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;			
	if(Key == 13)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo2(id);
		if(boolval)
		return true;
		else
		return false;				
	}
	if(Key ==33 || Key == 43 || Key >= 35 && Key <= 38 || Key >= 40 && Key <=42 || Key == 64 || Key == 94 || Key == 95 || Key == 126)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo3(id);
		if(boolval)
		return true;
		else
		return false;		
	}
}
function isEmpty2(s)
{  
	return ((s == null) || (s.length == 0))
}
function isWhitespace2(s)
{   
	return (isEmpty(s) || reWhitespace.test(s));
}
function GetquotesInfo2(Obj)
{
	
	var Getquotestxt = document.getElementById(Obj)
	if(Getquotestxt.value == "" || isWhitespace ( Getquotestxt.value) || Getquotestxt.value =="Get Quotes")
	{
		alert("Enter the Few Characters of a Company Name");
		Getquotestxt.focus();
	}
	else
	{
	    alert("Please select any of the company from Search Result");				
	}		
}
function respondToKey() 
{
    document.getElementById("ListCompany1_lstquote").value = "";
    var txt = document.getElementById("Getquotes2").value;
	listload(txt);
}

function listload(txt) {
    var Exchgval = document.getElementById("Td_Txt").innerHTML;
    var scheme = document.getElementById("ListCompany1_lstquote");
   
    CreateXmlHttp();
    document.body.style.cursor = "progress";
    var requestUrl = "../Watchlist/listquote.aspx?IpTrack=" + window.location.hostname + "&timeStamp=" + new Date().getTime() + "&srctxt=" + txt + "&Exchg=" + Exchgval;
    
    if (XmlHttp) {
        XmlHttp.onreadystatechange = function() { getSchemeResp55(scheme) };
        XmlHttp.open("GET", requestUrl, true);
        XmlHttp.send(null);
    }
}

function getSchemeResp55(ig_) {   
    if (XmlHttp.readyState == 4) {      
        if (XmlHttp.status == 200) {
            var strData = XmlHttp.responseText            
            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 = "Company is not available";
            }
            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 GetquotesInfo3(Obj)
{
	var Getquotestxt = document.getElementById(Obj)
	alert("Special Characters are not allowed");
	Getquotestxt.focus();
}
function txtempty2()
{
	document.getElementById("Getquotes2").value="";
}
function fill2()
{
	if(document.getElementById("Getquotes2").value == "")
	{
		document.getElementById("Getquotes2").value="Company Name"
	}
}
//Ends here
// Calling Ajax-Page While Onkeypress Event starts here
function trimall(sString) 
{
	while (sString.substring(0,1) ==" ")
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function cleartxt()
{
	document.getElementById("Getquotes2").value = "Company Name";
	document.getElementById("ListCompany1__lstquote").style.display = "none";
}		
function SearchQuote1()
{
    var code = document.getElementById("ListCompany1__lstquote").value;
	var optval = document.getElementById("ddlsec").value;	
	var idval = document.getElementById("ddlsec").value;	
	var ieval = document.getElementById("ddlsec").value;
	var ies=eval(24)+eval(ieval);
	if(code=="")
	{
		 alert("Please select a Company from the list");
		 document.getElementById("Getquotes2").value = "";
		 document.getElementById("Getquotes2").focus();
	}
	else
	{ 
		document.getElementById("Getquotes2").value = "Company Name";
		strurl = "../CorporateInfo/ScripSearch.aspx?ie="+ies+"&id="+idval+"&opt="+optval+"&cocode="+code;		
    	window.location = strurl;		
	}
}
//ends here
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();
    }
}
var XmlHttp;

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 browser = new Browser();

function CreateXmlHttp1()
{
//Creating object of XMLHTTP in IE
try
{
	XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
	try
	{
		XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch(oc)
	{
		XmlHttp = null;	
	}
}
//Creating object of XMLHTTP in Mozilla and Safari 
if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
{
	XmlHttp = new XMLHttpRequest();
}
}
//**** Function ExchngTimeClock Is used for to find out the market hours --- The ticker will automatically refresh only in market timings *****//			
function ExchngTimeClock(Exchg) {
     var time = new Date()
     var hour = time.getHours()
     if (hour >= 10 && hour <= 20)
	    clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"')",600000);
}

//**** Function killClock Is used for killing clock timer  *****//
function killClock(){
    clearTimeout(clockTimeoutID);
}	

function AddWatchlist_data()
{
    CreateXmlHttp();
    document.body.style.cursor = "progress";
    var requestUrl = "../Watchlist/Addwatch_Source.aspx?IpTrack=" + window.location.hostname + "&timeStamp=" + new Date().getTime();
    var code="";

    var to = document.getElementById("selSchemes");
    for (var i=(to.options.length-1); i>=0; i--)
     { 
        var o=to.options[i]; 
        code = code+","+ o.value;        
    }
    code = code.substring(1,code.length);

    var params = "co_code="+code;
    if(XmlHttp)	{
		XmlHttp.onreadystatechange = function(){getWatchlistResponse()};
		XmlHttp.open("POST", requestUrl,  true);
		XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		XmlHttp.setRequestHeader("Content-length", params.length);
        XmlHttp.setRequestHeader("Connection", "close");
		XmlHttp.send(params);
	}
}

function getWatchlistResponse()
{
// 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
        if(XmlHttp.status == 200)
        {             
            var strData = XmlHttp.responseText;
            if(strData="Yes")
                window.location = "default.aspx";
            else
                alert("Data is not updated");
        }
    }
}


// for another addwatch for members registered Starts 
function respondToKey1() 
{
    document.getElementById("ListCompany1_lstquote1").value = "";
	var txt=document.getElementById("Getquotes3").value;
	listload1(txt);			
}
function listload1(txt)
{
    var scheme = document.getElementById("ListCompany1_lstquote1");	
    CreateXmlHttp();
    document.body.style.cursor = "progress";
    var requestUrl = "../Watchlist/listquote.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&srctxt="+txt;

    if(XmlHttp)	{
        XmlHttp.onreadystatechange = function(){getSchemeResp5555(scheme)};
        XmlHttp.open("GET", requestUrl,  true);
        XmlHttp.send(null);
    }
}
function getSchemeResp5555(ig_)
{
    // 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
        if(XmlHttp.status == 200)
        {
            var strData = XmlHttp.responseText
            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 = "Company is not available";			
            }
            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";		
        }
    }
}	
var reWhitespace = /^\s+$/
function KeyingCom1(event,id)
{
	var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;		
  	if(Key == 13)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo2(id);
		if(boolval)
		return true;
		else
		return false;				
	}
	if(Key ==33 || Key == 43 || Key >= 35 && Key <= 38 || Key >= 40 && Key <=42 || Key == 64 || Key == 94 || Key == 95 || Key == 126)
	{
		var Scripid = document.getElementById(id);
		var boolval = GetquotesInfo3(id);
		if(boolval)
		return true;
		else
		return false;		
	}
}
function GetquotesInfo2(Obj)
{
	var Getquotestxt = document.getElementById(Obj)
	if(Getquotestxt.value == "" || isWhitespace ( Getquotestxt.value) || Getquotestxt.value =="Get Quotes")
	{
		alert("Enter the Few Characters of a Company Name");
		Getquotestxt.focus();
	}
	else
	{
	 alert("Please select any of the company from Search Result");
	}	
	
}
//Special characters not allowed
function GetquotesInfo3(Obj)
{
	var Getquotestxt = document.getElementById(Obj)
	alert("Special Characters are not allowed");
	Getquotestxt.focus();
}

function txtempty3()
{
	document.getElementById("Getquotes3").value="";
}
function fill3()
{
	if(document.getElementById("Getquotes3").value == "")
	{
		document.getElementById("Getquotes3").value="Company Name"
	}
}	
// addwatch for members registered Ends
function fixheight()
{
	var Content_Of_Body = document.getElementById('BodyID_Login');
	var height = Math.min( Content_Of_Body.offsetHeight, Content_Of_Body.scrollHeight);
	url="http://www.baljitsecurities.com/new/set_height_iframe.htm?height="+Content_Of_Body.scrollHeight;
	document.getElementById("Iframe_Resize").src = url;    
}
