function zamien_serch(wart) {
	tablica=new Array('portal','baza','oglo');
	tablica1=new Array('portal1','baza1','oglo1');
	tablica2=new Array('portal2','baza2','oglo2');
	for (var i=0;i<tablica.length;i++) {
		if (wart==tablica[i]) {
			document.getElementById(tablica[i]).style.display='block';
			document.getElementById(tablica1[i]).style.display='none';
			document.getElementById(tablica2[i]).style.display='block';
		} else {
			document.getElementById(tablica[i]).style.display='none';
			document.getElementById(tablica1[i]).style.display='block';
			document.getElementById(tablica2[i]).style.display='none';
		}
	}
}
function startuj() {
	document.getElementById('startuj').style.behavior='url(#default#homepage)';
	document.getElementById('startuj').setHomePage('http://www.nowiny.pl/');
}
function ulubione() {
	window.external.addFavorite('http://www.nowiny.pl/','Tygodnik Nowiny');
}
function ulubione_nr() {
	window.external.addFavorite('http://www.nowiny.pl/','Nowiny Raciborskie');
}
function ulubione_nw() {
	window.external.addFavorite('http://www.nowiny.pl/','Nowiny Wodzisławskie');
}
function ulubione_tr() {
	window.external.addFavorite('http://www.nowiny.pl/','Tygodnik Rybnicki');
}
function okienko(szer,wys,file_name) {
	window.open(file_name,'okienko','width='+szer+',height='+wys+',scrollbars=no,menubar=no,status=yes,resizable=no');
}

//pokazuje, ukrywa newsletter
function newsletter(wart) {
	if (document.getElementById(wart).style.display=='block') {
		document.getElementById(wart).style.display='none';
	} else {
		document.getElementById(wart).style.display='block';
	}
}

function okienko(szer,wys,file_name) {
	window.open(file_name,'okienko','width='+szer+',height='+wys+',scrollbars=no,menubar=no,status=yes,resizable=no');
}

function ValidateForm_PW() {
	var Check = 0;
  if (document.dodaj_post.tytul.value == '') { Check = 1; }
	if (document.dodaj_post.tresc.value == '') { Check = 1; }
	if (document.dodaj_post.odbiorca.value == '') { Check = 1; }

	if (Check == 1) {
		alert("Nie wprowadzono tytułu, treści lub odbiorcy wiadomości!!! Prosimy uzupełnić dane.");
		return false;
	} else {
		document.dodaj_post.submit.disabled = true;
		return true;
	}
}

function ValidateFormSendpassword() {
	var Check = 0;
  if (document.LOGIN.email.value == '') { Check = 1; }
	
	if (Check == 1) {
		alert("Nie wprowadzono aresu e-mail!!!");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}

function ValidateForm() {
	var Check = 0;
  if (document.LOGIN.UserName.value == '') { Check = 1; }
	if (document.LOGIN.PassWord.value == '') { Check = 1; }

	if (Check == 1) {
		alert("Prosze podać swój identyfikator i hasło zanim przejdziesz dalej");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}

function ValidateForm_Pass() {
	var Check = 0;
		
	if (document.REG.pass0.value == '') { Check = 1; }
	if (document.REG.pass1.value == '') { Check = 1; }
	if (document.REG.pass2.value == '') { Check = 1; }

	if (Check == 1) {
		alert("Prosze podać hasło zanim przejdziesz dalej");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}

function CheckEMail(email)
{
if (email == '')
return false;
if (email.indexOf('@') == -1 || email.indexOf('.') == -1)
return false;
if (email.length < 4 || email.length > 100)
return false;
if (email.indexOf('@') != email.lastIndexOf('@'))
return false;
if (email.indexOf(' ') != -1)
return false;
if (email.indexOf('	') != -1)
return false;
if (email.indexOf(';') != -1)
return false;
if (email.indexOf('?') != -1)
return false;
if (email.indexOf('/') != -1)
return false;
if (email.indexOf(',') != -1)
return false;
if (email.indexOf('>') != -1)
return false;
if (email.indexOf('<') != -1)
return false;
if (email.indexOf('{') != -1)
return false;
if (email.indexOf('}') != -1)
return false;
if (email.indexOf('[') != -1)
return false;
if (email.indexOf(']') != -1)
return false;
if (email.indexOf('#') != -1)
return false;
if (email.indexOf('&') != -1)
return false;
if (email.indexOf('?') != -1)
return false;
if (email.indexOf('|') != -1)
return false;
if (email.indexOf('(') != -1)
return false;
if (email.indexOf(')') != -1)
return false;
if (email.indexOf('%') != -1)
return false;
if (email.indexOf('$') != -1)
return false;
if (email.indexOf('^') != -1)
return false;
if (email.indexOf('+') != -1)
return false;
if (email.indexOf('=') != -1)
return false;
if (email.indexOf('*') != -1)
return false;
if (email.indexOf(':') != -1)
return false;
return true;
}

function validateForm2(REG)
{

if (REG.UserName.value == "")
{
alert ("Niewprowadzono nazwy użytkownika");
REG.UserName.focus ();
return false;
}

if (REG.PassWord.value == "")
{
alert ("Niewprowadzono hasła");
REG.PassWord.focus ();
return false;
}

if (REG.PassWord.value.length < 5)
{
alert ("Hasło powinno składać się z minimum 5 znaków.");
REG.PassWord.focus ();
return false;
}

if (REG.PassWord.value != REG.PassWord_Check.value)
{
alert ("Niepoprawne hasło");
REG.PassWord.focus ();
return false;
}

if ( !CheckEMail( REG.EmailAddress.value ) )
{
alert ("Niepoprawna  składnia adresu e-mail");
REG.EmailAddress.focus ();
return false;
}
if (REG.EmailAddress.value != REG.EmailAddress_two.value)
{
alert ("Niepoprawne adresy email");
REG.EmailAddress.focus ();
return false;
}


return true;
}



var myAgent   = navigator.userAgent.toLowerCase();
var myVersion = parseInt(navigator.appVersion);

var is_ie   = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));
var is_nav  = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
                && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
                && (myAgent.indexOf('webtv') ==-1)       && (myAgent.indexOf('hotjava')==-1));

