﻿function HideImage() {
        document.getElementById("LoadIMG").style.display = "none";
    }
//Bookmark function
function addBookmark(title, url) 
{
  if (window.sidebar) 
	{ // <strong class="highlight">firefox</strong>
		  window.sidebar.addPanel(title, url,"");
	}
  else if( document.all ) { //MSIE
			window.external.AddFavorite( url, title);
	} 
	else if(window.opera && window.print) { // Opera Hotlist 
			 var elem = document.createElement('a');
			 elem.setAttribute('href',url);
			 elem.setAttribute('title',title);
			 elem.setAttribute('rel','sidebar');
			 elem.click();
			 alert("Press Ctrl+D to bookmark This page"); 
	 }
	else {
		   alert("Sorry, your browser doesn't support this");
	}
}

 function openwindowPopUp(url) 					
    { 
        var linkurl = url;
        var newWin=window.open(linkurl,'name');	
        newWin.focus();
    }	
function openwindowLogin(url) 					
    { 
        var linkurl = url;
        var newWin=window.open(linkurl,'login');	
        newWin.focus();
    }


    function ShowImage(evt, id) {
        CheckCharacter();
        isNumberKey(evt);
        if (document.getElementById(id).value.length == 2) {
            document.getElementById("LoadIMG").style.display = "inline";
            document.body.style.cursor = "pointer";
        }
    }
    function isNumberKey(evt) {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

        return true;
    }
    function CheckCharacter() {
        var keyCode = event.keyCode ? event.keyCode : event.which;
        if ((keyCode > 90 || keyCode < 65) && (keyCode > 122 || keyCode < 97) && (keyCode != 32))
            return false;
        else {
            var key = String.fromCharCode(keyCode);
            key = key.toUpperCase();
            event.keyCode = key.charCodeAt();
            return true;
        }
    }

    function validations() {

        var CompName = document.getElementById("GetQuotes1_TxtGetQuotes").value;
        if (CompName == "") {
            alert("Please enter a company name");
            document.getElementById("GetQuotes1_TxtGetQuotes").focus();
            return false;
        }
        else if (CompName != "") {
            if (CompName.length < 3) {
                alert("Please enter atleast 3 characters of the company name");
                document.getElementById("GetQuotes1_TxtGetQuotes").focus();
                return false;
            }
        }
        return true;
    }

    function CreateXmlHttpSch() {
        var XmlHttpSch;
        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;
    }
     var XmlHttpSch0;
    function fill_funds() 
    {
        var fund = document.getElementById("MFCalculator1_drp_FundHouse");       
        if (document.getElementById("MFCalculator1_drp_FundHouse").value != "") {
            fund.length = 0;
            fund.options[0] = new Option();
            fund.options[0].value = "";
            fund.options[0].text = "Select Fund";
            XmlHttpSch0 = CreateXmlHttpSch();

            document.body.style.cursor = "progress";
            var requestUrl0 = "/HomeCtrls/getFunds.aspx";
        }

        if (XmlHttpSch0) {
            XmlHttpSch0.onreadystatechange = function() { getRespFund(fund); };
            XmlHttpSch0.open("GET", requestUrl0, true);
            XmlHttpSch0.send(null);
        } 
    }

    function getRespFund(ig_) {

        // To make sure receiving response data from server is completed
        if (XmlHttpSch0.readyState == 4) {
            // To make sure valid response is received from the server, 200 means response received is OK
            if (XmlHttpSch0.status == 200) {

                var strData = XmlHttpSch0.responseText
                if (strData != "") {
                    var arrSchm = strData.split("|");
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "Select Fund";
                    for (i = 0; i < arrSchm.length; 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];
                    }
                    //alert(arrSchmCode[0]);
                    getCategory();
                }
                else {
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "No funds 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 XmlHttpSch;    
    function getCategory() {        
        var fund = document.getElementById("MFCalculator1_drp_FundHouse");
        var category = document.getElementById("MFCalculator1_drp_Category");       
        if (document.getElementById("MFCalculator1_drp_FundHouse").value != "") {
            category.length = 0;
            category.options[0] = new Option();
            category.options[0].value = "";
            category.options[0].text = "Select Category";
            XmlHttpSch = CreateXmlHttpSch();

            document.body.style.cursor = "progress";
            var requestUrl = "/HomeCtrls/getFunds.aspx?Fund=" + encodeURIComponent(fund.value);            
        }
         if (XmlHttpSch) {
             XmlHttpSch.onreadystatechange = function() { getRespCat(category); };
            XmlHttpSch.open("GET", requestUrl, true);
            XmlHttpSch.send(null);
        }
    }
    function getRespCat(ig_) {

        // To make sure receiving response data from server is completed
        if (XmlHttpSch.readyState == 4) {
            // To make sure valid response is received from the server, 200 means response received is OK
            if (XmlHttpSch.status == 200) {

                var strData = XmlHttpSch.responseText
                //alert(strData);
                if (strData != "") {
                    var arrSchm = strData.split("|");
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "Select Category";
                    for (i = 0; i < arrSchm.length; 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];
                    }
                    SelectMFScheme();
                }
                else {
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "No catgory 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 XmlHttpSch1;
    function SelectMFScheme() {
        var scheme = document.getElementById("MFCalculator1_drp_Scheme");
        var fund = document.getElementById("MFCalculator1_drp_FundHouse");
        var Category = document.getElementById("MFCalculator1_drp_Category");

        XmlHttpSch1 = CreateXmlHttpSch();
        document.body.style.cursor = "progress";
        var requestUrl = "/HomeCtrls/getFunds.aspx?Fund=" + encodeURIComponent(fund.value) + "&Category=" + encodeURIComponent(Category.value);
        //alert(requestUrl);
        if (XmlHttpSch1) {
            XmlHttpSch1.onreadystatechange = function() { getSchemeResp(scheme) };
            XmlHttpSch1.open("GET", requestUrl, true);
            XmlHttpSch1.send(null);
        }
    }

    //Called when response comes back from server Only For MF_SchemeData
    function getSchemeResp(ig_) {
        // To make sure receiving response data from server is completed
        if (XmlHttpSch1.readyState == 4) {
            // To make sure valid response is received from the server, 200 means response received is OK
            if (XmlHttpSch1.status == 200) {
                //var availSchemes   = document.getElementById(ig_);
                var strData = XmlHttpSch1.responseText;
                //alert(strData);                
                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 = "Scheme 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 CreateXmlHttp() {
        //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();
        }
    }   
     var XmlHttpSch0;
    function fill_AMCs() {
        var fund = document.getElementById("SIPCalculator1_DrpAMC");
        if (document.getElementById("SIPCalculator1_DrpAMC").value != "") {
            fund.length = 0;
            fund.options[0] = new Option();
            fund.options[0].value = "";
            fund.options[0].text = "Select Fund";
            XmlHttpSch0 = CreateXmlHttpSch();

            document.body.style.cursor = "progress";
            var requestUrl0 = "/HomeCtrls/getFunds.aspx";
        }

        if (XmlHttpSch0) {
            XmlHttpSch0.onreadystatechange = function() { getRespAMC(fund); };
            XmlHttpSch0.open("GET", requestUrl0, true);
            XmlHttpSch0.send(null);
        }
    }

    function getRespAMC(ig_) {

        // To make sure receiving response data from server is completed
        if (XmlHttpSch0.readyState == 4) {
            // To make sure valid response is received from the server, 200 means response received is OK
            if (XmlHttpSch0.status == 200) {

                var strData = XmlHttpSch0.responseText
                if (strData != "") {
                    var arrSchm = strData.split("|");
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "Select Fund";
                    for (i = 0; i < arrSchm.length; 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];
                    }
                    //alert(arrSchmCode[0]);
                    loadSipScheme('27917');
                }
                else {
                    ig_.length = 0;
                    ig_.options[0] = new Option();
                    ig_.options[0].value = "";
                    ig_.options[0].text = "No funds 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 ChkNum(evt)
{	
	var k=(evt.which)? evt.which : evt.keyCode; 
	return (k > 31 && (k < 43 || k > 57))  ? false : true;	 	
}

function loadSipScheme(mf_code)
{  
	CreateXmlHttp();	
	document.body.style.cursor = "progress";
	if(mf_code=='')return false;
	var requestUrl = "../MutualFund/SipCalcSchData.aspx?MF_Code="+ mf_code;	
	if(XmlHttp)	{
				XmlHttp.onreadystatechange = function(){sipSchResp()}
				XmlHttp.open("GET", requestUrl,  true);
				XmlHttp.send(null);
    		}
}

//Called when response comes back from server Only For sip schemes
function sipSchResp()
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			var DrpScheme   = document.getElementById("SIPCalculator1_DrpScheme");
			var strData = XmlHttp.responseText			
			if(strData != "")
			{	
				if(strData!="NA") {
					var arrSchm = strData.split("|");
					
					var arrSCH_NAME   = eval(arrSchm[1]);
					arrMF_SCHCODE = eval(arrSchm[0]);
					arrMININVT    = eval(arrSchm[2]);

						DrpScheme.length = 0;
						DrpScheme.options[0] = new Option();
						DrpScheme.options[0].value = "";
						DrpScheme.options[0].text  = "Select Scheme";						
						for(i=1; i<=arrMF_SCHCODE.length; i++) {	
							DrpScheme.options[i] = new Option();
							DrpScheme.options[i].value = arrMF_SCHCODE[i-1];
							DrpScheme.options[i].text  = arrSCH_NAME[i-1].replace(/#/g,"'");
						}
				}
				else
					alert("Scheme is not available");
			}
			else
				alert("Scheme is not available");
				document.body.style.cursor = "auto";
		}
		else {
			alert("server is not ready");
			document.body.style.cursor = "auto";
		}
	}
	
	function MinSipAmt(schCode)
	  {
	    document.body.style.cursor = "progress";
	    var inv_Amnt  = document.getElementById("SIPCalculator1_TxtInvstAmt");
	    CreateXmlHttp();	
	    var requestUrl = "../MutualFund/SipStDtData.aspx?schCode="+ schCode;	
	    if(XmlHttp)	{
				    XmlHttp.onreadystatechange = function(){sipDtResp()}
				    XmlHttp.open("GET", requestUrl,  true);
				    XmlHttp.send(null);
			        }
      }

}
    function UrlSearch()
    {
      var Search=document.getElementById("Txt_Search");	
      if(Search.value == "" || Search.value == " " || Search.value == "Search")
      {
        alert("Please Enter Search Text.");
        Search.focus();
        return false; 
      }
      else
      {
       var url="../SerchEngine.aspx?id=41&amp;next=10&amp;old=0&amp;search="+Search.value;           
       document.location=url;
      }
     return false;
    }
    
    function submitpage()
	{   
	  var fund = document.getElementById("SIPCalculator1_DrpAMC").value;
	  var scheme = document.getElementById("SIPCalculator1_DrpScheme").value;
	  var Amt = document.getElementById("SIPCalculator1_TxtInvstAmt").value;

      if (fund == "" || fund == "Select Fund") {
          alert("Please click here for select a fund");         
          return false;
      }
      if (scheme == "" || scheme == "Select Scheme") {
          alert("Please select scheme first");
          document.getElementById("SIPCalculator1_DrpScheme").focus();
          return false;
      }
      if (Amt == "") {
          alert("Please enter amount in Rs");
          document.getElementById("SIPCalculator1_TxtInvstAmt").focus();
          return false;
      }
           
      window.location = "../MutualFund/MutualFundInner.aspx?id=070403&amp;Fund="+fund+"&amp;sch_Code="+scheme+"&amp;Amt="+Amt;   //+"&amp;stday="+stday.value+"&amp;Stmonth="+ Stmonth.value +"&amp;Styear="+ Styear.value +"&amp;edday="+ edday.value +"&amp;Enmonth="+ Enmonth.value +"&amp;Enyear="+Enyear.value;
      return false;
  }
   function DetachTicker(ticker,url)
    {
        document.getElementById(ticker).style.display = "None";    
        var newPop=window.open(url,'Bluechip','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=1000px,height=30px,screenX=0,screenY=0,left=5,right=5,top=292');//280
        newPop.focus();

    }
    function SpeedTicker(opt,bsemarq)
    {
	    if(opt=='PLUS')	
		    document.getElementById(bsemarq).scrollAmount = parseInt(document.getElementById(bsemarq).scrollAmount)+1;
    		
	    if(opt=='STOP')
	    {
		    if(document.getElementById(bsemarq).scrollAmount==0)
		    {
			    document.getElementById(bsemarq).scrollAmount=1;
			    document.getElementById("stop").src = "../images/stop.gif";
			    document.getElementById("stop").title = "stop";
			    }
		    else 
		    {
			    document.getElementById(bsemarq).scrollAmount=0;
			    document.getElementById("stop").src = "../images/PLAY.gif";
			    document.getElementById("stop").title = "play";
		    }
	    }	
	    if(opt=='MINUS')
	    {
		    if(document.getElementById(bsemarq).scrollAmount>1)
		    {
			    document.getElementById(bsemarq).scrollAmount = parseInt(document.getElementById(bsemarq).scrollAmount)-1; 
		    }
	    }
	    
    }
    
function PopupNewYear(fileName)
{
  var newWin1=window.open(fileName,'win1','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=480,height=520,screenX=0,screenY=0,left=160,top=200');
  newWin1.focus();
}
function SetRefresh()
   {
     var time = new Date();
     var hour = time.getHours();
      if(hour > 9 && hour < 16)
     { 
       location.reload(true);
     }
   }
	

	