// declare new variables for each new div that you add, and link to the div by ID
var doc = null;

function ajax() {
	// Make a new XMLHttp object
	if (typeof window.ActiveXObject != 'undefined' ) doc = new ActiveXObject("Microsoft.XMLHTTP");
	else doc = new XMLHttpRequest();
}

function SelectStateAff(id_country, id_state, destination, string_0, string_1, from_admin ){
    if (id_country != '' ) {
		ajax();
		var mydiv = document.getElementById(destination);
		if (doc && mydiv){
	    	doc.onreadystatechange = function() {
	    		if (doc.readyState == 4) {
	    			if (doc.responseText == "") {
						mydiv.innerHTML = string_0;
					} else {
						mydiv.innerHTML = doc.responseText;
					}
				} else {
					mydiv.innerHTML = string_1;
				}
			}
			if (from_admin == 1) {
				path = "../";
			} else {
				path = "";
			}
			doc.open("GET", path + "select_state.php?id_country=" + id_country + "&state_id=" + id_state, true);
			doc.send(null);
	    } else{
	       	mydiv.innerHTML = 'Browser unable to create XMLHttp Object';
	    }
	}
}

