    document.cookie = "res_width="+screen.width;
    document.cookie = "res_height="+screen.height;

  function winPopUp(name, url, width, height) {
    var x = Math.floor((screen.availWidth-width) / 2);
    var y = Math.floor((screen.availHeight-height) / 2);
    var config = ", left=" + x;
    config += ", top=" + y;
    config += ", scrollbars=yes,resizable=yes,status=yes";

    var popup=window.open(url,name,'width='+width+', height='+height+config);
  } /*winPopUp*/

  function winPopUpRet(name, url, width, height) {
    var x = Math.floor((screen.availWidth-width) / 2);
    var y = Math.floor((screen.availHeight-height) / 2);
    var config = ", left=" + x;
    config += ", top=" + y;
    config += ", scrollbars=yes,resizable=yes,status=yes";

    var popup=window.open(url,name,'width='+width+', height='+height+config);
    return popup;
  } /*winPopUp*/

  function winPopUp2(name, url, width, height) {
    winPopUp(name, url, width, height);
//    return false;
  }

  function parentRefresh (parent_anchor_id, element) {
    var text = "<table align=\"center\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\" class=\"blockItem\">\n"
      +"<tr>\n<td valign=\"top\">"+ element.value
      +"</td>\n</tr>\n</table><br />";

    opener.document.getElementById(parent_anchor_id).innerHTML = text;
  } /*parentRefresh*/

  function ResetParent (parent_anchor_id) {
    if (reset_parent_cond) {
      opener.document.getElementById(parent_anchor_id).innerHTML = start_value;
    } //if
  } /*ResetParent*/

  function parentSetFormInput(input, value)
  {
	  var formInput = opener.document.getElementById(input);
	  if (formInput != null)
	  {
		  formInput.value = value;
	  }
	  else
		  alert('[ERROR] Field not found: ' + input);
  }

  function parentOpenerSetFormInput(input, value)
  {
	  var formInput = parent.opener.document.getElementById(input);
	  if (formInput != null)
	  {
		  formInput.value = value;
	  }
	  else
		  alert('[ERROR] Field not found: ' + input);
  }
  function parentOpenerSetFormInputJQ(input, value, field)
  {

	  var formInput = parent.opener.document.getElementById(input);
	  var formInput2 = parent.opener.document.getElementById('finputGalleryImgInfo_'+field);
	  var formInput3 = parent.opener.document.getElementById('fileFinput_'+field);

	  formInput2.innerHTML = '';
	  formInput3.value = '';
	  
	  if (formInput != null)
	  {
		  formInput.value = value;
	  }
	  else
		  alert('[ERROR] Field not found: ' + input);
  }

  function getValue(input)
  {
	  var formInput = window.document.getElementById(input);
	  if (formInput == null)
		  alert('[ERROR] Field not found: ' + input);
	
	  return formInput.value;
  }


  function chooseDocument(input, id)
  {
	 parentSetFormInput(input, '?document=' + id);
	 window.close();
	 return false;
  }

  function chooseDocumentID(input, id)
  {
	 parentSetFormInput(input, id);
	 window.close();
	 return false;
  }

  function chooseDocumentAlias(input, name)
  {
	 parentSetFormInput(input, '?documentName=' + name);
	 window.close();
	 return false;
  }

  function chooseDocumentAliasName(input, name)
  {
	 parentSetFormInput(input, name);
	 window.close();
	 return false;
  }

  function chooseFile(input, path)
  {
	 parentOpenerSetFormInput(input, path);
	 parent.window.close();
	 return false;
  }

  function chooseFileJQ(input, path, field)
  {
	 parentOpenerSetFormInputJQ(input, path, field);
	 parent.window.close();
	 return false;
  }


    function showHideLayer (layer_id, show) {
        var styl = gls (layer_id);

        if (styl) {
            if (show) {
                styl.display = 'none';
            } //if
            else {
                styl.display = 'block';
            } //else
        } //if

        return false;

    } /*showHideLayer*/


  function gls (id) {
      var isIE = (document.all) ? true : false; 
      var isNS4 = (document.layers) ? true : false; 
      var isNS6 = (document.getElementById&&!document.all) ? true : false;

    if (id != "") {
      var styl;
      if (isIE) {
        styl = document.all[id].style;
      } //if
      else if (isNS6) {
        styl = document.getElementById(id).style;
      } //else if
      else if (isNS4) {
        return false;
      } //else if
      return styl;
    } //if
    else {
      return false;
    } //else
  } /*gls*/


    function correctTextXHTML (text) {
	    return String(text).replace(/\&/g, "&amp;").replace(/</g, "&lt;");
    } /*correctTextXHTML*/

    function validateXHTML (form) {

        var elems = form.elements;
        var i, text='', elem;
        for (i=0;i<elems.length; i++) {
            elem = elems[i];
            if (elem.type == 'text') {
                elem.value = correctTextXHTML (elem.value);
            } //if
            else if (elem.type == 'textarea') {
/*
                var nodes = elem.childNodes;
                var val = '';
                for (var i = 0; i < nodes.length; i++)
                    val += getXhtml(nodes[i]);
                elem.value = val;
*/
            } //else if
        } //for
    } /*validateXHTML*/

	function copyToClip (element_id) {
	    var testIE = (document.all) ? true : false; 
	    var testNS4 = (document.layers) ? true : false; 
	    var testNS6 = (document.getElementById&&!document.all) ? true : false;

		var text;
		var container;

		if (testIE) {
			container = document.getElementById(element_id);
			if (container != null) {
				text = container.innerText;
				clipboardData.setData('Text', text);
				alert ('Treść strony została skopiowana do schowka');
			}
		}
		else {
			alert ('Ta przeglądarka nie umożliwia tej operacji');
		}
	}
	
	function subitForm(formName) {
		document.forms[formName].submit();
	}
	
	function checkRedirect( tekst, url ) {
		if(confirm(tekst)) {
			document.location=url;
		}
	}
	
	function checkRedirect1( tekst, url ) {
		if(confirm(tekst)) {
			winPopUp('', url, 640, 550);
		}
	}
	
