// JavaScript Document


function next_dir() {

if (sel_dir<max_dir) {
sel_dir++;
document.getElementById('dir_name').innerHTML=dir[sel_dir];
document.getElementById('dir_link').href='?open=gallery&dir='+dir_link[sel_dir];
document.getElementById('dir_photo').src=photo[sel_dir][0];
} else if (sel_dir == max_dir) {
sel_dir=0;
document.getElementById('dir_name').innerHTML=dir[sel_dir];
document.getElementById('dir_link').href='?open=gallery&dir='+dir_link[sel_dir];
document.getElementById('dir_photo').src=photo[sel_dir][0];
}

}



function prev_dir() {

if (sel_dir>0) {
sel_dir--;
document.getElementById('dir_name').innerHTML=dir[sel_dir];
document.getElementById('dir_link').href='?open=gallery&dir='+dir_link[sel_dir];
document.getElementById('dir_photo').src=photo[sel_dir][0];
} else if (sel_dir == 0) {
sel_dir=max_dir;
document.getElementById('dir_name').innerHTML=dir[sel_dir];
document.getElementById('dir_link').href='?open=gallery&dir='+dir_link[sel_dir];
document.getElementById('dir_photo').src=photo[sel_dir][0];
}

}



function click_check(id) {

if (document.getElementById(id).checked == true) {
	document.getElementById(id).checked = false;
} else {
	document.getElementById(id).checked = true;
}
}






var photoId = 0;
var imageId = null;
var imageRotating = false;

function stopRotator() {
    if(imageRotating)
        clearTimeout(imageId)
    imageRotating = false;
}

function startRotator() {
    stopRotator();
    changeImage();
}

function changeImage() {

var countPhoto = photo[sel_dir].length-1;

document.getElementById('dir_photo').src = photo[sel_dir][photoId];

photoId = (photoId < countPhoto) ? photoId+1 : 0;

	imageId = setTimeout("changeImage()",5000);
    imageRotating = true;
}






var numeric = false;

function send_value(id,additional,numeric) {

var value = document.getElementById(id).value;

if (value == '') {
	alert('Musisz podać wartość');
} else {
	if (numeric == false) {
		document.location.href = '?open=adminconferencefiles&fields='+value+additional;
	} else {
		if (isNaN(value)) {
			alert('Musisz podać wartość liczbową');
		} else {
			document.location.href = '?open=adminconferencefiles&fields='+value+additional;
		}
	}
}

}



