function getpgs(val,cntryrog)
{
   var getpgvalue=val;
   var cntryid= cntryrog;
   //alert('in getpgs');
   var peopleGroupName = escape(document.getElementById("peopleGroupName").value);
   var pgalphas = escape(document.getElementById("pgalphas").value);
   if(peopleGroupName!='' &&pgalphas!='')
	{
		//var confirmation= confirm("do you want to select other countries people group areas?");
		//if(confirmation==true)
		//{
			 //alert("true");
			 document.getElementById("peopleGroupName").value ='others';
		 //}
		 //if(confirmation==false)
		 //{
			  //alert("false");
			  //document.getElementById("peopleGroupName").value ='';
			  //getpgvalue='';
			  //document.getElementById("pgothershdgdiv").innerHTML ='';
				//document.getElementById("pgalphasdiv").innerHTML ='';
				//document.getElementById("pglistdiv").innerHTML = '';
								
				//document.getElementById("pgothershdgdiv").style.display = 'none';
				//document.getElementById("pgalphasdiv").style.display = 'none';
				//document.getElementById("pglistdiv").style.display = 'none';
		  //}
	 }
   var xmlHttp=null;
		 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()
		{
			document.getElementById("statusDIV").innerHTML = 'Please wait process is going on...';
			showLoading(true);	
			if(xmlHttp.readyState == 4)
			{
			   //alert(xmlHttp.responseText);
				HandleResponse(xmlHttp.responseText);
			}
		}
		
		flag='12';
		xmlHttp.open("POST", "includes/webutilities.php", true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlHttp.send( '&flag=' + flag +'&cntryid='+ cntryid+'&getpgletter='+getpgvalue);
		function HandleResponse(response) 
		{
		   //alert(response);
		   if (document.getElementById("pglistdiv")) {
			  if (document.getElementById("pglistdyndiv")) {
				var pardiv = document.getElementById("pglistdiv");
				var childdiv = document.getElementById("pglistdyndiv");
				pardiv.removeChild(childdiv);
			  }
			   var newdiv = document.createElement("div");
			   newdiv.id = 'pglistdyndiv';
				//newdiv.innerHTML = "<table width='100%'><tr><td class='tab_table_label' width='500px'> People Group Name:</td><td><select class='selectboxes' style='width:145px; position:inherit' id='pgname_list' name='pgname_list'><option style='width:145px; position:inherit' selected='selected' value='all'> Select a People Group Name...</option>"+response+"</select></td></tr></table>";
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td class='tab_table_label' width='100%'> People Group Name:</td><td><select class='selectboxes' style='position:inherit' id='pgname_list' name='pgname_list'><option style='position:inherit' selected='selected' value='all'> Select a People Group Name...</option>"+response+"</select></td></tr></table>";
			   var container = document.getElementById("pglistdiv");
			   container.appendChild(newdiv);
				document.getElementById("statusDIV").innerHTML = '';
				showLoading(false);	
		   }
		}
}


function getstates(val)
{
   countryrog=val;
   //alert(countryrog);
   var countryselectedindex=escape(document.getElementById("countrieslist").selectedIndex);
   var countryresponse= document.update_pg.countrieslist.options[countryselectedindex].text;
   
   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)
			{
				HandleResponse(xmlHttp.responseText);
			}
		}

		var cntryid= "<?php echo $_REQUEST['cntry'];?>";
		flag='13';
		xmlHttp.open("POST", "includes/utilities.php", true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlHttp.send( '&flag=' + flag +'&cntryid='+ cntryid+'&countryrog='+countryrog);
		function HandleResponse(response) 
		{
		  // alert(response);	   
		   if (document.getElementById("stateslistdiv")) {
			  if (document.getElementById("statesdyndiv")) {
				var pardiv = document.getElementById("stateslistdiv");
				var childdiv = document.getElementById("statesdyndiv");
				pardiv.removeChild(childdiv);
			  }
			   var newdiv = document.createElement("div");
			   newdiv.id = 'statesdyndiv';
				newdiv.innerHTML = "<select class='rop_box' style='width:145px; position:inherit' id='stateslist' name='stateslist' onchange='getcities(this.value);'><option style='width:145px; position:inherit' selected='selected' value=''>Select a State...</option>"+response+"</select>";
			   var container = document.getElementById("stateslistdiv");
			   container.appendChild(newdiv);
		   }
		}
		
}

