function jTip( id )
{
	if ( helperText[id] != undefined )
	{
		//alert( helperText[id] );
	}
}

function printDocument()
{
	okno( "/print", "650", "650" )
}

function chr( code )
{
	if ( code == 0 ) return '@';
	return String.fromCharCode(code);
}

function openUrl( pageUrl ) {	document.location.href = pageUrl; }

var imagePopupWindow 	= null;
var imagePopupPrevUrl	= null;

function cssStyleSheet( document, styleSheetUrl ) {
	var cssObject = document.createElement( 'link' );
	cssObject.setAttribute( 'rel',  'stylesheet' );
	cssObject.setAttribute( 'type', 'text/css' );
	cssObject.setAttribute( 'href', styleSheetUrl );
	return cssObject;
}

function createElement( document, elemType, elemClass ) {
	var newElement = document.createElement( elemType );
	if ( elemClass != '' ) newElement.className = elemClass;
	return newElement;
}

function imgOpen( imgPath, imgWidth, imgHeight, imgDescription ) {  // v4.01
  imgW = Math.round(imgWidth) + 100;
  imgH = Math.round(imgHeight) + 130;
  if ( imgDescription != '' ) imgH = Math.round(imgHeight) + 140;
  txtW = Math.round(imgWidth) + 14;

  posLeft = (screen.width) ? (screen.width - imgW ) / 2 : 0;
  posTop 	= (screen.height) ? (screen.height - imgH) / 2 : 0;

	newWindow = window.open( "", "newWindow", "width=" + imgW + ",height=" + imgH + ",scrollbars=no,left=" + posLeft + ",top=" + posTop + "" );
  newWindow.document.open();
  newWindow.document.write( '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">' );
  newWindow.document.write( '<html><head><title>' + imgDescription + '</title>' );
  newWindow.document.write( '<link rel="stylesheet" href="/css/popup.css" type="text/css" />' );
  newWindow.document.write( '</head><body>' );
  newWindow.document.write( '<div id="header"><img src="/images/logo.gif" alt="" /></div>' );
  newWindow.document.write( '<div class="fotobig"><img src=\"' + imgPath + '\" alt=\"' + imgDescription + '\" title=\"' + imgDescription + '\" onclick="javascript:window.close();" class="fot" />' );
  if ( imgDescription != '' ) newWindow.document.write( '<div class="op">' + imgDescription + '</div>' );
    newWindow.document.write( '</div>' );
  newWindow.document.write( '</body></html>' );
  newWindow.document.close();
}


function okno(url, imgWidth, imgHeight) {
	if ( imgWidth == 0  ) {
		imgWidth  = screen.width  - 30;
		if ( imgWidth > 800 ) imgWidth = 800;
	}
	if ( imgHeight == 0 ) {
		imgHeight = screen.height - 30;
		if ( imgHeight > 800 ) imgHeight = 800;
	}

	posLeft = (screen.width) ? (screen.width-imgWidth)/2 : 0;
	posTop = (screen.height) ? (screen.height-imgHeight)/2 : 0;
	window.open( url,'okno','width=' + imgWidth + ',height=' + imgHeight + ',resizable=no,scrollbars=yes,left='+posLeft+',top='+posTop);
}

function getPage( ajaxFile, onInit, onDone, onFail ) {
	var ajaxFile = '/inc/ajax/' + ajaxFile;
	advAJAX.get( {
		url: ajaxFile,
		onInitialization : function() {
			if ( onInit != null && onInit != undefined ) eval( onInit );
		},
		onSuccess : function(obj) {
			$.unblockUI()
	   	var mResponse = obj.responseText.split( '||' );
	   	onDone = onDone + '( mResponse[0], mResponse[1], mResponse[2], mResponse[3] );';
			if ( onDone != null && onDone != "null" && onDone != undefined ) eval( onDone );
		},
		onError : function(obj) {
			$.unblockUI()
		 	if ( onFail != null && onFail != undefined ) eval( onFail );
		}
	})
}

/* -----------------------------------------------------------------
	Pobranie wszystkich wartości pol z formularza
----------------------------------------------------------------- */
function getFieldsValues( aFormName ) {
	var lForm  = document.getElementById( aFormName );
	var lParam = '';
	for ( var i = 0; i < lForm.elements.length; i++ ) {
		var lObject  = lForm.elements[i];
		var addParam = false;
		if (
			( ( lObject.type == 'checkbox' || lObject.type == 'radio' ) && lObject.checked ) ||
			( ( lObject.type == 'text' || lObject.type == 'hidden' || lObject.type == 'password' || lObject.type == 'textarea' || lObject.type == 'select-one' ) ) )
			addParam = true;
		if ( addParam ) {
			lValue = lObject.value;
			while ( lValue.indexOf( "\n" ) != - 1 )	lValue = lValue.replace( "\n", '^*^' );
			lParam = lParam + '&' + lObject.name + '=' + lValue;
		}
	}
	return lParam;
}

function setHtml( element, content ) { $( element ).html( content ); }
function evalCode( sEvalCode ) { if ( sEvalCode == '-' || sEvalCode ==  '-' ) return;	eval( sEvalCode ); }
function mcAlert( message ) {	$.blockUI( message + '<input type="button" id="mcAlertOk" value=" OK " onclick="$.unblockUI();" class="blockui-btn" />' ); }
function mcMessage( message ) { $.blockUI( '<h1 class="blockui"><img src=\"/skrypty/vx/scripts/jquery/plugins/blockui/busy.gif\" /> ' + message + '</h1>' ); }
function mcMessageRaw( message ) { $.blockUI( message ); }
function gotoPage( pageNum ) { $('#page').val( pageNum ); document.getElementById( 'page' ).form.submit(); }

function toggleFieldset(legend,toggle) {
	$('#'+toggle).toggle();
	if ( $('#'+toggle).css( 'display' ) == 'none' ) {
		legend.firstChild.nodeValue = "[ + ]";
	} else {
		legend.firstChild.nodeValue = "[ - ]";
	}
}