// reg/rjs/xml_http_request.js

//___________________________________________________

function FindState() {
	document.getElementById('stateID').style.display = 'block';
	
	var cont = document.getElementById('selectState');

	cont.innerHTML = 'Loading States...';

	document.getElementById('findID').style.display = 'none';
	var http = createRequestObject();
	if( http ) {
		http.open('get', 'reg/raj/selects.php?type=state');
		http.onreadystatechange = function () {
			if(http.readyState == 4) {
				cont.innerHTML = http.responseText;
			}
		}
		http.send(null);
	} else {
		document.location = '';
	}
}

//___________________________________________________
function FindUSCity() {
	document.getElementById('cityID').style.display = 'block';
	
	var cont = document.getElementById('selectCity');
	
	cont.innerHTML = 'Loading Cities...';
	
	var http = createRequestObject();
	if( http ) {
		http.open('get', 'reg/raj/selects.php?type=city&stateVal='+document.getElementById('state').value);
		http.onreadystatechange = function () {
			if(http.readyState == 4) {
				cont.innerHTML = http.responseText;
			}
		}
		http.send(null);
	} else {
		document.location = '';
	}
}

//___________________________________________________
function FindZipCode() {
	document.getElementById('zipID').style.display = 'block';
	var cont = document.getElementById('zipSelect');
	cont.innerHTML = 'Loading Zop Codes...';
//	document.getElementById('findID').style.display = 'none';
	var http = createRequestObject();
	if( http ) {
		http.open('get', 'reg/raj/selects.php?type=zip&stateVal='+document.getElementById('state').value+'&cityVal='+document.getElementById('city').value);
		http.onreadystatechange = function () {
			if(http.readyState == 4) {
				cont.innerHTML = http.responseText;
			}
		}
		http.send(null);
	} else {
		document.location = '';
	}
}

//___________________________________________________
function FindCities() {
	var country =document.getElementById('country').value;
	if(country == 'US') {
		document.getElementById('zipID').style.display = 'block';
		document.getElementById('findID').style.display = 'block';
		document.getElementById('cityID').style.display = 'none';
		document.getElementById('stateID').style.display = 'none';
	} else {
		document.getElementById('cityID').style.display = 'block';
		document.getElementById('zipID').style.display = 'none';
		document.getElementById('stateID').style.display = 'none';
		var cont = document.getElementById('selectCity');
		cont.innerHTML = 'Loading Cities...';
		var http = createRequestObject();
		if( http ) {
			http.open('get', 'reg/raj/selects.php?type=cities&countryVal='+country);
			http.onreadystatechange = function () {
				if(http.readyState == 4) {
					cont.innerHTML = http.responseText;
				}
			}
			http.send(null);
		} else {
			document.location = '';
		}
	}
}
//___________________________________________________
function SelectNextPhotos() {
	var cont = document.getElementById('idHeader');
	var http = createRequestObject();
	if( http ) {
		hd_ind++;
		http.open('get', 'reg/raj/select_header.php?type='+hd_ind);
		http.onreadystatechange = function () {
			if(http.readyState == 4) {
				$tt = http.responseText;
				if( $tt != '') {
					cont.innerHTML = http.responseText;
				}
			}
		}
		http.send(null);
	} else {
		document.location = '';
	}
}

//__________________________________________
// Create AJAX object
function createRequestObject()   
{  
        try { return new XMLHttpRequest() }  
        catch(e)   
        {  
            try { return new ActiveXObject('Msxml2.XMLHTTP') }  
            catch(e)   
            {  
                try { return new ActiveXObject('Microsoft.XMLHTTP') }  
                catch(e) { return null; }  
            }  
        }  
}

