// JavaScript Document

$(document).ready(function(){
	$('.item_btm').click(function(){
		window.location.href = $(this).attr('rel');							  
	});
});

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 
function surveyvote(id_survey,id_question) {
	http.open("GET", SITE_ADDRESS+"survey_vote/"+encodeURI(id_survey)+"/"+encodeURI(id_question)+"", true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
		  document.getElementById('divsurvey').innerHTML = http.responseText;
		}
	}
	http.send(null);
}
function showsurveyresults(id_survey) {
	http.open("GET", SITE_ADDRESS+"survey_results/"+encodeURI(id_survey)+"", true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
		  document.getElementById('divsurvey').innerHTML = http.responseText;
		}
	}
	http.send(null);
}
function valbutton(thisform,id_survey) {
	// place any other field validations that you require here
	// validate myradiobuttons
	myOption = -1;
	for (i=thisform.id_question.length-1; i > -1; i--) {
	if (thisform.id_question[i].checked) {
	myOption = i; i = -1;
	}
	}
	if (myOption == -1) {
	alert("Моля, изберете отговор!");
	return false;
	}
	
	return surveyvote(id_survey,thisform.id_question[myOption].value);
		
}
