var ETest  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

function changeFacebookStatus(url)
{       
	tekst = "<div style=\"clear: both; width: 220px; margin: 7px 0 0px 0px;\"><a name=\"fb_share\" type=\"button\" share_url=\"" + url + "\" href=\"http://www.facebook.com/sharer.php?t=Projekt domu\">Udostępnij</a><div style=\"margin-top: -20px; margin-left: 120px;\"><iframe src=\"http://www.facebook.com/plugins/like.php?href=" + url + "&amp;layout=button_count&amp;show_faces=false&amp;width=250&amp;action=like&amp;colorscheme=light&amp;height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:250px; height:21px;\" allowTransparency=\"true\"></iframe></div></div>";

        document.getElementById('fb-root').innerHTML = tekst;
        
}

function doPic(imgName, imgBig)
{
   imgOn = imgName;
   Widok = imgBig;
   document.getElementById('widok').src = imgOn;
}

function doWidok(imgBig, id)
{
   document.getElementById('grafika').src = ("../pliki/" + id + "/widoki/" + imgBig);
}

function displayWindowWR(url, width, height, nazwa, id, rzut)
{
   window.open(url + '&nazwap=' + nazwa + '&idp=' + id + '&rzut=' + rzut ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayPromesa(url, width, height, nazwa)
{
   window.open(url + '?nazwa=' + nazwa ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=yes,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayCharakterystyka(url, width, height, nazwa)
{
   window.open(url + '?nazwa=' + nazwa ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=yes,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayWindow(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayLustro(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayTablica(nazwa, width, height)
{
   window.open(strona + "/popUp/tablica.php?nazwa=" + nazwa,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayArchPakiet(nazwa, width, height)
{
   window.open(strona + "/popUp/archpakiet.php?nazwa=" + nazwa,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function display(url)
{
   window.open(url,'','');
   return false;
}

function promocja_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) {
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) {
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}

function setCheckboxes(the_form, do_check)
{
    var elts      = document.forms[the_form].elements['notes[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        }
    } else {
        elts.checked        = do_check;
    }

    return true;
}


function notes_submit(val)
{
   document.getElementById('sub').value = val;
   
   if (val == 2)
      document.forms['notesik'].target='_blank';
   else
      document.forms['notesik'].target='_self';
      
   document.forms['notesik'].submit();
}

function pokaz_regulamin(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function zglosreklamacje()
{
   error = '';
   if (document.getElementById('imie').value == '') error += "Podaj imie i nazwisko\n";
   if (document.getElementById('tresc').value == '') error += "Podaj czego dotyczy reklamacja\n";
   if (!ETest.test(document.getElementById('mejl').value)) error += "Podaj poprawny adres e-mail.\n";
   if (document.getElementById('zgoda').checked != 1) error += "Aby wysłać zgłoszenie musisz zgodzić\n się na wykorzystanie twoich danych.\n";

   if (error != '')
   {
      alert (error);
      return false;
   }
   else
      return true;
}

function zglosblad()
{
   error = '';
   if (document.getElementById('tresc').value == '') error += "Podaj opis bledu\n";
   if (document.getElementById('lnk').value == '') error += "Podaj link do bledu\n";
   if (!ETest.test(document.getElementById('mejl').value)) error += "Podaj poprawny adres e-mail.\n";
   
   if (error != '')
   {
      alert (error);
      return false;
   }
   else
      return true;
}

function polaczenie_szyfrowane()
{
	if (location.protocol=="http:") {
  		location.href = location.href.replace(/^http:/, "https:")
	}
}

function polaczenie_nieszyfrowane()
{
	if (location.protocol=="https:") {
  		location.href = location.href.replace(/^https:/, "http:")
	}
}

function zgoda_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) { 
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) { 
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}

function promocja_mtm_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) { 
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) { 
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}

function main_zakladki(co) {
	document.getElementById('main_zakladki_1').style.display = "none";
	document.getElementById('main_linki_1').style.fontWeight = "normal";
	document.getElementById('main_linki_1').style.color = "black";
	document.getElementById('main_zakladki_2').style.display = "none";
	document.getElementById('main_linki_2').style.fontWeight = "normal";
	document.getElementById('main_linki_2').style.color = "black";
	document.getElementById('main_zakladki_3').style.display = "none";
	document.getElementById('main_linki_3').style.fontWeight = "normal";
	document.getElementById('main_linki_3').style.color = "black";
	
	document.getElementById('main_zakladki_' + co).style.display = "block";
	document.getElementById('main_linki_' + co).style.fontWeight = "bold";
	document.getElementById('main_linki_' + co).style.color = "red";
}

function fj_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=fj_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function fj_showHideLayers() {
  var i,p,v,obj,args=fj_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=fj_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

