function new_script(s_url){
var script = document.getElementById('script_1');
if (script) {
	document.getElementsByTagName('HEAD').item(0).removeChild(script);
	}
	script = document.createElement('SCRIPT');
	script.id = 'script_1';
	script.src = 'http://www.stats.indiana.edu/pre/mibor_output/' + s_url;
	var head=document.getElementsByTagName('HEAD')[0];
	head.appendChild(script);
}

function waiting(status_flag){
if (status_flag == 'on'){
  //jg2.setColor("#ffffff");
  //jg2.fillRect(200,100, 135, 50);
  //jg2.setFont("arial","30px",Font.BOLD); 
  //jg2.setColor("#880000");
  //jg2.drawString("Loading",210,105);
  jg2.drawImage("http://www.stats.indiana.edu/pre/mibor_output/house.gif", 70, 30, 84, 137); 
  jg2.paint();

}
if (status_flag == 'off'){
  jg2.clear();
}

}

function sub_knit(ver){
var o_url
	
	o_url = 'repost.asp?mode=nav&page_id=' + ver + '&geo_val=' + document.alice.geo_val.value;
//alert(o_url);
waiting('on')
	new_script(o_url)
}


function knit(ver){
var o_url
	o_url = 'repost.asp?mode=nav&page_id=3&geo_val=' + document.alice.geo_val.value + ver;
	waiting('on')
	new_script(o_url)
}

function advanced_knit(ver){
var o_url
var table_parts = ""
var chk_status = ""
	o_url = 'repost.asp?mode=nav&page_id=3b&geo_val=' + document.alice.geo_val.value + ver;
	for (ax = 2; ax < 8; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	for (ax = 13; ax < 24; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	for (ax = 25; ax < 27; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	if (table_parts) {
	o_url = o_url + '&table_parts=' + table_parts
	}
	//alert(o_url);
	waiting('on')
	new_script(o_url)
}

function newwin2(note_url) {
	window.open(note_url,"","width=500,height=200,")
}


function pre_knit(ver){
var o_url
	o_url = 'repost.asp?mode=nav&page_id=3&geo_val=' + ver;
	waiting('on');
	new_script(o_url)
}

//functions for asp based navigation and request

function metro_point(metno, metname){
var new_geostring = ''
var ax
var no_insert_flag = ''

	if (document.alice.geo.length != 0){
		for(ax = 0; ax < document.alice.geo.length ; ax++){
			if (document.alice.geo.options[ax].value == metno){
				document.alice.geo.options[ax] = null	
				no_insert_flag = '1'	
			}else{
		//alert('h')
				if (new_geostring != ''){ new_geostring += '[' }
				new_geostring += document.alice.geo.options[ax].value
			}
		}
		if (new_geostring != ''){ new_geostring += '[' }
		new_geostring += metno
		if (no_insert_flag == ''){
		document.alice.geo.options[document.alice.geo.length] = new Option(metname, metno)}
	}else{
		document.alice.geo.options[document.alice.geo.length] = new Option(metname, metno);
		new_geostring = metno
	}
	document.alice.geo_val.value = new_geostring
}

function get_data(){
    document.alice.submit();
}

function get_tab(tab_no){
    document.alice.profile_tab.value = '' + tab_no;
    //alert(document.alice.profile_tab.value);
    document.alice.submit();
}

function get_place_data(place_target){
    document.alice.geo_val.value = place_target
    document.alice.submit();
}

function advanced_get_data(){
var table_parts = ""
	for (ax = 2; ax < 8; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	for (ax = 13; ax < 20; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	for (ax = 25; ax < 27; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	for (ax = 33; ax < 37; ax++){
		chk_status = eval('document.alice.chk' + ax);
		if (chk_status.checked) {
			if(table_parts){
			table_parts = table_parts + ',' + ax
			}else{
			table_parts = ax}
		}
	}
	if ((table_parts) && (document.alice.geo_val.value != '')) {
	    document.alice.table_parts.value = table_parts
        document.alice.submit();
	}else{
	    alert('You must select a Geography and an Indicator to continue')
    }
}