//funkcje do podmiany zdjec
function fon(n){document.images[n].src='grafika/'+n+'1.gif';}
function foff(n){document.images[n].src='grafika/'+n+'.gif';}

//funkcja do wyswietlania popupu
var okno_pop='';
function popup(wi,he,uerel,alignx,aligny,scrol)
{
	// Bartosz Szczecinski
	// 20.04.2006
	// Opera 8.x nie obsluguje !okno_pop.closed
	if(okno_pop && okno_pop.closed==false) {
		okno_pop.close()
	}
	if(wi=='100%'){wi=screen.availWidth-30}
	if(he=='100%'){he=screen.availHeight-0}
	if(alignx=='left'){xx=0}
	else if(alignx=='right'){xx=(screen.availWidth-wi)-10}
	else{xx=(screen.availWidth-wi)/2}
	if(aligny=='top'){yy=0}
	else if(aligny=='bottom'){yy=(screen.availHeight-he)}
	else{yy=(screen.availHeight-he)/2}
	okno_pop=window.open(uerel, '_blank', 'scrollbars='+scrol+',height='+he+',width='+wi+',top='+yy+',left='+xx);
}

function popupFrame(wi, he, url, alignX, alignY, scroll) {
	popup(wi, he, 'popup.php?popupFile='+url.replace(/\?/, '&'), alignX, alignY, scroll);
}

function blurall() {
	var links = document.getElementsByTagName('a');
	for (var i=0;i<links.length;i++){
		links[i].onfocus = blurme;
	}
}

function blurme()
{
	this.blur();
}


function printversion(id,path)
{
	var okno='';
	(okno && !okno.closed)?okno.close():'';
	he=400;
	wi=730;
	xx=(screen.availHeight-he)/2-10;
	yy=(screen.availWidth-wi)/2;
	okno=window.open('print_version.php?id='+id, '_blank', 'menubar=yes,scrollbars=yes,height='+he+',width='+wi+',top='+xx+',left='+yy);
}


/*ladowanie do casch-u zdjec
foto=new Array('pl','en');
menuA=new Array();menuB=new Array();
for(n=0;n<foto.length;n++){
menuA[n]=new Image();
menuA[n].src='grafika/'+foto[n]+'.gif';
menuB[n]=new Image();
menuB[n].src='grafika/'+foto[n]+'1.gif';
}
*/


function tabShow(caller, nr) {
	var show = document.getElementById('tab'+nr);
	if(!show) return;
	
	if(caller.parentNode.parentNode.getElementsByTagName('LI')[0].className == 'rss') {
		if(caller.parentNode.parentNode.getElementsByTagName('LI')[2].getElementsByTagName('A')[0] == caller) {
			caller.parentNode.parentNode.getElementsByTagName('LI')[0].style.display = '';
		}
		else {
			caller.parentNode.parentNode.getElementsByTagName('LI')[0].style.display = 'none';
		}
	}
	
	if(caller.parentNode.parentNode.getElementsByTagName('LI')[1].className == 'rss2') {
		if(caller.parentNode.parentNode.getElementsByTagName('LI')[4].getElementsByTagName('A')[0] == caller) {
			caller.parentNode.parentNode.getElementsByTagName('LI')[1].style.display = '';
		}
		else {
			caller.parentNode.parentNode.getElementsByTagName('LI')[1].style.display = 'none';
		}
	}
	
	var div = caller.parentNode.parentNode.parentNode.getElementsByTagName('DIV');
	for(var i = 0, j = div.length ; i < j ; i++) {
		if(div[i].className.indexOf('isTab') > -1) div[i].style.display = 'none';
	}
	show.style.display = 'block';
	
	var a = caller.parentNode.parentNode.getElementsByTagName('A');
	for(var i = 0, j = a.length ; i < j ; i++) {
		if(a[i].className.indexOf('active') > -1) a[i].className = a[i].className.replace(/active/, '');
	}	
	caller.className = caller.className + ' active';
	caller.blur();
}

function sendAjaxSignupAction(user_id, group_id, mode) {
	var ao = new AjaxObject101(); 
	ao.sndReq('post','ajax-signup.php','group_id='+group_id+'&mode='+mode);
}

function AjaxObject101() {
	this.createRequestObject = function() {
		try {
			var ro = new XMLHttpRequest();
		}
		catch (e) {
			var ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return ro;
	}
	this.sndReq = function(action, url, data) {
		if (action.toUpperCase() == "POST") {
			this.http.open(action,url,true);
			this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			try {this.http.onreadystatechange = this.handleResponse;}
			catch(ex) {
				this.http.onload = this.handleResponse;
			}
			this.http.send(data);
		}
		else {
			this.http.open(action,url + '?' + data,true);
			try {this.http.onreadystatechange = this.handleResponse;}
			catch(ex) {
				this.http.onload = this.handleResponse;
			}
			this.http.send(null);
		}
	}
	this.handleResponse = function() {
		if ( me.http.readyState == 4) {
			if (typeof me.funcDone == 'function') { me.funcDone();}
			var rawdata = me.http.responseText.split("|");
			for ( var i = 0; i < rawdata.length; i++ ) {
				var item = (rawdata[i]).split("=>");
				if (item[0] != "") {
					if (item[1].substr(0,3) == "%V%" ) {
						document.getElementById(item[0]).value = item[1].substring(3);
					}
					else {
						document.getElementById(item[0]).innerHTML = item[1];
					}
				}
			}
		}
		if ((me.http.readyState == 1) && (typeof me.funcWait == 'function')) { me.funcWait(); }
	}
	var me = this;
	this.http = this.createRequestObject();
	
	var funcWait = null;
	var funcDone = null;
}
