/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 * @param    container    DOM element
 */
function markAllRows(container_id) {

    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
            }
        }
    }
    return true;
}


function checkMark(container_id) {

    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;
	var counter = 0;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if (checkbox.checked == true) 
			{
				counter = counter + 1;
            }
        }
    }
	if(counter > 0)
	{
		return true;
	}
	else
	{
		alert("Please select option");
		return false;
	}
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
        }
    }
    return true;
}

//sprawdza dane przy dodawaniu administratora
function sprawdzAdmin(frm)
{
	if(frm.login.value == "")
	{
		alert("Please enter login.");
		frm.login.focus();
		return false;
	}

	if(frm.haslo1.value == "")
	{
		alert("Please enter password.");
		frm.haslo1.focus();
		return false;
	}

	if(frm.haslo1.value != frm.haslo2.value || frm.haslo1.value == "" )
	{
		alert("Please repeat password.");
		frm.haslo2.focus();
		return false;
	}
	return true;
}

//sprawdza dane przy zmianie hasła administratora
function sprawdzZmianaHasla(frm)
{

	if(frm.haslo1.value == "")
	{
		alert("Please enter password.");
		frm.haslo1.focus();
		return false;
	}

	if(frm.haslo1.value != frm.haslo2.value || frm.haslo1.value == "" )
	{
		alert("Please correct repeat password.");
		frm.haslo2.focus();
		return false;
	}
	return true;
}

function logowanie(){
	var frm = document.frm
  
	if(frm.login.value == '')
	{
		frm.login.focus();
	}
}

// JavaScript Document
function openWindow(url,szer,wys,tytul)
{
	var nowe;
	nowe = window.open('','nowe',' width='+szer+',height='+wys+',menubar=no, toolbar=no, status=no');
	nowe.document.open();
    nowe.document.write("<HEAD><title>"+tytul+"</title><META HTTP-EQUIV=\"imagetoolbar\" CONTENT=\"no\"></head><BODY leftmargin=1 topmargin=1><IMG src="+url+"></body>");
    nowe.document.close();
    nowe.focus();
}


// JavaScript Document
function windowOpen(url,szer,wys,tytul)
{
	var nowe;
	nowe = window.open(url,'nowe',' width='+szer+',height='+wys+',menubar=no, toolbar=no, status=no');
}


/* funkcja do generowania flasha */
function getFlashObject(width, height, path)
{	
	var str = "<object type=\"application/x-shockwave-flash\" data=\""+path+"\" width=\""+width+"\" height=\""+height+"\">";
	str += "<param name=\"wmode\" value=\"transparent\" />";
	str += "<param name=\"movie\" value=\""+path+"\" />";
	str += "</object>";
	document.write(str);
}