function flash(filename,w,h,kolor) { 

		var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '" bgcolor="' + kolor + '">'
		+ '<param name="allowScriptAccess" value="sameDomain" />'
		+ '<param name="movie" value="' + filename + '" /><param name="quality" value="high" /><param name="scale" value="noscale" />'
		+ '<embed src="' + filename + '" quality="high" scale="noscale" width="' + w + '" height="' + h + '" name="xxx" align="middle" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" allowScriptAccess="sameDomain"  bgcolor="' + kolor + '" /><param name=bgcolor value="' + kolor + '" />'
		+ '</object>';

		majorVersion=8;
		minorVersion=8;
//		installinfo='<div style="margin-top: 170px; text-align: center;"><style>body { background: #ffffff; }</style><a href="https://www.macromedia.com/go/getflashplayer" target="_blank" style="font-family: Tahoma; color: #000000; text-decoration: none; font-size: 11px;">Strona wymaga zainstalowanego pluginu<br /><b>Flash Player</b> w wersji 8 lub wyższej.<br/><br/><img src="images/get_flash.jpg" alt="pobierz Flash Playera" border="0" /><br/><br/>Pobierz wtyczkę <strong>Flash Player</strong></a><br /><br /><br />'; 
		installinfo='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '" bgcolor="' + kolor + '"><embed src="' + filename + '" quality="high" scale="noscale" width="' + w + '" height="' + h + '" name="xxx" align="middle" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" allowScriptAccess="sameDomain"  bgcolor="' + kolor + '" /><param name=bgcolor value="' + kolor + '" />'; 
		if(navigator.product=='Gecko' || navigator.userAgent.indexOf('Opera')!=-1) {
		 if(plugin=navigator.plugins["Shockwave Flash"]) {
		  if(majorVersion > parseInt(plugin.description.substr(plugin.description.indexOf(".")-1, 1))
		  || minorVersion > parseInt(plugin.description.substr(plugin.description.length-2)) )
			document.write(installinfo);
		  else document.write(oeTags);
		 } else {
			document.write(installinfo); 
		 }
		}
		else document.write(oeTags);
		//-->
}

         function move_in(img_name,img_nazwa) {
         document[img_name].src=img_nazwa;
         }
         function move_out(img_name,img_nazwa) {
         document[img_name].src=img_nazwa;
         }

         function big(lyr) {
         document.all[lyr].style.height='80px';
         }
         function small(lyr) {
         document.all[lyr].style.height='27px';
         }
         function start() {
         document.all.Layer1.style.height='27px';
         }

         function showmenu(elmnt)
         {
         document.all(elmnt).style.visibility="visible"
         }
         function hidemenu(elmnt)
         {
         document.all(elmnt).style.visibility="hidden"
         }
         
         var IFrameObj;
         function changeSelect(selectName, selectedIndex)
         {
                if (!document.createElement) {return true};
                var IFrameDoc;
                var URL = "selectIFrame.php?name=" +selectName+ "&id=" +selectedIndex

                if (!IFrameObj && document.createElement) {
		// create the IFrame and assign a reference to the
		// object to our global variable IFrameObj.
		// this will only happen the first time
		// callToServer() is called
		try {
			var tempIFrame=document.createElement('iframe');
			tempIFrame.setAttribute('id','RSIFrame');
			tempIFrame.style.border='0px';
			tempIFrame.style.width='0px';
			tempIFrame.style.height='0px';
			IFrameObj = document.body.appendChild(tempIFrame);
			
			if (document.frames) {
				// this is for IE5 Mac, because it will only
				// allow access to the document object
				// of the IFrame if we access it through
				// the document.frames array
				IFrameObj = document.frames['RSIFrame'];
			}
		} catch(exception) {
			// This is for IE5 PC, which does not allow dynamic creation
			// and manipulation of an iframe object. Instead, we'll fake
			// it up by creating our own objects.
			iframeHTML='<iframe id="RSIFrame" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;';
			iframeHTML+='"><\/iframe>';
			document.body.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
			IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;
			}
		}
	}
	
	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('changeSelect("'+selectName+', '+selectedIndex+'")',10);
		return false;
	}	
	if (IFrameObj.contentDocument) {
		// For NS6
		IFrameDoc = IFrameObj.contentDocument;
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		IFrameDoc = IFrameObj.document;
	} else {
		return true;
	}	
	IFrameDoc.location.replace(URL);
	return false;
        }

        function receiveIFrame(selectName, ids, names)
        {
        //wstaw elementy z array do selecta
                if(document.forms['theForm'].elements[selectName])
                {
                   document.forms['theForm'].elements[selectName].length=ids.length
                   for(i=1; i<ids.length; i++)
                   {
                         document.forms['theForm'].elements[selectName].options[i] = new Option(names[i],ids[i])
                   }
                }
        }


