/** obsluga okna zlista osob uczesniczacych w projekcie
*/
function small_window(myurl) {
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=300,height=200';
newWindow = window.open(myurl, "Add_from_Src_to_Dest", props);
}
// Adds the list of selected items selected in the child
// window to its list. It is called by child window to do so.  
function addToParentList(sourceList) {
destinationList = window.document.forms['projForm'].personsPk;
for(var count = destinationList.options.length - 1; count >= 0; count--) {
destinationList.options[count] = null;
}
for(var i = 0; i < sourceList.options.length; i++) {
if (sourceList.options[i] != null)
destinationList.options[i] = new Option(sourceList.options[i].value, sourceList.options[i].value );
   }
window.document.forms['projForm'].elements['personsPk'].value = destinationList;	   
}
// Marks all the items as selected for the submit button.  
function selectList(sourceList) {
sourceList = window.document.forms[0].personsPk;
for(var i = 0; i < sourceList.options.length; i++) {
if (sourceList.options[i] != null)
sourceList.options[i].selected = true;
}
return true;
}

// Deletes the selected items of supplied list.
function deleteSelectedItemsFromList(sourceList) {
var maxCnt = sourceList.options.length;
for(var i = maxCnt - 1; i >= 0; i--) {
if ((sourceList.options[i] != null) && (sourceList.options[i].selected == true)) {
sourceList.options[i] = null;
      }
   }
}


<!--

/**
*	Funkcja dodaje do okna doc,
*	do podanego formularza, selecta opcje
*srcListID
*/
function addUserToList(doc, formName, elemName, size, destListID, destFormName){
	
	var nameList = doc.getElementById('personsName');	
	var pkList = doc.getElementById(destListID);
	var pkLen = pkList.length;
	//najpierw trzebaskasowac wszystkie pola jakie byly
	for (var i = pkLen; i > -1; i--){
	//usuwam kolejne elementy option
		pkList.remove(i);
		nameList.remove(i);
	}

	for(i=0;i<size;i++){
		if (window.document.forms[formName].elements[elemName+'['+i+']'].checked){
		//wstawiam do opener	
			body = window.document.getElementById('user['+i+']').firstChild.nodeValue;
			value = window.document.forms[formName].elements[elemName+'['+i+']'].value;
			opt = new Option(value, value);						
			opt.selected=true;
			pkList.options[pkLen] = opt;
			//name = new Option(body, body);
			//name.selected=true;
			//nameList.options[nameList.length] = name;
		}
	}
	
/*
	var srcLen = srcList.length;
	var tgtLen = tgtList.length;
	var tgt = "x";

	//build array of target items
	for (var i=tgtLen-1; i > -1; i--) {
		tgt += "," + tgtList.options[i].value + ","
	}

	//Pull selected resources and add them to list
	for (var i=0; i < srcLen; i++) {
		if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) {
			opt = new Option( srcList.options[i].text, srcList.options[i].value );
			tgtList.options[tgtList.length] = opt;
			srcList.options[i].style.fontStyle = "italic";
			srcList.options[i].style.color = "#aaaaaa";
			srcList.options[i].selected = false;
		}
	}
	*/
	//alert(destList.length);
}


/*inne */
function winXpos()
{
	if (window.screenX) return (window.screenX + 20);
	else if (window.screenLeft) return (window.screenLeft + 20);
	else return 0;
}
function winYpos()
{
	if (window.screenY) return (window.screenY + 20);
	if (window.screenTop) return (window.screenTop + 20);
	else return 0;
}

function openWindow(height, width,x,y, url, name)
{	
//	if ( newWindow == null || ! newWindow.focus()){
	//	newWindow = window.open(url, name, 'location=0,width='+width+', height='+height+',left='+winXpos()+',top='+winYpos()+',status=no,resizable=yes,scrollbars=yes');	
//	}
	window.open(url, name, 'location=0,width='+width+', height='+height+',left='+x+',top='+y+',status=no,resizable=yes,scrollbars=yes');	
}

