// JavaScript Document
function Validation()
{
	if (document.frmReg.name.value=="")
	{
		alert("Please Enter Your Name");
		document.frmReg.name.focus();
		return false;
	}
	
	if (document.frmReg.email.value=="")
	{
		alert("Please Enter Your E-mail");
		document.frmReg.email.focus();
		return false;
	}
	if(echeck(document.frmReg.email.value)==false) 
	{
		document.frmReg.email.value="";
		document.frmReg.email.focus();
		return false;
	}
	if (document.frmReg.mobile.value=="")
	{
		alert("Please Enter Your Mobile Number");
		document.frmReg.mobile.focus();
		return false;
	}
	if(isNumeric(document.getElementById('mobile'))==false)
	{
		alert("Enter a valid mobile number");
		//document.mob.mobilenumber.value=="";
		document.frmReg.mobile.focus();
		return false;
	}
	var addDes2 = document.frmReg.mobile.value;
	if(addDes2.length > 10)
	{
	alert("You can enter a maximum of 10 numbers only. Currently you have entered "+addDes2.length+" numbers");
	document.frmReg.mobile.focus();
	return false;
	}
	else if(addDes2.length < 10)
	{
	alert("You can enter a minimum of 10 numbers. Currently you have entered only "+addDes2.length+" numbers");
	document.frmReg.mobile.focus();
	return false;
	}
	if (document.frmReg.imgbox.value=="")
	{
		alert("Please Enter The Code");
		document.frmReg.imgbox.focus();
		return false;
	}
	return true;
}

function echeck(str) { //check mail id in correct format

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }	
	}
	
	function isNumeric(elem)
{
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
	return true;
}
else
{
	return false;
}
}

function getmostpopular(cat)
		{
		var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
			  alert("Your browser does not support AJAX!");
			  return false;
			  }
			}
		  }
		  xmlHttp.onreadystatechange=function()
			{
			if(xmlHttp.readyState==4)
			  {
				  //alert(xmlHttp.responseText);
				  document.getElementById("poplst").innerHTML=xmlHttp.responseText;
				  
			  }
			}
		 var category = cat;											
		  xmlHttp.open("GET","http://www.makemystocks.com/getmostpopular.php?cat="+category,true);
		  xmlHttp.send(null);
		  }
		  
	function getMktMovers(cat)
	{
		var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
			  alert("Your browser does not support AJAX!");
			  return false;
			  }
			}
		  }
		  xmlHttp.onreadystatechange=function()
			{
			if(xmlHttp.readyState==4)
			  {
				  //alert(xmlHttp.responseText);
				  document.getElementById("mktDisp").innerHTML=xmlHttp.responseText;
				  
			  }
			}
		 var category = cat;											
		  xmlHttp.open("GET","http://www.makemystocks.com/getmktmovers.php?cat="+category,true);
		  xmlHttp.send(null);
	}
	function vote(){
var xmlHttp;
var sel;
	try{
	 xmlHttp = new XMLHttpRequest(); 
	}catch(e){
	 try{
	    xmlHttp = new ActiveXObject("Mxml2.XMLHTTP");
		}catch(e){
		 try{
		  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		 }catch(e){
		  alert("Your browser does not support Ajax");
		  return false;
		 }
		}
	}
	
	  xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
       // document.myForm.time.value=xmlHttp.responseText;
	   alert('Your Vote Recorded');
        }
      }

	
    if(document.getElementById("valone").checked==true){
	 sel=document.getElementById("valone").value;
	}if(document.getElementById("valtwo").checked==true){
	sel=document.getElementById("valtwo").value;
	}if(document.getElementById("valthree").checked==true){
	sel=document.getElementById("valthree").value;
	}
xmlHttp.open("GET","vote.php?result="+sel,true);
xmlHttp.send(null);
 }
 
 function submitForm()
{
	document.quoteform.action = "http://www.makemystocks.com/market/getquote/"+ document.quoteform.cmpname.value;
	document.quoteform.submit();
}

function doSubmit(e)
    {

        var key;

         if(window.event)
              key = window.event.keyCode;     //IE

         else
              key = e.which;     //firefox

    
        if (key == 13)
        {
           document.quoteform.action = "http://www.makemystocks.com/market/getquote/"+ document.quoteform.cmpname.value;
			document.quoteform.submit();

        }

   }