function dodaj_reklame(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.Nazwa.value == "")
  {
    alert("Podaj nazwę ośrodka noclegowego");
    theForm.Nazwa.focus();
    return (false);
  }

 if (theForm.Opis.value == "")
  {
    alert("Podaj opis ośrodka");
    theForm.Opis.focus();
    return (false);
  }

 if (theForm.Miasto.value == "")
  {
    alert("Podaj miejscowość");
    theForm.Miasto.focus();
    return (false);
  }

 if (theForm.Link.value == "")
  {
    alert("Podaj adres strony interetowej");
    theForm.Link.focus();
    return (false);
  }

 if (theForm.Wybierz_Kategorie.selectedIndex == 0)
  {
    alert("Wybierz kategorię");
    theForm.Wybierz_Kategorie.focus();
    return (false);
  }

 if (theForm.e_mail.value == "")
      {
       alert("Podaj adres email");
       theForm.e_mail.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.e_mail.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)


  return (true);
}

function dodaj_reklame2(theForm)
{

 if (theForm.akceptacja.checked==false)
  {
  alert("Musisz zaakceptować warunku regulaminu");
  return (false);
  }

  return (true);
}


function dodaj_link(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.Nazwa.value == "")
  {
    alert("Podaj  nazwę jaka ma się pojawić na pasku przewijania");
    theForm.Nazwa.focus();
    return (false);
  }

 if (theForm.Link.value == "")
  {
    alert("Podaj adres strony interetowej");
    theForm.Link.focus();
    return (false);
  }

 if (theForm.Wybierz_Kategorie.selectedIndex == 0)
  {
    alert("Wybierz kategorię");
    theForm.Wybierz_Kategorie.focus();
    return (false);
  }

 if (theForm.akceptacja.checked==false)
  {
  alert("Musisz zaakceptować warunku regulaminu");
  return (false);
  }

 if (theForm.e_mail.value == "")
      {
       alert("Podaj adres email");
       theForm.e_mail.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.e_mail.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)


  return (true);
}



function usun_wpis(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.nazwa.value == "")
  {
    alert("Podaj Imię, Nazwisko lub Nick");
    theForm.nazwa.focus();
    return (false);
  }

 if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

  return (true);
}


function usun_wpis(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.nazwa.value == "")
  {
    alert("Podaj Imię, Nazwisko lub Nick");
    theForm.nazwa.focus();
    return (false);
  }

 if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

  return (true);
}

function dodaj_platne1(theForm)
{

  if (theForm.autor.value == "")
  {
    alert("Podaj Miejscowość");
    theForm.autor.focus();
    return (false);
  }

  if (theForm.tytul.value == "")
  {
    alert("Podaj nazwę ośrodka");
    theForm.tytul.focus();
    return (false);
  }

  if (theForm.recenzent.value == "")
  {
    alert("Podaj telefon");
    theForm.recenzent.focus();
    return (false);
  }
 
  if (theForm.adres.value == "")
  {
    alert("Podaj Adres");
    theForm.adres.focus();
    return (false);
  }

  if (theForm.kategoria0.selectedIndex == 0)
  {
    alert("Wybierz kategorię.");
    theForm.kategoria0.focus();
    return (false);
  }

  if (theForm.akceptacja.checked==false)
  {
  alert("Musisz zaakceptować warunku regulaminu");
  return (false);
  }

  return (true);
}

function dodaj_platne1a(theForm)
{

  if (theForm.autor.value == "")
  {
    alert("Podaj Miejscowość");
    theForm.autor.focus();
    return (false);
  }

  if (theForm.tytul.value == "")
  {
    alert("Podaj nazwę ośrodka");
    theForm.tytul.focus();
    return (false);
  }

  if (theForm.recenzent.value == "")
  {
    alert("Podaj telefon");
    theForm.recenzent.focus();
    return (false);
  }
 
  if (theForm.adres.value == "")
  {
    alert("Podaj Adres");
    theForm.adres.focus();
    return (false);
  }

  if (theForm.kategoria0.selectedIndex == 0)
  {
    alert("Wybierz kategorię.");
    theForm.kategoria0.focus();
    return (false);
  }

   return (true);
}