var is_win   =  ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
var is_mac    = (myAgent.indexOf("mac")!=-1);

//-- mod_bbcode begin
var is_opera = (myAgent.indexOf("opera") != -1);
//-- mod_bbcode end

// IBC Code stuff
	var text_enter_url      = "wpisz adres dla odsyłacza";
	var text_enter_url_name = "wpisz tytuł strony";
	var text_enter_image    = "wpisz url obrazka";
	var text_enter_email    = "wpisz adres e-mail";
	var text_enter_flash    = "wpisz url animacji flash";
	var text_code           = "[CODE] twój kod tutaj.. [/CODE]";
	var text_quote          = "[QUOTE] twój cytat tutaj... [/QUOTE]";
	var error_no_url        = "wpisz URL";
	var error_no_title      = "musisz wpisać tytuł";
	var error_no_email      = "wpisz adres e-mail";
	var error_no_width      = "wpisz szerokość";
	var error_no_height     = "wpisz wysokość";
	var prompt_start        = "WprowadĄ tekst do sformatowania";

	var help_bold           = "Wstaw pogrubiony tekst (alt + b)";
	var help_italic         = "Wstaw tekst w kursywie (alt + i)";
	var help_under          = "Wsta podkreślony tekst (alt + u)";
	var help_font           = "Wstaw tag rodzaju czcionki";
	var help_size           = "Wstaw tag rozmiaru czcionki";
	var help_color          = "Wstaw tag koloru czcionki";
	var help_close          = "Zamknij wszystkie otwarte tagi";
	var help_url            = "Wstaw hiperłącze (alt+ h)";
	var help_img            = "Obraz (alt + g) [img]http://www.dom.com/img.gif[/img]";
	var help_email          = "Wstaw adres e-mail (alt + e)";
	var help_quote          = "Wstaw cytat (alt + q)";
	var help_list           = "Stwórz listę (alt + l)";
	var help_code           = "Wstaw tekst monotypowy - kod (alt + p)";
	var help_click_close    = "Wciśnij przycisk ponownie, aby zamknąć tag";
	var help_center    = "Wstaw wyśrodkowywanie tekstu";
	var help_sql    = "Wstaw kod SQL";
	var help_html    = "Wstaw kod HTML";
	var list_prompt         = "WprowadĄ pozycje listy. Wciśnij 'anuluj' lub zostaw puste, aby zakonczyć";

//--------------------------------------------
// EMOTICONS
//--------------------------------------------

function emoticon(theSmilie)
{
    doInsert(" " + theSmilie + " ", "", false);
}


//--------------------------------------------
// GENERAL INSERT FUNCTION
//--------------------------------------------
// ibTag: opening tag
// ibClsTag: closing tag, used if we have selected text
// isSingle: true if we do not close the tag right now
// return value: true if the tag needs to be closed later

//