function getcities(val)
{
   countryname= 'INDIA';
   statename= 'goa';
   //alert(countryrog);
   var countryselectedindex=escape(document.getElementById("countrieslist").selectedIndex);
   var countryresponse= document.update_pg.countrieslist.options[countryselectedindex].text;
   var stateselectedindex=escape(document.getElementById("stateslist").selectedIndex);
   var stateresponse= document.update_pg.stateslist.options[stateselectedindex].text;
   var xmlHttp14;
		 try
		 {
			 // Firefox, Opera 8.0+, Safari
			 xmlHttp14=new XMLHttpRequest();
		 }
		catch (e)
		{
		  // Internet Explorer
		  try
			{
				xmlHttp14=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
				xmlHttp14=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
				alert("Your browser does not support AJAX!");
				return false;
			  }
			}
		}
		
		xmlHttp14.onreadystatechange = function()
		{
			document.getElementById("statusDIV").innerHTML = 'Please wait process is going on...';
			showLoading(true);	
			if(xmlHttp14.readyState == 4)
			{
				HandleResponse(xmlHttp14.responseText);
			}
		}

		//alert("country name:"+countryresponse+"\n state name:"+stateresponse);
		flag='14';
		xmlHttp14.open("POST", "includes/webutilities.php", true);
		xmlHttp14.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlHttp14.send( '&flag=' + flag +'&countryname='+ countryresponse+'&statename='+stateresponse);
		function HandleResponse(response) 
		{
		  //alert(response);
		   //document.getElementById("cityselection").value= 1;
		   if (document.getElementById("citieslistdiv")) {
			  if (document.getElementById("citiesdyndiv")) {
				var pardiv = document.getElementById("citieslistdiv");
				var childdiv = document.getElementById("citiesdyndiv");
				pardiv.removeChild(childdiv);
			  }
			   var newdiv = document.createElement("div");
			   newdiv.id = 'citiesdyndiv';
				newdiv.innerHTML = "<select class='rop_box' style='position:inherit' id='citieslist' name='citieslist'><option style='position:inherit' selected='selected' value=''>Select a City...</option>"+response+"</select>";
			   var container = document.getElementById("citieslistdiv");
			   container.appendChild(newdiv);
				document.getElementById("statusDIV").innerHTML = '';
				showLoading(false);	
		   }
		}
}