function dodaj_platne2(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.autor.value == "")
  {
    alert("Podaj Miejscowość");
    theForm.autor.focus();
    return (false);
  }

  if (theForm.tytul.value == "")
  {
    alert("Podaj nazwę ośrodka");
    theForm.tytul.focus();
    return (false);
  }

/*
  if (theForm.streszczenie.value == "")
  {
    alert("Wpisz adres strony WWW");
    theForm.streszczenie.focus();
    return (false);
  }
*/

  if (theForm.recenzent.value == "")
  {
    alert("Podaj telefon");
    theForm.recenzent.focus();
    return (false);
  }
 
  if (theForm.adres.value == "")
  {
    alert("Podaj Adres");
    theForm.adres.focus();
    return (false);
  }


  if (theForm.Number.value == "")
  {   {
     alert("Podaj ilość linkow");
     theForm.Number.focus();
     return (false);
     }
     if (!Wzor_cyfry.test(theForm.Number.value))
     {
     return (true)
     }
     alert("Tylko przy użyciu cyfr")
     return (false)
    }


  if (theForm.Number2.value == "")
  {
    alert("Podaj ilość zdjęć w galerii");
    theForm.Number2.focus();
    return (false);
  }

/*
 if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

*/

  return (true);
}

function dodaj_platne2a(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.autor.value == "")
  {
    alert("Podaj Miejscowość");
    theForm.autor.focus();
    return (false);
  }

  if (theForm.tytul.value == "")
  {
    alert("Podaj nazwę ośrodka");
    theForm.tytul.focus();
    return (false);
  }

  if (theForm.streszczenie.value == "")
  {
    alert("Wpisz adres strony WWW");
    theForm.streszczenie.focus();
    return (false);
  }

  if (theForm.recenzent.value == "")
  {
    alert("Podaj telefon");
    theForm.recenzent.focus();
    return (false);
  }
 
  if (theForm.adres.value == "")
  {
    alert("Podaj Adres");
    theForm.adres.focus();
    return (false);
  }

 if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

  return (true);
}

// aktualizacja
function dodaj_platne2aa(theForm)
{

  Wzor_cyfry=/^[0-9]+$/;

  if (theForm.autor.value == "")
  {
    alert("Podaj Miejscowość");
    theForm.autor.focus();
    return (false);
  }

  if (theForm.tytul.value == "")
  {
    alert("Podaj nazwę ośrodka");
    theForm.tytul.focus();
    return (false);
  }

  if (theForm.recenzent.value == "")
  {
    alert("Podaj telefon");
    theForm.recenzent.focus();
    return (false);
  }
/* 
 if (theForm.emaill.value == "")
      {
       alert("Podaj adres emaill");
       theForm.emaill.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.emaill.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)
*/
  return (true);
}

function ChrCount(tarea, max) {
	maxChrs = max
	chrs = maxChrs - tarea.value.length
	if (chrs < 0) {
		tarea.value = tarea.value.substring(0, maxChrs)
		alert('Długość tego pola jest zbyt duża!\n(max. długość to '+max+' znaków)')
		tarea.focus();
	}
}

function showMsg() {
		document.getElementById("popupMsg").style.visibility='visible'
	}

function sprawdzPole(pole,komunikat){
  pole=document.getElementById(pole).value;
  if(!pole || pole=='' || pole==undefined)
    return komunikat;
  else
    return '';
}

