function ShowSubmenu(nr)
{
  for(i=1; i<=7; i++)
  {
    document.getElementById('sub_mainmenu'+i).style.display='none';
  }

  document.getElementById('sub_mainmenu'+nr).style.display='block';
}

function HideSubmenu(nr)
{
  document.getElementById('sub_mainmenu'+nr).style.display='none';
}

function HideAllSubmenu()
{
  for(i=1; i<=7; i++)
  {
    document.getElementById('sub_mainmenu'+i).style.display='none';
	 
	 
  }
	

	
  
}

function dodajDoUlubionych() 
{

    var tytul = 'Hadykowka.pl';
    var adres = 'http://www.hadykowka.pl';

    //FireFox
    if (window.sidebar) { 

        window.sidebar.addPanel(tytul, adres, ""); 

    //IE
    } else if (window.external) {

        window.external.AddFavorite(adres, tytul); 

    //Opera
    } else if (window.opera && window.print) {

        var a = document.createElement('a');
        a.setAttribute('href', adres);
        a.setAttribute('title', tytul);
        a.setAttribute('rel','sidebar');
        a.click();
    }
}

function insertRow(content)
{
	var item = document.getElementById("tabelkaContent");
	var row = item.insertRow(0);
	//row.innerHTML = content;
	var tekst = content.split("<sep>");
	var c1 = row.insertCell(-1);
		c1.className = 'newrow';
		c1.innerHTML = "<strong>"+tekst[0]+"</strong>";
		c1 = row.insertCell(-1);
		c1.className = 'newrow';
		c1.innerHTML = tekst[1];
		c1 = row.insertCell(-1);
		c1.className = 'newrow';
		c1.style.textAlign = "center";
		c1.innerHTML = tekst[2];
	//document.getElementById("hidForm").value = '';
	//document.getElementById('imgDodajKsiega').onclick = null;
	setTimeout('cleanup()',1000);
}

function cleanup()
{
	//document.getElementById('formKsiega').innerHTML = '';
	document.getElementById('formKsiega').style.display= 'none';
}

function dodajKsiega()
{
	document.getElementById("formKsiega").style.display= 'block';
	/*
	var a0= "dodaj";
		a0+=",ksiega";
		a0+=".html";
	var item = document.getElementById("formKsiega");
		item.style.display = "block";
	var content = "<div class=\"formContainer\">";
		content+= "<form action=\""+a0+"\" method=\"post\"><fieldset>";
		content+= "<legend>Dodaj nowy wpis:</legend>";
		content+= "<div style=\"overflow: hidden;\"><label for=\"nick_tf\">nick: </label><input id=\"nick_tf\" type=\"text\" class=\"formTf\" name=\"nick\" value=\"\"></div>";
		content+= "<div style=\"overflow: hidden; margin: 5px 0;\"><label for=\"mail_tf\">e-mail: </label><input id=\"mail_tf\" type=\"text\" class=\"formTf\" name=\"nick\" value=\"\"></div>";
		content+= "<div style=\"overflow: hidden; margin-bottom: 5px;\"><label for=\"tresc_ta\">treść: </label><textarea class=\"formTa\" name=\"tresc\" id=\"tresc_ta\" rows=\"10\" cols=\"20\"></textarea></div>";
		content+= "<input id=\"fButton\" type=\"button\" onclick=\"sendForm()\" value=\"Wyślij\" class=\"formButton\">";
		content+= "<input type=\"hidden\" id=\"hidForm\" value=\"yes\">";
		content+= "</fieldset></form>";
		content+= "</div>";
	item.innerHTML = content;
	*/
}

function sendForm()
{
	var aa = "index.php?module=ksiega_gosci&ajax=1";
	var nf = document.getElementById("nick_tf");
	var mf = document.getElementById("mail_tf");
	var ta = document.getElementById("tresc_ta");
	var hf = document.getElementById("hidForm");
	var pn = document.getElementById('fButton');
	if(nf.value != "" && mf.value != "" && ta.value != "")
		advAJAX.post({
			url: aa,
			parameters: {
				"content" : ta.value,
				"nick" : nf.value,
				"mail" : mf.value,
				"is_submit" : hf.value == 'yes' ? "Yes" : "No"
			},
			onInitialization : function() {
				pn.value = "Wysyłanie, proszę czekać...";
			},
			onSuccess : function(obj) {
					switch(obj.responseText)
					{
						case 'nick' : pn.value = 'Błąd!\nPuste pole \'nick\''; break;
						case 'mail' : pn.value = 'Błąd!\nNieprawidłowa wartość e-mail!'; break;
						case 'content' : pn.value = 'Błąd!\nPuste pole treści!'; break;
						default : 
						{
							pn.value = "Wysłano! Dziękujemy";
							insertRow(obj.responseText);
						}
					}
			},
			onError : function()
			{
				pn.value = "Błąd wysyłania danych!\nSpróbuj ponownie.";
			}
		});
	else
	{
		pn.value = "Błąd!\nNie wszystkie pola wypełnione!";
	}
}
