
/**
 * zaznaczanie checkboxów
 *
 */
function toggle() {

    var pLen = pForm.elements.length;
    var pBoxes = true;
	var pImg = document.getElementById( 'togglebox' );

    for ( i = 0; i < pLen; i++ ) {
        if ( !pForm.elements[i].checked )
            pBoxes = false;
    }
    if ( pBoxes ) {
		pBoxes = false;
		pImg.className = 'sfJSTogleOff';
	}else {
		pBoxes = true;
		pImg.className = 'sfJSTogleOn';
	}
    for ( i = 0; i < pLen; i++ ) {
        pForm.elements[i].checked = pBoxes;
    }
}

/**
 * sortowanie
 *
 */
function sort( pMode ) {
	pForm.method = 'post';
	pForm.action = pMode + '.php';
	pForm.submit();
}

/**
 * sortowanie na trybach order i share
 *
 */
function sort_objects( pVal ) {
	pFormSorting.sort.value = pVal;
	pFormSorting.submit();
}



/**
 * wyswietla alert i zapisuje zmiany przy paginacji 
 * (hurtowa zmiana nazw i opisow)
 *  )
 *
 */
function ask() {
  var pSubmit = true;
  if ( !confirm("Czy na pewno chcesz zapisać zmiany?") ) 
    pSubmit = false;  
  if ( pSubmit ) {
			pForm.submit();
	}  
}

/**
 * sprawdza 
 * (hurtowa zmiana nazw i opisow)
 *  )
 *
 */
function check( pAction ) {	
	if ( pAction == 'save' ) {
		if ( document.getElementById( 'pass' ).value != document.getElementById( 'repeat' ).value) {
			alert( 'Powtórka hasła musi być identyczna z hasłem!' );
			return false;
		}
    else {
			return true;
		}
	}
  else if ( pAction == 'delete' ) {
		if ( pForm.delete_album_confirm.checked ) {
			return true;
		}
    else {
			alert( 'W celu usunięcia albumu zaznacz checkbox z potwierdzeniem' );
			return false;
		}
	}
}

/**
 * uruchamianie wiekszości akcji na zdjęciach w tybrach view, order i share
 * pAction: czesc action do formularza
 * pIsChecked: czy ma sprawdzac zaznaczenie checkboxów
 * pType: czesc action do formularza
 * pMode: tryb submitu formualrza
 *
 */

function execute( pAction , pIsChecked , pType , pMode ) {

	var pSubmit = true;

	if ( pType == 'albums' ) {
		pTxtRemove = 'wybrane albumy';
		pTxtCheck = 'jeden album';
	}else if ( pType == 'photos' ) {
		pTxtRemove = 'wybrane zdjęcia';
		pTxtCheck = 'jedno zdjęcie';
	}else if ( pType == 'projects' ) {
		pTxtRemove = 'wybrane projekty';
		pTxtCheck = 'jeden projekt';
	}else if ( pType == 'comments' ) {
		pTxtRemove = 'wybrane komentarze';
		pTxtCheck = 'jeden komentarz';
		}
	if ( pMode != 'share' && pMode != 'projects' ) {
		pForm.mode.value = pAction + '_' + pType;
	}
	if ( pMode == 'gallery' ) {
		pForm.mode.value = pAction;
	}
 	if ( pIsChecked ) {
		pSubmit = checkAnyCheckboxChecked(pTxtRemove, pTxtCheck, pAction);
	}

	if ( pMode == 'view' || pMode == 'projects' || pMode == 'gallery' || pMode == 'remove_comments' ) {
		if ( pSubmit ) {
			pForm.submit();
		}
	}else if ( pMode == 'order' || pMode == 'share' ) {
		return pSubmit;
	}
}

function checkAnyCheckboxChecked( pTxtRemove, pTxtCheck, pAction ) {
	var pAnyChecked = false;
	var pLen = pForm.elements.length;
	for ( i = 0; i < pLen; i++ ) {
		if ( pForm.elements[i].checked ) pAnyChecked = true;
	}
	if ( pAnyChecked ) {
		if ( pAction == 'remove' || pAction == 'remove_photos' || pAction == 'remove_albums' ) {
			if ( !confirm( 'Czy jesteś pewny/a że chcesz usunąć ' + pTxtRemove + '?' ) ) return false;
		}
	}else {
		alert( 'Musisz zaznaczyć przynajmniej ' + pTxtCheck );
		return false;
	}
	return true;
}

