
function okno(x) {
	if((x=='')||(x==undefined)) x = './wypisz.php';
	window.open(x,"okno3","width=980,height=380");
	//"tollbars=yes,scrollbars=yes,width=450,height=450");
}

function do_submit() {
	var adres;
	//adres = "zapisz.php?email="+document.zapisz.email.value;
	adres = "zapisz.php?email="+$('email').value;
	//alert(adres);
	okno(adres);
	return false;	
}

function  visibli_elem( id, sw ) {
  var obj=document.getElementById(id);
  obj.style.display = sw==1 ? "block" : "none";
  //obj.style.visibility= sw==1 ? "visible" : "hidden";
}


// Odblokowuje przycisk do glosowania
function click_answer(id) {
	if(($('submit_'+id).disabled)) {
		$('submit_'+id).disabled = false;		
	}
	return true;
}

function submit_form(id) {
	var tb = $("pool_"+id).getInputs("radio");
	var cd = 0;
	var sz = tb.size();
	for(var a=0;a<sz;a++) {
		if(tb[a].checked) { var cd = 1; }
	}
	if(cd==1) {
		$("pool_"+id).submit();
	} else {
		return false;
	}
}


function vote_pool(id) {
	
	var url = "./pool.php";
	var pool = "pool_"+id;
	var place = "pool_place_"+id;
	
	var myAjax = new Ajax.Updater(
		place,
		url,
		{
			method: 'post', 
			update: place,
			asynchronous: true,
			parameters: Form.serialize(pool)
		}								
	);
		
}

function addcomment(id,biuletyn,place) {
	var myAjax = new Ajax.Updater(
			place,
			"no_layout.php?page_idx=99&biuletyn="+biuletyn+"&id="+id, 
			{
				method: 'post', 
				parameters: Form.serialize('form_'+id),
				evalScripts: true								
			});
}

function get(id,url,pars) {
	var myAjax = new Ajax.Updater(
			id,
			url, 
			{
				method: 'get', 
				parameters: pars,
				evalScripts: true				
				//insertion: Insertion.Bottom
			});
}


function comments(aid,id) { // pokazuje i ukrywa komentarze
	//alert(aid+' :: '+id)
	var obj=document.getElementById(aid);
	if(obj) {
		if(obj.innerHTML=="") {
			//makeRequest('no_layout.php?page_idx=2&id='+id+'&ajax_id='+aid,aid);
			get(aid,'no_layout.php?page_idx=2&id='+id+'&ajax_id='+aid);
		} else {
			obj.innerHTML = "";
		}
	}
	return true;
}




var http_request = false;

function makeRequest(url, id) {
	http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// http_request.overrideMimeType('text/xml');
			// Przeczytaj o tym wierszu ponizej
		}
	} 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('Poddaje sie :( Nie moge stworzyc instancji obiektu XMLHTTP');
		return false;
	}
	
	http_request.onreadystatechange = function() { alertContents(http_request, id); };
	http_request.open('GET', url, true);
	http_request.send(null);
}

function alertContents(http_request, id) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			var obj = document.getElementById( id );
			obj.innerHTML = http_request.responseText;
		} else {
			alert('Wystapil problem z zapytaniem.');
		}
	}
}

function dojs(str) {
	return eval(str);
}

function vh_elem( id, sw ) {
	var obj=document.getElementById(id);
	obj.style.display = obj.style.display=="block" ? "none" : "block";
}


function verify(id) {
  var form = document.getElementById('form_'+id);
  var content = document.getElementById('content_'+id);
  var signature = document.getElementById('signature_'+id);
  var code = document.getElementById('code_'+id);
  if((content.value=='')||(signature.value=='')||(code.value=='')) {
    alert('Aby dodać komentarz, należy wypełnić wszystkie pola.');
  } else {
  	form.submit();
  }
}
