// JavaScript Document

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var xmlHttp

function researchreport(a)
{
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="research-ajax.php?subcat="+a;
xmlHttp.onreadystatechange = function(){ stateChanged1(1); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function Trim(str)
{  while(str.charAt(0) == (" ") )
  {
    str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {
    str = str.substring(0,str.length-1);
  }
  return str;
}

function checkTaxform()
{

var talk=document.frmTax.talk.value;
if(talk=="a")
{
		for (var i=0; i < document.frmTax.category.length; i++)
   		{
   			if (document.frmTax.category[i].checked)
      		{
      			var category = document.frmTax.category[i].value;
	  			
      		}
   		}
}
else if(talk=="b")
{
	var category = document.frmTax.category.value;
}
var fname			=	document.frmTax.txtfname.value;
var mobile			=	document.frmTax.txtmobile.value;
var email			=	document.frmTax.txtemail.value;
var state			=	document.frmTax.state.value;
var city			=	document.frmTax.city.value;
var question		=	document.frmTax.question.value;
var security_code	=	document.frmTax.security_code.value;

	var alphaExp = /^[0-9a-zA-Z]+$/;
	var num = /^[0-9]+$/;
	flg=0;
		if(Trim(fname)=="")
			{
				alert("Please Enter First Name.")
				document.frmTax.txtfname.focus();
				flg=1;
				return false;
			}
		if (flg==0)
		{
		if (mobile=="")
			{
				alert("Please Enter Mobile No:")
				document.frmTax.txtmobile.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
		if (mobile.length != 10)
			{
				alert("Please Enter Valid Mobile No:")
				document.frmTax.txtmobile.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
		if (!mobile.match(num))
			{
				alert("Please Enter Valid Mobile No:")
				document.frmTax.txtmobile.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
		if (email.value=="")
			{
				alert("Please Enter E-mail Id.")
				document.frmTax.txtemail.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
			if (email!="")
				{
				if (email.indexOf("@",2) == -1)
					{
					alert ("Please Enter a valid Email Id.");
					document.frmTax.txtemail.focus();
					flg=1;
					return false;
					}
				else if (email.indexOf(".",4) == -1)
					{
					alert ("Please Enter a valid Email Id.");
					document.frmTax.txtemail.focus();
					flg=1;
					return false;
					}	
				}
		}
				
		if(flg==0)
		{
			if (document.frmTax.state.value=="")
			{
				alert("Please Select State.");
				document.frmTax.state.focus();
				flg=1;
				return false;
			}
		}
		if(flg==0)
		{
			if (document.frmTax.city.value=="")
			{
				alert("Please Select City.");
				document.frmTax.city.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
		if(Trim(question)=="")
			{
				alert("Please Enter Your Question.")
				document.frmTax.question.focus();
				flg=1;
				return false;
			}
		}
		if (flg==0)
		{
			if(document.frmTax.security_code.value=="")
			{
				alert("Please Enter The Code.");
				document.frmTax.security_code.focus();
				flg=1;
				return false;
			}
		}	
if(flg==0)
{
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return false;
  } 
var url="tax-ajax.php?category="+category+"&fname="+fname+"&mobile="+mobile+"&email="+email+"&state="+state+"&city="+city+"&question="+question+"&security_code="+security_code;
xmlHttp.onreadystatechange = function(){ stateChanged1(2); };
xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 ){
				document.getElementById('msg_success').style.visibility="visible";
				var result = xmlHttp.responseText;
				//alert(result);
				//document.getElementById('country41').innerHTML = '<img src="images/loading.gif" />';
				document.getElementById('msg_success').innerHTML = result;
				
				if(result=="<font color='#FF0000'><b>Request Send Successfully</b></font>"){
					document.getElementById("txtfname").value = "";
					document.getElementById("txtmobile").value = "";
					document.getElementById("txtemail").value = "";
					document.getElementById("question").value = "";
					document.getElementById("state").value = "";
					document.getElementById("city").value = "";
					document.getElementById("security_code").value = "";
				}
			}
		}
xmlHttp.send(null)
}
} 

function articlelist(a)
{
	
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="article-ajax.php?aid="+a;
xmlHttp.onreadystatechange = function(){ stateChanged1(3); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function cityselect()
{
var state=document.form1.state.value;
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="register-city-ajax.php?state="+state;
xmlHttp.onreadystatechange = function(){ stateChanged1(4); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function productselect()
{
var category=document.frmins.subcat.value;
document.frmins.action="insurance-comparison-tool.php?page_id=21&subcat="+category;	
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="financial-planner-ajax.php?category="+category;
xmlHttp.onreadystatechange = function(){ stateChanged1(5); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function bankselect()
{
var category=document.frmbank.subcat.value;
document.frmbank.action="banking-comparison-tool.php?page_id=22&subcat="+category;	
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="financial-planner-ajax.php?category="+category;
xmlHttp.onreadystatechange = function(){ stateChanged1(7); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 


function sensextimer()
{
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="sensex1.php";
xmlHttp.onreadystatechange = function(){ stateChanged1(6); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function stateChanged1(param) 
{ 
	if(param==1)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			//alert(xmlHttp.responseText);
			document.getElementById("resreport").innerHTML =xmlHttp.responseText;            
		} 
	}
	if(param==2)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			//alert(xmlHttp.responseText);
			document.getElementById("taxins").innerHTML ="<font color='#FF0000'><b>Your Question will be answered to Your Mail.</b> </font><br />";
			//alert(xmlHttp.responseText);            
		} 
	}
	if(param==3)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			//alert(xmlHttp.responseText);
			document.getElementById("tab1").innerHTML =xmlHttp.responseText;            
		} 
	}
	if(param==4)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
 			var cty=xmlHttp.responseText;
			var cityname=cty.split("-");
			removeAllOptions(document.form1.city);
			for(var i=0;i<=cityname.length-2;i++)
			{
				var cityid=cityname[i].split(",");
				addOption(document.form1.city, cityid[0], cityid[1] );
			}
		} 
	}
	if(param==5)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
 			var prod=xmlHttp.responseText;
			var prodname=prod.split("##");
			//alert(prod);
			removeAllOptions(document.frmins.prod1);
			removeAllOptions(document.frmins.prod2);
			removeAllOptions(document.frmins.prod3);
			for(var i=0;i<=prodname.length-2;i++)
			{
				var prodid=prodname[i].split(",");
				if(i==0)
				addOption(document.frmins.prod1, prodid[0], prodid[1] );
				if(i==1)
				addOption(document.frmins.prod2, prodid[0], prodid[1] );
				if(i==2)
				addOption(document.frmins.prod3, prodid[0], prodid[1] );
			}
			for(var i=0;i<=prodname.length-2;i++)
			{
				var prodid=prodname[i].split(",");
				addOption(document.frmins.prod1, prodid[0], prodid[1] );
				addOption(document.frmins.prod2, prodid[0], prodid[1] );
				addOption(document.frmins.prod3, prodid[0], prodid[1] );
			}
		} 
	}
	if(param==6)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			//alert(xmlHttp.responseText)
			document.getElementById("sensexhere").innerHTML =xmlHttp.responseText;
			//clearTimeout(subButton);
		} 
	}
	if(param==7)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
 			var prod=xmlHttp.responseText;
			var prodname=prod.split("##");
			//alert(prod);
			removeAllOptions(document.frmbank.prod1);
			removeAllOptions(document.frmbank.prod2);
			removeAllOptions(document.frmbank.prod3);
			for(var i=0;i<=prodname.length-2;i++)
			{
				var prodid=prodname[i].split(",");
				if(i==0)
				addOption(document.frmbank.prod1, prodid[0], prodid[1] );
				if(i==1)
				addOption(document.frmbank.prod2, prodid[0], prodid[1] );
				if(i==2)
				addOption(document.frmbank.prod3, prodid[0], prodid[1] );
			}
			for(var i=0;i<=prodname.length-2;i++)
			{
				var prodid=prodname[i].split(",");
				addOption(document.frmbank.prod1, prodid[0], prodid[1] );
				addOption(document.frmbank.prod2, prodid[0], prodid[1] );
				addOption(document.frmbank.prod3, prodid[0], prodid[1] );
			}
		} 
	}
}
function GetXmlHttpObject1()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}
function moveLeft()
{
document.getElementById('sensMarquee').direction='left';

}
function moveRight()
{
document.getElementById('sensMarquee').direction='right';
}







function localityselect()
{
var city=document.form1.city.value;
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="real-locality.php?city="+city;
xmlHttp.onreadystatechange = function(){ stateChanged2(1); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function stateChanged2(param) 
{ 
	if(param==1)
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
 			var cty=xmlHttp.responseText;
			var cityname=cty.split("-");
			removeAllOptions(document.form1.locality);
			addOption(document.form1.locality, "", "All Localities" );
			for(var i=0;i<=cityname.length-2;i++)
			{
				var cityid=cityname[i].split(",");
				addOption(document.form1.locality, cityid[0], cityid[1] );
			}
		} 
	}
}
