﻿function CreateXmlHttp1()
{
	try
	{
		XmlHttp1 = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttp1 = null;				
		}
	}
	if(!XmlHttp1 && typeof XMLHttpRequest != "undefined")
	{
		XmlHttp1 = new XMLHttpRequest();
	}
}
function CreateXmlHttp2()
{
	try
	{
		XmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttp2 = null;				
		}
	}
	if(!XmlHttp2 && typeof XMLHttpRequest != "undefined")
	{
		XmlHttp2 = new XMLHttpRequest();
	}
}
var k;
var PageLink ="../IPO/IPOHome.aspx";
function LoadTopBanner(id,bannerid) 
{
    //document.getElementById("imgTopBanner").className = "TopBanner";    
    try 
    {
        if (bannerid == "") 
        {
            if (imgid == parseInt(Pg.length - 1))
                k = 0;
            else
                k = parseInt(imgid) + 1;
                
            document.getElementById(id).src = Pg[k];
            imgid = k;             
        }
        else 
        {
            document.getElementById(id).src = Pg[bannerid];
            imgid = bannerid;
        }
        PageLink = Pg2[imgid];
    }
    catch (Err) 
    {
        alert(Err.description);
    }
}

function TopBannerLink() 
{
//    alert(PageLink);
//    return false;
     window.location = PageLink;
}
function SubsNewsLetters(Products,Email)
{
    CreateXmlHttp1();
    var Dt= Date();
    var requestUrl1 = unescape("../WealthManagement/AddNewsLetters.aspx?Email=" + Email + "&Product=" + Products + "&t=" + Dt);
    //alert(requestUrl1);
   if(XmlHttp1)
	{
		XmlHttp1.onreadystatechange = function(){getLetterDetails();};
		XmlHttp1.open("GET", requestUrl1,  true);
		XmlHttp1.send(null);
	}
	return false;	
}
function getLetterDetails()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp1.readyState == 4)
	{
	     //alert(XmlHttp1.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp1.status == 200)
		{
		    if(XmlHttp1.responseText !="0")
		    {
		    //var strurl =  window.location.href;
			    alert("Thanks for Subscribe to Newsletters,we will get back to you soon."); 
			//window.location = strurl.replace("#", "");
			}
			else
			{
			    alert("Already Exist"); 
			}
		}
		else
		{
			//alert("Try again..!"); 
		}
	}
}
function LeadDataCapture(Name, contactNo, Email, City, opt) 
{

    //alert(Name+"~"+contactNo+"~"+Email+"~"+City+"~"+opt);
    var TaximOth = document.getElementById("HidD32");
    CreateXmlHttp2();
    var Dt = Date();
    if (opt == 'undefined')
        opt = 0;
    if(TaximOth == null)
    {
        var URL = "../ToolsAndDownloads/Openaccount.aspx?name=" + Name + "&Email=" + Email + "&phone=" + contactNo + "&City=" + City + "&Optn=" + opt + "&t=" + Dt+"&OtherTax=";
    }else
    {
        var URL = "../ToolsAndDownloads/Openaccount.aspx?name=" + Name + "&Email=" + Email + "&phone=" + contactNo + "&City=" + City + "&Optn=" + opt + "&t=" + Dt+"&OtherTax="+TaximOth.value;
    }
   
    if (Name  != 'undefined' || contactNo !='undefined')
    {
       var requestOpenUrl = unescape(URL);
       if(XmlHttp2)
	    {
		    XmlHttp2.onreadystatechange = function(){getOpenActnDetails();};
		    XmlHttp2.open("GET", requestOpenUrl,  true);
		    XmlHttp2.send(null);
	    }
	}
	return false;	
}
function getOpenActnDetails()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp2.readyState == 4)
	{
	    //alert(XmlHttp2.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp2.status == 200)
		{
		    if(XmlHttp2.responseText =="0")
		    {
		        alert("Already Exist"); 
	        }
	        else
	        {
	            //var strurl =  window.location.href;
		    alert("Thanks for registration,we will get back to you soon."); 
		    //window.location = strurl.replace("#", "");
	        }
		}
		else
		{
			//alert("Try again..!"); 
		}
	}
}

function LeadCapture(str) 
{
    //alert("HI" + str); //split this value
    var arr = str.split(",");
    var strsubmitValus = LeadDataCapture(arr[0], arr[1], arr[2], arr[3], arr[4]);

    //alert(strsubmitValus);
    //alert(arr[4]);
    if(strsubmitValus !="")
    {
        if (arr[4] == "3") 
        {
            window.location = "../ToolsAndDownloads/ChildFuturePlanner.aspx";
        }
        if (arr[4] == "4") {
            window.location = "../ToolsAndDownloads/IncomeTaxCalculator.aspx";       
        }
        if (arr[4] == "5") 
        {
            //window.location = "../ToolsAndDownloads/WealthCalculator.aspx";
        }
        if (arr[4] == "6") {
            window.location = "../ToolsAndDownloads/SIPcalculator.aspx";
        } 
        if (arr[4] == "7") 
        {
            window.location = "../ToolsAndDownloads/RetirementCalculator.aspx";
        } 
        if (arr[4] == "8") {
           window.location = "../ToolsAndDownloads/HumanLifeCalculator.aspx";
        }   
        if (arr[4] == "9") 
        {
         window.location = "../ToolsAndDownloads/GoalCalculator.aspx";
        }
         if (arr[4] == "10") 
        {
         window.location = "../ToolsAndDownloads/Risk-calculator.aspx";
        }
       if (arr[4] == "19") 
       {
         window.location = "../ToolsAndDownloads/HealthCalculator.aspx";
       }
   }
}
function GotoPage() 
{
    //alert();
    var newWin=window.open("http://www.adityabirlamoney.com/OpenAccount.aspx",'FavWindow','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=1,copyhistory=no,width=750px,height=420px,screenX=0,screenY=0,left=210,top=200');	
	newWin.focus();
}

function emptybox(txtSearch) {
    document.getElementById(txtSearch).value = "";
}

function fillbox(txtSearch, text) {
    if (document.getElementById(txtSearch).value == "") {
        document.getElementById(txtSearch).value = text;
    }
}

function EnterScript2(evt, id, text) 
{
    if (evt.keyCode == 39)
        return false;
    if (evt.keyCode == 45)
        return false;
}