function submitForm(form_object, action_url, confirmation_text) {
  if ( confirmation_text )
  	if ( !confirm( confirmation_text ) ) return false;
  form_object.action = action_url;
  form_object.submit();
}


function checkAndSubmitForm(form_object, action_url, check_failed_text, confirmation_text) {
	var pAnyChecked = false;
	var pLen = form_object.elements.length;
	for ( i = 0; i < pLen; i++ )
		if ( form_object.elements[i].checked ) pAnyChecked = true;

	if ( pAnyChecked ) {
	  return submitForm(form_object, action_url, confirmation_text);
	}else {
		alert( check_failed_text );
		return false;
	}
}


/**
 * sprawdznaie poprawnosci wypelnienia formualrzy przy kolejnych krokach tworzenia projektu
 * pStep: krok
 * pType: typ kalendarza/ramki
 *
 */
function project_step( pStep , pRadioName , pGadget ) {
	pName = 'projekt_typ';
	if ( typeof(pRadioName) != 'undefined' && pName != pRadioName ) pName = pRadioName;
	if ( pRadioName == 'layout' ) pTxt = 'układ zdjęć';
	else pTxt = 'wzór ramki';

	switch ( pStep ) {

		case 'type':
			if ( pForm.nazwa.value == '' ) {
				alert( 'Podaj nazwę' );
				return false;
			}
			var pType = false;

			for ( i = 0; i < pForm.length ; i++) {
				if ( pForm.elements[ i ].name == pName && pForm.elements[ i ].checked ) {
					pType = pForm.elements[ i ].value;
				}
			}

			if ( pGadget == 'mug' && pType == 'white_c' ) {
			    pForm.kolor.value = pForm.kolory_arr.value;
			}

			if ( !pType ) {
				alert( 'Wybierz typ' );
				return false;
			}else {
				return true;
			}
			break;

		case 'month':
			if ( pForm.year.value == -1 || pForm.month.value == -1 ) {
				alert( 'Musisz wybrac rok oraz miesiąc startowy dla kalendarza trzynasto-stronicowego' );
				return false;
			}else {
				return true;
			}
			break;

		case 'border':
			var pChecked = false;

			for ( i = 0; i < pForm.length ; i++) {
				if ( pForm.elements[ i ].checked ) {
					pChecked = true;
				}
			}
			if ( !pChecked ) alert( 'Musisz wybrać ' + pTxt );

			return pChecked;
			break;

		case 'logo':
			if ( pForm.userfile.value == '' ) {
				alert( 'Musisz wybrać logotyp, aby móc przejść dalej' );
				return false;
			}else {
				return true;
			}
			break;
	}
}

/**
 * ustawienie kubka z kolorowym środkiem po wybraniu selekta z kolorem
 *
 */
function setInsideColor() {
    for ( i = 0; i < pForm.length ; i++) {
		if ( pForm.elements[ i ].value == 'white_c' ) {
			pForm.elements[ i ].click();
		}
	}
}

/**
 * wyśweitlanie nowego okna do podgladu kalendarza w trakcie wyboru ramki
 *
 */
function preview( pSrc ) {
	window.open( pSrc , 'preview' ,'height=470,width=460,location=no,menubars=no,scrollbars=no,toolbars=no,resizable=no' );
}

/**
 * wyświetlanie i chowanie fragmentów strony bez przeładowania
 *
 */
function tab( pId , pClear ) {
	for ( i = 0; i < pTabs.length; i++ ) {
		if ( pTabs[ i ] != pId && pTabs[ i ] != '' && pClear ) {
			document.getElementById( pTabs[ i ] ).style.display = 'none';
		}
		else if ( pTabs[ i ] == pId ) {
			document.getElementById( pTabs[ i ] ).style.display = 'block';
		}
	}
} 
function show_tab( tab1, tab2, tab3 , view ) {
  if ( view ) {
    document.getElementById( tab1 ).style.display='block';
    document.getElementById( tab2 ).style.display='none';
    document.getElementById( tab3 ).style.display='block';
  }
  else {
    document.getElementById( tab1 ).style.display='none';
    document.getElementById( tab2 ).style.display='block';
    document.getElementById( tab3 ).style.display='none';
  }
}
    
/**
 * paginacja w koszyku
 *
 */
function usePage( num ) {
	var use = document.getElementById( 'use_page' );
	use.value = num;
	document.forms[ 0 ].submit();
}

/**
 * tworzenie gadgetu na sposob new_gadgets[mad]
 *
 */
