// JavaScript Document
function getXMLHTTP1() { //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 get_caste(id)
{
		
var strURL="ajax_selectcaste.php?id="+id;
	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
}
function get_subcaste(id)
{
		
var strURL="ajax_select_subcaste.php?id="+id;
	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
}

function getCasteSearch(casteid) {

	var strURL="ajax_select_religionsearch.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}
function getCasteWeb(relid,casteid) {

	var strURL="ajax_select_religion_whois_web.php?relid="+relid+'&casteid='+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}
function getCasteAdvancedSearch(casteid) {

	var strURL="ajax_religion_adv_search.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}

function getSubCasteAdvancedSearch(casteid) {

	var strURL="ajax_caste_adv_select.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}


function getCastehome(casteid) {

	var strURL="ajax_select_religionhome.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) { 
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}




function getCaste(casteid,cast) {

	var strURL="ajax_select_religion.php?casteid=" + casteid + "&cast=" + cast;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}
function getCasteEdit(casteid,cast) {

	var strURL="ajax_select_religion.php?casteid="+casteid+"&cast="+cast;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}	
	
//getSubCaste(this.selectedvalue);	
}

function getSubCaste(casteid,subcastid) {	

	var strURL="ajax_select_cast.php?casteid=" + casteid + "&subcastid=" + subcastid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getSubCasteEdit(casteid,subcastid) {	
	var strURL="ajax_select_cast.php?casteid="+casteid+"&subcastid="+subcastid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getSubCastesearch(casteid) {	
	var strURL="ajax_select_castsearch.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}


function getCasteExp(casteid,caste_ids) {	

	var strURL="exp_ajax_select_religion.php?casteid="+casteid+"&caste_ids="+caste_ids;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
			// only if "OK"
				if (req.status == 200) {
					document.getElementById('exp_caste_disp').innerHTML=req.responseText;						
				
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getSubCasteExp(casteid) {		

	var strURL="exp_ajax_select_cast.php?casteid="+casteid;

	var req = getXMLHTTP1();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					document.getElementById('subcaste1').innerHTML=req.responseText;	
			
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function HaveChildnp()
	{
//		var MARST = document.register1.maritial_status.options[document.register1.maritial_status.selectedIndex].value;



		var CHILDLW = document.register1.no_of_children.options[document.register1.no_of_children.selectedIndex].value;

		
		if(document.register1.maritial_status[0].checked)
		{
		document.register1.no_of_children.disabled=true;	
		document.register1.child_living_with_me[0].disabled=true;		
		document.register1.child_living_with_me[1].disabled=true;									
	    }
		 else if ( document.register1.maritial_status[1].checked || document.register1.maritial_status[2].checked  || document.register1.maritial_status[3].checked  || document.register1.maritial_status[4].checked)
		{
		document.register1.no_of_children.disabled=false;			
		document.register1.child_living_with_me[0].disabled=false;		
		document.register1.child_living_with_me[1].disabled=false;											
		}
		
		
		if(document.register1.maritial_status[0].checked && document.register1.child_living_with_me[0].checked || document.register1.child_living_with_me[1].checked)
		{
		document.register1.child_living_with_me[0].disabled=true;		
		document.register1.child_living_with_me[1].disabled=true;											
		}
		

		if(CHILDLW > 0)
		{
			if ( document.register1.maritial_status[0].checked)
			{
					if ( (document.register1.child_living_with_me[0].checked || document.register1.child_living_with_me[1].checked) && (!document.register1.child_living_with_me[0].checked || !document.register1.child_living_with_me[1].checked) )
					{
							document.register1.child_living_with_me[0].checked=false;
							document.register1.child_living_with_me[1].checked=false;
							document.register1.child_living_with_me[0].disabled=true;		
							document.register1.child_living_with_me[1].disabled=true;	
					}
					
		
					
			}
		}

		if(CHILDLW == 0)
		{
		document.register1.child_living_with_me[0].disabled=true;		
		document.register1.child_living_with_me[1].disabled=true;							
	    }
			 
		else if ( CHILDLW > 1)
		{
		document.register1.child_living_with_me[0].disabled=false;		
		document.register1.child_living_with_me[1].disabled=false;							
		}
		
		
	}
	
	function showhidediv(val)
	{ 
		if (val=='India')
		{
			document.getElementById('select_state').style.display='block';
			document.getElementById('select_city').style.display='block';
			document.getElementById('text_state').style.display='none';
			document.getElementById('text_city').style.display='none';
			document.getElementById('country_identiy').value='India';
		}
		else
		{
			document.getElementById('select_state').style.display='none';
			document.getElementById('select_city').style.display='none';
			document.getElementById('text_state').style.display='block';
			document.getElementById('text_city').style.display='block';
			document.getElementById('country_identiy').value='';
		}
	}

	function get_state(id,state_id) {	

		if (id== 98)
		{	
			document.getElementById('city_list').style.display = 'block'; 
			document.getElementById('city_text').style.display = 'none';
		} 		 
		else
		{
			document.getElementById('city_text').style.display = 'block'; 
			document.getElementById('city_list').style.display = 'none'; 
		}

			var strURL="ajax_get_state.php?id=" + id + "&state_id=" + state_id;
			
			var req = getXMLHTTP1();
			if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) { 
							document.getElementById('states').innerHTML = req.responseText;		
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}	
				}	
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}	
		
	}
	function get_city(id,city_id) {	

			var strURL="ajax_get_city.php?id=" + id + "&city_id=" + city_id;
			var req = getXMLHTTP1();
			if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) { 
							document.getElementById('city_list').innerHTML = req.responseText;		
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}	
				}	
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}	
		
	}
	
	function matriValidation()
	{
		if (document.getElementById('matri_id').value == '')
		{
			alert("Please enter the profile id.");
			return false; 
		}
		return true;
	}
