//if(document.layers) document.captureEvents(Event.KEYPRESS);

function RegisterKey() {
  if (document.getElementById("pomocnik_powiedz").onkeydown != Key) {
    document.getElementById("pomocnik_powiedz").onkeydown = Key;
  }
}


function Key(e) {
  if (!e) { var e = e || event; }
  //window.alert(e.keyCode);
  if (e.keyCode == 13) PomocnikKonsola();
}



function ch_class_el(nazwa_nowej_klasy, element) {
	var el = document.getElementById(element);
	el.style.className = nazwa_nowej_klasy;
	
}


function Show(T,t){
  if (window.opera) {
    T.title='';

    T.parentNode.lastChild.style.visibility=t?'visible':'hidden';
    T.parentNode.lastChild.style.height=t?'auto':'0px';
    T.parentNode.lastChild.style.width=t?'140px':'0px';
    T.parentNode.lastChild.style.border=t?'1px':'0px'
  }
  else {
    T.title='';
    T.parentNode.lastChild.style.display=t?'block':'none';
  }
 
}


function OperaCssSwitch() {
  if (window.opera) document.write("<div class='showoffOpera'>")
  else document.write("<div class='showoff'>");
}


function pre_load_img(obrazki) {
	prefetch=new Array();
	
	for (i=0; i<obrazki.length; i++) {		
		prefetch[i]=new Image();
		prefetch[i].src=obrazki[i];
	}
}	


function Togluj (id) {
   var elem = document.getElementById(id);
   
	 if (elem.className == 'hidden' && elem.style.display != 'block' && elem.style.display != 'none') { elem.style.display = 'block'; return false; }
	 
	 if (elem.style.display != "none") { elem.style.display = "none"; }
   else { elem.style.display = "block"; }
	 
	 return false;
}


function SetInnerHTML (id, text) {
   var elem = document.getElementById(id);
   elem.innerHTML = text;
}

function SetTextContent (id, text) {
   var elem = document.getElementById(id);
   elem.textContent = text;
}

function SetElem(id, adres, parametr, output) {
   elem = document.getElementById(id);
   advAJAX.post({
      url: adres,
      
      parameters : { 
         "_ajax"     : "_on",
				 "_parametr" : parametr // parametr = [ _main_only | _header_only | _footer_only ]
      }, 
  
      onSuccess : function(obj) { // to jest funkcja w razie sukcesu - załadowania informacji
         SetInnerHTML(id, obj.responseText);
				 //alert(obj.responseText);
         
      }
   });

}

var znajomi_wygen = 0;
var znajomi_lista = "";
var znajomi_wartosc = "";
function Znajomi () {
  znajomi_wartosc = document.getElementById('znajomi_wartosc').value;
	 return false;
	if (znajomi_wartosc == '0') {  return false;  }
	else if (znajomi_wartosc == '1')  {  overlib('<div class=\'showoff\' style=\'width:300px;\'><div class=\'div_gora\' style=\'width:300px; text-align:right; color:#FAFAFA;\' ><strong><span onclick=\'nd();\' class=\'ahiperx\'>[&times;]</span></strong></div><div id=\'znajomi_id\' style=\'width:300px; background-color:#111111; color:#FAFAFA\'></div><div class=\'div_dol\' style=\'width:300px;\'></div></div>', FULLHTML, VAUTO, OFFSETX, 10);   }
	else if (znajomi_wartosc == '2')  {  overlib('<div class=\'showoff\' style=\'width:300px;\'><div class=\'div_gora\' style=\'width:300px; text-align:right; color:#FAFAFA;\' ><strong><span onclick=\'nd();\' class=\'ahiperx\'>[&times;]</span></strong></div><div id=\'znajomi_id\' style=\'width:300px; background-color:#111111; color:#FAFAFA\'></div><div class=\'div_dol\' style=\'width:300px;\'></div></div>', FULLHTML, VAUTO, STICKY, OFFSETX, 10);   }
  
	
	if (!(document.getElementById('znajomi_id'))) {
	  nd();
	  if (znajomi_wartosc == '1')  {  overlib('<div class=\'showoff\' style=\'width:300px;\'><div class=\'div_gora\' style=\'width:300px; text-align:right; color:#FAFAFA;\' ><strong><span onclick=\'nd();\' class=\'ahiperx\'>[&times;]</span></strong></div><div id=\'znajomi_id\' style=\'width:300px; background-color:#111111; color:#FAFAFA\'></div><div class=\'div_dol\' style=\'width:300px;\'></div></div>', FULLHTML, VAUTO, OFFSETX, 10);   }
		else if (znajomi_wartosc == '2')  {  overlib('<div class=\'showoff\' style=\'width:300px;\'><div class=\'div_gora\' style=\'width:300px; text-align:right; color:#FAFAFA;\' ><strong><span onclick=\'nd();\' class=\'ahiperx\'>[&times;]</span></strong></div><div id=\'znajomi_id\' style=\'width:300px; background-color:#111111; color:#FAFAFA\'></div><div class=\'div_dol\' style=\'width:300px;\'></div></div>', FULLHTML, VAUTO, STICKY, OFFSETX, 10);   }

	}
	
	if (znajomi_wygen == 0) {
		advAJAX.post({
			url: "znajomi.php?opcja=krotkie",
			
			parameters : { 
				"_ajax"     : "_on",
				"_parametr" : "_main_only", // parametr = [ _main_only | _header_only | _footer_only ]
				"_output"   : "_print"
			}, 
			
			onLoading : function(obj) {
			  document.getElementById('info_div').innerHTML = "<span style='background-color:yellow; color:black;'>\u0141adowanie...</span>";
			},
			
			onSuccess : function(obj) {
				znajomi_lista = obj.responseText;
				document.getElementById('znajomi_id').innerHTML = znajomi_lista;
				//alert(obj.responseText);
				znajomi_wygen++;
			  document.getElementById('info_div').innerHTML = "";
			}
		});
	}
	else {
	  document.getElementById('znajomi_id').innerHTML = znajomi_lista;
	}
	
}