function createGadget( pFormat , pPages_count , pCover ) {
    var pColor;

	document.getElementById( 'format' ).value = pFormat;
	document.getElementById( 'pages_count' ).value = pPages_count;
	if ( pCover == 'carton' ) {
		for ( i = 0; i < pForm.gadget_color.length; i++ ) {
		    if ( pForm.gadget_color[ i ].checked ) pColor = pForm.gadget_color[ i ].value;
		}
	    pCover += pColor;
	}else if ( pCover == 'plexi' ) {
	    pColor = document.getElementById( 'plexi_color' ).value;
	}
	document.getElementById( 'cover' ).value = pCover;
	return true
}

/**
 * zaznaczenie radiobuttona po kliknieciu na link
 * np. zaznaczenie tematu fotospinki po kliknieciu na thumbnail
 *
 */
function checkItem( pItem ) {
	document.getElementById( pItem ).click();
}

/**
 * zmiana opcji selekta, podowujaca zmiany na innych selectach
 *
 */
function ProjSelect( newSel ) {
	if ( oldSel = document.getElementById( newSel.value ) ) {
		oldSel = document.getElementById( newSel.value );
		oldSel.options[ oldSel.selectedIndex ].selected = false;
		oldSel.value = newSel.id;
		oldSel.id = newSel.id;
	}
	newSel.id = newSel.value;
}

/**
 *  zmiana akcji formularza i submit
 */
function nextEditStep(sAction){
	document.getElementById('sfEditGadget').action = sAction;
	document.getElementById('sfEditGadget').submit();
}

/**
 *  dodanie stringa do akcji formularza i submit
 */
function addFormActionAndSubmit(sAction) {
	document.getElementById('sfEditGadget').action += sAction;
	document.getElementById('sfEditGadget').submit();
}

/**
 * zmiana strony gadgetu
 *
 */
function changePage( pPage , pGadget , pAction ) {
	if ( pGadget == 'photo_book' ) {
        window.location.href = pAction + '&pg_page=' + pPage;
	}else {
		document.getElementById( 'change_page' ).value = pPage;
		pForm.submit();
	}
}

/**
 *  zmiana strony gadgetu po nowemu
 */

function jumpToPage (iPage, sGadget, sAction) {
    window.location.href = sAction + '&pg_page=' + iPage;
}

/**
 * zmiana layoutu strony
 *
 */
function changeLayout( pLayout , pId , pPreview_path , pHash) {
	var pInput = document.getElementById( pId );
	var pTxt = 'Uwaga!\nPrzy zmianie orientacji wszysktie ustawienia dot. strony będą skasowane i trzeba będzie dodać zdjęcie do strony raz jeszcze.\n\nCzy jesteś pewny/a że chcesz zmienić orientację?';
	var pConfirm = false;

	if ( pLayout != pInput.value ) {
	    if ( pPreview_path != '' && confirm( pTxt ) ) {
			pConfirm = true;
		}
		if ( pPreview_path == '' ) {
		    pConfirm = true;
		}
	    if ( pConfirm ) {
			pInput.value = pLayout;
			pForm.action += '#' + pHash;
	   		pForm.submit();
		}
	}
}

/**
 * sprawdzenie nazwy gadgetu
 *
 */
function checkName() {
	var pTxt = 'Musisz podac nazwę projektu';

	if ( document.getElementById( 'gadget_name' ).value == '' ) {
		alert( pTxt );
		return false;
	}else {
		return true;
	}
}
/**
 * sgeneruje losową nazwę gadgetu
 *
 */
function get_random_name( gadgetName ) {
    if ( document.getElementById('gadget_name').value == '' ) {
      document.getElementById('gadget_name').value=gadgetName;
    }
}
/**
 * toplayer z komunikatem
 *
 */
function showInfoLayer() {
	var pId = 'file_';
	var pSubmit = false;
	for ( i = 1; i < 11; i++ ) {
	    pId += i;
	    if ( document.getElementById( pId ).value != '' ) {
	        pSubmit = true;
		}
		pId = 'file_';
	}
	if ( !pSubmit ) {
	    alert( 'Musisz kliknąć "przeglądaj" i otworzyć choć jeden plik by móc go załadować do serwisu' );
	    return false;
	}else {
		document.getElementById( 'info_layer' ).style.display = 'block';
		return true;
	}
}

/**
 * sprawdzanie enterów w polu tekstowym w fotospince
 *
 */
