/* MAIN FORM FUNCTIONS*/

function HandleCreateValid()
{
	var refFunction;
	try
	{
	  refFunction = IsCreateValid;
	}
	catch(e)
	{
	  refFunction = null;
	}
	
	if( refFunction != null )
		return refFunction();
	return true;	
}

function HandleUpdateValid()
{
	var refFunction;
	try
	{
	  refFunction = IsUpdateValid;
	}
	catch(e)
	{
	  refFunction = null;
	}
	
	if( refFunction != null )
		return refFunction();
	return true;	
}

function Create()
{

	Valid = HandleCreateValid();
	if(Valid != false) 
	{

		document.bForm.act.value = "create";
		return true;
	}
	else
	{
		return false;	
	}
}

function Update()
{
	Valid = HandleUpdateValid();
	if(Valid != false) 
	{
		document.bForm.act.value = "update";
		return true;
	}
	else
	{
		return false;	
	}
}
function Delete(i_id)
{
	if (confirm('Czy na pewno chcesz usun±ć wybrany wpis?'))
	{
		document.bForm.act.value = "delete";
		document.bForm.id.value = i_id;
		document.bForm.submit();
	}
}
function Modify(i_id)
{
	document.bForm.act.value = "modify";
	document.bForm.id.value = i_id;
	document.bForm.submit();
}

function UploadPhoto()
{
	if(document.bForm.photo.value == "") 
	{
		alert('Proszę wyszukać plik fotografii');
	}
	else
	{
		if (document.bForm.SPAW_index_toolbar_bottom_html)
			SPAW_UpdateFields();
		document.bForm.act.value = "upload_photo";
		document.bForm.submit();
	}
}

function UploadFile()
{
	if(document.bForm.file.value == "") 
	{
		alert('Proszę wyszukać plik');
	}
	else
	{
		if (document.bForm.SPAW_index_toolbar_bottom_html)
			SPAW_UpdateFields();
		document.bForm.act.value = "upload_file";
		document.bForm.submit();
	}
}

/*POPUP FUNCTIONS*/

function popup(doc, name, width, height) {
    
    window.open(doc, name, 'scrollbars=1, width=' + width + ', height=' + height);
}
function popitup2(content)
{
newwindow2=window.open('','name','height=200,width=150');
var tmp = newwindow2.document;
tmp.write(content);
tmp.close();
}

