function WinRefresh() {

	//Netscape likes a refresh, but Microsoft doesn't
	if (navigator.appName.indexOf("Netscape")>-1)
	history.go(0)

}

function load_data(i, opt0, opt1, ctl) {

	var data = new Option(opt0, opt1);

	ctl.options[i]=data;

}

function clear_data(ctl) {

	if (ctl.options.length > 0) {
   		var length=ctl.options.length;
   		for (var i=0; i < length; i++) {
			ctl.options[length-1-i]=null;
		}
	var blank_list = new Option("", "");
	ctl.options[0]=blank_list;
   }
	   
}

function populate_city(country_ctl, city_ctl, frm_name) {

/*
	if (country_ctl.selectedIndex == 0)
	{
	alert("hello");
*/	

/*
	   if (city_ctl.options.length > 0) {
	   		var length=city_ctl.options.length;
	   		for (var i=0; i < length; i++) {
				city_ctl.options[length-1-i]=null;
			}
		var blank_list = new Option("", "");
		city_ctl.options[0]=blank_list;
	   }
*/
	clear_data(city_ctl);
	   
/*
		country_ctl.focus();
		return (false);
	}
*/
	objRS.getData("LoadCity", city_ctl.name, frm_name, getValue(country_ctl));
	
	if (city_ctl.options.length > 0) {
		city_ctl.options[0].selected=false;
		city_ctl.options[0].selected=true;

	}	
	
}

function populate_area(country_ctl, city_ctl, area_ctl, frm_name) {

	clear_data(area_ctl);
/*	
	   if (area_ctl.options.length > 0) {
	   		var length=area_ctl.options.length;
	   		for (var i=0; i < length; i++) {
				area_ctl.options[length-1-i]=null;
			}
		var blank_list = new Option("", "");
		area_ctl.options[0]=blank_list;
	   }
*/

	objRS.getData("LoadArea", area_ctl.name, frm_name, getValue(country_ctl), getValue(city_ctl));
	
	if (area_ctl.options.length > 0) {
		area_ctl.options[0].selected=true;
	}

}


//get select box's value
function getValue(selBox) {
	return selBox[selBox.selectedIndex].value
}

function createContainer(blankSrc) {
	if (typeof(blankSrc) == "undefined") {
		if (typeof(affID) == "undefined")
			blankSrc = "blank.html"
		else
			blankSrc = "about:blank"
	}

	if (document.layers) {
		document.write("<layer name=" + this.containerName + " visibility=hidden width=0 height=0></layer>")
		}
	else {
		document.write("<iframe name=" + this.containerName + " src=" + blankSrc + " style=visibility:hidden width=0 height=0></iframe>")
//		document.write("<iframe name=" + this.containerName + " src=" + blankSrc + " ></iframe>")
		}
}

function remScript(url, callBack, containerName, objName) {
	if (typeof(containerName) == "undefined")
		containerName = "rs"

	if (typeof(objName) == "undefined")
		objName = "objRS"

	this.containerName = containerName
	this.objName = objName
	this.url = url
	this.callBack = callBack
	this.busy = false
	this.createContainer = createContainer
	this.getData = getData
}

function getData(func, ctl_name, frm_name, args) {

	var params = "f=" + escape(func);
	params += "&ctl_name=" + escape(ctl_name);
	params += "&frm_name=" + escape(frm_name);
	for (var i=0; i<arguments.length-3; i++) {
		params += "&p=" + escape(arguments[i+3])
	}

	if (document.layers)
		document.layers[this.containerName].src = this.url + "?" + params
	else
		window.frames[this.containerName].location.replace(this.url + "?" + params)

}

function InitPop() {

	objRS = new remScript("pop_query.asp", '');
	objRS.createContainer("blank.html");

}