/* pomocnicze funkcje do zabawy elementami przy uzyciu prepare w finpucie do dodawania zdjec */
function pSwitchObj(idObjH, idObjS) {
	$(idObjH).css("display","none");
	$(idObjS).css("display","block");
}

function clearFields(field1, field2, field3){
	  var formInput = document.getElementById(field1);
	  var formInput2 = document.getElementById(field2);
	  var formInput3 = document.getElementById(field3);
	  formInput3.innerHTML = '';
	  formInput3.value = '';
	  formInput.value = '';
	  return false;
}

function finputGalleryUploadFotoJQuery(id) {
 if($('#fileFinput_'+id).value != '') {
	$('#finputGalleryImgInser_'+id).hide();
	$('#finputGallerySnake_'+id).show();
	
	$.ajaxFileUpload
			(
				{
					url:'index.php?command=service/addFotoFinputGallery',
					secureuri:false,
					fileElementId: 'fileFinput_'+id,
					oldFileId: id,
					dataType: 'json',
					success: function (data, status)
					{
						if(typeof(data.error) != 'undefined')
						{
							if(data.error != '')
							{
								alert(data.error);
								$('#finputGallerySnake_'+id).hide();
								$('#finputGalleryImgInser_'+id).show();
								
							}
							else
							{
					
								$('#finputGalleryImgInfo_'+id).html("<b>Plik został wgrany na serwer. <br/>Znajduje się w "+data.fotoName+".</b>");
								$('#field_'+id).val(data.fotoName);
								$('#finputGallerySnake_'+id).hide();
								$('#finputGalleryImgInser_'+id).show();
								$('#finputGalleryImg_'+id).hide();
							}
						}
						else 
						{	
							alert('Error: Problem z przeslaniem pliku!!!');
							$('#finputGallerySnake_'+id).hide();
							$('#finputGalleryImgInser_'+id).show();
						}
					},
					error: function (data, status, e)
					{
						alert('Problem z przeslaniem pliku!!!');
						$('#finputGallerySnake_'+id).hide();
						$('#finputGalleryImgInser_'+id).show();
					}
				}
			);
	}
	else {
		alert('Brak pliku');
	}
}


