/* Local JS functions */

function warn_education(){
	var v = document.ACMEForm.education.options[document.ACMEForm.education.selectedIndex].value;
	
	alert("Education validator sample.");	
}

function VMC_updateSelect(d,o,m) {
	var i,s,b;
	if(typeof o == 'string') {
		var z=o;
	} else {
		var z=o.options[o.selectedIndex].value;
	}	
	var l=document.getElementById(d);
	l.length=0;l.options[0]=new Option('-1',m);
	b=(z!='nill')?eval('C'+z+'_items'):0;
	for(i=0;i<b.length;i++){ 
		s=b[i].split("|");
		l.options[i]=new Option(s[1],s[0]);
		if(s[0] == "-2"){l.options[i].style.backgroundColor ="555555";l.options[i].style.color="FFFFFF";}
	}
	l.selectedIndex=0;return;
}

function preSelect(where,what) {
	var j;
	ar = eval('C'+where+'_items');
	what = what.replace('%20',' ');
	for(j=0;j<ar.length;j++){
		a=ar[j].split("-");
		a=a[1].split(";");
		if (a[0] == what) {
			document.ACMEForm.field.options[j].selected = true;
			break;
		}
	}
}

/* Local JS functions */

function warn_education(){
	var v = document.ACMEForm.education.options[document.ACMEForm.education.selectedIndex].value;
	
	alert("Education validator sample.");	
}

function VMC_updateSelect(d,o,m) {
	var i,s,b;
	if(typeof o == 'string') {
		var z=o;
	} else {
		var z=o.options[o.selectedIndex].value;
	}	
	var l=document.getElementById(d);
	l.length=0;l.options[0]=new Option('-1',m);
	b=(z!='nill')?eval('C'+z+'_items'):0;
	for(i=0;i<b.length;i++){ 
		s=b[i].split("|");
		l.options[i]=new Option(s[1],s[0]);
		if(s[0] == "-2"){l.options[i].style.backgroundColor ="555555";l.options[i].style.color="FFFFFF";}
	}
	l.selectedIndex=0;return;
}

function preSelect(where,what) {
	var j;
	ar = eval('C'+where+'_items');
	what = what.replace('%20',' ');
	for(j=0;j<ar.length;j++){
		a=ar[j].split("-");
		a=a[1].split(";");
		if (a[0] == what) {
			document.ACMEForm.field.options[j].selected = true;
			break;
		}
	}
}
// SWAP TITLE OF DOCUMENT
function toggleTitle(item) {
document.title =theTitles[item];
	}

// SWAP CLASS OF OBJECT
function toggleClass(id, value){
theElement=document.getElementById(id);
theElement.className=value;
}  
 

// SHOW / HIDE FUNCTION - controls multiple "zones" & may "activate" the selected link
var currentToggles = {};
var lastId = {};
var lastClass = {};
var activeClass = {};

function toggle(set, id, event, srcid) {
// reset class of last nav item selected
if (lastClass[set]) {
document.getElementById(lastId[set]).className = lastClass[set];
	}	

// set current selected nav item class to 'active' state
if (srcid){
	lastId[set]=srcid;
	lastClass[set]=document.getElementById(srcid).className;
	activeClass[set]=lastClass[set]+"-active";
	document.getElementById(srcid).className = activeClass[set];
}	
//start toggle display //
if (set in currentToggles) {
	document.getElementById(currentToggles[set]).style.display = "none";
	}
	
	document.getElementById(id).style.display = "block";
	currentToggles[set] = id;
}


// SHOW / HIDE FUNCTION - controls the SAME div container

function toggleSame(id) {
var o = document.getElementById(id);
if (o.style.display == 'block') {
hideElement(id);
} else {
showElement(id);
}
}
function showElement(id) {
var o = document.getElementById(id);
o.style.display = 'block';
}
function hideElement(id) {
var o = document.getElementById(id);
o.style.display = 'none';
}

// Select a specific program by VALUE from Select drop-down
function changeProgram(paramValue) {
window.opener.document.getElementById('program').value=paramValue;
window.opener=self;
window.close();
}

subject_id = '';

function handleHttpResponse() {
	if (http.readyState == 4) {
		if (subject_id != '') {
			document.getElementById(subject_id).innerHTML = http.responseText;

/*
			document.getElementById('zip').disabled = false;
			document.getElementById('submit_s1').disabled = false;
			document.getElementById('loading').style.display = 'none';
			updateZip(); 
			return checkZip();

			if(subject_id == "output_programs") {
				document.getElementById('program').disabled = false;				
			}
*/
		}
	}
}

function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object

