// Roshan's Ajax dropdown code with php
// This notice must stay intact for legal use
// Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
// If you have any problem contact me at http://roshanbh.com.np
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getState(countryId) {		
		
		var strURL="findState.php?country="+countryId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	function getCity(countryId,stateId) {		
		var strURL="findCity.php?country="+countryId+"&state="+stateId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
		function getUserInfo(selectedValue) {		
		var strURL="finduserinfo.php?selectedvalue="+selectedValue;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('userinfodiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
/////////////////////////////////
var xmlHttp2;

function getLoginStatus(str)
{

var usertype1 = document.getElementById("nu_0").checked;
var usertype2 = document.getElementById("nu_1").checked;

xmlHttp2=GetXmlHttpObject2();
if (xmlHttp2==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 

if(usertype1==true){
var url="findLoginStatus.php?login="+str+"&usertp=new";
}else if (usertype2==true){
var url="findLoginStatus.php?login="+str+"&usertp=exist";
}
url=url+"&sid="+Math.random(); 
xmlHttp2.onreadystatechange=AlertRestriction;
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);
} 
function AlertRestriction() 
{ 
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 

  //var  resp2 = xmlHttp2.responseText;
  var respln = xmlHttp2.responseText.length;
//alert(respln); 
   if(respln==8){
    document.getElementById("loginStatus").innerHTML="";
    document.getElementById("loginStatus").innerHTML="Invalid";
   } else if(respln==6){
    document.getElementById("loginStatus").innerHTML="";
    document.getElementById("loginStatus").innerHTML="Not Available";
   } else if(respln==10){
    document.getElementById("loginStatus").innerHTML="";
    document.getElementById("loginStatus").innerHTML="Available";
   } else if(respln==14){
    document.getElementById("loginStatus").innerHTML="";
    document.getElementById("loginStatus").innerHTML="Invalid Login Email";
   } else if(respln==3){
    document.getElementById("loginStatus").innerHTML="";
    document.getElementById("loginStatus").innerHTML="Login Email ok";
   }else{
	document.getElementById("loginStatus").innerHTML="";
    
   }
   
   
   
 } 
}
 
function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp2=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp2;
}
/////////////////////////////////////
