//////		general things
// IE does not have these constants . . . .
if(!window.Node) {
	Node = {
		ELEMENT_NODE: 1,
		ATTRIBUTE_NODE: 2,
		TEXT_NODE: 3,
		CDATA_SECTION_NODE: 4,
		ENTITY_REFERENCE_NODE: 5,
		ENTITY_NODE: 6,
		PROCESSING_INSTRUCTION_NODE: 7,
		COMMENT_NODE: 8,
		DOCUMENT_NODE: 9,
		DOCUMENT_TYPE_NODE: 10,
		DOCUMENT_FRAGMENT_NODE: 11,
		NOTATION_NODE: 12
	}
}
// get corresponding http request object
function getHttpReqObject() {
	http_req = false;
	if(window.XMLHttpRequest) {
		http_req = new XMLHttpRequest();
		// fix for some mozilla browsers if header is not text/xml
		try {
			http_req.overrideMimeType('text/xml');
		} catch(e) {}
	} else if(window.ActiveXObject) {
		http_req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return http_req;
}
// add an option to a select
function select_add_option(select,option) {
	try {
		select.add(option,null);
	} catch(e) {
		select.add(option) // we hate IE
	}
}

// This does the actual request to url using method and sending data.
// It sets func as the callback function.
function getInfo(url,func,method,data) {
	var hr = getHttpReqObject();
	if(!hr) return false;
	hr.onreadystatechange = function() {
		switch(hr.readyState) {
			case 0: // unitialized
				break;
			case 1: // loading
				break;
			case 2: // loaded
				break;
			case 3: // interactive
				break;
			case 4: // complete
					break;
		}
				 	
	}
	hr.open(method,url,true);
	if(method=='POST')
		hr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	hr.send(data);
}

function addVote(faq_id,category_id) {
	getInfo("/add_vote.php?faq_id="+faq_id+"&category_id="+category_id,null,"GET",null);
}

function vote(faq_id,category_id) {
	votes = document.getElementsByName("vote");
	point_id = 0;
	for(i=0;i<votes.length;i++)
		if(votes[i].checked)
			point_id = votes[i].value;
	getInfo("/add_vote.php?faq_id="+faq_id+"&category_id="+category_id+"&point_id="+point_id,null,"GET",null);
}


