
function ifVoterEnabled(id){
	if(id == "false") {
		if(document.getElementById("articles05")!=null) {
			var mainBlock = document.getElementById("articles05");		
			mainBlock.id = "";
		}
	}	
}

function removeTag(html) {

	Html0 = html.replace(/^\s+/, '').replace(/\s+$/, '');
	Html1=Html0.replace(/^<div[^>]*>/, '').replace(/^\s+/, '');
	Html2=Html1.replace(/<\/div>$/, '').replace(/\s+$/, '');
	Html3=Html2.replace(/^<div[^>]*>/, '').replace(/^\s+/, '');
	Html4=Html3.replace(/<\/div>$/, '').replace(/\s+$/, '');
	return Html4;
}

function getVoter(id, news_cat_id,layoutValue) {
	var layoutVariable;
	if(layoutValue.indexOf("fx_") != -1){
		layoutVariable="fx_ajax";
	}else{			
		layoutVariable="ajax";
	}		
	advAJAX.get(
		{
			url : '/bossa/ajax2.jsp',
			parameters : { page:'voter', layout:'ajax', score:'false', vote_id: id, news_cat_id: news_cat_id,layoutParam:layoutVariable},
			onSuccess:function(obj){
				document.getElementById('voter'+id).innerHTML = removeTag(obj.responseText);
				votersDesc('par');
			},
			onError : function(obj) { alert("Error: " + obj.status);}
		});
}

function getScore(id, news_cat_id,layoutValue) {
	var layoutVariable;
	if(layoutValue.indexOf("fx_") != -1){
		layoutVariable="fx_ajax";
	}else{			
		layoutVariable="ajax";
	}		
	advAJAX.get(
	{
		url : '/bossa/ajax2.jsp',
		parameters : { page:'voter', layout:'ajax', score:'true', vote_id: id, news_cat_id: news_cat_id,layoutParam:layoutVariable},
		onSuccess:function(obj){
			document.getElementById('voter'+id).innerHTML = removeTag(obj.responseText);
			votersDesc('par');
		},
		onError : function(obj) { alert("Error: " + obj.status);}
	});
}
function score(id,layoutValue) {
	var options = document.getElementById('voter_'+id).vote_item_id;
	var length = options.length;
	var test = 0;
	var i = 0;
	var layoutVariable;
	for(i=0;i<length;i++) {
		if (test == 0) {
			if(options[i].checked == true)
				var test=1
			else
				var test=0;
		}
	}
	if (test == 1) {
		if(layoutValue.indexOf("fx_") != -1){
			layoutVariable="fx_ajax";
		}else{			
			layoutVariable="ajax";
		}		
		
		advAJAX.submit(
			document.getElementById('voter_'+id),{
				url : '/bossa/ajax2.jsp?vStats=' + id, parameters : { page:'voter', layout:'ajax',layoutParam:layoutVariable},
				onSuccess:function(obj){
					document.getElementById('voter'+id).innerHTML = removeTag(obj.responseText);
					votersDesc('par');
				},
				onError : function(obj) { alert("Error: " + obj.status);}
			});
	}
	else
		document.getElementById('info'+id).innerHTML = '<span>Proszę zaznaczyć jedną z poniższych opcji</span>';
		votersDesc('par');
}


function checkVoted(){
	var ciacha = document.cookie.split("; ");
	var czyIst = false;
	for(var i=0;i<ciacha.length;i++){
		if(ciacha[i].split("=")[0] == 'polls') {
			var cook1 = ciacha[i].split("=")[1];
			czyIst = true;
		}
	}
	if(czyIst){
		var cook2 = cook1.replace(/\"/g, "");
		var ciastko = cook2.split(",");
		for(var i=0;i<ciastko.length;i++){
			var voter = "";
			voter = "voter"+ciastko[i];
			var voterDiv = document.getElementById(voter);
			if(voterDiv){
				var vscore = "";
				var pytanie = "";				
				vscore = "vscore"+ciastko[i];
				document.getElementById(vscore).style.display="block"
				pytanie = voterDiv.getElementsByTagName("div")
				for(var j=0;j<pytanie.length;j++){
					if(pytanie[j].className == "vform"){
						pytanie[j].style.display = "none";
					}	
				}
			}
		}
	}
}

