/* ------------------------------------------
 @pete 28/01/2009 modifications starts here
------------------------------------------ */

	// CSS Browser Selector v0.3.1 - Rafael Lima (http://rafael.adm.br)
	function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

	// ----------------------------------------------------------------------
	// ---------------------------------------------- icons cache
	// ----------------------------------------------------------------------

	window.onload = function() {
	
		cache_img_1 = new Image
		cache_img_2 = new Image
		cache_img_3 = new Image
		cache_img_4 = new Image
		cache_img_5 = new Image
		
		cache_img_1.src = '../../img/loading.gif';
		cache_img_2.src = '../../img/close.png';
		cache_img_3.src = '../../img/loading_fav.gif';
		cache_img_4.src = '../../img/added_fav.gif';
		cache_img_4.src = '../../img/empty_favs.jpg';
		
		}

	// ----------------------------------------------------------------------
	// ---------------------------------------------- favourite schools
	// ----------------------------------------------------------------------
	
	// ----------------- add to favourites from the SERP level

	var msie = ((navigator.appVersion.indexOf("MSIE")!= -1)&&!window.opera)? true : false;

	function addfavourite(sid) {

		var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject ('MSXML2.XMLHTTP.3.0');
		
		var url = "/inc/dodatki/favourites.php?action=add&schoolid=" + sid + "&sid=" + Math.random();
		
		xmlHttp.open ('GET', url, true);
		xmlHttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
		
		document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/loading_fav.gif" width="16" height="16" title="Zapisuję szkołę, proszę czekać..." alt="Zapisuję szkołę, proszę czekać..." />';
		
		xmlHttp.onreadystatechange = function() {
			
			if (xmlHttp.readyState == 4 && (xmlHttp.status == 200 || xmlHttp.readyState == 'complete')) {
				
				document.getElementById('ilosc_ulubionych').innerHTML = xmlHttp.responseText;
				document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/added_fav.gif" width="16" height="16" title="Ta szkoła aktualnie znajduje się w ulubionych!" alt="Ta szkoła aktualnie znajduje się w ulubionych!" />';
				
				if (xmlHttp.responseText == "1 szkoła") {
					if (msie) document.getElementById('empty_favs').style.display = 'none';
					else document.getElementById('empty_favs').fade(0);
				}
			}
		}
		
	xmlHttp.send (null);

	}

	// ----------------- add to favourites from the page level
	
	function addfavouritepage(sid) {

		var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject ('MSXML2.XMLHTTP.3.0');
		
		var url = "/inc/dodatki/favourites.php?action=add&schoolid=" + sid + "&sid=" + Math.random();
		
		xmlHttp.open ('GET', url, true);
		xmlHttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
		
		document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/loading_fav.gif" width="16" height="16" title="Zapisuję szkołę, proszę czekać..." alt="Zapisuję szkołę, proszę czekać..." />';
		
		xmlHttp.onreadystatechange = function() {
			
			if (xmlHttp.readyState == 4 && (xmlHttp.status == 200 || xmlHttp.readyState == 'complete')) {
				
				document.getElementById('ilosc_ulubionych').innerHTML = xmlHttp.responseText;
				document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/added_fav.gif" width="16" height="16" title="Ta szkoła aktualnie znajduje się w ulubionych!" alt="Ta szkoła aktualnie znajduje się w ulubionych!" />';
				
				if (xmlHttp.responseText == "1 szkoła") {
					if (msie) document.getElementById('empty_favs').style.display = 'none';
					else document.getElementById('empty_favs').fade(0);
				}
				
			}
		}
		
	xmlHttp.send (null);

	}
	
	// ----------------- delete from favourites
	
	function delfavourite(sid) {

	document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/loading_fav.gif" width="16" height="16" title="Usówam szkołę, proszę czekać..." alt="Usówam szkołę, proszę czekać..." />';

	var conf = confirm('Na pewno chcesz usunąć wybraną szkołę z listy ulubionych ?');
	
		if (conf == true) {
		
		document.getElementById('favschool_del_'+sid).innerHTML = '';
		document.getElementById('favschool_loading_'+sid).innerHTML = '';
		document.getElementById('schooldetails_close_'+sid).innerHTML = '';
		
			var favarray = Cookie.read('favschools_del');
			if (favarray != null) save_favarray = favarray + '-' + sid; else save_favarray = sid;
			var pomaturze = Cookie.write('favschools_del', save_favarray, {path: '/'});
			
			var cnt_init = document.getElementById('favschool_count_init').value;
			cnt_upd = parseInt(cnt_init) - parseInt(1);
			document.getElementById('favschool_count_init').value = cnt_upd;
			
				if (cnt_upd == "") odmiana = ' szkół';
				else if (cnt_upd == "1") odmiana = ' szkoła';
				else if (cnt_upd < "5") odmiana = ' szkoły';
				else odmiana = ' szkół';
			
			document.getElementById('ilosc_ulubionych').innerHTML = cnt_upd + odmiana;
			document.getElementById('favschool_count').innerHTML = cnt_upd + odmiana;
			
			if (cnt_upd == 0) {
				
				setTimeout("document.getElementById('favschool_count_msg').style.display = 'block'", 600);
				new Fx.Slide('favschool_list').slideOut();
				document.getElementById('delallfavsbtn').style.display = 'none';
				
			}
			
			new Fx.Slide('favschool_'+sid).slideOut();
			
		} else {
		
		document.getElementById('favschool_loading_'+sid).innerHTML = '<img src="../../img/added_fav.gif" width="16" height="16" title="Ta szkoła aktualnie znajduje się w ulubionych!" alt="Ta szkoła aktualnie znajduje się w ulubionych!" />';
		
		}

	}

	// ----------------- delete all favourites
	
	function delallfavs() {

	var conf = confirm('Na pewno chcesz usunąć wszystkie szkoły z listy ulubionych ?');
	
		if (conf == true) {
		
			document.getElementById('favschool_count').innerHTML = '0 szkół';
			document.getElementById('ilosc_ulubionych').innerHTML = '0 szkół';	
			
			document.getElementById('favschool_list').style.display = 'none';
			document.getElementById('delallfavsbtn').style.display = 'none';
			
			var pomaturze = Cookie.write('favschools', '', {path: '/'});
			var pomaturze = Cookie.write('favschools_del', '', {path: '/'});
			
			document.getElementById('favschool_count_msg').style.display = 'block';
		
		}
	
	}

	// ----------------------------------------------------------------------
	// ---------------------------------------------- school details
	// ----------------------------------------------------------------------

	// ----------------- close listing box
	
	function schooldetailsclose(sid) {

		var myVerticalSlide = new Fx.Slide('schooldetails_'+sid);
		myVerticalSlide.slideOut();
		document.getElementById('schooldetails_close_'+sid).innerHTML = '';	

	}
	
	// ----------------- get data and open listing box

	function showdetails(sid) {

		if (document.getElementById('schooldetails_close_'+sid).innerHTML == '') {
		
			var myVerticalSlide = new Fx.Slide('schooldetails_'+sid);
			myVerticalSlide.hide();
			
				var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject ('MSXML2.XMLHTTP.3.0');
				
				var url = "/inc/dodatki/schooldetails.php?schoolid=" + sid + "&sid=" + Math.random();
				
				xmlHttp.open ('GET', url, true);
				xmlHttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
				
				document.getElementById('schooldetails_'+sid).style.display = 'block';
				document.getElementById('schooldetails_loading_'+sid).innerHTML = '<img src="../../img/loading.gif" width="16" height="16" title="Wczytuję dane, proszę czekać..." alt="Wczytuję dane, proszę czekać..." />';
				
				xmlHttp.onreadystatechange = function() {
					
					if (xmlHttp.readyState == 4 && (xmlHttp.status == 200 || xmlHttp.readyState == 'complete')) {
						
						document.getElementById('schooldetails_'+sid).innerHTML = xmlHttp.responseText;
						document.getElementById('schooldetails_loading_'+sid).innerHTML = '';
						document.getElementById('schooldetails_close_'+sid).innerHTML = '<div onclick="schooldetailsclose(\''+sid+'\')" style="cursor: pointer;"><img src="../../img/close.png" width="16" height="16" title="Zamknij" alt="Zamknij" /></div>';
						myVerticalSlide.slideIn();
						
					}
				}
				
			xmlHttp.send (null);
		
		}
		
	}

	function printinfo(sid) {
	
		printwindow = window.open(sid,'printing','width=780,height=540,toolbar=0,resizable=1,scrollbars=1');

	}

	function loading_search() {
	
		document.getElementById('search_progress').style.display = 'block';
	
	}
	
	function loading_search_map() {
	
		document.getElementById('search_progress_map').style.display = 'block';
	
	}

	function sttn(text) {
	
		if (text != "") document.getElementById('ntnext').innerHTML = text; else document.getElementById('ntnext').innerHTML = '&nbsp;';
	
	}
	
/* ------------------------------------------
     @pete 28/01/2009 modifications EOM
------------------------------------------ */