function merlin_k4_check(id, url, alt) {
	process(id, 'ext/merlinx/validate.php', 'ep3[]='+url+'&id='+id+'&alt='+alt, 0, 'merlin_k4_cback', true);
}

function merlin_k4_cback(reply) {
	/*$('debug').innerHTML=reply;*/
	elems=reply.split('!');
	data=elems[0].split(';');
	if ($(elems[1])) while($(elems[1]).childNodes.length > 0) $(elems[1]).removeChild($(elems[1]).childNodes[0]);
	a=document.createElement('a');
	//a.setAttribute('href', 'javascript:void(0);');
	if (data.length >= 9 && data[1] == "BA" && data[9].match(/\/validate.php\?ep3\[\]=/)) {
		link=data[9].substr(data[9].indexOf("ep3[]")+6);
		$(elems[1]).appendChild(document.createTextNode('Oferta jest dostępna.'));
		$(elems[1]).appendChild(document.createElement('br'));
		//~a.setAttribute('onclick', 'merlinx_popup(\'ext/merlinx/merlinx_popup.php?ep3[]='+link+'\');');
		a.setAttribute('href', 'wycieczki.html'+unescape(link));
		a.appendChild(document.createTextNode('rezerwuj'));
		$(elems[1]).appendChild(a);
	}
	else {
		$(elems[1]).appendChild(document.createTextNode('Oferta jest niedostępna.'));
		if (data[1].length == 0 || data[1] != "XX") {
			a.setAttribute('href', 'wycieczki.html?'+elems[2]);
			a.appendChild(document.createTextNode('Sprawdź alternatywy'));
			$(elems[1]).appendChild(document.createElement('br'));
			$(elems[1]).appendChild(a);
		}
	}
}

function merlinx_popup(url) {
	if (url) window.open(url, 'merlinx_popup', 'directories=no,location=no,menubar=no,scrollbars=yes,resizable=no,status=no,toolbar=no,width=700,height=650,top=5,left=5', true);
}

