function help( object, helpId ) {
	if ( object.title != '' ) return;
	$.ajax( {
  	type: 	"GET",
   	url: 	"/inc/ajax/help.Descriptor.php",
   	data: "id=" + helpId,
   	success: function( msg ) {
    	object.title = msg;
   	}
 	} )
}

function doPrint() {
	okno( '/printer.php', 650, 650 )
}
function showProduct( proId ) {
	okno( '/index.php?nav=2&amp;id=' + proId, 650, 650 )
}

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 imgOpen3( imageUrl, imageWidth, imageHeight, imageTitle ) {  // v4.01
	var imageLogo			= '/images/lfm-small.gif';
  var windowWidth 	= Math.round( imageWidth  ) + 24;
  var windowHeight 	= Math.round( imageHeight ) + ( imageTitle == '' ? 77 : 102 );
  var windowLeft		= screen.width 	? ( screen.width  - windowWidth  ) / 2 : 0;
  var windowTop	 		= screen.height ? ( screen.height - windowHeight ) / 4 : 0


	$.extend($.blockUI.defaults.overlayCSS, 		{ backgroundColor: '#000' });
	$.extend($.blockUI.defaults.overlayCSS, 		{ opacity: '0.65' });
	$.extend($.blockUI.defaults.pageMessageCSS, { width: windowWidth + 'px' });
	$.extend($.blockUI.defaults.pageMessageCSS, { height: windowHeight + 'px' });
	$.extend($.blockUI.defaults.pageMessageCSS, { top: windowTop + 'px' });
	$.extend($.blockUI.defaults.pageMessageCSS, { left: windowLeft + 'px' });
	$.extend($.blockUI.defaults.pageMessageCSS, { margin: '0px' });

	var innerHtml = '<div class="popup"><div class="header"><div class="logo"><img src="' + imageLogo + '" alt="" /></div></div>';
	innerHtml = innerHtml + '<div class="fotobig"><div class="inr"><div class="fo"><img src=\"' + imageUrl + '\" alt=\"' + imageTitle + '\" title=\"' + imageTitle + '\" onclick="javascript:$.unblockUI();" style="width:' + imageWidth + '; height:' + imageHeight + '\;" /></div>';
	if ( imageTitle != '' ) {
		innerHtml = innerHtml + '<div class="op">' + imageTitle + '</div>';
	}
	innerHtml = innerHtml + '</div></div>';
	$.blockUI( innerHtml );

}


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( '<html><head><title>' + imgDescription + '</title>' );
  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/main.css" type="text/css" />' );
  newWindow.document.write( '<link rel="stylesheet" href="/css/style.css" type="text/css" />' );
  newWindow.document.write( '<link rel="stylesheet" href="/css/layers.css" type="text/css" />' );
  newWindow.document.write( '</head><body class="body-popup">' );
  newWindow.document.write( '<div class="popup">' );
  newWindow.document.write( '<div class="header"><div class="logo"><img src="/images/logo.gif" alt="" /></div></div>' );
  newWindow.document.write( '<div class="f-big"><table cellspacing="0" cellpadding="5" align="center"><tr><td><img src=\"' + imgPath + '\" alt=\"' + imgDescription + '\" title=\"' + imgDescription + '\" onclick="javascript:window.close();" style="width:' + imgWidth + '; height:' + imgHeight + '\;" /></td></tr></table>' );
  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' + Math.random(10000),'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 gotoPage( pageNum ) { $('#page').val( pageNum ); document.getElementById( 'page' ).form.submit(); }

/***********************************
      POWIEKSZANIE CZCIONKI
***********************************/

function zoom(size)
{
	if(size == -1)
	{
		var re=new RegExp('art_size'+"=[^;]+", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			size = document.cookie.match(re)[0].split("=")[1]
		else
			size = 0;
	}
	// set cookie
  var expdate = new Date ();
  expdate.setTime (expdate.getTime() + (3650 *24 * 60 * 60 * 1000));
	document.cookie = 'art_size='+size+'; path=/;expires=' + expdate;

	var tags = new Array('font','div','td');
	var fontSize = new Array( '11px','14px','18px' );
	var lineHeight = new Array( '15px','18px','24px' );

	var dc = document.getElementById('divPrintDoc');
	var vt;

	dc.style.fontSize = fontSize[size];
	dc.style.lineHeight = lineHeight[size];

	for ( i = 0 ; i < tags.length ; i++ )
	{
		vt = dc.getElementsByTagName( tags[ i ] );
		for ( j = 0 ; j < vt.length ; j++ )
		{
			vt[ j ].style.fontSize = fontSize[ size ];
			vt[ j ].style.lineHeight = lineHeight[size];
		}
	}
}
