// JavaScript Document
var xmlHttp;

function GetXmlHttpObject()
{
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 change_project(client_id,consultant_id)
{
	
	 var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
var url="change_project.php";
url=url+"?id="+client_id;

//xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);

xmlHttp.send();
  xmlHttp.onreadystatechange = function() {  
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200)
			{
				if(xmlHttp.responseText != "")
				{
					
					document.getElementById('project').innerHTML="";
               		document.getElementById('project').innerHTML=xmlHttp.responseText;
					
				}
			}
			
        }
    }
}



function change_country1(val) {
	if(val=='other') {
		document.getElementById('othercountry').style.display='';
	}
	else {
		document.getElementById('othercountry').style.display='none';
	}
}

function change_state(val) {
	if(val=='other') {
		document.getElementById('otherstate').style.display='';
	}
	else {
		document.getElementById('otherstate').style.display='none';
	}
}

function change_city(val) {
	if(val=='other') {
		document.getElementById('othercity').style.display='';
	}
	else {
		document.getElementById('othercity').style.display='none';
	}
}


function GetXmlHttpObject() {
	
	if (window.XMLHttpRequest) {
  // code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
  // code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}


function getCity2(){
	var state=document.getElementById('state1').value;
	if(state == ""){
		window.alert('state required');
		state.focus();
		return false;
	}
	var url = "getCity2.php?state="+state;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeCity1;
	xmlhttp.send(null);
}

function changeCity1() {
		
		if(xmlhttp.readyState!=4)
		{
			document.getElementById('preloader').style.display='';
		}
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
				document.getElementById('preloader').style.display='none';
	             document.getElementById('city').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}


function getState2(){
	var country=document.getElementById('country').value;
	if(country == ""){
		window.alert('country required');
		country.focus();
		return false;
	}
	var url = "getState.php?country="+country;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeState;
	xmlhttp.send(null);
}

function changeState() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('state1').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getDetail(){
	var country=document.getElementById('country').value;
	if(country == ""){
		window.alert('country required');
		country.focus();
		return false;
	}
	var url = "getState.php?country="+country;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeState;
	xmlhttp.send(null);
}

function changeState() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('state1').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getSubArea(){
	var area=document.getElementById('area').value;
	if(area == ""){
		window.alert('Area required');
		area.focus();
		return false;
	}
	var url = "getSubArea.php?area="+area;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeSubArea;
	xmlhttp.send(null);
}

function changeSubArea() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('sub_area').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getNonCoalStateCity(){
	var origin=document.getElementById('origin').value;
	if(origin == ""){
		window.alert('Origin required');
		origin.focus();
		return false;
	}
	var url = "getNonCoalStateCity.php?origin="+origin;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeNonCoalState;
	xmlhttp.send(null);
}

function changeNonCoalState() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('noncoal_state').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}



function getWorkCity(){
	var work_state=document.getElementById('work_state').value;
	if(work_state == ""){
		window.alert('State required');
		work_state.focus();
		return false;
	}
	var url = "getWorkCity.php?work_state="+work_state;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeWorkCity;
	xmlhttp.send(null);
}

function changeWorkCity() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('work_district').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}


function getPort(){
	var work_country=document.getElementById('work_country').value;
	if(work_country == ""){
		window.alert('Country required');
		work_country.focus();
		return false;
	}
	var url = "getPort.php?work_country="+work_country;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changePort;
	xmlhttp.send(null);
}

function changePort() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('port').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getMinesName(){
	var area_mines=document.getElementById('area_mines').value;
	if(area_mines == ""){
		window.alert('Area/Mines required');
		area_mines.focus();
		return false;
	}
	var url = "getMinesName.php?area_mines="+area_mines;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeAreaMines;
	xmlhttp.send(null);
}

function changeAreaMines() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('mines_name').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getNonCoalCity(){
	var noncoal_state=document.getElementById('noncoal_state').value;
	if(noncoal_state == ""){
		window.alert('State required');
		noncoal_state.focus();
		return false;
	}
	var url = "getNoncoalCity.php?noncoal_state="+noncoal_state;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changenonCoalCity;
	xmlhttp.send(null);
}

function changenonCoalCity() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('noncoaldistrict').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}


function getNonCoalport(){
	var noncoaldistrict=document.getElementById('noncoaldistrict').value;
	if(noncoaldistrict == ""){
		window.alert('District required');
		noncoaldistrict.focus();
		return false;
	}
	var url = "getNoncoalPort.php?noncoaldistrict="+noncoaldistrict;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changenonCoalPort;
	xmlhttp.send(null);
}

function changenonCoalPort() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('noncoal_port').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function subForm(id)
{
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	 var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
if(name=='' || email=='' || phone=='') {
	alert("Please enter all details!");
	return;
}
var url="submitenq.php";
url=url+"?id="+id;
url=url+"&name="+name;
url=url+"&email="+email;
url=url+"&phone="+phone;
//alert(url);
//xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);

xmlHttp.send();
  xmlHttp.onreadystatechange = function() {  
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200)
			{
				if(xmlHttp.responseText != "")
				{
					//alert(xmlHttp.responseText);
					iBox.hide();
					document.getElementById('contact_'+id).style.display="";
					document.getElementById('more_'+id).style.display="none";
					
				}
			}
			
        }
    }
}

function checkCrn(){
	var crn=document.getElementById('crn').value;
	if(crn == ""){
		window.alert('CRN required');
		crn.focus();
		return false;
	}
	var url = "checkCrn.php?crn="+crn;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = changeCheckCRN;
	xmlhttp.send(null);
}

function changeCheckCRN() {
	   if(xmlhttp.readyState==4)
	   {
	    if(xmlhttp.status==200)
	        {
	             document.getElementById('checkcrn').innerHTML=xmlhttp.responseText;;
	        }
	    else
	    {
	       alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
	    }
	   }
}

function getEnquiry(id){
	if(id!='') {
	alert(id);
	return;
	}
	var url = "getEnq.php?id="+id;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = stateChangeEnquiry;
	xmlhttp.send(null);
}

function stateChangeEnquiry() {
   if(xmlhttp.readyState==4)
    {
        if(xmlhttp.status==200)
            {
                 document.getElementById('enquiry').innerHTML=xmlhttp.responseText;;
            }
        else
        {
           alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
        }
    }

}


function getDetail(id){
var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	if(name=='' || email=='' || phone=='') {
	alert("Please enter all details!");
	return;
	}
	var url = "getDtl.php?id="+id+"&email="+email+"&name="+name+"&phone="+phone;
	xmlhttp = GetXmlHttpObject();
	if (xmlhttp === null) {
		alert('Your browser does not support XMLHTTP!');
		return;
	}
	
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = stateChanged;
	xmlhttp.send(null);
}

function stateChanged() {
   if(xmlhttp.readyState==4)
    {
        if(xmlhttp.status==200)
            {
                 document.getElementById('detail').innerHTML=xmlhttp.responseText;;
				 document.getElementById('enquiry').style.display='none';
            }
        else
        {
           alert("Error loading pagen"+ xmlhttp.status +":"+xmlhttp.statusText);
        }
    }

}



function change_origin(orig)
{
	if(orig=="Indian"){
		document.getElementById('area').style.display="block";
		document.getElementById('mine').style.display="none";
	}
	if(orig=="International"){
		document.getElementById('mine').style.display="block";
		document.getElementById('area').style.display="none";
	}
}

