var http_request = false;

function makeRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/xml');
			//http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance.');
		return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('GET', url + parameters, true);
	http_request.send(null);
}

function fwdtocon(resres) {
	document.location = "contact.cfm?IDs=" + resres;
}
function donothing() {
	return false;
}

function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			result = http_request.responseText;
			if (result != 0){
				resultsplit = result.split(",");
				numout = resultsplit.length;
				onC='fwdtocon(result)';
				document.getElementById('conlink').style.display = 'block';
				document.getElementById('rightestimg').src = '/images/greenleft.gif';
				document.getElementById('resultdiv').className = 'resultdivon';
				document.getElementById('resultdiv').onclick = new Function(onC);
			} else {
				numout = 0;
				result = "";
				onC='donothing()';
				document.getElementById('conlink').style.display = 'none';
				document.getElementById('rightestimg').src = '/images/match-advcount-right.gif';
				document.getElementById('resultdiv').className = 'resultdivoff';
				document.getElementById('resultdiv').onclick = new Function(onC);
			}
			if (numout == 1) {
				document.getElementById('advisorslash').innerHTML = 'advisor';
			} else {
				document.getElementById('advisorslash').innerHTML = 'advisors';
			}
			document.getElementById('myspan').innerHTML = numout;
			document.getElementById('conlink').href = "contact.cfm?IDs=" + result;
		} else {
			alert("Error: Unable to add advisor.\r\nPlease inform support@mystockoptions.com as soon as possible.");
		}
	}
}
  
function checkit(objref, avalue, ischecked) {
	var getstr = "?";
	var obj = document.getElementById(objref);
	for (i=0; i<obj.elements.length; i++) {
		var that = obj.elements[i];
		if (that.type == 'checkbox') {
			if (that.value == avalue) {
				that.checked = (ischecked == true) ? true : false;
			}
			if (that.checked) {
				getstr += that.name + "=" + that.value + "&";
			} else {
				getstr += that.name + "=&";
			}
		}
		
		if (that.name == 'otherIDs' || that.name == 'eliteIDs') {
			getstr += that.name + "=" + that.value + "&";
		}
	}
	makeRequest('get.cfm', getstr);
}