function ZnajomiZmien(opcja) {
	advAJAX.post({
		url: "znajomi.php?zmien=".opcja,
		
		parameters : { 
			"_ajax"     : "_on",
			"_parametr" : "_main_only", // parametr = [ _main_only | _header_only | _footer_only ]
			"_output"   : "_no_output"
		}, 
		
		onLoading : function(obj) {
			document.getElementById('info_div').innerHTML = "<span style='background-color:yellow; color:black;'>\u0141adowanie...</span>";
		},
		
		onSuccess : function(obj) {
			//alert(obj.responseText);
			znajomi_wygen++;
			document.getElementById('info_div').innerHTML = "";
		}
	});
	nd();
}







/**
 * Pomocnik
 * @author azi <azrael.valedhel@gmail.com>
 * @version 0.1
 * @param  strona   to jest przekazywana z php zmienna $title
 */
function Pomocnik(strona) {
  if (!strona) var strona = ""; // jeżeli nie jest podana strona to strona = ""
  /*
   * deklaracja zmiennych lokalnych
   */
  //var pomocnik = document.getElementById("pomocnik"); // w tej chwili nieużywana

  var url = "/pomocnik.php?s=" + escape(strona);
  var tytul = "Helpinia Semper";
  var argumenty = "width=450px,height=190px,right=20px,top=20px,resize=1,scrolling=1";
  /*
   * Cialo funkcji
   */
  pomocnik_okno=dhtmlwindow.open("ajaxbox", "ajax", url, tytul, argumenty);
  //pomocnik_okno.onclose=function(){return window.confirm("Close window 3?"); } //Run custom code when window is about to be closed

  // koniec funkcji
}


/**
 * PomocnikKonsola
 * @author azi <azrael.valedhel@gmail.com>
 * @version 0.1
 */
function PomocnikKonsola() {
  var input = document.getElementById("pomocnik_powiedz");
  var tekst = document.getElementById("pomocnik_tekst");

  advAJAX.post({
    url: "/pomocnik.php",

    parameters : {
      "s" : input.value
    },
    
    onInitialization : function(obj) {
      document.body.style.cursor = "progress";
      //window.alert(input.value);
    },

    onLoading : function(obj) {
      //input.disabled = "true";
      while (tekst.firstChild) {
        tekst.removeChild(tekst.firstChild);
      }
      tekst.innerHTML = "\u0141adowanie...";
    },

    onSuccess : function(obj) {
		  tekst.innerHTML = obj.responseText;
    },

    onFinalization : function(obj) {
      if (tekst.innerHTML != "\u0141adowanie...") {
        input.value = "";
      }
      document.body.style.cursor = "auto";
    }
  });
}  




/**
 * @var przetrzymuje wartosc style.border dla przywrocenia w Podswietl()
 */
var pod_border_tmp;

/**
 * Podswietl
 * @author azi <azrael.valedhel@gmail.com>
 * @param  el    id elementu
 * @param  tryb  1=podswietl, 0=przywroc
 */
function Podswietl(el, tryb) {
  el = document.getElementById(el);
  if (tryb == 1) {
    pod_border_tmp = el.style.border;
    el.style.border = "1px solid red";
  }
  else if (tryb == 0) {
    el.style.border = pod_border_tmp;
  }
}

	/*
CSS Browser Selector v0.3.1
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/

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);




