function copyToClipboard( meintext )
{
    if (window.clipboardData) {
   
        window.clipboardData.setData("Text", meintext);
    }
    
    else if (window.netscape) { 
   
        // you have to sign the code to enable this, or see notes below 
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
        // maak een interface naar het clipboard
        var clip = Components.classes['@mozilla.org/widget/clipboard;1']
                        .createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;
   
        var trans = Components.classes['@mozilla.org/widget/transferable;1']
                        .createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
   
        trans.addDataFlavor('text/unicode');

        var str = new Object();
        var len = new Object();

        var str = Components.classes["@mozilla.org/supports-string;1"]
                        .createInstance(Components.interfaces.nsISupportsString);
   
        var copytext=meintext;

        str.data=copytext;

        trans.setTransferData("text/unicode",str,copytext.length*2);

        var clipid=Components.interfaces.nsIClipboard;

        if (!clip) return false;

        clip.setData(trans,null,clipid.kGlobalClipboard);

    }
    
   alert("Poniższy tekst został skopiowany do schowka:\n\n" + meintext);
   return false;
}

//sprawdzanie inputa z ceną; na wejściu obiekt inputa//
function validPrice(price)
{
  price.value.replace(',','.');

  if(price.value.length > 0)
  if(!isNaN(price.value))
    {
	 return true;
	}
  
  return false;  
}

//sprawdzanie inputa textowego - czy niepusty; na wejściu obiekt inputa//
function validText(text)
{
 if(text.value != "" && text.lenght > 0 )
   {
    return true;   
   }
 return false;  
}

//sprawdzanie poprawności wypełnienia formy; na wejściu string z nazwami i typami wymaganych pól//
function validForm(array_fields)
{

alert(array_fields.length);

for(var i = 0; i<array_fields.length; i++)
  {
	var tab_field = new Array;
	 
	tab_field = array_fields[i].split('|');
  }

}

//sprawdza czy isnieje zmienna//
function isset(varname)  
{
 if(typeof( window[ varname ] ) != "undefined") return true;
 else return false;
}


//zapytanie usera  przed wysłaniem formy czy jest pewien//
function submitForm(name)
{
  //sprawdzenie poprawności danych//
  if(isset('validFields'))
  if(name != 'delete' && name != 'addnew' ) validForm(validFields);
  
  var q = '';
  var action = document.getElementById('action');
  action.value = name;
  
  if(name == 'delete') q = 'Czy na pewno usunąć wybrany obiekt?';
  if(name == 'view') q = 'Czy na pewno chcesz zobaczyć podgląd obiektu?';
  if(name == 'addnew') q = 'Czy na pewno dodać obiekt?';
  if(name == 'save') q = 'Czy na pewno zapisać obiekt?';
  if(name == 'update') q = 'Czy na pewno zaktualizować obiekt?';
  
  if(confirm(q))
    {
	  document.forms['AdminForm'].submit();
    } 
}



var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}

function isSavedForm() {

    return true;

    var allElements = document.getElementsByName("save");

    if( allElements.length == 1 ) {
    
        var inputValue = allElements[0].value;
        if( confirm( "Pewne informacje mogły nie zostać zapisane.\nAby je zapisać kliknij 'Anuluj' a następnie '"+ inputValue +"'.\nAby kontunuować bez zapisywania kliknij 'OK'.") ) {
        
            return true;
        }
        
        return false;
    }
    /** /
    for (var i=0; i < allElements.length; i++) {
    
        alert(allElements[i].value);
    }
    /**/

    //alert( 'Test' );
    return true;
}