function getlgs(val,cntryrog)
{
   var getlgvalue=val;
   var cntryid= cntryrog;
   //alert('in getpgs');
   var languageNameVal = escape(document.getElementById("languageName").value);
   var lgalphas = escape(document.getElementById("lgalphas").value);
   var languageNameVal = escape(document.getElementById("languageName").value);
   var lgalphas = escape(document.getElementById("lgalphas").value);
   if(languageNameVal!='' &&lgalphas!='')
	{
		//var confirmation= confirm("do you want to select other countries languages?");
		//if(confirmation==true)
		//{
			 //alert("true");
			 document.getElementById("languageName").value ='others';
		 //}
		 //if(confirmation==false)
		 //{
			  //alert("false");
			  //document.getElementById("languageName").value ='';
			  //getpgvalue='';
			  //document.getElementById("lgothershdgdiv").innerHTML ='';
				//document.getElementById("lgalphasdiv").innerHTML ='';
				//document.getElementById("lglistdiv").innerHTML = '';
								
				//document.getElementById("lgothershdgdiv").style.display = 'none';
				//document.getElementById("lgalphasdiv").style.display = 'none';
				//document.getElementById("lglistdiv").style.display = 'none';
		  //}
	 }
   var xmlHttp=null;
		 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()
		{
			document.getElementById("statusDIV").innerHTML = 'Please wait process is going on...';
			showLoading(true);	
			if(xmlHttp.readyState == 4)
			{
			   //alert(xmlHttp.responseText);
				HandleResponse(xmlHttp.responseText);
			}
		}
		
		flag='20';
		xmlHttp.open("POST", "includes/webutilities.php", true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlHttp.send( '&flag=' + flag +'&cntryid='+ cntryid+'&getlgletter='+getlgvalue);
		function HandleResponse(response) 
		{
		   //alert(response);
		   if (document.getElementById("lglistdiv")) {
			  if (document.getElementById("lglistdyndiv")) {
				var pardiv = document.getElementById("lglistdiv");
				var childdiv = document.getElementById("lglistdyndiv");
				pardiv.removeChild(childdiv);
			  }
			   var newdiv = document.createElement("div");
			   newdiv.id = 'lglistdyndiv';
				//newdiv.innerHTML = "<select class='selectboxes' style='width:145px; position:inherit' id='lgname_list' name='lgname_list'><option style='width:145px; position:inherit' selected='selected' value='all'> Select a Language Group Name...</option>"+response+"</select>";
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='tab_table_label' width='100%'> Language Name:</td><td><select class='selectboxes' style='position:inherit' id='lgname_list' name='lgname_list'><option style='position:inherit' selected='selected' value='all'> Select a Language Group Name...</option>"+response+"</select></td></tr></table>";
			   var container = document.getElementById("lglistdiv");
			   container.appendChild(newdiv);
				document.getElementById("statusDIV").innerHTML = '';
				showLoading(false);	
		   }
		}
}


function pgareas(val,countrycode)
{
	
	var compare= document.getElementById("peopleGroupName").value;
	//if(compare!='')
	//{
		if(compare=='others'||compare=='')
		{
			var alphabetslist = "<option value='a'>a</option><option value='b'>b</option><option value='c'>c</option><option value='d'>d</option><option value='e'>e</option><option value='f'>f</option><option value='g'>g</option><option value='h'>h</option><option value='i'>i</option><option value='j'>j</option><option value='k'>k</option><option value='l'>l</option><option value='m'>m</option><option value='n'>n</option><option value='o'>o</option><option value='p'>p</option><option value='q'>q</option><option value='r'>r</option><option value='s'>s</option><option value='t'>t</option><option value='u'>u</option><option value='v'>v</option><option value='w'>w</option><option value='x'>x</option><option value='y'>y</option><option value='z'>z</option>";
			if (document.getElementById("pgothershdgdiv")) {
				if (document.getElementById("pgothershdgdyndiv")) {
					var pardiv = document.getElementById("pgothershdgdiv");
					var childdiv = document.getElementById("pgothershdgdyndiv");
					pardiv.removeChild(childdiv);
				}
			    //	Only Lable will come
				var newdiv = document.createElement("div");
				newdiv.id = 'pgothershdgdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='label_small' width='100%'>People Groups of Other Countries</td><td>&nbsp;</td></tr></table>";
				var container = document.getElementById("pgothershdgdiv");
				container.appendChild(newdiv);
				document.getElementById("pgothershdgdiv").style.display = 'block';
			}		  
            // Alphabets will come
			if (document.getElementById("pgalphasdiv")) {
				//alert("coming to inner"+countryids);
				if (document.getElementById("pgalphasdyndiv")) {
					var pardiv = document.getElementById("pgalphasdiv");
					var childdiv = document.getElementById("pgalphasdyndiv");
					pardiv.removeChild(childdiv);
				}
				var newdiv = document.createElement("div");
				newdiv.id = 'pgalphasdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='tab_table_label' width='100%'>Select by alphabet: </td><td><select class='selectboxes' style='position:inherit' id='pgalphas' name='pgalphas' onchange=getpgs(this.value,'"+countrycode+"')><option style='position:inherit' selected='selected' value=''>Select an alphabet...</option>"+alphabetslist+"</select></td></tr></table>";
				var container = document.getElementById("pgalphasdiv");
				container.appendChild(newdiv);
				document.getElementById("pgalphasdiv").style.display = 'block';
			}		  
           // Pg list will come
			if (document.getElementById("pglistdiv")) {
				if (document.getElementById("pglistdyndiv")) {
					var pardiv = document.getElementById("pglistdiv");
					var childdiv = document.getElementById("pglistdyndiv");
					pardiv.removeChild(childdiv);
				}
				var newdiv = document.createElement("div");
				newdiv.id = 'pglistdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='tab_table_label' width='100%'>People Group Name:</td><td><select class='selectboxes' style='position:inherit' id='pgname_list' name='pgname_list'><option style='position:inherit' selected='selected' value='all'> Select a People Group Name...</option></select></td></tr></table>";
				var container = document.getElementById("pglistdiv");
				container.appendChild(newdiv);
				document.getElementById("pglistdiv").style.display = 'block';
			}
			document.getElementById("statusDIV").innerHTML = '';
			showLoading(false);	
			if(document.getElementById("pgalphas").value=='')
			{
			  //	document.getElementById("peopleGroupName").value =""; 
			 }
		}
		if(compare!='others')
		{
			  
			var peopleGroupName= document.getElementById("peopleGroupName").value;
			if(document.getElementById("pgalphas"))
			{
				document.getElementById("pgothershdgdiv").innerHTML ='';
				document.getElementById("pgalphasdiv").innerHTML ='';
				document.getElementById("pglistdiv").innerHTML = '';
								
				document.getElementById("pgothershdgdiv").style.display = 'none';
				document.getElementById("pgalphasdiv").style.display = 'none';
				document.getElementById("pglistdiv").style.display = 'none';
			 }
		}
	//}
 }
 
 function lgarea(val,countrycode)
{
  //	alert("coming to pgarea");
	var compare= document.getElementById("languageName").value;
	//if(compare!='')
	//{
		if (compare=='others'||compare=='')
		{
			var alphabetslist = "<option value='a'>a</option><option value='b'>b</option><option value='c'>c</option><option value='d'>d</option><option value='e'>e</option><option value='f'>f</option><option value='g'>g</option><option value='h'>h</option><option value='i'>i</option><option value='j'>j</option><option value='k'>k</option><option value='l'>l</option><option value='m'>m</option><option value='n'>n</option><option value='o'>o</option><option value='p'>p</option><option value='q'>q</option><option value='r'>r</option><option value='s'>s</option><option value='t'>t</option><option value='u'>u</option><option value='v'>v</option><option value='w'>w</option><option value='x'>x</option><option value='y'>y</option><option value='z'>z</option>";
			if (document.getElementById("lgothershdgdiv")) {
				if (document.getElementById("lgothershdgdyndiv")) {
					var pardiv = document.getElementById("lgothershdgdiv");
					var childdiv = document.getElementById("lgothershdgdyndiv");
					pardiv.removeChild(childdiv);
				}
				var newdiv = document.createElement("div");
				newdiv.id = 'lgothershdgdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='label_small' width='100%'>Language Groups of Other Countries</td><td>&nbsp;</td></tr></table>";
				var container = document.getElementById("lgothershdgdiv");
				container.appendChild(newdiv);
				document.getElementById("lgothershdgdiv").style.display = 'block';
			}		  

			if (document.getElementById("lgalphasdiv")) {
				if (document.getElementById("lgalphasdyndiv")) {
					var pardiv = document.getElementById("lgalphasdiv");
					var childdiv = document.getElementById("lgalphasdyndiv");
					pardiv.removeChild(childdiv);
				}
				var newdiv = document.createElement("div");
				newdiv.id = 'lgalphasdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='tab_table_label' width='100%'>Select by alphabet: </td><td><select class='selectboxes' style='position:inherit' id='lgalphas' name='lgalphas' onchange=getlgs(this.value,'"+countrycode+"')><option style='position:inherit' selected='selected' value=''>Select an alphabet...</option>"+alphabetslist+"</select></td></tr></table>";
				var container = document.getElementById("lgalphasdiv");
				container.appendChild(newdiv);
				document.getElementById("lgalphasdiv").style.display = 'block';
			}		  

			if (document.getElementById("lglistdiv")) {
				if (document.getElementById("lglistdyndiv")) {
					var pardiv = document.getElementById("lglistdiv");
					var childdiv = document.getElementById("lglistdyndiv");
					pardiv.removeChild(childdiv);
				}
				var newdiv = document.createElement("div");
				newdiv.id = 'lglistdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0'><tr><td class='tab_table_label' width='100%'>Language Name:</td><td><select class='selectboxes' style='position:inherit' id='lgname_list' name='lgname_list'><option style='position:inherit' selected='selected' value='all'> Select a Language Group Name...</option></select></td></tr></table>";
				var container = document.getElementById("lglistdiv");
				container.appendChild(newdiv);
				document.getElementById("lglistdiv").style.display = 'block';
			}
			document.getElementById("statusDIV").innerHTML = '';
			showLoading(false);	
		} 
		if(compare!='others')
		{
			  
			var peopleGroupName= document.getElementById("peopleGroupName").value;
			if(document.getElementById("lgalphas"))
			{
				document.getElementById("lgothershdgdiv").innerHTML ='';
				document.getElementById("lgalphasdiv").innerHTML ='';
				document.getElementById("lglistdiv").innerHTML = '';
								
				document.getElementById("lgothershdgdiv").style.display = 'none';
				document.getElementById("lgalphasdiv").style.display = 'none';
				document.getElementById("lglistdiv").style.display = 'none';
			 }
		}
	//}
}
 
 
 
 
 
 
function getothers(val,cntryrog)
{
   var getpgvalue=val;
   var cntryid= cntryrog;
   //alert('in getothers');
   var peopleGroupName = escape(document.getElementById("peopleGroupName").value);
   var pgalphas = escape(document.getElementById("pgalphas").value);
   
   var xmlHttp=null;
		 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()
		{
			document.getElementById("statusDIV").innerHTML = 'Please wait process is going on...';
			showLoading(true);	
			if(xmlHttp.readyState == 4)
			{
			   //alert(xmlHttp.responseText);
				HandleResponse(xmlHttp.responseText);
			}
		}
		
		flag='12';
		xmlHttp.open("POST", "includes/utilities.php", true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlHttp.send( '&flag=' + flag +'&cntryid='+ cntryid+'&getpgletter='+getpgvalue);
		function HandleResponse(response) 
		{
		   //alert(response);
		   if (document.getElementById("pglistdiv")) {
			  if (document.getElementById("pglistdyndiv")) {
				var pardiv = document.getElementById("pglistdiv");
				var childdiv = document.getElementById("pglistdyndiv");
				pardiv.removeChild(childdiv);
			  }
			   var newdiv = document.createElement("div");
			   newdiv.id = 'pglistdyndiv';
				newdiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td class='tab_table_label' width='500px'> People Group Name:</td><td><select class='selectboxes' style='position:inherit' id='pgname_list' name='pgname_list'><option style='position:inherit' selected='selected' value='all'> Select a People Group Name...</option>"+response+"</select></td></tr></table>";
			   var container = document.getElementById("pglistdiv");
			   container.appendChild(newdiv);
				document.getElementById("statusDIV").innerHTML = '';
				showLoading(false);	
		   }
		}
}
 