function checkText( pTxt ) {
	var pEnters = 0;
	for ( i = 0; i < pTxt.length; i++ ) {
       	if ( pTxt.charCodeAt( i ) == 10 ) pEnters += 1;
	}
	if ( pEnters > 1 ) {
		alert('UWAGA!\n\nWprowadzony tekst może mieć maksymalnie dwie linijki.\nJeżeli nie usuniesz nadmiarowych wyświeltany napis nie będzie widoczny.');
	}
}

/**
 * wyswietlenie dodatkowej warstwy
 *
 */
function openLayer( pLayer , pId , pPage , pNeighborId , pMaxRows) {
	if ( !pAlredyOpenedLayer ) {
		changeObjectsVisibility( 'select' , 'none' );
		document.getElementById( pLayer ).style.display = 'block';
		pAlredyOpenedLayer = true;
		pCurrentPage = pPage;
		pCurrentPageId = pId;
		pNeighborPageId = pNeighborId;
		pMaxRowsInTextarea = pMaxRows;
		if ( pLayer == 'subtitles' ) {
		    readSubtitle( pId , pPage );
		    document.getElementById('subtitles_textarea').focus();
		}
	}else {
		alert( 'Musisz najpierw zamknąć już otwartą warstwę' );
	}
}

/**
 * zamkniecie dodatkowej warstwy
 *
 */
function closeLayer( pLayer ) {
	document.getElementById( pLayer ).style.display = 'none';
	changeObjectsVisibility( 'select' , '' );
	pAlredyOpenedLayer = false;
}

/**
 * blokowanie wyswietlania niektorych obiektow HTML przydatne przy wysweitlaniu wyzszych warstw
 *
 */
function changeObjectsVisibility( pObject , pDisplay ) {
    pSelects = document.getElementsByTagName( pObject );
	for ( i = 0; i < pSelects.length ; i++ ) {
	    pSelects[ i ].style.display = pDisplay;
	}
}

/**
 * odczytanie biezacych napisow
 *
 */
function readSubtitle( pId , pPage ) {
	pInputId = 'page_' + pPage + '_subtitle_' + pId;
	pCurrentSubtitleInput = document.getElementById( pInputId );
	pTextarea = document.getElementById( 'subtitles_textarea' );
	pTextarea.value = pCurrentSubtitleInput.value;
}

/**
 * zapisanie biezacych napisow
 *
 */
function saveSubtitle() {
    pTextarea = document.getElementById( 'subtitles_textarea' );

	var sRows = pTextarea.value;
	var bIE = (document.all);
	if(bIE)
		aRows = sRows.split("\r\n");
	else
		aRows = sRows.split("\n");
	if (aRows.length > pMaxRowsInTextarea)
	{
	    window.alert('To pole tekstowe może mieć tylko ' + pMaxRowsInTextarea + ' linie');
	    return false;
	}

  pCurrentSubtitleInput.value = pTextarea.value;
	pForm.action += '&pg_page=' + pNeighborPageId;
	return true;
}

/**
 * zapisanie nowego layoutu
 *
 */
function saveLayout( pSide ) {
	pPage = pCurrentPage;
	pLayout = '';

	if ( pSide == 'left' ) pRadio = pForm.current_layout_left;
	else if ( pSide == 'right' ) pRadio = pForm.current_layout_right;

	for ( i = 0; i < pRadio.length; i++ ) {
	    if ( pRadio[ i ].checked ) pLayout = pRadio[ i ].value;
	}

	if ( pLayout != '' ) {
	    pInputId = 'page_' + pPage + '_layout';
	    document.getElementById( pInputId ).value = pLayout;
	    pForm.action += '&pg_page=' + pNeighborPageId;
	    return true;
	}else {
	    alert( 'Musisz wybrać układ strony, albo zamknąć okno bez zapisywania zmian' );
	    return false;
	}
}

/**
 * umozliwienie zamowienia gadgetu
 *
 */
function allowGadgetOrder() {
	document.getElementById( 'mode' ).disabled = false;
	document.getElementById( 'id' ).disabled = false;
	return true;
}

/*
 *	blokuje wybor miesiecy dla ostatniego roku
 */

function calendarCheckYear(oSelf) {
	var iYear = 0;
	var oYear = document.getElementById('selectYear');
	var oMonth  = document.getElementById('selectMonth');

	if (oMonth && oYear && (oYear.length-1) == oYear.selectedIndex && oMonth.selectedIndex) {
		iYear = oYear.options[oYear.selectedIndex].value;
		oMonth.selectedIndex = 0;
		alert('Dla roku '+iYear+' możliwy jest tylko wybór miesiąca Stycznia');
	}
}

