///////////////////////////////////////////////////////////////////
//Walidacja do formularza powiadom znajomego
function walidacja2(AForm, fokus1, fokus2){
    //Email odbiorcy
	reg = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/;
    wyn = AForm.email_odbiorcy.value.match(reg);
    if (wyn == null){
        alert("Proszę wypełnić poprawnie pole adres email.");
		var formularz1 = document.getElementById(fokus1);
		formularz1.focus();
        return false;
    }
    //Osoba polecająca
	wyn = AForm.osoba_polecajaca.value;
    if (wyn == ''){
        alert("Proszę wypełnić poprawnie pole osoba polecajaca");
		var formularz2 = document.getElementById(fokus2);
		formularz2.focus();
        return false;
    }
	else {
	    return true;
	}
}

///////////////////////////////////////////////////////////////////
//Walidacja do formularza subskrypcji
function walidacja3(AForm, fokus1){
    //Email odbiorcy
	reg = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/;
    wyn = AForm.email_subskrypcja.value.match(reg);
    if (wyn == null){
        alert("Proszę wypełnić poprawnie pole adres email.");
		var formularz1 = document.getElementById(fokus1);
		formularz1.focus();
        return false;
    }
	else {
	    return true;
	}
}

///////////////////////////////////////////////////////////////////
//Walidacja do formularza wyszukiwarki
function walidacja_wyszukiwarka(AForm, fraza){
    if (AForm.fraza.value.length < 4){
        alert("Podaj co najmniej 4 znaki!");
        return false;
    } else {
        return true;
	}
}

///////////////////////////////////////////////////////////////////////////
//Dodaj do ulubionych
function displayLink(p_type, p_url, p_title, p_link_text) {
  var agt = navigator.userAgent.toLowerCase();
  var p_here = top.location.href

  if (p_type == 3)
  {
    if ((agt.indexOf("opera") != -1)) // || (agt.indexOf("firefox") != -1))
    {
      document.write("<a href=\""+p_here+"\" title=\"" + p_title + "\" rel=\"sidebar\">" + p_link_text + "</a>");
    } else
    {
      document.write("<a href=\"javascript:addBookmark('"+p_title+"',top.location.href);\" title=\"" + p_title + "\" >" + p_link_text + "</a>");
    }
  } else
  {
    if (agt.indexOf("opera") != -1) 
    {
      document.write("<a href=\"" + p_url + "\" title=\"" + p_title + "\" rel=\"sidebar\">" + p_link_text + "</a>");
    } else
    {
      document.write("<a href=\"javascript:addBookmark('"+p_title+"','"+p_url+"');\" title=\"" + p_title + "\" >" + p_link_text + "</a>");
    }
  }
}
function addBookmark(title,url) {

  var msg_netscape = "Wiadomo¶ć Netscape";
  var msg_opera    = "Ta funkcja nie działa z t± wersj± Opery. Dodaj nas do ulubionych ręcznie.";
  var msg_other    = "Twoja przegl±darka nie wspiera automatycznego dodawania do ulubionych. Dodaj nas do ulubionych ręcznie.";
  var agt          = navigator.userAgent.toLowerCase();
  if (agt.indexOf("opera") != -1) 
  {
    if (window.opera && window.print)
    {
      return true;
    } else 
    {
      alert(msg_other);
    }
  }    
  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
  else alert(msg_other);
}

/////////////////////////////////////////////////////
//Licznik znaków
function textCounter(field, countfield, maxlimit){
	if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
	else countfield.value = maxlimit - field.value.length;
}
//Wstawianie emotikonow
function emo(emo){
	document.all.komentarz.value += emo;
	document.all.komentarz.focus();
	return;
}

//Walidacja do formularza komentarza
function walidacja_komentarz(AForm, fokus1, fokus2){
	wyn = AForm.autor.value;
    if (wyn == ''){
        alert("Proszę wypełnić poprawnie pole autor.");
		var formularz1 = document.getElementById(fokus1);
		formularz1.focus();
        return false;
    }
    //Osoba polecająca
	wyn = AForm.komentarz.value;
    if (wyn == ''){
        alert("Proszę wypełnić poprawnie pole komentarz.");
		var formularz2 = document.getElementById(fokus2);
		formularz2.focus();
        return false;
    }
	else {
	    return true;
	}
}

//funkcja otwierania zewnętrznego okna
function displayWindow(url, width, height){
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,left=200,top=100' );
}


///////////////////////////////////////////////////////////////////
//Walidacja do formularza kontakt
function walidacja4(AForm, fokus1, fokus2, fokus3){
	wyn = AForm.imie_nazwisko.value;
    if (wyn == ''){
        alert("Proszę wypełnić poprawnie pole imię i nazwisko");
		var formularz1 = document.getElementById(fokus1);
		formularz1.focus();
        return false;
    }
    //Email odbiorcy
	reg = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/;
    wyn = AForm.adres_email.value.match(reg);
    if (wyn == null){
        alert("Proszę wypełnić poprawnie pole adres email.");
		var formularz2 = document.getElementById(fokus2);
		formularz2.focus();
        return false;
    }
	wyn = AForm.Tresc.value;
    if (wyn == ''){
        alert("Proszę wypełnić poprawnie pole Treść");
		var formularz3 = document.getElementById(fokus3);
		formularz3.focus();
        return false;
    }
	else {
	    return true;
	}
}

//FUNKCJA POWIEKSZANIA LITER
var tgs = new Array('div','td','h6','h5','h4');
var tgs2 = new Array('h4');
var szs = new Array( '11px','13px','16px' );
var startsz = '';

function getURLParam(strParamName){
  var strReturn = "x";
  var strHref = window.location.href;
  if ( strHref.indexOf("&") > -1 ){ 
    var strQueryString = strHref.substr(strHref.indexOf("&")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

startsz = getURLParam('startsz');


function ts( tgs,trgt,inc ) { 
	if (!document.getElementById) return;
	var d = document,cEl = null,sz,i,j,cTags;
	
	sz = inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 2 ) sz = 2;
	startsz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize   = szs[ sz ];
	if (inc==2) cEl.style.lineHeight = '22px';
	else	    cEl.style.lineHeight = '18px';


	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ){ 
			cTags[ j ].style.fontSize = szs[ sz ]; 
			if (inc==2) cTags[ j ].style.lineHeight = '22px';
			else	    cTags[ j ].style.lineHeight = '18px';	


		}
	}
}

function setCoo(size)
{
    document.cookie='rozmiar_czcionki='+size+'; path=/';
}

function getCoo(cookie)
{
    var position = cookie.indexOf("rozmiar_czcionki");
    if (position != -1) {
        return cookie.substr(position+17, 1);
    }
    return -1;
}