function file(path,x,y) {

//var szer = document.getElementById(id).style.width;
//var wys = document.getElementById(id).style.height;

var x = parseInt(x)+40;
var y = parseInt(y)+40;

var szer = x;
var wys = y;

var width = screen.width;
var height = screen.height;

if (x > width) {
var x = width;
}
if (y > height) {
var y = height;
}

var w = parseInt((width/2) - (szer/2));
var h = parseInt((height/2) - (wys/2));

window.open('upload/'+path, path, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,fullscreen=no,channelmode=no,left='+w+',top='+h+',width='+x+'px,height='+y+'px');

}












function end_article(id) {

if (document.getElementById(id).checked) {
	document.getElementById('new_page').style.visibility = 'hidden';
	document.getElementById('submit').style.visibility = 'visible';
} else {
	document.getElementById('new_page').style.visibility = 'visible';
	document.getElementById('submit').style.visibility = 'hidden';
}

}





function person_edit(id) {

var szerokosc = screen.width;
var wysokosc = screen.height;

var szer = (szerokosc/2)-215;
var wys = (wysokosc/2)-120

window.open('person_edit.php?id=' + id +'', '', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,width=430,height=120,top=' + wys + ',left=' + szer + '').focus;

}


function person_del(id) {

if (confirm('Czy na pewno usunąć członka koła?')) {
	document.location.href = 'actions.php?action=del_member&id=' + id + '';
}

}





function person_add() {

var funkcja = document.person.funkcja.value;
var osoba = document.person.osoba.value;
var kierunek = document.person.kierunek.value;
var rok = document.person.rok.value;

if (funkcja == 'opiekun') {

	if (osoba != '') {
		document.person.submit();
	} else {
		alert('Musisz podać imię i nazwisko opiekuna koła.');
	}

} else if (funkcja == 'przewodniczacy') {

		if (osoba == '' && kierunek != '' && rok != '') {
			alert('Musisz podać imię i nazwisko nowego przewodniczącego koła');
		} else if (osoba != '' && kierunek == '' && rok != '') {
			alert('Musisz podać kierunek studiów nowego przewodniczącego koła');
		} else if (osoba != '' && kierunek != '' && rok == '') {
			alert('Musisz podać rok studiów przewodniczącego nowego koła');
		} else if (osoba == '' && kierunek == '' && rok == '') {
			alert('Musissz podać imię i nazwisko, kierunek i rok studiów nowego przewodniczącego koła');
		} else if (osoba == '' && kierunek == '' && rok != '') {
			alert('Musisz podać imię i nazwisko oraz kierunek studiów nowego przewodniczącego koła');
		} else if (osoba == '' && kierunek != '' && rok == '') {
			alert('Musisz podać imię i nazwisko oraz rok studiów nowego przewodniczącego koła');
		} else if (osoba != '' && kierunek == '' && rok == '') {
			alert('Musisz podać kierunek i rok studiów nowego przewodniczącego koła');
		} else if (osoba != '' && kierunek != '' && rok != '') {
			document.person.submit();
		}

} else if (funkcja == 'zastepca') {

		if (osoba == '' && kierunek != '' && rok != '') {
			alert('Musisz podać imię i nazwisko nowego z-cy przewodniczącego koła');
		} else if (osoba != '' && kierunek == '' && rok != '') {
			alert('Musisz podać kierunek studiów nowego z-cy przewodniczącego koła');
		} else if (osoba != '' && kierunek != '' && rok == '') {
			alert('Musisz podać rok studiów nowego z-cy przewodniczącego koła');
		} else if (osoba == '' && kierunek == '' && rok == '') {
			alert('Musissz podać imię i nazwisko, kierunek i rok studiów nowego z-cy przewodniczącego koła');
		} else if (osoba == '' && kierunek == '' && rok != '') {
			alert('Musisz podać imię i nazwisko oraz kierunek studiów nowego z-cy przewodniczącego koła');
		} else if (osoba == '' && kierunek != '' && rok == '') {
			alert('Musisz podać imię i nazwisko oraz rok studiów nowego z-cy przewodniczącego koła');
		} else if (osoba != '' && kierunek == '' && rok == '') {
			alert('Musisz podać kierunek i rok studiów nowego z-cy przewodniczącego koła');
		} else if (osoba != '' && kierunek != '' && rok != '') {
			document.person.submit();
		}

} else if (funkcja == 'skarbnik') {

		if (osoba == '' && kierunek != '' && rok != '') {
			alert('Musisz podać imię i nazwisko nowego skarbnika koła');
		} else if (osoba != '' && kierunek == '' && rok != '') {
			alert('Musisz podać kierunek studiów nowego skarbnika koła');
		} else if (osoba != '' && kierunek != '' && rok == '') {
			alert('Musisz podać rok studiów nowego skarbnika koła');
		} else if (osoba == '' && kierunek == '' && rok == '') {
			alert('Musissz podać imię i nazwisko, kierunek i rok studiów nowego skarbnika koła');
		} else if (osoba == '' && kierunek == '' && rok != '') {
			alert('Musisz podać imię i nazwisko oraz kierunek studiów nowego skarbnika koła');
		} else if (osoba == '' && kierunek != '' && rok == '') {
			alert('Musisz podać imię i nazwisko oraz rok studiów nowego skarbnika koła');
		} else if (osoba != '' && kierunek == '' && rok == '') {
			alert('Musisz podać kierunek i rok studiów nowego skarbnika koła');
		} else if (osoba != '' && kierunek != '' && rok != '') {
			document.person.submit();
		}

} else if (funkcja == 'czlonek') {

		if (osoba == '' && kierunek != '' && rok != '') {
			alert('Musisz podać imię i nazwisko nowego członka koła');
		} else if (osoba != '' && kierunek == '' && rok != '') {
			alert('Musisz podać kierunek studiów nowego członka koła');
		} else if (osoba != '' && kierunek != '' && rok == '') {
			alert('Musisz podać rok studiów nowego członka koła');
		} else if (osoba == '' && kierunek == '' && rok == '') {
			alert('Musissz podać imię i nazwisko, kierunek i rok studiów nowego członka koła');
		} else if (osoba == '' && kierunek == '' && rok != '') {
			alert('Musisz podać imię i nazwisko oraz kierunek studiów nowego członka koła');
		} else if (osoba == '' && kierunek != '' && rok == '') {
			alert('Musisz podać imię i nazwisko oraz rok studiów nowego członka koła');
		} else if (osoba != '' && kierunek == '' && rok == '') {
			alert('Musisz podać kierunek i rok studiów nowego członka koła');
		} else if (osoba != '' && kierunek != '' && rok != '') {
			document.person.submit();
		}

} else if (funkcja == '') {

	alert('Musisz wybrać funkcję nowego członka koła');

}




}








function open_sem(sciezka,szer,wys) {

var width = screen.width;
var height = screen.height;

var w = (width/2) - 395;
var h = (height/2) - 250;

window.open(''+sciezka+'', '', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,fullscreen=no,channelmode=no,left=' + w + ',top=' + h + ',width='+szer+',height='+wys+'');

}





var mousePos = new Array();

function getXY(e) {
	x = (window.Event) ? e.pageX : event.clientX;
	y = (window.Event) ? e.pageY : event.clientY;
	
	mousePos[1] = x;
	mousePos[2] = y;
	return mousePos;
}





function getMousePosition() {
	if (window.Event) {
	document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = getXY;
}

window.onload = getMousePosition();




function grow_div(x) {

	if (x < 200) {
	x++;
	document.getElementById('divek').style.width = x+'px';
	grow_div(x);
	}

}














// bbcode
function mail(user,domain) {
window.location = 'mailto:' + user + '@' + domain;
}



function getCookie(name) {
var cookie = name + '=';
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(cookie);
		if (offset != -1) {
			offset += cookie.length;
			cookieEnd = document.cookie.indexOf(';',offset);
			if (cookieEnd == -1) {
				cookieEnd = document.cookie.length;
			}
			return unescape(document.cookie.substring(offset,cookieEnd));
		}
	}
}



function book_submit() {

var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var quest_book = document.getElementById('guest_book').value;

if (name == '' || name == 'przedstaw się...') {
	alert('Musisz przedstawić się');
	return false;
}



if (email != '' && email != 'tu możesz podać swój e-mail...') {
	if ((email.indexOf("@")<1) &&(email.indexOf(".pl")<1)
	&&(email.indexOf(".us")<1) &&(email.indexOf("uk")<1)
	&&(email.indexOf(".de")<1) &&(email.indexOf(".mil")<1)
	&&(email.indexOf(".com")<1) &&(email.indexOf(".gov")<1)) {
		alert('Podaj poprawną formę adresu e-mail!');
		return false;
	}
}

alert('ok');

}

	
function show_image(path,width,height) {

var id = 'showcase';

if (document.getElementById(id).style.display == 'none') {
document.getElementById(id).style.background='url(foto/'+path+')';
document.getElementById(id).style.width=width+'px';
document.getElementById(id).style.height=height+'px';

var szer = screen.availWidth;
var wys = screen.availHeight;

var x = (szer/2)-(width/2)+'px';
var y = (wys/2)-(height/2)+'px';

document.getElementById(id).style.left=x;
document.getElementById(id).style.top=y;

document.getElementById(id).style.display='block';
}

}







function href(path) {
	document.location.href=path;
}





function newWindow(path) {
	window.open(path);
}




searcher = false;

function show_hide(id,searcher) {

	if (document.getElementById(id).style.display=='none') {
		document.getElementById(id).style.display='block';
	} else {
		document.getElementById(id).style.display='none';
		
		if (searcher == true) {
		document.getElementById('forum').checked = false;
		document.getElementById('artykuly').checked = false;
		document.getElementById('aktualnosci').checked = false;
		document.getElementById('ksiega').checked = false;
		document.getElementById('konferencje').checked = false;
		}
	}

}




function check_cookies(number) {


for(i=1;i<=number;i++) {
	if (document.cookie("display_"+i).value == 'block') {
	document.getElementById('block_'+i).style.display = 'block';
	}
	if (document.cookie("display_"+i).value == 'none') {
	document.getElementById('block_'+i).style.display = 'none';
	}
}


}


function roll(id) {

var expDate = new Date();
var expires = 'Monday, 01-Jan-'+(expDate.getFullYear()+5)+' 12:00:00 GMT';

	if (document.getElementById('block_'+id).style.display=='none') {

	var cookie_param = "display_"+id+"="+escape("block")+"; expires="+expires;
	document.cookie = cookie_param;
	var cookie_param = "img_"+id+"="+escape("min")+";expires="+expires;
	document.cookie = cookie_param;

		document.getElementById('bar_'+id).src='gfx/bar_image_min.jpg';
		document.getElementById('block_'+id).style.display='block';
	} else {

	var cookie_param = "display_"+id+"="+escape("none")+"; expires="+expires;
	document.cookie = cookie_param;
	var cookie_param = "img_"+id+"="+escape("max")+";expires="+expires;
	document.cookie = cookie_param;

		document.getElementById('bar_'+id).src='gfx/bar_image_max.jpg';
		document.getElementById('block_'+id).style.display='none';
	}

}


function art_over(id) {
document.getElementById('row_'+id+'_1').style.background='#999999';
document.getElementById('row_'+id+'_2').style.background='#999999';
}

function art_out(id) {
document.getElementById('row_'+id+'_1').style.background='';
document.getElementById('row_'+id+'_2').style.background='';
}




function over(id) {
document.getElementById(id).style.background='url(gfx/button_grey.jpg)';
document.getElementById(id).style.color='#ffffff';
}

function out(id,selected) {
if (selected == true) {
	var src = 'gfx/button_red.jpg';
	var color = '#ffffff';
} else {
	var src = '';
	var color = '#dd2b27';
}

document.getElementById(id).style.background='url('+src+')';
document.getElementById(id).style.color=color;
}







function set_info_defaults(bookmarks_number) {

var bookmarks_number = 1;

var bookmarks = new Array();
bookmarks[1] = 'info';
bookmarks[2] = 'na stronie';
bookmarks[3] = 'zalogowani';

var bookmark_headlines = new Array();
bookmark_headlines[1] = 'info strony';
bookmark_headlines[2] = 'statystyki';
bookmark_headlines[3] = 'zalogowani użytkownicy';


for (i=1;i<=bookmarks_number;i++) {
document.getElementById('info'+i).innerHTML = bookmarks[i];
}

document.getElementById('info1').style.background='url(gfx/info_sel.gif)';
document.getElementById('info1').style.color='#ffffff';
document.getElementById('info_headline').innerHTML = bookmark_headlines[1];
document.getElementById('info_container').innerHTML = bookmark_content[1];

}





function over_info(id) {
document.getElementById('info'+id).style.background='url(gfx/button_grey.jpg)';
document.getElementById('info'+id).style.color='#ffffff';
}

function out_info(id) {
if (document.getElementById('info_headline').innerHTML == bookmark_headlines[id]) {
	var src = 'gfx/info_sel.gif';
	var color = '#ffffff';
} else {
	var src = 'gfx/info.gif';
	var color = '#dd2b27';
}

document.getElementById('info'+id).style.background='url('+src+')';
document.getElementById('info'+id).style.color=color;
}







function info_change(id,bookmarks_number) {

for (i=1;i<=bookmarks_number;i++) {
document.getElementById('info'+i).style.background='url(gfx/info.gif)';
document.getElementById('info'+i).style.color='#666666';
}

document.getElementById('info'+id).style.background='url(gfx/info_sel.gif)';
document.getElementById('info'+id).style.color='#ffffff';
document.getElementById('info_headline').innerHTML = bookmark_headlines[id];
document.getElementById('info_container').innerHTML = bookmark_content[id];

}