/**
 * zapisuje formularz przy dodawaniu zdjecia w spince
 *
 */
function chooseFoto(sURL)
{
	setCookie('sfCrop', 'no');
    document.getElementById( 'goto' ).value = sURL;
    document.gadget_form.submit();
}
/**
 * wyswietlenie podgladu strony w toplayerze
 *
 */
function zoomPage (url)
{
	if ( !pAlredyOpenedLayer ) {
	    pAlredyOpenedLayer = true;
	    changeObjectsVisibility( 'select' , 'none' );
	    document.getElementById( 'zoomPage' ).innerHTML = '<img src="' + url + '">';
    	document.getElementById( 'zoom' ).style.display = 'block';
    }
    else
    {
        window.alert( 'Musisz najpierw zamknąć już otwartą warstwę' );
	}
}

/**
 *  pokazuje lub ukrywa elementy na podstawie taga i jego klasy
 */

function displayTagByClass (sTag, sClass, sDisplay)
{
	aTag = document.getElementsByTagName(sTag);
	for (i=0; i<aTag.length; i++)
	    if (aTag[i].className == sClass)
	        aTag[i].style.display = sDisplay;
}
/**
 *  okazuje i ukrywa dane dla firmy i osoby prywatnej
 */
function partnerType(oSelect)
{
	var aType = new Array('person', 'firm');
	for (i=0; i<aType.length; i++)
	{
	    if (i == oSelect.selectedIndex)
	        document.getElementById(aType[i]).style.display = '';
		else
			document.getElementById(aType[i]).style.display = 'none';
	}
}
/**
 *  sprawdza czy został wybrany rozmiar bannera
 */
function partnerCheckBannerSend (oForm)
{
	if (oForm.format.options[oForm.format.selectedIndex].value == 'none')
	{
		window.alert('musisz wybrać rozmiar bannera (1)');
		return false;
	}
}
/**
 *  dla randoma zmienia opis pod przyciskiem
 */
function partnerCheckRandom (oCheckbox)
{
	var aText = new Array('wyświetl banner','wygeneruj kod bannera losowego')
	document.getElementById('partner_next').innerHTML = (oCheckbox.checked)?aText[1]:aText[0];
}
/**
 *  ukrywa wszystkie divy klasy bannerView i pokazuje biezacy
 */
function partnerShowLayer(sDiv)
{
	displayTagByClass('div', 'bannerView' , 'none');
	document.getElementById(sDiv).style.display = 'block';
}
/**
 *  zamyka konkretny toplayer
 */
function closeTopLayer (sDiv)
{
	document.getElementById(sDiv).style.display = 'none';
}
/**
 *  sluzy do zaznaczania (i kopiowania w IE) zawartosci pola formularza
 */
function selectAndCopy (sField)
{
	oField = document.getElementById(sField);
	oField.focus();
	oField.select();

	if (document.all)
	{
		oRange = oField.createTextRange();
		oRange.execCommand("Copy");
	}
}

/**
 * Zmiana kolejnosci zdjec w galeriach prywatnych
 */
function changeUserOrder( iId , iOrderValue ) {
	document.getElementById('sf_user_id').value = iId;
	document.getElementById('sf_user_order').value = iOrderValue;
	document.getElementById('gallery').submit();
}

/**
 * funkcja stanowi rozszerzenie metody DOM
 */
function getElementsByTagNames(list,obj) {
        if (!obj) var obj = document;
        var tagNames = list.split(',');
        var resultArray = new Array();
        for (var i=0;i<tagNames.length;i++) {
                var tags = obj.getElementsByTagName(tagNames[i]);
                for (var j=0;j<tags.length;j++) {
                        resultArray.push(tags[j]);
                }
        }
        var testNode = resultArray[0];
        if (testNode.sourceIndex) {
                resultArray.sort(function (a,b) {
                                return a.sourceIndex - b.sourceIndex;
                });
        }
        else if (testNode.compareDocumentPosition) {
                resultArray.sort(function (a,b) {
                                return 3 - (a.compareDocumentPosition(b) & 6);
                });
        }
        return resultArray;
}

/**
 * generuje spis treści na podstawie znacznikow H1 i H2, naglowki musza miec ustawione ID jeśli warstwy sa ukrywane hidden=false
 */
