/* ~~~ Vodafone Namespace ~~~ */

var VF = window.VF || {};

VF.roaming = function() {
	// private variables and functions
	var Y = YAHOO.util,
		$D = Y.Dom,
		$E = Y.Event,
		$C = Y.Connect;

 	// public variables and functions
	return {
		makeRequest : function() {
			var sURL = 'getcountry.jsp';
			var div = $D.get('replacethis');
		
			var handleSuccess = function(o){
				if(o.responseText !== undefined){
					div.innerHTML = o.responseText;
				}
			}
			
			var handleFailure = function(o){
				if(o.responseText !== undefined){
					div.innerHTML = "<!-- Transaction id: " + o.tId + "\n";
					div.innerHTML += "HTTP status: " + o.status + "\n";
					div.innerHTML += "Status code message: " + o.statusText + " -->";
				}
			}
			
			var callback = {
			  success: handleSuccess,
			  failure: handleFailure,
			  argument: { }
			};
			
			div.innerHTML = '<div style="text-align:center"><img src="loader.gif" width="32" height="32" alt="Network information is loading" /></div>';
			ob = $D.get('selCountries');
			var chosenCountry = '';
			for (var i = 0; i < ob.options.length; i++) if (ob.options[ i ].selected) chosenCountry = (ob.options[ i ].value);
			var request = $C.asyncRequest('GET', sURL + '?type=country&country=' + chosenCountry, callback);
		}
	};
}();

YAHOO.util.Event.on(window, 'load', VF.roaming.init);


/* // old code
function formHandler(area){
	var selectBox = document.formall.all;
	var URL = selectBox.options[selectBox.selectedIndex].value;
	if (URL.length == 0) {
		alert('Please select a country');
		return false;
	} else {
		window.location.href = ("/roaming/countries/" + URL);
	}
}

*/