function doInsert(ibTag, ibClsTag, isSingle)
{
    var isClose = false;
    var obj_ta = document.dodaj_post.tresc;

    if ( (myVersion >= 4) && is_ie && is_win) // Ensure it works for IE4up / Win only
    {
        if(obj_ta.isTextEdit){ // this doesn't work for NS, but it works for IE 4+ and compatible browsers
            obj_ta.focus();
            var sel = document.selection;
            var rng = sel.createRange();
            rng.colapse;
            if((sel.type == "Text" || sel.type == "None") && rng != null){
                if(ibClsTag != "" && rng.text.length > 0)
                    ibTag += rng.text + ibClsTag;
                else if(isSingle)
                    isClose = true;

                rng.text = ibTag;
            }
        }
        else{
            if(isSingle)
                isClose = true;

            obj_ta.value += ibTag;
        }
    }
    else
    {

//-- mod_bbcode begin
        // this should work with Mozillas
        if ( (myVersion >= 4) && is_win && !is_opera) {
            var length = obj_ta.textLength;
            var start = obj_ta.selectionStart;
            var end = obj_ta.selectionEnd;
            if (end == 1 || end == 2)
                end = length;
            var head = obj_ta.value.substring(0,start);
            var rng = obj_ta.value.substring(start, end);
            var tail = obj_ta.value.substring(end, length);
            if( start != end ){
                if (ibClsTag != "" && length > 0)
                    ibTag += rng + ibClsTag;
                else if (isSingle)
                    isClose = true;
                rng = ibTag;
                obj_ta.value = head + rng + tail;
                start = start + rng.length;
            }
            else{
                if(isSingle)
                    isClose = true;
                obj_ta.value = head + ibTag + tail;
                start = start + ibTag.length;
            }
            obj_ta.selectionStart = start;
            obj_ta.selectionEnd = start;
        }
        else {
//-- mod_bbcode end
        if(isSingle)
            isClose = true;

        obj_ta.value += ibTag;
//-- mod_bbcode begin
        }
//-- mod_bbcode end

    }

    obj_ta.focus();

    // clear multiple blanks
//    obj_ta.value = obj_ta.value.replace(/  /, " ");

    return isClose;
}


function simpletagB()
{

if (document.dodaj_post.B.value == ' B ')
{
			doInsert("[B]", "[/B]", true);
         eval("document.dodaj_post.B.value += '*'");         
}else
{
					doInsert("[/B]", "", false);

            eval("document.dodaj_post.B.value = ' B '");

}
}

function simpletagI()
{

if (document.dodaj_post.II.value == ' I ')
{
			doInsert("[I]", "[/I]", true);
         eval("document.dodaj_post.II.value += '*'");         
}else
{
					doInsert("[/I]", "", false);

            eval("document.dodaj_post.II.value = ' I '");

}
}

function simpletagU()
{

if (document.dodaj_post.U.value == ' U ')
{
			doInsert("[U]", "[/U]", true);
         eval("document.dodaj_post.U.value += '*'");         
}else
{
					doInsert("[/U]", "", false);

            eval("document.dodaj_post.U.value = ' U '");

}
}

function tag_url()
{
    var FoundErrors = '';
    var enterURL   = prompt(text_enter_url, "http://");
    var enterTITLE = prompt(text_enter_url_name, "My Webpage");

    if (!enterURL) {
        FoundErrors += " " + error_no_url;
    }
    if (!enterTITLE) {
        FoundErrors += " " + error_no_title;
    }

    if (FoundErrors) {
        alert("Error!"+FoundErrors);
        return;
    }

    doInsert("[URL="+enterURL+"]"+enterTITLE+"[/URL]", "", false);
}

<!-- bbcode_function -->
//-- mod_bbcode end
function tag_image()
{
    var FoundErrors = '';
    var enterURL   = prompt(text_enter_image, "http://");

    if (!enterURL) {
        FoundErrors += " " + error_no_url;
    }

    if (FoundErrors) {
        alert("Error!"+FoundErrors);
        return;
    }

    doInsert("[IMG]"+enterURL+"[/IMG]", "", false);
}


function tag_email()
{
    var emailAddress = prompt(text_enter_email, "");

    if (!emailAddress) {
        alert(error_no_email);
        return;
    }

    doInsert("[EMAIL]"+emailAddress+"[/EMAIL]", "", false);
}



function emo_pop()
{
  window.open('all_emots.php','Legends','width=800,height=200,resizable=yes,scrollbars=yes');
}

function dodaj_komentarz() {
	var stan=document.getElementById('add_kom').style.display;
	if (stan=='none') {
		document.getElementById('add_kom').style.display='block';
	} else {
		document.getElementById('add_kom').style.display='none';
	}
}
// Alt panels
var horizontal_offset="9px" 

var vertical_offset="0" 
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	if (whichedge=="rightedge"){
		var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
	} else{
		var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
	}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
	if ((ie||ns6) && document.getElementById("onmouseBox")){
		dropmenuobj=document.getElementById("onmouseBox")
		dropmenuobj.innerHTML=menucontents
		dropmenuobj.style.left=dropmenuobj.style.top=-500
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style
			dropmenuobj.widthobj.width=tipwidth
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		dropmenuobj.style.visibility="visible"
		obj.onmouseout=hidetip
	}
}

function hidetip(e){
	dropmenuobj.style.visibility="hidden"
	dropmenuobj.style.left="-500px"
}

function createhintbox(){
	var divblock=document.createElement("div")
	divblock.setAttribute("id", "onmouseBox")
	document.body.appendChild(divblock)
}

if (window.addEventListener)
	window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
	window.attachEvent("onload", createhintbox)
else if (document.getElementById)
	window.onload=createhintbox