function createIndex(from,create_to,hidden,column){
	var oRoot = document.getElementById(from);
	var aTemp = getElementsByTagNames('h1,h2',oRoot);
	var sIndex = '<table class="site_index col'+column+'"><tr><td class="vt">';
	var iRows = 0;
	var aH = new Array();
	var sDiv = '';
	for (i=0; i<aTemp.length; i++){
	    if(aTemp[i].id){
	        aH.push(aTemp[i]);
	    }
	}
	for (i=0; i<aH.length; i++){
		if(aH[i].id){
		    iRows++;
		    if (aH[i].nodeName == 'H1'){
		        if (iRows >= Math.floor(aH.length/column)){
		            sIndex += '</td><td class="vt">';
		            iRows = 0;
				}
				sDiv = aH[i].id;
		        sIndex += '<a href="javascript:goToIndex(\''+sDiv+'\',\''+aH[i].id+'\',\''+hidden+'\')" class="orange arrow block"><b>'+delHTMLtag(aH[i].innerHTML)+'</b></a>';
			}
			else {
			    sIndex += '<a href="javascript:goToIndex(\''+sDiv+'\',\''+aH[i].id+'\',\''+hidden+'\')" class="block">'+aH[i].innerHTML+'</a>';
			    if (!hidden && iRows >= Math.ceil(aH.length/column)){
		            sIndex += '</td><td class="vt">';
		            iRows = 0;
				}
			}
		}
	}
	sIndex += '</td></tr></table>';
	document.getElementById(create_to).innerHTML = sIndex;

	var sURL = document.URL;
	var iHash = sURL.indexOf('#')+1;
	if (iHash>0){
		var sId = sURL.substr(iHash);
		var sDiv = sId.replace(/[0-9]/gi,'');
		goToIndex(sDiv, sId, hidden);
	}
}
/**
 * realizuje skoki w spisie treści
 */
function goToIndex(sDiv,sId,hidden)
{
	if (hidden){
		displayTagByClass ('div', 'help_module', 'none');
		if (document.getElementById(sDiv+'_div'))
			document.getElementById(sDiv+'_div').style.display = 'block';
	}
	window.location = '#'+sId;
}

function polishFormat(base, number) {
	var poz = 0;
	var numberMore = number % 10;
	if (number < 15)
	{
	    switch (number)
		{
			case 1:
			    poz = 2;
			    break;
			case 2: case 3: case 4:
			    poz = 1;
		}
	}
	else
	{
	    switch (numberMore)
		{
			case 2: case 3: case 4:
			    poz = 1;
		}
	}
	document.write(base[poz]);
}

var aTips = new Array();

function toolTipInit() {
	var aToolTip = $$('.tip');
	for ( i = 0; i < aToolTip.length; i++) {
		aTips.push(new Tooltip(aToolTip[i], aToolTip[i].getAttribute('title')));
		aToolTip[i].removeAttribute('title');
	}
}

function registerFormCheck () {
	var error = '';
	var oZgoda = document.getElementById('zgoda');
	var oHaslo = document.getElementById('haslo_r');
	var oHaslo2 = document.getElementById('haslo_r2');
	var oForm = document.getElementById('fSignIn');
	if (oHaslo.value != oHaslo2.value)
		error += '- hasło i powtórka hasła muszą być takie same\n';
	if (oHaslo.value.length < 3)
		error += '- hasło musi mieć długość conajmniej 3 znaków\n';
	if (!oZgoda.checked)
		error += '- wymagane jest zapoznanie się z warunkami i regulaminem Superfoto.pl\n';

	if (error)
		alert ('Popraw wprowadzone dane:\n'+error);
	else
		oForm.submit();
}

/**
 * detekcja przegladarki
 *
 */

// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//     is_sun, is_sun4, is_sun5, is_suni86
//     is_irix, is_irix5, is_irix6
//     is_hpux, is_hpux9, is_hpux10
//     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//     is_linux, is_sco, is_unixware, is_mpras, is_reliant
//     is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater")
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1);

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);
    var is_aix2  = (agt.indexOf("aix 2") !=-1);
    var is_aix3  = (agt.indexOf("aix 3") !=-1);
    var is_aix4  = (agt.indexOf("aix 4") !=-1);
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var is_mpras    = (agt.indexOf("ncr")!=-1);
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
                 is_sco ||is_unixware || is_mpras || is_reliant ||
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