function sprawdz(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('tresc',"- Wpisz komentarz\n");
komunikat+=sprawdzPole('nazwa',"- Podaj Imię/Nazwisko lub Nick\n");
  if (email=='')
komunikat+="- Podaj Adres e-mail\n";

 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function dodaj(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('tytul1',"- Wpisz Tytuł\n");
komunikat+=sprawdzPole('pytanie',"- Wpisz pytanie\n");
komunikat+=sprawdzPole('nazwa',"- Podaj Imię/Nazwisko lub Nick\n");
  if (email=='')
komunikat+="- Podaj Adres e-mail\n";

 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}


function dodaj_wiad(theForm)
{

  if (theForm.tytul1.value == "")
  {
    alert("Podaj tytuł widomości");
    theForm.tytul1.focus();
    return (false);
  }

  if (theForm.tytul1.value.length > 100)
  {
    alert("W polu tytuł może być najwięcej 100 znaków");
    theForm.tytul1.focus();
    return (false);
  }

  if (theForm.pytanie.value == "")
  {
    alert("Podaj twoje pytanie");
    theForm.pytanie.focus();
    return (false);
  }

  if (theForm.pytanie.value.length > 1000)
  {
    alert("W Pytaniu może być najwięcej 1000 znaków");
    theForm.pytanie.focus();
    return (false);
  }

  if (theForm.nazwa.value == "")
  {
    alert("Podaj Imię/Nazwisko lub Nick");
    theForm.nazwa.focus();
    return (false);
  }

  if (theForm.nazwa.value.length > 50)
  {
    alert("W polu Imię/Nazwisko lub Nick może być najwięcej 50 znaków");
    theForm.nazwa.focus();
    return (false);
  }

  if (theForm.publish.checked)
  {

     if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

  return (true);
  }

  return (true);
}

function dodaj_kom(theForm)
{

 
  if (theForm.tresc.value == "")
  {
    alert("Wpisz twój komentarz");
    theForm.tresc.focus();
    return (false);
  }

  if (theForm.tresc.value.length > 1000)
  {
    alert("W Komentarzu może być najwięcej 1000 znaków");
    theForm.tresc.focus();
    return (false);
  }

  if (theForm.nazwa.value == "")
  {
    alert("Podaj Imię/Nazwisko lub Nick");
    theForm.nazwa.focus();
    return (false);
  }

  if (theForm.nazwa.value.length > 50)
  {
    alert("W polu Imię/Nazwisko lub Nick może być najwięcej 50 znaków");
    theForm.nazwa.focus();
    return (false);
  }

  if (theForm.publish.checked)
  {

     if (theForm.email.value == "")
      {
       alert("Podaj adres email");
       theForm.email.focus();
       return (false);
      }

      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.email.value)){
      return (true)
      }
      alert("Podany adres e-mail jest nieprawidłowy")
      return (false)

  return (true);
  }

  return (true);
}

function change_address_field(){
		var state=!document.getElementById("bbb").checked;
		if (!state) color="#FAF4E3";
		else color="#FBEAB8";

		x=document.getElementById("aaa");
		if (x) {x.disabled=state;x.style.backgroundColor=color;}
			x=document.getElementById("fm_ac_code");
		
}

function logowanie(){
var komunikat='';

komunikat+=sprawdzPole('username',"- Podaj użytkownika\n");
komunikat+=sprawdzPole('password',"- Podaj hasło\n");	

  if(komunikat!=''){
    alert("Logowanie:\n\n"+komunikat);
    return false;
  }
  else{
    return true;
  }
}

function win(url, width, height) {
	width1=width/2;
	height1=height/2;
	x=screen.availWidth/2-width1;
	y=screen.availHeight/2-height1;
    var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes, menubar=no, left='+x+', top='+y );
	Win.resizeTo(width, height);
	Win.focus();
};

function dodaj_platne2old(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('autor',"- Wpisz Miasto\n");
komunikat+=sprawdzPole('tytul',"- Wpisz nazwę ośrodka\n");
// if (email=='')
// komunikat+="- Podaj Adres e-mail\n";
komunikat+=sprawdzPole('recenzent',"- Wpisz telefon\n");
komunikat+=sprawdzPole('adres',"- Wpisz adres\n");
komunikat+=sprawdzPole('Number',"- Poodaj ilość linków (max. 5)\n");
komunikat+=sprawdzPole('Number2',"- Poodaj ilość zdjęć w galerii (max. 10)\n");


 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function dodaj_platne1old(){
var komunikat='';

komunikat+=sprawdzPole('autor',"- Wpisz Miasto\n");
komunikat+=sprawdzPole('tytul',"- Wpisz nazwę ośrodka\n");
komunikat+=sprawdzPole('adres',"- Wpisz adres\n");

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function show(plik) {
var w = 'toolbar=no,scrollbars=yes,resizable=no,menubar=no,width=400,height=250,left=20,top=20';
window.open(plik,'Pomoc',w);
}

function admin()
{
	var wspx = (screen.availWidth-800)/2;
	var wspy = (screen.availHeight-600)/2;
	var w = 'width=800,height=600,left='+wspx+',top='+wspy+',resizable=0,scrollbars=yes,menubar=no';
	window.open('/panel','Panel klienta on-line',w );
}

function showDiv(id) {
 if (document.getElementById)
    current=(document.getElementById(id).style.display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = current;
}

function ukrywanie(id) {
 if (document.getElementById)
 current=(document.getElementById(id).style.display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = current;
}
