// ugf.js
// (C)2009 Derek Skeba

function getAjax() {

	var ajaxObj;
	
	if (window.XMLHttpRequest) {
		// works with IE7+, Firefox, Chrome, Opera, Safari
		ajaxObj = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// works with IE6, IE5
		ajaxObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Warning: You need an AJAX supported browser to use the Unlock Guide Finder.");
	}
	
	return ajaxObj;
	
}

function getModels(phone_man) {

	if (document.getElementById('ugf_manufacturers').value == "default") {
	
		document.getElementById('ugf_models_cell').innerHTML = "<select id='ugf_models' title='Select Phone Model' disabled><option value='default'>Select Phone Model:</option></select>";
		
	} else {
	
		var ajax = getAjax();
		
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				document.getElementById('ugf_models_cell').innerHTML = ajax.responseText;
			}
		}
		
		var ajax_url = "http://hyfeno.com/unlockguidefinder/getmodels.php?manufacturer=" + phone_man;
		
		ajax.open("GET", ajax_url, true);
		ajax.send(null);
	
	}

}

function getManufacturers() {

	var ajax = getAjax();
	
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 4) {
			document.getElementById('ugf_manufacturers_cell').innerHTML = ajax.responseText;
		}
	}
	
	ajax.open("GET", "http://hyfeno.com/unlockguidefinder/getmanufacturers.php", true);
	ajax.send(null);

}

function getGuide(url) {

	// redirect the user to the phone guide
	window.location = url;

}

// Run our main code now:

getManufacturers();


// Then End of the main code