function openOptionWindow(name,height, width,x,y, url, name)
{	
//	if ( newWindow == null || ! newWindow.focus()){
	//	newWindow = window.open(url, name, 'location=0,width='+width+', height='+height+',left='+winXpos()+',top='+winYpos()+',status=no,resizable=yes,scrollbars=yes');	
//	}
	window.open(url, name, 'location=0,width='+width+', height='+height+',left='+x+',top='+y+',status=no,resizable=yes,scrollbars=yes');	
}


function strGenerator (len)
{
	if (typeof(len) != 'number') len = 0;
	var result = '';
	var baseChar = 'abcdefghijklmnopqrstuvwxyz0123456789';
	var i = 0;

	for (i=1; i<=len; i++) result = result + baseChar.charAt(Math.round(Math.random()*baseChar.length));

	return result;
}

function setRowBgColor (theRow, theColor)
{
	var theCells = null
	var c = null
	//
	if (typeof (theRow.style) == 'undefined')
        return false
	//
    if (typeof (document.getElementsByTagName) != 'undefined')
        theCells = theRow.getElementsByTagName ('td')
    else if (typeof (theRow.cells) != 'undefined')
        theCells = theRow.cells;
    else
        return false;
	//
	for (c = 0; c < theCells.length; c++)
		setCellBgColor (theCells[c], theColor)
}

function setCellBgColor (theCell, theColor)
{
	if ((typeof (window.opera) == 'undefined') && (typeof (theCell.getAttribute) != 'undefined'))
		theCell.setAttribute('bgcolor', theColor, 0)
	else
		theCell.style.backgroundColor = theColor
}

/**
 * Wyswietla okienko potwierdzenia przed wykonaniem kasowania
 * Funkcja jest wywolywana przy wybieraniu linka
 *
 * @param   object   link
 * @param   object   pytanie
 *
 * @return  boolean  wykonać zadanie czy nie
 */

var confirmMsg='Czy na pewno chcesz skasować?';
 
function confirmLink(link, query)
{

    // dla opery potwierdzenie nie jest wymagane -slaba implementaca js
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' :\n' + query);
    if (is_confirmed) {
        link.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
}

var confirmMsgButton=' ';

function confirmButton(link, query)
{

    // dla opery potwierdzenie nie jest wymagane -slaba implementaca js
    if (confirmMsgButton == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsgButton + query);
    if (is_confirmed) {
        link.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
}

function openWindowConfirmButton(height, width,x,y, url, name,query)
{	
//	if ( newWindow == null || ! newWindow.focus()){
	//	newWindow = window.open(url, name, 'location=0,width='+width+', height='+height+',left='+winXpos()+',top='+winYpos()+',status=no,resizable=yes,scrollbars=yes');	
//	}
    if (confirmButton(url, query))
    {
	  window.open(url, name, 'location=0,width='+width+', height='+height+',left='+x+',top='+y+',status=no,resizable=yes,scrollbars=yes');	
    }  
}


<!-- ********* formularze -->

function changeSort(formName, order, orderType){
	window.document.forms[formName].order.value=order;
	window.document.forms[formName].orderType.value=orderType;
	submit(formName);
}

function changeRows(formName, pos, rows){
	window.document.forms[formName].pos.value=pos;	
	window.document.forms[formName].rows.value=rows;

	submit(formName);
}

function submit(formName){
	window.document.forms[formName].submit();
}

function markAll(formName, tableName, tableSize, markName){

	for(i=0; i < tableSize; i++){
		inputName=tableName+'['+i+']'+'.'+markName;	
		if (! document.forms[formName].elements[inputName].checked){
			document.forms[formName].elements[inputName].checked=true;
		} 
		else{
			document.forms[formName].elements[inputName].checked=false;
		}


	}
}

//-->
